[mutter/gnome-3-30] display: Move finishing of touch sequence to the backend



commit fa3f2272369ef597b6dd34942d0d03293a37bdde
Author: Jonas Ådahl <jadahl gmail com>
Date:   Thu Oct 24 21:19:36 2019 +0200

    display: Move finishing of touch sequence to the backend
    
    We need to manipulate an X11 grab when a touch sequence ends; move that
    logic to where it belongs - in the X11 backend.
    
    https://gitlab.gnome.org/GNOME/mutter/merge_requests/886

 src/backends/meta-backend-private.h     | 16 ++++++++++++++++
 src/backends/meta-backend.c             | 14 ++++++++++++++
 src/backends/x11/meta-backend-x11.c     | 23 +++++++++++++++++++++++
 src/core/display.c                      | 33 +++++++++++++++------------------
 src/core/meta-gesture-tracker-private.h |  9 ++-------
 5 files changed, 70 insertions(+), 25 deletions(-)
---
diff --git a/src/backends/meta-backend-private.h b/src/backends/meta-backend-private.h
index d3467940e..486317357 100644
--- a/src/backends/meta-backend-private.h
+++ b/src/backends/meta-backend-private.h
@@ -51,6 +51,14 @@
 #define META_TYPE_BACKEND (meta_backend_get_type ())
 G_DECLARE_DERIVABLE_TYPE (MetaBackend, meta_backend, META, BACKEND, GObject)
 
+typedef enum
+{
+  META_SEQUENCE_NONE,
+  META_SEQUENCE_ACCEPTED,
+  META_SEQUENCE_REJECTED,
+  META_SEQUENCE_PENDING_END
+} MetaSequenceState;
+
 struct _MetaBackendClass
 {
   GObjectClass parent_class;
@@ -73,6 +81,10 @@ struct _MetaBackendClass
                               int          device_id,
                               uint32_t     timestamp);
 
+  void (* finish_touch_sequence) (MetaBackend          *backend,
+                                  ClutterEventSequence *sequence,
+                                  MetaSequenceState     state);
+
   void (* warp_pointer) (MetaBackend *backend,
                          int          x,
                          int          y);
@@ -136,6 +148,10 @@ gboolean meta_backend_ungrab_device (MetaBackend *backend,
                                      int          device_id,
                                      uint32_t     timestamp);
 
+void meta_backend_finish_touch_sequence (MetaBackend          *backend,
+                                         ClutterEventSequence *sequence,
+                                         MetaSequenceState     state);
+
 void meta_backend_warp_pointer (MetaBackend *backend,
                                 int          x,
                                 int          y);
diff --git a/src/backends/meta-backend.c b/src/backends/meta-backend.c
index 6d1c22e65..191d18059 100644
--- a/src/backends/meta-backend.c
+++ b/src/backends/meta-backend.c
@@ -960,6 +960,20 @@ meta_backend_ungrab_device (MetaBackend *backend,
   return META_BACKEND_GET_CLASS (backend)->ungrab_device (backend, device_id, timestamp);
 }
 
+/**
+ * meta_backend_finish_touch_sequence: (skip)
+ */
+void
+meta_backend_finish_touch_sequence (MetaBackend          *backend,
+                                    ClutterEventSequence *sequence,
+                                    MetaSequenceState     state)
+{
+  if (META_BACKEND_GET_CLASS (backend)->finish_touch_sequence)
+    META_BACKEND_GET_CLASS (backend)->finish_touch_sequence (backend,
+                                                             sequence,
+                                                             state);
+}
+
 /**
  * meta_backend_warp_pointer: (skip)
  */
diff --git a/src/backends/x11/meta-backend-x11.c b/src/backends/x11/meta-backend-x11.c
index ed81364e2..f01fa9ffd 100644
--- a/src/backends/x11/meta-backend-x11.c
+++ b/src/backends/x11/meta-backend-x11.c
@@ -584,6 +584,28 @@ meta_backend_x11_ungrab_device (MetaBackend *backend,
   return (ret == Success);
 }
 
