Commit 4198b4d9 authored by Lars Ingebrigtsen's avatar Lars Ingebrigtsen

Get positions of menus and tooltips right on HiDPI

* src/gtkutil.c (xg_get_scale): New function.
(xg_show_tooltip): Use it.

* src/xmenu.c (create_and_show_popup_menu): Put menus in the
right place.
parent 8729634c
......@@ -204,6 +204,14 @@ xg_display_open (char *display_name, Display **dpy)
*dpy = gdpy ? GDK_DISPLAY_XDISPLAY (gdpy) : NULL;
}
/* Scaling/HiDPI functions. */
int
xg_get_scale (struct frame *f)
{
if (FRAME_VISIBLE_P (f) && FRAME_GTK_WIDGET (f))
return gtk_widget_get_scale_factor (FRAME_GTK_WIDGET (f));
return 1;
}
/* Close display DPY. */
......@@ -724,7 +732,8 @@ xg_show_tooltip (struct frame *f, int root_x, int root_y)
if (x->ttip_window)
{
block_input ();
gtk_window_move (x->ttip_window, root_x, root_y);
gtk_window_move (x->ttip_window, root_x / xg_get_scale (f),
root_y / xg_get_scale (f));
gtk_widget_show_all (GTK_WIDGET (x->ttip_window));
unblock_input ();
}
......
......@@ -156,6 +156,7 @@ extern void xg_frame_resized (struct frame *f,
extern void xg_frame_set_char_size (struct frame *f, int width, int height);
extern GtkWidget * xg_win_to_widget (Display *dpy, Window wdesc);
extern int xg_get_scale (struct frame *f);
extern void xg_display_open (char *display_name, Display **dpy);
extern void xg_display_close (Display *dpy);
extern GdkCursor * xg_create_default_cursor (Display *dpy);
......
......@@ -1271,6 +1271,11 @@ create_and_show_popup_menu (struct frame *f, widget_value *first_wv,
/* Child of win. */
&dummy_window);
#ifdef HAVE_GTK3
/* Use window scaling factor to adjust position for hidpi screens. */
x /= xg_get_scale (f);
y /= xg_get_scale (f);
#endif
unblock_input ();
popup_x_y.x = x;
popup_x_y.y = y;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment