Subject: bug#31223: [PATCH] Fix empty/incorrect GTK menus on HiDPI monitors with window scaling factor > 1

From: Tobias Bading <[email-masked]>
Date: Thu, 28 Nov 2019 10:32:39 +0100

On 28.11.19 09:20, Robert Pluim wrote:
 >>>>>> On Wed, 27 Nov 2019 17:03:32 +0100, Tobias Bading
<[email-masked]> 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.

Noam Postavsky already did that over a year ago, although I have no idea
what
"merging" means in this bug tracker. The new comments don't appear in the
merged reports and there's no indication as to which report became kind
of the
leading one after the merged. I simply chose 31223 because that's the
one Noam
sent his "merge 23672 28106 31223" command to, if I'm reading it right.

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

This change in xg_update_frame_menubar is already a part of my patch,
with the
only difference that I replaced the empty line. Or am I reading this hunk
wrong?

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

Good point. The documentation of gdk_monitor_get_geometry() says

"Retrieves the size and position of an individual monitor within the display
coordinate space. The returned geometry is in "application pixels", not in
"device pixels" (see gdk_monitor_get_scale_factor())."

Unfortunately, I don't have a second monitor at hand to test this.

Tobias