+static void
+meta_backend_x11_finish_touch_sequence (MetaBackend          *backend,
+                                        ClutterEventSequence *sequence,
+                                        MetaSequenceState     state)
+{
+  MetaBackendX11 *x11 = META_BACKEND_X11 (backend);
+  MetaBackendX11Private *priv = meta_backend_x11_get_instance_private (x11);
+  int event_mode;
+
+  if (state == META_SEQUENCE_ACCEPTED)
+    event_mode = XIAcceptTouch;
+  else if (state == META_SEQUENCE_REJECTED)
+    event_mode = XIRejectTouch;
+  else
+    g_return_if_reached ();
+
+  XIAllowTouchEvents (priv->xdisplay,
+                      META_VIRTUAL_CORE_POINTER_ID,
+                      clutter_x11_event_sequence_get_touch_detail (sequence),
+                      DefaultRootWindow (priv->xdisplay), event_mode);
+}
+
 static void
 meta_backend_x11_warp_pointer (MetaBackend *backend,
                                int          x,
@@ -769,6 +791,7 @@ meta_backend_x11_class_init (MetaBackendX11Class *klass)
   backend_class->post_init = meta_backend_x11_post_init;
   backend_class->grab_device = meta_backend_x11_grab_device;
   backend_class->ungrab_device = meta_backend_x11_ungrab_device;
+  backend_class->finish_touch_sequence = meta_backend_x11_finish_touch_sequence;
   backend_class->warp_pointer = meta_backend_x11_warp_pointer;
   backend_class->get_current_logical_monitor = meta_backend_x11_get_current_logical_monitor;
   backend_class->get_keymap = meta_backend_x11_get_keymap;
diff --git a/src/core/display.c b/src/core/display.c
index f6b4d5b9f..3537ace9c 100644
--- a/src/core/display.c
+++ b/src/core/display.c
@@ -57,6 +57,7 @@
 #include "backends/native/meta-backend-native.h"
 #include "backends/x11/meta-backend-x11.h"
 #include "backends/meta-stage-private.h"
+#include "backends/meta-backend-private.h"
 #include "backends/meta-input-settings-private.h"
 #include <clutter/x11/clutter-x11.h>
 
@@ -602,27 +603,23 @@ gesture_tracker_state_changed (MetaGestureTracker   *tracker,
                                MetaSequenceState     state,
                                MetaDisplay          *display)
 {
-  if (meta_is_wayland_compositor ())
+  switch (state)
     {
-      if (state == META_SEQUENCE_ACCEPTED)
-        meta_display_cancel_touch (display);
-    }
-  else
-    {
-      MetaBackendX11 *backend = META_BACKEND_X11 (meta_get_backend ());
-      int event_mode;
+    case META_SEQUENCE_NONE:
+    case META_SEQUENCE_PENDING_END:
+      return;
+    case META_SEQUENCE_ACCEPTED:
+      meta_display_cancel_touch (display);
 
-      if (state == META_SEQUENCE_ACCEPTED)
-        event_mode = XIAcceptTouch;
-      else if (state == META_SEQUENCE_REJECTED)
-        event_mode = XIRejectTouch;
-      else
-        return;
+      /* Intentional fall-through */
+    case META_SEQUENCE_REJECTED:
+      {
+        MetaBackend *backend;
 
-      XIAllowTouchEvents (meta_backend_x11_get_xdisplay (backend),
-                          META_VIRTUAL_CORE_POINTER_ID,
-                          clutter_x11_event_sequence_get_touch_detail (sequence),
-                          DefaultRootWindow (display->x11_display->xdisplay), event_mode);
+        backend = meta_get_backend ();
+        meta_backend_finish_touch_sequence (backend, sequence, state);
+        break;
+      }
     }
 }
 
diff --git a/src/core/meta-gesture-tracker-private.h b/src/core/meta-gesture-tracker-private.h
index 0e39af27f..35c64c0f2 100644
--- a/src/core/meta-gesture-tracker-private.h
+++ b/src/core/meta-gesture-tracker-private.h
@@ -28,6 +28,8 @@
 #include <clutter/clutter.h>
 #include <meta/window.h>
 
+#include "backends/meta-backend-private.h"
+
 #define META_TYPE_GESTURE_TRACKER            (meta_gesture_tracker_get_type ())
 #define META_GESTURE_TRACKER(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), META_TYPE_GESTURE_TRACKER, 
MetaGestureTracker))
 #define META_GESTURE_TRACKER_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass),  META_TYPE_GESTURE_TRACKER, 
MetaGestureTrackerClass))
@@ -38,13 +40,6 @@
 typedef struct _MetaGestureTracker MetaGestureTracker;
 typedef struct _MetaGestureTrackerClass MetaGestureTrackerClass;
 
-typedef enum {
-  META_SEQUENCE_NONE,
-  META_SEQUENCE_ACCEPTED,
-  META_SEQUENCE_REJECTED,
-  META_SEQUENCE_PENDING_END
-} MetaSequenceState;
-
 struct _MetaGestureTracker
 {
   GObject parent_instance;


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