[gtk/BUG_tooltip_position_CLEAN] GtkTooltip: fix tooltip position when inside a Popover in Wayland
- From: Nelson Ben <nbenitez src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/BUG_tooltip_position_CLEAN] GtkTooltip: fix tooltip position when inside a Popover in Wayland
- Date: Tue, 20 Oct 2020 01:22:26 +0000 (UTC)
commit 3954acc6f75420e16dd66dcf8bdcf4753d717873
Author: Nelson Benítez León <nbenitezl gmail com>
Date: Mon Oct 19 19:14:56 2020 -0400
GtkTooltip: fix tooltip position when inside a Popover in Wayland
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
gtk/gtktooltip.c | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
---
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;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]