diff options
author | Timm Bäder <mail@baedert.org> | 2020-05-15 08:22:04 +0200 |
---|---|---|
committer | Timm Bäder <mail@baedert.org> | 2020-05-16 22:03:55 +0200 |
commit | f9370d7e836da2f7dd13b80ff60c1b7f4b31b19e (patch) | |
tree | 126750db7784fc77e76fe1d5e286f05ba1d55087 /gtk/gtkmain.c | |
parent | b2b207041524d6d97d6521030390113362cfbeac (diff) | |
download | gtk+-f9370d7e836da2f7dd13b80ff60c1b7f4b31b19e.tar.gz |
main: Translate coordinates from surface to native before picking
gtk_widget_pick() needs them to be in @self coordinates.
Diffstat (limited to 'gtk/gtkmain.c')
-rw-r--r-- | gtk/gtkmain.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/gtk/gtkmain.c b/gtk/gtkmain.c index 787abd4b23..89e1235fdf 100644 --- a/gtk/gtkmain.c +++ b/gtk/gtkmain.c @@ -96,6 +96,7 @@ #include "gsk/gskprivate.h" #include "gsk/gskrendernodeprivate.h" #include "gtkarrayimplprivate.h" +#include "gtknativeprivate.h" #include <locale.h> @@ -1511,7 +1512,8 @@ handle_pointing_event (GdkEvent *event) GtkWindow *toplevel; GdkEventSequence *sequence; GdkDevice *device; - gdouble x, y; + double x, y; + int native_x, native_y; GtkWidget *native; GdkEventType type; @@ -1522,6 +1524,10 @@ handle_pointing_event (GdkEvent *event) toplevel = GTK_WINDOW (gtk_widget_get_root (event_widget)); native = GTK_WIDGET (gtk_widget_get_native (event_widget)); + gtk_native_get_surface_transform (GTK_NATIVE (native), &native_x, &native_y); + x -= native_x; + y -= native_y; + type = gdk_event_get_event_type (event); sequence = gdk_event_get_event_sequence (event); @@ -1555,7 +1561,7 @@ handle_pointing_event (GdkEvent *event) target = gtk_window_lookup_pointer_focus_implicit_grab (toplevel, device, sequence); if (!target) - target = gtk_widget_pick (native, x, y, GTK_PICK_DEFAULT); + target = gtk_widget_pick (native, x, y, GTK_PICK_DEFAULT); if (!target) target = GTK_WIDGET (native); @@ -1601,8 +1607,7 @@ handle_pointing_event (GdkEvent *event) if (type == GDK_BUTTON_RELEASE) { - GtkWidget *new_target; - new_target = gtk_widget_pick (GTK_WIDGET (native), x, y, GTK_PICK_DEFAULT); + GtkWidget *new_target = gtk_widget_pick (native, x, y, GTK_PICK_DEFAULT); if (new_target == NULL) new_target = GTK_WIDGET (toplevel); gtk_synthesize_crossing_events (GTK_ROOT (toplevel), GTK_CROSSING_POINTER, target, new_target, |