all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Re: Scaling stuff for high dpi screens
       [not found]     ` <87lhulyz7g.fsf@topper.koldfront.dk>
@ 2015-01-28  6:23       ` Lars Ingebrigtsen
  2015-01-28  8:46         ` David Kastrup
  0 siblings, 1 reply; 10+ messages in thread
From: Lars Ingebrigtsen @ 2015-01-28  6:23 UTC (permalink / raw)
  To: Adam Sjøgren; +Cc: ding, emacs-devel

asjo@koldfront.dk (Adam Sjøgren) writes:

>   (defun get-x11-dpi ()
>     (let ((xrandr
>            (with-output-to-string
>              (call-process "xrandr" nil standard-output))))

Hm.  Doesn't Emacs have a way of determining the DPI of the screen?  If
not, it should have.

I've Cc'd emacs-devel in case somebody there knows.

-- 
(domestic pets only, the antidote for overdose, milk.)
  bloggy blog http://lars.ingebrigtsen.no/



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Scaling stuff for high dpi screens
  2015-01-28  6:23       ` Scaling stuff for high dpi screens Lars Ingebrigtsen
@ 2015-01-28  8:46         ` David Kastrup
  2015-01-29  1:02           ` Lars Ingebrigtsen
                             ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: David Kastrup @ 2015-01-28  8:46 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: Adam Sjøgren, ding, emacs-devel

Lars Ingebrigtsen <larsi@gnus.org> writes:

