aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRobert Pluim2018-06-22 09:59:47 +0200
committerRobert Pluim2018-06-22 10:02:27 +0200
commitd22b8d1ad12c69a2c97bb9f4c9eb4316df13429e (patch)
tree45ce3777c6981d549c1435f1fb9e3e39a3c3a797 /src
parent3d2e3dc1ca8ee7226668ab5bbd35061d37bcbbec (diff)
downloademacs-d22b8d1ad12c69a2c97bb9f4c9eb4316df13429e.tar.gz
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')
-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
1162 GtkRequisition req; 1162 GtkRequisition req;
1163 int max_x = -1; 1163 int max_x = -1;
1164 int max_y = -1; 1164 int max_y = -1;
1165#ifdef HAVE_GTK3
1166 int scale;
1167#endif
1165 1168
1166 Lisp_Object frame, workarea; 1169 Lisp_Object frame, workarea;
1167 1170
1168 XSETFRAME (frame, data->f); 1171 XSETFRAME (frame, data->f);
1169 1172
1173#ifdef HAVE_GTK3
1174 scale = xg_get_scale (data->f);
1175#endif
1170 /* TODO: Get the monitor workarea directly without calculating other 1176 /* TODO: Get the monitor workarea directly without calculating other
1171 items in x-display-monitor-attributes-list. */ 1177 items in x-display-monitor-attributes-list. */
1172 workarea = call3 (Qframe_monitor_workarea, 1178 workarea = call3 (Qframe_monitor_workarea,
@@ -1192,11 +1198,20 @@ menu_position_func (GtkMenu *menu, gint *x, gint *y, gboolean *push_in, gpointer
1192 max_y = x_display_pixel_height (dpyinfo); 1198 max_y = x_display_pixel_height (dpyinfo);
1193 } 1199 }
1194 1200
1201 /* frame-monitor-workarea and {x,y}_display_pixel_width/height all
1202 return device pixels, but GTK wants scaled pixels. The positions
1203 passed in via data were already scaled for us. */
1204#ifdef HAVE_GTK3
1205 max_x /= scale;
1206 max_y /= scale;
1207#endif
1195 *x = data->x; 1208 *x = data->x;
1196 *y = data->y; 1209 *y = data->y;
1197 1210
1198 /* Check if there is room for the menu. If not, adjust x/y so that 1211 /* Check if there is room for the menu. If not, adjust x/y so that
1199 the menu is fully visible. */ 1212 the menu is fully visible. gtk_widget_get_preferred_size returns
1213 scaled pixels, so there is no need to apply the scaling
1214 factor. */
1200 gtk_widget_get_preferred_size (GTK_WIDGET (menu), NULL, &req); 1215 gtk_widget_get_preferred_size (GTK_WIDGET (menu), NULL, &req);
1201 if (data->x + req.width > max_x) 1216 if (data->x + req.width > max_x)
1202 *x -= data->x + req.width - max_x; 1217 *x -= data->x + req.width - max_x;