emacs-devel
[Top][All Lists]
Advanced

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

[PATCH] Fix frameset-restore in the presence of scaling


From: Robert Pluim
Subject: [PATCH] Fix frameset-restore in the presence of scaling
Date: Thu, 18 Jan 2018 15:32:36 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.91 (gnu/linux)

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.

>From f62eb8f2aa1716bdb2c43ab6eb3f22a17ba434f3 Mon Sep 17 00:00:00 2001
From: Robert Pluim <address@hidden>
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 via email to

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