unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* [PATCH] Fix frameset-restore in the presence of scaling
@ 2018-01-18 14:32 Robert Pluim
  2018-01-19 18:55 ` martin rudalics
  0 siblings, 1 reply; 4+ messages in thread
From: Robert Pluim @ 2018-01-18 14:32 UTC (permalink / raw)
  To: emacs-devel

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


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

* Re: [PATCH] Fix frameset-restore in the presence of scaling
  2018-01-18 14:32 [PATCH] Fix frameset-restore in the presence of scaling Robert Pluim
@ 2018-01-19 18:55 ` martin rudalics
  2018-01-22 10:58   ` Robert Pluim
  0 siblings, 1 reply; 4+ messages in thread
From: martin rudalics @ 2018-01-19 18:55 UTC (permalink / raw)
  To: emacs-devel

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

When 'left' and top' are negative, they specify a frame position
relative to the right or bottom edge of the display.  Are such
specifications affected/corrected by your patch with scaling on?

martin



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

* Re: [PATCH] Fix frameset-restore in the presence of scaling
  2018-01-19 18:55 ` martin rudalics
@ 2018-01-22 10:58   ` Robert Pluim
  2018-01-22 12:49     ` Robert Pluim
  0 siblings, 1 reply; 4+ messages in thread
From: Robert Pluim @ 2018-01-22 10:58 UTC (permalink / raw)
  To: martin rudalics; +Cc: emacs-devel

martin rudalics <rudalics@gmx.at> writes:

>> 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.
>
> When 'left' and top' are negative, they specify a frame position
> relative to the right or bottom edge of the display.  Are such
> specifications affected/corrected by your patch with scaling on?

They will almost certainly be corrected. My testcase involved
destop-save, which doesn't use such specifications for frames as far
as I know, I'll have to do some manual testing.

Robert



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

* Re: [PATCH] Fix frameset-restore in the presence of scaling
  2018-01-22 10:58   ` Robert Pluim
@ 2018-01-22 12:49     ` Robert Pluim
  0 siblings, 0 replies; 4+ messages in thread
From: Robert Pluim @ 2018-01-22 12:49 UTC (permalink / raw)
  To: emacs-devel

Robert Pluim <rpluim@gmail.com> writes:

> martin rudalics <rudalics@gmx.at> writes:
>
>>> 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.
>>
>> When 'left' and top' are negative, they specify a frame position
>> relative to the right or bottom edge of the display.  Are such
>> specifications affected/corrected by your patch with scaling on?
>
> They will almost certainly be corrected. My testcase involved
> destop-save, which doesn't use such specifications for frames as far
> as I know, I'll have to do some manual testing.

Negative offsets work correctly with my patch.

Robert



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

end of thread, other threads:[~2018-01-22 12:49 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-01-18 14:32 [PATCH] Fix frameset-restore in the presence of scaling Robert Pluim
2018-01-19 18:55 ` martin rudalics
2018-01-22 10:58   ` Robert Pluim
2018-01-22 12:49     ` Robert Pluim

Code repositories for project(s) associated with this public inbox

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

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 read-only IMAP folder(s) and NNTP newsgroup(s).