emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Scaling stuff for high dpi screens


From: Adam Sjøgren
Subject: Re: Scaling stuff for high dpi screens
Date: Fri, 30 Jan 2015 00:57:14 +0100
User-agent: Gnus/5.130012 (Ma Gnus v0.12) Emacs/24.4 (gnu/linux)

David writes:

> (/ (display-pixel-width) (/ (display-mm-width) 25.4))

Here are my observations so far:

 a) When starting Emacs by using "emacs" on the command line,
    display-pixel-width and display-mm-width returns what I expect
    (3200, 406).

 b) after-make-frame-functions are not called when I start Emacs using
    "emacs" on the command line and the first frame appears.

    If I subsequently create a new frame with C-x 5 2, or emacsclient
    --create-frame --alternate-editor="", they are called, and the
    widths are as expected.

 c) If I use 'emacsclient --create-frame --alternate-editor=""' to start
    Emacs, then after-make-frame-functions are called, but when I call
    display-pixel-width and display-mm-width in such a function, I get
    (10, nil) back.

    If I subsequently make a new frame with C-x 5 2, or emacsclient
    --create-frame --alternate-editor="", then the expected values are
    returned.

I don't understand b), but don't mind much, as it is easy to call my
function on the first frame created in my init.el.

I don't understand c) either, but it is quite annoying, because I can't
find a suitable way/hook in which to call display-pixel/mm-width at a
time where they give the results I expect.

This is what I have been playing around with in my init.el:

    (defun get-x11-dpi ()
      (let ((pixel-width (display-pixel-width))
            (mm-width (display-mm-width)))
        (message "display-pixel-width: %s" pixel-width)
        (message "display-mm-width: %s" mm-width)
        (if (and pixel-width mm-width)
            (round (/ (display-pixel-width) (/ (display-mm-width) 25.4)))
          100)))

    ; Activate scaling:
    (defun asjo-new-frame-setup-scaling (new-frame)
      (set-frame-parameter new-frame 'image-dpi-scale-magnitude (if (> 
(get-x11-dpi) 100) 2.0 1.0)))

    ; This does not work for the first emacsclient frame, but it does for
    ; subsequent frames, it is not run for first emacs frame either:
    (add-hook 'after-make-frame-functions 'asjo-new-frame-setup-scaling)
    ; This is for non-emacsclient startup:
    (asjo-new-frame-setup-scaling nil)


  Best regards,

    Adam

-- 
 "I think I've learned by now                                 Adam Sjøgren
  There's never an easy way"                             address@hidden




reply via email to

[Prev in Thread] Current Thread [Next in Thread]