[mutter/gbsneto/cleanup-x11-from-meta-window: 4/5] window: Trap X11 warp pointer errors on MetaBackendX11



commit 762fc99e3f421ff696f7b3614f74b20a07f26ba1
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date:   Sat Dec 22 19:19:16 2018 -0200

    window: Trap X11 warp pointer errors on MetaBackendX11
    
    Only the X11 backend cares about trapping X11 errors when
    warping pointers, and there is no reason for it to be done
    by MetaWindow.
    
    Move the push()/pop() calls to MetaBackendX11, and simplify
    warp_grab_pointer() by removing the boolean return value
    that is not being used anywhere.
    
    https://gitlab.gnome.org/GNOME/mutter/merge_requests/372

 src/backends/x11/meta-backend-x11.c |  9 +++++++++
 src/core/window.c                   | 18 ++----------------
 2 files changed, 11 insertions(+), 16 deletions(-)
---
diff --git a/src/backends/x11/meta-backend-x11.c b/src/backends/x11/meta-backend-x11.c
index c1c976986..3eace0b0b 100644
--- a/src/backends/x11/meta-backend-x11.c
+++ b/src/backends/x11/meta-backend-x11.c
@@ -43,6 +43,7 @@
 #include "compositor/compositor-private.h"
 #include "core/display-private.h"
 #include "meta/meta-cursor-tracker.h"
+#include "meta/meta-x11-errors.h"
 #include "meta/util.h"
 
 struct _MetaBackendX11Private
@@ -589,6 +590,10 @@ meta_backend_x11_warp_pointer (MetaBackend *backend,
 {
   MetaBackendX11 *x11 = META_BACKEND_X11 (backend);
   MetaBackendX11Private *priv = meta_backend_x11_get_instance_private (x11);
+  MetaDisplay *display = meta_get_display ();
+
+  if (display)
+    meta_x11_error_trap_push (display->x11_display);
 
   XIWarpPointer (priv->xdisplay,
                  META_VIRTUAL_CORE_POINTER_ID,
@@ -596,6 +601,10 @@ meta_backend_x11_warp_pointer (MetaBackend *backend,
                  meta_backend_x11_get_xwindow (x11),
                  0, 0, 0, 0,
                  x, y);
+
+  if (display &&
+      meta_x11_error_trap_pop_with_return (display->x11_display) != Success)
+    meta_verbose ("Failed to warp pointer\n");
 }
 
 static MetaLogicalMonitor *
diff --git a/src/core/window.c b/src/core/window.c
index aa5522938..1d08f4716 100644
--- a/src/core/window.c
+++ b/src/core/window.c
@@ -52,7 +52,6 @@
 #include "meta/group.h"
 #include "meta/meta-cursor-tracker.h"
 #include "meta/meta-enum-types.h"
-#include "meta/meta-x11-errors.h"
 #include "meta/prefs.h"
 #include "ui/ui.h"
 #include "x11/meta-x11-display-private.h"
@@ -6797,7 +6796,7 @@ meta_window_is_ancestor_of_transient (MetaWindow *window,
 /* Warp pointer to location appropriate for grab,
  * return root coordinates where pointer ended up.
  */
-static gboolean
+static void
 warp_grab_pointer (MetaWindow          *window,
                    MetaGrabOp           grab_op,
                    int                 *x,
@@ -6838,8 +6837,6 @@ warp_grab_pointer (MetaWindow          *window,
   *x = CLAMP (*x, 0, display_rect.width - 1);
   *y = CLAMP (*y, 0, display_rect.height - 1);
 
-  meta_x11_error_trap_push (display->x11_display);
-
   meta_topic (META_DEBUG_WINDOW_OPS,
               "Warping pointer to %d,%d with window at %d,%d\n",
               *x, *y, rect.x, rect.y);
@@ -6855,19 +6852,8 @@ warp_grab_pointer (MetaWindow          *window,
   meta_window_get_frame_rect (window,
                               &display->grab_anchor_window_pos);
 
-  {
-    MetaBackend *backend = meta_get_backend ();
-    meta_backend_warp_pointer (backend, *x, *y);
-  }
-
-  if (meta_x11_error_trap_pop_with_return (display->x11_display) != Success)
-    {
-      meta_verbose ("Failed to warp pointer for window %s\n",
-                    window->desc);
-      return FALSE;
-    }
 
-  return TRUE;
+  meta_backend_warp_pointer (meta_get_backend (), *x, *y);
 }
 
 void


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