all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Robert Pluim <rpluim@gmail.com>
To: emacs-devel@gnu.org
Subject: [PATCH] Fix frameset-restore in the presence of scaling
Date: Thu, 18 Jan 2018 15:32:36 +0100	[thread overview]
Message-ID: <87efmnb5kr.fsf@gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 443 bytes --]

Running emacs-26 with GDK_SCALING=2, frameset-restore will position
2nd and subsequent frames incorrectly if they are in the right half of
the screen. Turns out that we're querying GTK for the dimensions of
the display in order to ensure that frames remain on-screen, and those
dimensions need scaling. Patch attached, tested on GTK 3.18, I'd
appreciate if someone with a HiDPI screen and GTK >= 3.22 could
confirm whether it works for them.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Scale-monitor-dimensions-obtained-from-GTK.patch --]
[-- Type: text/x-diff, Size: 1430 bytes --]

From f62eb8f2aa1716bdb2c43ab6eb3f22a17ba434f3 Mon Sep 17 00:00:00 2001
From: Robert Pluim <rpluim@gmail.com>
Date: Thu, 18 Jan 2018 15:19:29 +0100
Subject: [PATCH] Scale monitor dimensions obtained from GTK

* src/xfns.c (Fx_display_monitor_attributes_list): Take scaling factor
into account when using GTK to query the monitor dimensions, which
allows frameset-restore to position frames correctly.
---
 src/xfns.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/src/xfns.c b/src/xfns.c
index dd3b36c133..4ea5113265 100644
--- a/src/xfns.c
+++ b/src/xfns.c
@@ -4940,6 +4940,7 @@ Internal use only, use `display-monitor-attributes-list' instead.  */)
       gint width_mm = -1, height_mm = -1;
       GdkRectangle rec, work;
       struct MonitorInfo *mi = &monitors[i];
+      int scale;
 
 #if GTK_CHECK_VERSION (3, 22, 0)
       GdkMonitor *monitor = gdk_display_get_monitor (gdpy, i);
@@ -4985,6 +4986,16 @@ Internal use only, use `display-monitor-attributes-list' instead.  */)
       }
 #endif
 
+      /* GTK returns scaled sizes for the workareas.  */
+#if GTK_CHECK_VERSION (3, 22, 0)
+      scale = gdk_monitor_get_scale_factor (monitor);
+#else
+      scale = gdk_screen_get_monitor_scale_factor (gscreen, i);
+#endif
+      rec.width *= scale;
+      rec.height *= scale;
+      work.width *= scale;
+      work.height *= scale;
 
       mi->geom.x = rec.x;
       mi->geom.y = rec.y;
-- 
2.16.0.rc1


             reply	other threads:[~2018-01-18 14:32 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-18 14:32 Robert Pluim [this message]
2018-01-19 18:55 ` [PATCH] Fix frameset-restore in the presence of scaling martin rudalics
2018-01-22 10:58   ` Robert Pluim
2018-01-22 12:49     ` Robert Pluim

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=87efmnb5kr.fsf@gmail.com \
    --to=rpluim@gmail.com \
    --cc=emacs-devel@gnu.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.
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.