summaryrefslogtreecommitdiff
path: root/src/xmenu.c
diff options
context:
space:
mode:
authorGlenn Morris <rgm@gnu.org>2018-06-23 07:50:59 -0700
committerGlenn Morris <rgm@gnu.org>2018-06-23 07:50:59 -0700
commitb81e193ac0c4644d041a4eb4fa4cb62cf9446bd6 (patch)
tree837db70e4aff8fce66886b0cfbe82dbccdea4b06 /src/xmenu.c
parent4df361557c3f1b4039fa59d23cd1ed66c2ca5b1c (diff)
parent5cb3991a4f78b39a2c95b22a5159ae3ba779397e (diff)
downloademacs-b81e193ac0c4644d041a4eb4fa4cb62cf9446bd6.tar.gz
Merge from origin/emacs-26
5cb3991 Fix a typo in emacs-lisp-intro.texi d6aa55e Avoid segfaults in replace-buffer-contents with large buffers d22b8d1 Adjust for scaling for mode-line popup menus (Bug#31880) 3d2e3dc Change name of `seqp' argument (Bug#26411) 40e1db8 Change index of ";" to better reflect it's usage (Bug#31623) d289e7e Fix bug of 'mouse-drag-and-drop-region' to detect edges of re... e292c09 Fix #'fun handling inside `labels' (Bug#31792)
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 22995d8c7e8..6477d5b0aca 100644
--- a/src/xmenu.c
+++ b/src/xmenu.c
@@ -1158,11 +1158,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,
@@ -1188,11 +1194,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;