[mutter/wip/carlosg/clutter-seat: 23/36] clutter: Drop select_stage_events() device manager vfunc



commit 2844498e2ba481b54944182001175ee1ef375bd0
Author: Carlos Garnacho <carlosg gnome org>
Date:   Wed Oct 2 17:00:54 2019 +0200

    clutter: Drop select_stage_events() device manager vfunc
    
    This is specific to X11, so handle it within the X11 backend.
    
    https://gitlab.gnome.org/GNOME/mutter/merge_requests/852

 clutter/clutter/clutter-device-manager-private.h |  3 --
 clutter/clutter/clutter-device-manager.c         | 13 ---------
 clutter/clutter/clutter-device-manager.h         |  2 --
 src/backends/x11/meta-device-manager-x11.c       | 37 ------------------------
 src/backends/x11/meta-seat-x11.c                 | 36 +++++++++++++++++++++++
 src/backends/x11/meta-seat-x11.h                 |  2 ++
 src/backends/x11/meta-stage-x11.c                | 14 ++-------
 7 files changed, 41 insertions(+), 66 deletions(-)
---
diff --git a/clutter/clutter/clutter-device-manager-private.h 
b/clutter/clutter/clutter-device-manager-private.h
index 49f0c363b..1f0191211 100644
--- a/clutter/clutter/clutter-device-manager-private.h
+++ b/clutter/clutter/clutter-device-manager-private.h
@@ -203,9 +203,6 @@ CLUTTER_EXPORT
 void            _clutter_device_manager_remove_device           (ClutterDeviceManager *device_manager,
                                                                  ClutterInputDevice   *device);
 void            _clutter_device_manager_update_devices          (ClutterDeviceManager *device_manager);
-CLUTTER_EXPORT
-void            _clutter_device_manager_select_stage_events     (ClutterDeviceManager *device_manager,
-                                                                 ClutterStage         *stage);
 ClutterBackend *_clutter_device_manager_get_backend             (ClutterDeviceManager *device_manager);
 
 /* input device */
diff --git a/clutter/clutter/clutter-device-manager.c b/clutter/clutter/clutter-device-manager.c
index 056edd581..c8164ae09 100644
--- a/clutter/clutter/clutter-device-manager.c
+++ b/clutter/clutter/clutter-device-manager.c
@@ -311,19 +311,6 @@ clutter_device_manager_get_core_device (ClutterDeviceManager   *device_manager,
   return manager_class->get_core_device (device_manager, device_type);
 }
 
-void
-_clutter_device_manager_select_stage_events (ClutterDeviceManager *device_manager,
-                                             ClutterStage         *stage)
-{
-  ClutterDeviceManagerClass *manager_class;
-
-  g_return_if_fail (CLUTTER_IS_DEVICE_MANAGER (device_manager));
-
-  manager_class = CLUTTER_DEVICE_MANAGER_GET_CLASS (device_manager);
-  if (manager_class->select_stage_events)
-    manager_class->select_stage_events (device_manager, stage);
-}
-
 /*
  * _clutter_device_manager_add_device:
  * @device_manager: a #ClutterDeviceManager
diff --git a/clutter/clutter/clutter-device-manager.h b/clutter/clutter/clutter-device-manager.h
index 8ef3ed5f8..3fe45fec0 100644
--- a/clutter/clutter/clutter-device-manager.h
+++ b/clutter/clutter/clutter-device-manager.h
@@ -62,8 +62,6 @@ struct _ClutterDeviceManagerClass
                                            ClutterInputDevice     *device);
   void                (* remove_device)   (ClutterDeviceManager   *manager,
                                            ClutterInputDevice     *device);
-  void                (* select_stage_events) (ClutterDeviceManager *manager,
-                                               ClutterStage       *stage);
 
   /* padding */
   gpointer _padding[4];
diff --git a/src/backends/x11/meta-device-manager-x11.c b/src/backends/x11/meta-device-manager-x11.c
index e78e2cdf7..3db27bbbf 100644
--- a/src/backends/x11/meta-device-manager-x11.c
+++ b/src/backends/x11/meta-device-manager-x11.c
@@ -51,42 +51,6 @@ G_DEFINE_TYPE (MetaDeviceManagerX11,
                meta_device_manager_x11,
                CLUTTER_TYPE_DEVICE_MANAGER)
 
-static void
-meta_device_manager_x11_select_stage_events (ClutterDeviceManager *manager,
-                                             ClutterStage         *stage)
-{
-  MetaStageX11 *stage_x11;
-  XIEventMask xi_event_mask;
-  unsigned char *mask;
-  int len;
-
-  stage_x11 = META_STAGE_X11 (_clutter_stage_get_window (stage));
-
-  len = XIMaskLen (XI_LASTEVENT);
-  mask = g_new0 (unsigned char, len);
-
-  XISetMask (mask, XI_Motion);
-  XISetMask (mask, XI_ButtonPress);
-  XISetMask (mask, XI_ButtonRelease);
-  XISetMask (mask, XI_KeyPress);
-  XISetMask (mask, XI_KeyRelease);
-  XISetMask (mask, XI_Enter);
-  XISetMask (mask, XI_Leave);
-
-  XISetMask (mask, XI_TouchBegin);
-  XISetMask (mask, XI_TouchUpdate);
-  XISetMask (mask, XI_TouchEnd);
-
-  xi_event_mask.deviceid = XIAllMasterDevices;
-  xi_event_mask.mask = mask;
-  xi_event_mask.mask_len = len;
-
-  XISelectEvents (clutter_x11_get_default_display (),
-                  stage_x11->xwin, &xi_event_mask, 1);
-
-  g_free (mask);
-}
-
 static void
 meta_device_manager_x11_add_device (ClutterDeviceManager *manager,
                                     ClutterInputDevice   *device)
