[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] scratch/hidpi 6c1a219: Get positions of menus and tooltips
From: |
Lars Ingebrigtsen |
Subject: |
[Emacs-diffs] scratch/hidpi 6c1a219: Get positions of menus and tooltips right on HiDPI |
Date: |
Sun, 16 Jul 2017 10:42:44 -0400 (EDT) |
branch: scratch/hidpi
commit 6c1a2195d464934711fe4decb0ccfcaa07c55bb7
Author: Lars Ingebrigtsen <address@hidden>
Commit: Lars Ingebrigtsen <address@hidden>
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.
---
src/gtkutil.c | 11 ++++++++++-
src/gtkutil.h | 1 +
src/xmenu.c | 5 +++++
3 files changed, 16 insertions(+), 1 deletion(-)
diff --git a/src/gtkutil.c b/src/gtkutil.c
index 2d4abef..2550915 100644
--- a/src/gtkutil.c
+++ b/src/gtkutil.c
@@ -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 ();
}
diff --git a/src/gtkutil.h b/src/gtkutil.h
index 0abcb06..a252cbe 100644
--- a/src/gtkutil.h
+++ b/src/gtkutil.h
@@ -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);
diff --git a/src/xmenu.c b/src/xmenu.c
index 6c8a0c5..64df151 100644
--- a/src/xmenu.c
+++ b/src/xmenu.c
@@ -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;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] scratch/hidpi 6c1a219: Get positions of menus and tooltips right on HiDPI,
Lars Ingebrigtsen <=