unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Robert Pluim <rpluim@gmail.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: 31223@debbugs.gnu.org, tbading@web.de
Subject: bug#31223: [PATCH] Fix empty/incorrect GTK menus on HiDPI monitors with window scaling factor > 1
Date: Tue, 17 Dec 2019 15:43:50 +0100	[thread overview]
Message-ID: <m2bls7t3kp.fsf@gmail.com> (raw)
In-Reply-To: <vu7c70k1t285s5.fsf@chaotikum.eu>

>>>>> On Tue, 03 Dec 2019 09:22:16 +0100, Robert Pluim <rpluim@gmail.com> said:

    Robert> Iʼll leave the bug open until I get a chance to verify the
    Robert> multi-monitor cases.

So the multi-monitor case is either interesting or annoying, depending
on your point of view.

Under Wayland GTK supports per-monitor scaling values, and returns
scaled values for the geometry of the monitors, so normally you'd need
to scale width/height and the coordinates of the top left corner for
each monitor. However, let's say you have two monitors next to each
other, with the tops aligned:

A: 3840x2160 | B: 1920x1080

with scaling factors A: 2, B: 1

You'd want to report the geometry of B as

(3840 0 1920 1080)

but because the GTK API gives you scaled values, it becomes

(1920 0 1920 1080)

which is incoherent with the workarea, where we are scaling back up:

(3840 0 1920 1080)

Normally you wouldnʼt know that you need to scale this by 2, except
that the scaling factor of B is actually reported as 2, not 1, so
applying scaling gets us the right answer. This 'error' in reporting
the scaling factor is because Emacs is not a pure GTK application: a
pure GTK application reports 2 and 1 for the scaling factors.

So until Emacs is a pure GTK app [1], I propose the following:

diff --git a/src/xfns.c b/src/xfns.c
index 47aa19607f..51a46bd6db 100644
--- a/src/xfns.c
+++ b/src/xfns.c
@@ -5091,6 +5091,8 @@ DEFUN ("x-display-monitor-attributes-list", Fx_display_monitor_attributes_list,
 #elif defined HAVE_GTK3
       scale = gdk_screen_get_monitor_scale_factor (gscreen, i);
 #endif
+      rec.x *= scale;
+      rec.y *= scale;
       rec.width *= scale;
       rec.height *= scale;
       work.x *= scale;

Footnotes:
[1]  When it is, we can stop doing this scaling entirely, the toolkit
     will take care of it for us.






  reply	other threads:[~2019-12-17 14:43 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-20 11:40 bug#31223: 25.3; New menus are empty with GTK3 Thomas Schneider
     [not found] ` <handler.31223.B.15242361664927.ack@debbugs.gnu.org>
2018-05-01 16:16   ` Thomas Schneider
2018-05-01 16:48     ` Eli Zaretskii
2018-05-01 17:01       ` Thomas Schneider
2018-05-01 17:08         ` Eli Zaretskii
2018-05-01 17:20           ` Thomas Schneider
2018-05-01 18:43             ` Eli Zaretskii
2018-05-03  8:36               ` Thomas Schneider
2018-05-03 17:52                 ` Eli Zaretskii
2018-07-20 22:44         ` Noam Postavsky
2018-05-01 23:18 ` Noam Postavsky
2019-11-27 16:03 ` bug#31223: [PATCH] Fix empty/incorrect GTK menus on HiDPI monitors with window scaling factor > 1 Tobias Bading
2019-11-28  8:20   ` Robert Pluim
2019-11-28  9:32     ` Tobias Bading
2019-11-28  9:44       ` Robert Pluim
2019-12-02 10:35         ` Robert Pluim
2019-12-02 15:53           ` Eli Zaretskii
2019-12-03  8:22             ` Robert Pluim
2019-12-17 14:43               ` Robert Pluim [this message]
2020-01-07 16:15                 ` Robert Pluim
2020-01-07 16:22                   ` Eli Zaretskii
2020-01-07 16:31                     ` Robert Pluim
2019-11-28 12:04       ` Noam Postavsky

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

  List information: https://www.gnu.org/software/emacs/

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

  git send-email \
    --in-reply-to=m2bls7t3kp.fsf@gmail.com \
    --to=rpluim@gmail.com \
    --cc=31223@debbugs.gnu.org \
    --cc=eliz@gnu.org \
    --cc=tbading@web.de \
    /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 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).