summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNelson Benítez León <nbenitezl@gmail.com>2020-10-19 19:14:56 -0400
committerNelson Benítez León <nbenitezl@gmail.com>2020-10-19 21:20:37 -0400
commit3954acc6f75420e16dd66dcf8bdcf4753d717873 (patch)
treef05bc41ed2f28f49a261cf8a50f34038540cb470
parentfab2558747ace63ee656257f7001f81b3c6b9b49 (diff)
downloadgtk+-BUG_tooltip_position_CLEAN.tar.gz
GtkTooltip: fix tooltip position when inside a Popover in WaylandBUG_tooltip_position_CLEAN
When pointer is over a Popover in Wayland, gdk_window_get_device_position() call fails to retrieve x relative to the passed in toplevel widget, and instead returns x relative to the Popover. So to fix that behaviour in the GtkTooltip code, we use gtk_widget_translate_coordinates() to obtain the x offset of the Popover wrt the toplevel widget, and then add that to the previous incomplete pointer_x so now pointer_x contains the expected x relative to the 'effective_toplevel' widget. This fixes issue #1708
-rw-r--r--gtk/gtktooltip.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/gtk/gtktooltip.c b/gtk/gtktooltip.c
index 9917d93197..065f30a416 100644
--- a/gtk/gtktooltip.c
+++ b/gtk/gtktooltip.c
@@ -41,6 +41,7 @@
#ifdef GDK_WINDOWING_WAYLAND
#include "wayland/gdkwayland.h"
+#include "gtkpopover.h"
#endif
@@ -933,6 +934,26 @@ gtk_tooltip_position (GtkTooltip *tooltip,
device,
&pointer_x, &pointer_y, NULL);
+#ifdef GDK_WINDOWING_WAYLAND
+ if (GDK_IS_WAYLAND_DISPLAY (display))
+ {
+ /* When pointer is over a Popover in Wayland, previous gdk_window_get_device_position()
+ * call fails to retrieve x relative to the passed in 'effective_toplevel' widget, and
+ * instead returns x relative to the Popover, so to obtain the expected semantic (for
+ * this buggy case) we use gtk_widget_translate_coordinates() to obtain the x offset of
+ * the Popover wrt the toplevel widget, and then add that to pointer_x so now pointer_x
+ * contains the expected x relative to the 'effective_toplevel' widget. Issue #1708
+ */
+ GtkWidget *popover = gtk_widget_get_ancestor (new_tooltip_widget, GTK_TYPE_POPOVER);
+ if (popover)
+ {
+ int popover_x;
+ gtk_widget_translate_coordinates (popover, toplevel, 0, 0, &popover_x, NULL);
+ pointer_x += popover_x;
+ }
+ }
+#endif
+
if (anchor_rect.height > max_anchor_rect_height)
{
anchor_rect.x = pointer_x - 4;