> asjo@koldfront.dk (Adam Sjøgren) writes:
>
>>   (defun get-x11-dpi ()
>>     (let ((xrandr
>>            (with-output-to-string
>>              (call-process "xrandr" nil standard-output))))
>
> Hm.  Doesn't Emacs have a way of determining the DPI of the screen?  If
> not, it should have.

Sure.

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

-- 
David Kastrup



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Scaling stuff for high dpi screens
  2015-01-28  8:46         ` David Kastrup
@ 2015-01-29  1:02           ` Lars Ingebrigtsen
  2015-01-29 22:26           ` Adam Sjøgren
  2015-01-29 23:57           ` Adam Sjøgren
  2 siblings, 0 replies; 10+ messages in thread
From: Lars Ingebrigtsen @ 2015-01-29  1:02 UTC (permalink / raw)
  To: David Kastrup; +Cc: Adam Sjøgren, ding, emacs-devel

David Kastrup <dak@gnu.org> writes:

>> Hm.  Doesn't Emacs have a way of determining the DPI of the screen?  If
>> not, it should have.
>
> Sure.
>
> (/ (display-pixel-width) (/ (display-mm-width) 25.4))

Cool.

-- 
(domestic pets only, the antidote for overdose, milk.)
  bloggy blog http://lars.ingebrigtsen.no/



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Scaling stuff for high dpi screens
  2015-01-28  8:46         ` David Kastrup
  2015-01-29  1:02           ` Lars Ingebrigtsen
@ 2015-01-29 22:26           ` Adam Sjøgren
  2015-01-29 23:57           ` Adam Sjøgren
  2 siblings, 0 replies; 10+ messages in thread
From: Adam Sjøgren @ 2015-01-29 22:26 UTC (permalink / raw)
  To: emacs-devel; +Cc: ding

David writes:

> Lars Ingebrigtsen <larsi@gnus.org> writes:

>> Hm.  Doesn't Emacs have a way of determining the DPI of the screen?  If
>> not, it should have.

> Sure.

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

Perfect, thanks!


  Best regards,

    Adam

-- 
 "I skal gå tre skridt væk fra mig                            Adam Sjøgren
  For jeg har fundet en som rammer"                      asjo@koldfront.dk




^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Scaling stuff for high dpi screens
  2015-01-28  8:46         ` David Kastrup
  2015-01-29  1:02           ` Lars Ingebrigtsen
  2015-01-29 22:26           ` Adam Sjøgren
@ 2015-01-29 23:57           ` Adam Sjøgren
  2015-01-30  6:26             ` Eli Zaretskii
  2015-01-30 10:05             ` David Kastrup
  2 siblings, 2 replies; 10+ messages in thread
From: Adam Sjøgren @ 2015-01-29 23:57 UTC (permalink / raw)
  To: emacs-devel; +Cc: ding

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"                             asjo@koldfront.dk




^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Scaling stuff for high dpi screens
  2015-01-29 23:57           ` Adam Sjøgren
@ 2015-01-30  6:26             ` Eli Zaretskii
  2015-01-30 10:05             ` David Kastrup
  1 sibling, 0 replies; 10+ messages in thread
From: Eli Zaretskii @ 2015-01-30  6:26 UTC (permalink / raw)
  To: Adam Sjøgren; +Cc: ding, emacs-devel

> From: asjo@koldfront.dk (Adam Sjøgren)
> Date: Fri, 30 Jan 2015 00:57:14 +0100
> Cc: ding@gnus.org
> 
>  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.

Those functions accept a 'frame' argument, so perhaps the default they
try using (see the doc string) misfires in this particular scenario.




^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Scaling stuff for high dpi screens
  2015-01-29 23:57           ` Adam Sjøgren
  2015-01-30  6:26             ` Eli Zaretskii
@ 2015-01-30 10:05             ` David Kastrup
  2015-01-30 15:19               ` Vincent Bernat
  1 sibling, 1 reply; 10+ messages in thread
From: David Kastrup @ 2015-01-30 10:05 UTC (permalink / raw)
  To: Adam Sjøgren; +Cc: ding, emacs-devel

asjo@koldfront.dk (Adam Sjøgren) writes:

> 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.

You might have to provide the functions with explicit display arguments
if the "selected frame" does not correspond to a graphical display.

display-pixel-width is a compiled Lisp function in `frame.el'.

(display-pixel-width &optional DISPLAY)

Return the width of DISPLAY's screen in pixels.
DISPLAY can be a display name or a frame.
If DISPLAY is omitted or nil, it defaults to the selected frame's display.

For character terminals, each character counts as a single pixel.

For graphical terminals, note that on "multi-monitor" setups this
refers to the pixel width for all physical monitors associated
with DISPLAY.  To get information for each physical monitor, use
`display-monitor-attributes-list'.


-- 
David Kastrup



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Scaling stuff for high dpi screens
  2015-01-30 10:05             ` David Kastrup
@ 2015-01-30 15:19               ` Vincent Bernat
  2015-01-30 23:38                 ` Adam Sjøgren
  0 siblings, 1 reply; 10+ messages in thread
From: Vincent Bernat @ 2015-01-30 15:19 UTC (permalink / raw)
  To: David Kastrup; +Cc: Adam Sjøgren, emacs-devel, ding

 ❦ 30 janvier 2015 11:05 +0100, David Kastrup <dak@gnu.org> :

>>> (/ (display-pixel-width) (/ (display-mm-width) 25.4))
[...]
>> 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.

For some reason, I didn't get the original message and I don't have the
whole thread either. Sorry if it has already been told.

If you use GTK as a toolkit for your Emacs, DPI changes are
automatically handled. I was previously using Lucid and switched to GTK
for this reason. This works automatically in Gnome or likewise
environments.

If you have a more "basic" environment, you need something like
xsettingsd with the target DPI*1024:

Xft/DPI 98304

I generate one with this snippet:

#+BEGIN_SRC sh
sed +Xft/DPI+d  ~/.xsettingsd
dpi=$(xdpyinfo | awk  '$1 ~ /resolution:/ { print $2 }' | sed 's/x.*//')
echo Xft/DPI $(( $dpi * 1024 )) >> ~/.xsettingsd
pid=$(xprop -name xsettingsd _NET_WM_PID 2> /dev/null | awk '{print $NF}')
if [ x"$pid" = x ]; then
    xsettingsd -c ~/.xsettingsd &
else
    kill -HUP $pid
fi

# Also use xrdb for very old stuff (you know, LibreOffice)
echo Xft.dpi: $dpi | xrdb -merge
#+END_SRC sh

However, note that the GTK version of Emacs can kill itself if a display
becomes unavailable because of some limitation of GTK.
-- 
Use library functions.
            - The Elements of Programming Style (Kernighan & Plauger)



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Scaling stuff for high dpi screens
  2015-01-30 15:19               ` Vincent Bernat
@ 2015-01-30 23:38                 ` Adam Sjøgren
  2015-01-31 15:59                   ` Vincent Bernat
  0 siblings, 1 reply; 10+ messages in thread
From: Adam Sjøgren @ 2015-01-30 23:38 UTC (permalink / raw)
  To: ding; +Cc: emacs-devel

Vincent writes:

> If you use GTK as a toolkit for your Emacs, DPI changes are
> automatically handled.

Images are automatically rescaled for you on high dpi screens? They
aren't for me.

> However, note that the GTK version of Emacs can kill itself if a
> display becomes unavailable because of some limitation of GTK.

Yes, it is a shame that this has not been resolved yet. I never quite
understood what exactly it is in GTK that still needs fixing, even when
I did try digging.

Unfortunately the "killing itself" was introduced because I reported my
disk filling up with error messages from Emacs+GTK once. I feel somewhat
guilty.


  Best regards,

    Adam

-- 
 "Sadly, these days, if you know the difference               Adam Sjøgren
  between a phillips- and a flat head screwdriver,       asjo@koldfront.dk
  you're a renaissance man."




^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Scaling stuff for high dpi screens
  2015-01-30 23:38                 ` Adam Sjøgren
@ 2015-01-31 15:59                   ` Vincent Bernat
  0 siblings, 0 replies; 10+ messages in thread
From: Vincent Bernat @ 2015-01-31 15:59 UTC (permalink / raw)
  To: Adam Sjøgren; +Cc: ding, emacs-devel

 ❦ 31 janvier 2015 00:38 +0100, asjo@koldfront.dk (Adam Sjøgren) :

>> If you use GTK as a toolkit for your Emacs, DPI changes are
>> automatically handled.
>
> Images are automatically rescaled for you on high dpi screens? They
> aren't for me.

Not for me either. My screen is only 144 dpi so this is bearable.
-- 
Too much is just enough.
		-- Mark Twain, on whiskey



^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2015-01-31 15:59 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <87vbu5m25o.fsf@topper.koldfront.dk>
     [not found] ` <b4ma9bfzbny.fsf@jpl.org>
     [not found]   ` <871twqefd6.fsf@topper.koldfront.dk>
     [not found]     ` <87lhulyz7g.fsf@topper.koldfront.dk>
2015-01-28  6:23       ` Scaling stuff for high dpi screens Lars Ingebrigtsen
2015-01-28  8:46         ` David Kastrup
2015-01-29  1:02           ` Lars Ingebrigtsen
2015-01-29 22:26           ` Adam Sjøgren
2015-01-29 23:57           ` Adam Sjøgren
2015-01-30  6:26             ` Eli Zaretskii
2015-01-30 10:05             ` David Kastrup
2015-01-30 15:19               ` Vincent Bernat
2015-01-30 23:38                 ` Adam Sjøgren
2015-01-31 15:59                   ` Vincent Bernat

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.