@@ -253,7 +217,6 @@ meta_device_manager_x11_class_init (MetaDeviceManagerX11Class *klass)
   manager_class->get_devices = meta_device_manager_x11_get_devices;
   manager_class->get_core_device = meta_device_manager_x11_get_core_device;
   manager_class->get_device = meta_device_manager_x11_get_device;
-  manager_class->select_stage_events = meta_device_manager_x11_select_stage_events;
 }
 
 static void
diff --git a/src/backends/x11/meta-seat-x11.c b/src/backends/x11/meta-seat-x11.c
index 3d4cb0ea5..8c8fdc2f9 100644
--- a/src/backends/x11/meta-seat-x11.c
+++ b/src/backends/x11/meta-seat-x11.c
@@ -2227,3 +2227,39 @@ meta_seat_x11_lookup_device_id (MetaSeatX11 *seat_x11,
   return g_hash_table_lookup (seat_x11->devices_by_id,
                               GINT_TO_POINTER (device_id));
 }
+
+void
+meta_seat_x11_select_stage_events (MetaSeatX11  *seat,
+                                   ClutterStage *stage)
+{
+  MetaStageX11 *stage_x11;
+  XIEventMask xi_event_mask;
+  unsigned char *mask;
+  int len;
+
+  stage_x11 = META_STAGE_X11 (_clutter_stage_get_window (stage));
+
+  len = XIMaskLen (XI_LASTEVENT);
+  mask = g_new0 (unsigned char, len);
+
+  XISetMask (mask, XI_Motion);
+  XISetMask (mask, XI_ButtonPress);
+  XISetMask (mask, XI_ButtonRelease);
+  XISetMask (mask, XI_KeyPress);
+  XISetMask (mask, XI_KeyRelease);
+  XISetMask (mask, XI_Enter);
+  XISetMask (mask, XI_Leave);
+
+  XISetMask (mask, XI_TouchBegin);
+  XISetMask (mask, XI_TouchUpdate);
+  XISetMask (mask, XI_TouchEnd);
+
+  xi_event_mask.deviceid = XIAllMasterDevices;
+  xi_event_mask.mask = mask;
+  xi_event_mask.mask_len = len;
+
+  XISelectEvents (clutter_x11_get_default_display (),
+                  stage_x11->xwin, &xi_event_mask, 1);
+
+  g_free (mask);
+}
diff --git a/src/backends/x11/meta-seat-x11.h b/src/backends/x11/meta-seat-x11.h
index ff7d1000d..d27ec5fa9 100644
--- a/src/backends/x11/meta-seat-x11.h
+++ b/src/backends/x11/meta-seat-x11.h
@@ -34,6 +34,8 @@ gboolean meta_seat_x11_translate_event (MetaSeatX11  *seat,
                                        ClutterEvent *event);
 ClutterInputDevice * meta_seat_x11_lookup_device_id (MetaSeatX11 *seat_x11,
                                                      int          device_id);
+void meta_seat_x11_select_stage_events (MetaSeatX11  *seat,
+                                        ClutterStage *stage);
 
 G_END_DECLS
 
diff --git a/src/backends/x11/meta-stage-x11.c b/src/backends/x11/meta-stage-x11.c
index 1bb2dee14..bf8d0d955 100644
--- a/src/backends/x11/meta-stage-x11.c
+++ b/src/backends/x11/meta-stage-x11.c
@@ -33,6 +33,7 @@
 #include "core/display-private.h"
 #include "meta/meta-x11-errors.h"
 #include "meta-backend-x11.h"
+#include "meta-seat-x11.h"
 #include "meta-stage-x11.h"
 
 #define STAGE_X11_IS_MAPPED(s)  ((((MetaStageX11 *) (s))->wm_state & STAGE_X11_WITHDRAWN) == 0)
@@ -314,8 +315,8 @@ meta_stage_x11_realize (ClutterStageWindow *stage_window)
   MetaStageX11 *stage_x11 = META_STAGE_X11 (stage_window);
   ClutterStageCogl *stage_cogl = CLUTTER_STAGE_COGL (stage_window);
   ClutterBackend *backend = CLUTTER_BACKEND (stage_cogl->backend);
+  MetaSeatX11 *seat_x11 = META_SEAT_X11 (clutter_backend_get_default_seat (backend));
   Display *xdisplay = clutter_x11_get_default_display ();
-  ClutterDeviceManager *device_manager;
   float width, height;
   GError *error = NULL;
 
@@ -382,16 +383,7 @@ meta_stage_x11_realize (ClutterStageWindow *stage_window)
    */
   XSelectInput (xdisplay, stage_x11->xwin, META_STAGE_X11_EVENT_MASK);
 
-  /* input events also depent on the actual device, so we need to
-   * use the device manager to let every device select them, using
-   * the event mask we passed to XSelectInput as the template
-   */
-  device_manager = clutter_device_manager_get_default ();
-  if (G_UNLIKELY (device_manager != NULL))
-    {
-      _clutter_device_manager_select_stage_events (device_manager,
-                                                   stage_cogl->wrapper);
-    }
+  meta_seat_x11_select_stage_events (seat_x11, stage_cogl->wrapper);
 
   meta_stage_x11_fix_window_size (stage_x11,
                                   stage_x11->xwin_width,


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