From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.emacs.gnus.general/84500 Path: news.gmane.org!not-for-mail From: asjo@koldfront.dk (Adam =?utf-8?Q?Sj=C3=B8gren?=) Newsgroups: gmane.emacs.gnus.general Subject: Re: Scaling stuff for high dpi screens Date: Thu, 01 May 2014 23:18:59 +0200 Organization: koldfront - analysis & revolution, Copenhagen, Denmark Message-ID: <87lhulyz7g.fsf@topper.koldfront.dk> References: <87vbu5m25o.fsf@topper.koldfront.dk> <871twqefd6.fsf@topper.koldfront.dk> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: ger.gmane.org 1398979221 19655 80.91.229.3 (1 May 2014 21:20:21 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 1 May 2014 21:20:21 +0000 (UTC) To: ding@gnus.org Original-X-From: ding-owner+M32746@lists.math.uh.edu Thu May 01 23:20:13 2014 Return-path: Envelope-to: ding-account@gmane.org Original-Received: from util0.math.uh.edu ([129.7.128.18]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1WfyOo-0000lB-Vi for ding-account@gmane.org; Thu, 01 May 2014 23:20:11 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.math.uh.edu) by util0.math.uh.edu with smtp (Exim 4.63) (envelope-from ) id 1WfyNx-0003qj-54; Thu, 01 May 2014 16:19:17 -0500 Original-Received: from mx1.math.uh.edu ([129.7.128.32]) by util0.math.uh.edu with esmtps (TLSv1:AES256-SHA:256) (Exim 4.63) (envelope-from ) id 1WfyNu-0003qW-EM for ding@lists.math.uh.edu; Thu, 01 May 2014 16:19:14 -0500 Original-Received: from quimby.gnus.org ([80.91.231.51]) by mx1.math.uh.edu with esmtps (TLSv1:AES128-SHA:128) (Exim 4.76) (envelope-from ) id 1WfyNs-00070W-4D for ding@lists.math.uh.edu; Thu, 01 May 2014 16:19:13 -0500 Original-Received: from plane.gmane.org ([80.91.229.3]) by quimby.gnus.org with esmtp (Exim 4.80) (envelope-from ) id 1WfyNq-00013Q-46 for ding@gnus.org; Thu, 01 May 2014 23:19:10 +0200 Original-Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1WfyNp-0007yd-Lv for ding@gnus.org; Thu, 01 May 2014 23:19:09 +0200 Original-Received: from 2505ds5-by.0.fullrate.dk ([89.150.142.116]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 01 May 2014 23:19:09 +0200 Original-Received: from asjo by 2505ds5-by.0.fullrate.dk with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 01 May 2014 23:19:09 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 52 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: 2505ds5-by.0.fullrate.dk OpenPGP: id=49D0746121BDE416; url=http://asjo.koldfront.dk/gpg.asc Mail-Follow-Up-To: never X-Now-Playing: volume: 80% repeat: off random: off single: off consume: off X-Face: )qY&CseJ?.:=8F#^~GcSA?F=9eu'{KAFfL1C3/A&:nE?PW\i65"ba0NS)97,Q(^@xk}n4Ou rPuR#V8I(J_@~H($[ym:`K_+]*kjvW>xH5jbgLBVFGXY:(#4P>zVBklLbdL&XxL\M)%T}3S/IS9lMJ ^St'=VZBR Precedence: bulk Xref: news.gmane.org gmane.emacs.gnus.general:84500 Archived-At: 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