[mutter/wip/carlosg/input-thread: 46/67] clutter: Make ClutterSeat::handle_device_event vfunc more generic




commit b61c3d6e9ee68f552648f31162050d8eba84cfdb
Author: Carlos Garnacho <carlosg gnome org>
Date:   Tue Aug 11 11:27:18 2020 +0200

    clutter: Make ClutterSeat::handle_device_event vfunc more generic
    
    Make it able to handle not just device added/removed events, but perform
    any kind of post-processing that needed to be done on ClutterEvents at
    the seat level.
    
    https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1403

 clutter/clutter/clutter-main.c         |  8 +-------
 clutter/clutter/clutter-mutter.h       |  3 +++
 clutter/clutter/clutter-seat.c         | 15 +++++----------
 clutter/clutter/clutter-seat.h         |  7 ++-----
 src/backends/meta-backend.c            |  5 +++++
 src/backends/native/meta-seat-native.c |  6 +++---
 src/backends/x11/meta-seat-x11.c       |  6 +++---
 7 files changed, 22 insertions(+), 28 deletions(-)
---
diff --git a/clutter/clutter/clutter-main.c b/clutter/clutter/clutter-main.c
index 0bc12383e4..090ec1e020 100644
--- a/clutter/clutter/clutter-main.c
+++ b/clutter/clutter/clutter-main.c
@@ -1938,13 +1938,7 @@ _clutter_process_event_details (ClutterActor        *stage,
 
       case CLUTTER_DEVICE_ADDED:
       case CLUTTER_DEVICE_REMOVED:
-        if (!_clutter_event_process_filters (event))
-          {
-            ClutterSeat *seat;
-
-            seat = clutter_backend_get_default_seat (context->backend);
-            clutter_seat_handle_device_event (seat, event);
-          }
+        _clutter_event_process_filters (event);
         break;
 
       case CLUTTER_EVENT_LAST:
diff --git a/clutter/clutter/clutter-mutter.h b/clutter/clutter/clutter-mutter.h
index 654c6dac0e..9c75ad6a25 100644
--- a/clutter/clutter/clutter-mutter.h
+++ b/clutter/clutter/clutter-mutter.h
@@ -71,6 +71,9 @@ gboolean clutter_actor_has_transitions (ClutterActor *actor);
 CLUTTER_EXPORT
 ClutterFrameClock * clutter_actor_pick_frame_clock (ClutterActor  *self,
                                                     ClutterActor **out_actor);
+CLUTTER_EXPORT
+gboolean clutter_seat_handle_event_post (ClutterSeat        *seat,
+                                         const ClutterEvent *event);
 
 #undef __CLUTTER_H_INSIDE__
 
diff --git a/clutter/clutter/clutter-seat.c b/clutter/clutter/clutter-seat.c
index d3e2eaa245..ed78f43a59 100644
--- a/clutter/clutter/clutter-seat.c
+++ b/clutter/clutter/clutter-seat.c
@@ -27,6 +27,7 @@
 #include "clutter-input-device-tool.h"
 #include "clutter-input-pointer-a11y-private.h"
 #include "clutter-marshal.h"
+#include "clutter-mutter.h"
 #include "clutter-private.h"
 #include "clutter-seat.h"
 #include "clutter-virtual-input-device.h"
@@ -635,8 +636,8 @@ clutter_seat_compress_motion (ClutterSeat        *seat,
 }
 
 gboolean
-clutter_seat_handle_device_event (ClutterSeat  *seat,
-                                  ClutterEvent *event)
+clutter_seat_handle_event_post (ClutterSeat        *seat,
+                                const ClutterEvent *event)
 {
   ClutterSeatClass *seat_class;
   ClutterInputDevice *device;
@@ -644,16 +645,10 @@ clutter_seat_handle_device_event (ClutterSeat  *seat,
   g_return_val_if_fail (CLUTTER_IS_SEAT (seat), FALSE);
   g_return_val_if_fail (event, FALSE);
 
-  g_assert (event->type == CLUTTER_DEVICE_ADDED ||
-            event->type == CLUTTER_DEVICE_REMOVED);
-
   seat_class = CLUTTER_SEAT_GET_CLASS (seat);
 
-  if (seat_class->handle_device_event)
-    {
-      if (!seat_class->handle_device_event (seat, event))
-        return FALSE;
-    }
+  if (seat_class->handle_event_post)
+    seat_class->handle_event_post (seat, event);
 
   device = clutter_event_get_source_device (event);
   g_assert_true (CLUTTER_IS_INPUT_DEVICE (device));
diff --git a/clutter/clutter/clutter-seat.h b/clutter/clutter/clutter-seat.h
index cb2ebf9779..6ef748fddd 100644
--- a/clutter/clutter/clutter-seat.h
+++ b/clutter/clutter/clutter-seat.h
@@ -88,8 +88,8 @@ struct _ClutterSeatClass
                             ClutterEvent       *event,
                             const ClutterEvent *to_discard);
 
-  gboolean (* handle_device_event) (ClutterSeat  *seat,
-                                    ClutterEvent *event);
+  gboolean (* handle_event_post) (ClutterSeat        *seat,
+                                  const ClutterEvent *event);
 
   void (* warp_pointer) (ClutterSeat *seat,
                          int          x,
@@ -162,9 +162,6 @@ void clutter_seat_compress_motion (ClutterSeat        *seat,
                                    ClutterEvent       *event,
                                    const ClutterEvent *to_discard);
 
-gboolean clutter_seat_handle_device_event (ClutterSeat  *seat,
-                                           ClutterEvent *event);
-
 CLUTTER_EXPORT
 void clutter_seat_warp_pointer (ClutterSeat *seat,
                                 int          x,
diff --git a/src/backends/meta-backend.c b/src/backends/meta-backend.c
index f27184f4c6..e25d629c1b 100644
--- a/src/backends/meta-backend.c
+++ b/src/backends/meta-backend.c
@@ -981,12 +981,17 @@ clutter_source_dispatch (GSource     *source,
                          gpointer     user_data)
 {
   MetaBackendSource *backend_source = (MetaBackendSource *) source;
+  MetaBackendPrivate *priv =
+    meta_backend_get_instance_private (backend_source->backend);
   ClutterEvent *event = clutter_event_get ();
+  ClutterSeat *seat;
 
   if (event)
     {
       event->any.stage =
         CLUTTER_STAGE (meta_backend_get_stage (backend_source->backend));
+      seat = clutter_backend_get_default_seat (priv->clutter_backend);
+      clutter_seat_handle_event_post (seat, event);
       clutter_do_event (event);
       clutter_event_free (event);
     }
diff --git a/src/backends/native/meta-seat-native.c b/src/backends/native/meta-seat-native.c
index e7cbf869e8..e07080daed 100644
--- a/src/backends/native/meta-seat-native.c
+++ b/src/backends/native/meta-seat-native.c
@@ -1494,8 +1494,8 @@ evdev_remove_device (MetaSeatNative        *seat,
 }
 
 static gboolean
-meta_seat_native_handle_device_event (ClutterSeat  *seat,
-                                      ClutterEvent *event)
+meta_seat_native_handle_event_post (ClutterSeat        *seat,
+                                    const ClutterEvent *event)
 {
   MetaSeatNative *seat_native = META_SEAT_NATIVE (seat);
   ClutterInputDevice *device = event->device.device;
@@ -2879,7 +2879,7 @@ meta_seat_native_class_init (MetaSeatNativeClass *klass)
   seat_class->get_supported_virtual_device_types = meta_seat_native_get_supported_virtual_device_types;
   seat_class->compress_motion = meta_seat_native_compress_motion;
   seat_class->warp_pointer = meta_seat_native_warp_pointer;
-  seat_class->handle_device_event = meta_seat_native_handle_device_event;
+  seat_class->handle_event_post = meta_seat_native_handle_event_post;
   seat_class->query_state = meta_seat_native_query_state;
 
   props[PROP_SEAT_ID] =
diff --git a/src/backends/x11/meta-seat-x11.c b/src/backends/x11/meta-seat-x11.c
index 6bc8f851e9..de9a76640a 100644
--- a/src/backends/x11/meta-seat-x11.c
+++ b/src/backends/x11/meta-seat-x11.c
@@ -719,8 +719,8 @@ remove_device (MetaSeatX11        *seat_x11,
 }
 
 static gboolean
-meta_seat_x11_handle_device_event (ClutterSeat  *seat,
-                                   ClutterEvent *event)
+meta_seat_x11_handle_event_post (ClutterSeat        *seat,
+                                 const ClutterEvent *event)
 {
   MetaSeatX11 *seat_x11 = META_SEAT_X11 (seat);
   ClutterInputDevice *device = event->device.device;
@@ -1740,7 +1740,7 @@ meta_seat_x11_class_init (MetaSeatX11Class *klass)
   seat_class->create_virtual_device = meta_seat_x11_create_virtual_device;
   seat_class->get_supported_virtual_device_types = meta_seat_x11_get_supported_virtual_device_types;
   seat_class->warp_pointer = meta_seat_x11_warp_pointer;
-  seat_class->handle_device_event = meta_seat_x11_handle_device_event;
+  seat_class->handle_event_post = meta_seat_x11_handle_event_post;
   seat_class->query_state = meta_seat_x11_query_state;
 
   props[PROP_OPCODE] =


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