Gnus development mailing list
 help / color / mirror / Atom feed
From: asjo@koldfront.dk (Adam Sjøgren)
To: ding@gnus.org
Subject: Re: Scaling stuff for high dpi screens
Date: Thu, 01 May 2014 23:18:59 +0200	[thread overview]
Message-ID: <87lhulyz7g.fsf@topper.koldfront.dk> (raw)
In-Reply-To: <871twqefd6.fsf@topper.koldfront.dk>

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

> Thanks a bunch - now I just need to figure out how to extract the
> current dpi from X, and adjust the magnitude value on the fly.

I stole some code from from
https://github.com/bodil/emacs.d/blob/master/bodil-theme.el and adapted
it a little; so this calls xrandr to find the dpi by grabbing the
vertical pixels and the vertical mm size from the output:

  (defun get-x11-dpi ()
    (let ((xrandr
           (with-output-to-string
             (call-process "xrandr" nil standard-output))))
      (string-match "\\(.+\\) connected primary \\(.+\\)x.+ (.+) \\(.+\\)mm x .+mm" xrandr)
      (when (not (match-string 2 xrandr))
        (string-match "\\(.+\\) connected \\(.+\\)x.+ (.+) \\(.+\\)mm x .+mm" xrandr))
      (if (match-string 2 xrandr)
          (let ((pixels (string-to-number (match-string 2 xrandr)))
                (phys (string-to-number (match-string 3 xrandr))))
            (round (/ pixels (/ phys 25.6))))
        96)))

And I use this in a hook, to set a frame parameter with the
magnification I want - I am going simple here - if the dpi is above 100,
I want double up:
        
  (add-hook 'after-make-frame-hook
            '(lambda (new-frame)
               (set-frame-parameter new-frame 'image-dpi-scale-magnitude (if (> (get-x11-dpi) 100) 2.0 1.0))))

I then use Katsumi-san's two defadvices, where I have changed the
magnitude line to grab the frame parameter, like this:
               
      (let* ((magnitude (frame-parameter nil 'image-dpi-scale-magnitude))

For some reason I don't quite understand, it seems that the
hook/get-x11-dpi works inconsistently, so basically I have to evaluate
the set-frame-paremeter part manually a couple of times for it to work,
which I don't understand, but other than that, it is a good step
forward.

Thanks again for the advice!


  :-),

    Adam

-- 
 "Tell them to give it to Donovan."                           Adam Sjøgren
                                                         asjo@koldfront.dk




  reply	other threads:[~2014-05-01 21:18 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-04-19 21:37 Adam Sjøgren
2014-04-21  1:58 ` Katsumi Yamaoka
2014-04-21 17:56   ` Adam Sjøgren
2014-05-01 21:18     ` Adam Sjøgren [this message]
2015-01-28  6:23       ` 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
2015-01-28  9:39       ` Andreas Schwab
2015-01-29 22:28         ` Adam Sjøgren

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87lhulyz7g.fsf@topper.koldfront.dk \
    --to=asjo@koldfront.dk \
    --cc=ding@gnus.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).