[gtk/wip/carlosg/rewritten-events-from-other-toplevels: 1/2] gtk/main: Make coords out of surface when rewriting events for grabs




commit aa43d97a80ffd07afa3e30d538bf1ebbd4d94e81
Author: Carlos Garnacho <carlosg gnome org>
Date:   Mon Mar 14 13:29:11 2022 +0100

    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

 gtk/gtkmain.c | 22 +---------------------
 1 file changed, 1 insertion(+), 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,31 +899,11 @@ 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);
 
-  switch ((guint) type)
-    {
-    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:


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]