Subject: bug#58289: context-menu-mode on multi-head hidpi display

From: Po Lu <[email-masked]>
Date: Wed, 05 Oct 2022 08:24:45 +0800

Ethan Ongstad <[email-masked]> writes:

> Setup: two 4k 27" displays, left vertical, right horizontal. Using gnome
> 42.4 on X11 with 200% upscaling.
>
> Bug:
> 1. emacs -Q
> 2. M-x context-menu-mode
> 3. Go full screen on right display
> 4. right click anywhere on left half of right display
>
> Outcome: the context menu will only popup on the very most left edge of the
> right display. 
>
> Doesn't occur when 100% scaled, when using the left monitor,
> or when clicking on the right half of the right display.

Please tell me whether or not this patch resolves the problem:

diff --git a/src/xmenu.c b/src/xmenu.c
index 1452b3c6d1..f972186154 100644
--- a/src/xmenu.c
+++ b/src/xmenu.c
@@ -1430,7 +1430,11 @@ menu_position_func (GtkMenu *menu, gint *x, gint *y, gboolean *push_in, gpointer
      items in x-display-monitor-attributes-list. */
   workarea = call3 (Qframe_monitor_workarea,
                     Qnil,
-                    make_fixnum (data->x),
+#ifdef HAVE_GTK3
+                    make_fixnum (data->x * scale),
+                    make_fixnum (data->y * scale)
+#else
+		    make_fixnum (data->x),
                     make_fixnum (data->y));
 
   if (CONSP (workarea))