summaryrefslogtreecommitdiff
path: root/src/xmenu.c
diff options
context:
space:
mode:
authorRobert Pluim <rpluim@gmail.com>2018-06-22 09:59:47 +0200
committerRobert Pluim <rpluim@gmail.com>2018-06-22 10:02:27 +0200
commitd22b8d1ad12c69a2c97bb9f4c9eb4316df13429e (patch)
tree45ce3777c6981d549c1435f1fb9e3e39a3c3a797 /src/xmenu.c
parent3d2e3dc1ca8ee7226668ab5bbd35061d37bcbbec (diff)
downloademacs-d22b8d1ad12c69a2c97bb9f4c9eb4316df13429e.tar.gz
emacs-d22b8d1ad12c69a2c97bb9f4c9eb4316df13429e.tar.bz2
emacs-d22b8d1ad12c69a2c97bb9f4c9eb4316df13429e.zip
Adjust for scaling for mode-line popup menus (Bug#31880)
* src/xmenu.c (menu_position_func) [HAVE_GTK3]: Take scaling into account when calculating screen size.
Diffstat (limited to 'src/xmenu.c')
-rw-r--r--src/xmenu.c17
1 files changed, 16 insertions, 1 deletions
diff --git a/src/xmenu.c b/src/xmenu.c
index e7ef31ac564..d285e568b03 100644
--- a/src/xmenu.c
+++ b/src/xmenu.c
@@ -1162,11 +1162,17 @@ menu_position_func (GtkMenu *menu, gint *x, gint *y, gboolean *push_in, gpointer
GtkRequisition req;
int max_x = -1;
int max_y = -1;
+#ifdef HAVE_GTK3
+ int scale;
+#endif
Lisp_Object frame, workarea;
XSETFRAME (frame, data->f);
+#ifdef HAVE_GTK3
+ scale = xg_get_scale (data->f);
+#endif
/* TODO: Get the monitor workarea directly without calculating other
items in x-display-monitor-attributes-list. */
workarea = call3 (Qframe_monitor_workarea,
@@ -1192,11 +1198,20 @@ menu_position_func (GtkMenu *menu, gint *x, gint *y, gboolean *push_in, gpointer
max_y = x_display_pixel_height (dpyinfo);
}
+ /* frame-monitor-workarea and {x,y}_display_pixel_width/height all
+ return device pixels, but GTK wants scaled pixels. The positions
+ passed in via data were already scaled for us. */
+#ifdef HAVE_GTK3
+ max_x /= scale;
+ max_y /= scale;
+#endif
*x = data->x;
*y = data->y;
/* Check if there is room for the menu. If not, adjust x/y so that
- the menu is fully visible. */
+ the menu is fully visible. gtk_widget_get_preferred_size returns
+ scaled pixels, so there is no need to apply the scaling
+ factor. */
gtk_widget_get_preferred_size (GTK_WIDGET (menu), NULL, &req);
if (data->x + req.width > max_x)
*x -= data->x + req.width - max_x;