From: Robert Pluim <rpluim@gmail.com>
To: Tobias Bading <tbading@web.de>
Cc: 31223@debbugs.gnu.org
Subject: bug#31223: [PATCH] Fix empty/incorrect GTK menus on HiDPI monitors with window scaling factor > 1
Date: Thu, 28 Nov 2019 09:20:35 +0100 [thread overview]
Message-ID: <m24kyoif8s.fsf@gmail.com> (raw)
In-Reply-To: <0425bcb6-97ee-4845-3571-9db492966a34@web.de> (Tobias Bading's message of "Wed, 27 Nov 2019 17:03:32 +0100")
>>>>> On Wed, 27 Nov 2019 17:03:32 +0100, Tobias Bading <tbading@web.de> said:
Tobias> This should fix Bug#31223, Bug#28106, Bug#23672 as well as Ubuntu bug
Tobias> https://bugs.launchpad.net/ubuntu/+source/emacs25/+bug/1695228
If those are all the same bug we should merge them.
Tobias> Also fixes the formerly unscaled Y value returned by
Tobias> frame-monitor-workarea (and display-monitor-attributes-list).
Tobias> For details on why some GTK menus were empty please see thread
Tobias> https://lists.gnu.org/archive/html/emacs-devel/2019-11/msg01061.html
Thanks for that, I can reproduce with that (I never use the Dired
menus).
Tobias> diff --git a/src/gtkutil.c b/src/gtkutil.c
Tobias> index cf5c31aa20..7e6db57c9d 100644
Tobias> --- a/src/gtkutil.c
Tobias> +++ b/src/gtkutil.c
Tobias> @@ -3471,6 +3471,7 @@ menubar_map_cb (GtkWidget *w, gpointer user_data)
Tobias> GtkRequisition req;
Tobias> struct frame *f = user_data;
Tobias> gtk_widget_get_preferred_size (w, NULL, &req);
Tobias> + req.height *= xg_get_scale (f);
Tobias> if (FRAME_MENUBAR_HEIGHT (f) != req.height)
Tobias> {
Tobias> FRAME_MENUBAR_HEIGHT (f) = req.height;
Tobias> @@ -3502,7 +3503,7 @@ xg_update_frame_menubar (struct frame *f)
Tobias> g_signal_connect (x->menubar_widget, "map", G_CALLBACK (menubar_map_cb), f);
Tobias> gtk_widget_show_all (x->menubar_widget);
Tobias> gtk_widget_get_preferred_size (x->menubar_widget, NULL, &req);
Tobias> -
Tobias> + req.height *= xg_get_scale (f);
Tobias> if (FRAME_MENUBAR_HEIGHT (f) != req.height)
Tobias> {
Tobias> FRAME_MENUBAR_HEIGHT (f) = req.height;
Yes.
Tobias> @@ -3568,8 +3569,9 @@ xg_event_is_for_menubar (struct frame *f, const XEvent *event)
Tobias> list = gtk_container_get_children (GTK_CONTAINER (x->menubar_widget));
Tobias> if (! list) return 0;
Tobias> - rec.x = event->xbutton.x;
Tobias> - rec.y = event->xbutton.y;
Tobias> + int scale = xg_get_scale (f);
Tobias> + rec.x = event->xbutton.x / scale;
Tobias> + rec.y = event->xbutton.y / scale;
Tobias> rec.width = 1;
Tobias> rec.height = 1;
Yes. You need this as well, I think:
diff --git a/src/gtkutil.c b/src/gtkutil.c
index cf5c31aa20..4f8b06941b 100644
--- a/src/gtkutil.c
+++ b/src/gtkutil.c
@@ -3503,6 +3503,8 @@ xg_update_frame_menubar (struct frame *f)
gtk_widget_show_all (x->menubar_widget);
gtk_widget_get_preferred_size (x->menubar_widget, NULL, &req);
+ req.height *= xg_get_scale (f);
if (FRAME_MENUBAR_HEIGHT (f) != req.height)
{
FRAME_MENUBAR_HEIGHT (f) = req.height;
Tobias> diff --git a/src/xfns.c b/src/xfns.c
Tobias> index b1b40702c2..47aa19607f 100644
Tobias> --- a/src/xfns.c
Tobias> +++ b/src/xfns.c
Tobias> @@ -5093,6 +5093,8 @@ DEFUN ("x-display-monitor-attributes-list", Fx_display_monitor_attributes_list,
Tobias> #endif
Tobias> rec.width *= scale;
Tobias> rec.height *= scale;
Tobias> + work.x *= scale;
Tobias> + work.y *= scale;
Tobias> work.width *= scale;
Tobias> work.height *= scale;
This seems correct as well. Probably rec.x and rec.y need scaling as well, for
the multi-monitor case, which will require some cabling for me to test.
Robert
next prev parent reply other threads:[~2019-11-28 8:20 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 [this message]
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
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=m24kyoif8s.fsf@gmail.com \
--to=rpluim@gmail.com \
--cc=31223@debbugs.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).