summaryrefslogtreecommitdiff
path: root/gtk/gtkmain.c
diff options
context:
space:
mode:
authorCarlos Garnacho <carlosg@gnome.org>2022-03-14 13:29:11 +0100
committerCarlos Garnacho <carlosg@gnome.org>2022-03-15 14:29:16 +0100
commitaa43d97a80ffd07afa3e30d538bf1ebbd4d94e81 (patch)
treeb3826884a8a06333beb87ee9027c5d182c9e0751 /gtk/gtkmain.c
parenteb599653e653ca185648fef3131ad65e3597fd2d (diff)
downloadgtk+-aa43d97a80ffd07afa3e30d538bf1ebbd4d94e81.tar.gz
gtk/main: Make coords out of surface when rewriting events for grabs
If a grab is held on a toplevel surface tree, and events happen on a different surface tree from another toplevel/window group, we rewrite these events so they look like generated on the window group that holds the grab, but it missed that coordinates would fail to be translated, so these would stay unchanged and "pointing" to random parts of the toplevel that is holding the grab and handling the events. Since off-surface coordinates are not specially meaningful, and in fact impossible to obtain in some backends, just fake the coordinates making it sure that all rewritten events point outside the surface. The grabbing window will still handle the events, but the coordinates in these will be harmlessly moot. Fixes: https://gitlab.gnome.org/GNOME/gtk/-/issues/4760
Diffstat (limited to 'gtk/gtkmain.c')
-rw-r--r--gtk/gtkmain.c22
1 files changed, 1 insertions, 21 deletions
diff --git a/gtk/gtkmain.c b/gtk/gtkmain.c
index aa32930242..470dc54315 100644
--- a/gtk/gtkmain.c
+++ b/gtk/gtkmain.c
@@ -899,7 +899,7 @@ rewrite_event_for_surface (GdkEvent *event,
GdkSurface *new_surface)
{
GdkEventType type;
- double x, y;
+ double x = -G_MAXDOUBLE, y = -G_MAXDOUBLE;
double dx, dy;
type = gdk_event_get_event_type (event);
@@ -908,26 +908,6 @@ rewrite_event_for_surface (GdkEvent *event,
{
case GDK_BUTTON_PRESS:
case GDK_BUTTON_RELEASE:
- case GDK_MOTION_NOTIFY:
- case GDK_TOUCH_BEGIN:
- case GDK_TOUCH_UPDATE:
- case GDK_TOUCH_END:
- case GDK_TOUCH_CANCEL:
- case GDK_TOUCHPAD_SWIPE:
- case GDK_TOUCHPAD_PINCH:
- case GDK_TOUCHPAD_HOLD:
- gdk_event_get_position (event, &x, &y);
- gdk_surface_translate_coordinates (gdk_event_get_surface (event), new_surface, &x, &y);
- break;
- default:
- x = y = 0;
- break;
- }
-
- switch ((guint) type)
- {
- case GDK_BUTTON_PRESS:
- case GDK_BUTTON_RELEASE:
return gdk_button_event_new (type,
new_surface,
gdk_event_get_device (event),