[mutter/wip/wayland-clutter-events: 17/17] wayland: Use an event filter instead of the captured event signal



commit ef00e3fc0b96ab8964eda7fa353948e657ff4490
Author: Neil Roberts <neil linux intel com>
Date:   Thu Sep 5 12:19:58 2013 +0100

    wayland: Use an event filter instead of the captured event signal
    
    In order to see all Clutter events, Mutter was previously installing a
    signal handler on the ‘captured-event’ signal on the stage and
    additionally using a signal emission hook to cope with grabs. This
    changes it to use the new clutter_event_add_filter API so that we can
    avoid the signal emission hook hack.

 src/wayland/meta-wayland.c |   79 ++++---------------------------------------
 1 files changed, 8 insertions(+), 71 deletions(-)
---
diff --git a/src/wayland/meta-wayland.c b/src/wayland/meta-wayland.c
index d020d8a..4485eef 100644
--- a/src/wayland/meta-wayland.c
+++ b/src/wayland/meta-wayland.c
@@ -559,10 +559,10 @@ reset_idletimes (const ClutterEvent *event)
 }
 
 static gboolean
-event_cb (ClutterActor *stage,
-          const ClutterEvent *event,
-          MetaWaylandCompositor *compositor)
+event_filter_cb (const ClutterEvent *event,
+                 gpointer            user_data)
 {
+  MetaWaylandCompositor *compositor = user_data;
   MetaWaylandSeat *seat = compositor->seat;
   MetaWaylandPointer *pointer = &seat->pointer;
   MetaWaylandSurface *surface;
@@ -601,7 +601,8 @@ event_cb (ClutterActor *stage,
       if (pointer->current == NULL)
        meta_cursor_tracker_revert_root (seat->cursor_tracker);
 
-      meta_cursor_tracker_queue_redraw (seat->cursor_tracker, stage);
+      meta_cursor_tracker_queue_redraw (seat->cursor_tracker,
+                                        CLUTTER_ACTOR (event->any.stage));
     }
 
   display = meta_get_display ();
@@ -630,58 +631,6 @@ event_cb (ClutterActor *stage,
     }
 }
 
-static gboolean
-event_emission_hook_cb (GSignalInvocationHint *ihint,
-                        guint n_param_values,
-                        const GValue *param_values,
-                        gpointer data)
-{
-  MetaWaylandCompositor *compositor = data;
-  ClutterActor *actor;
-  ClutterEvent *event;
-
-  g_return_val_if_fail (n_param_values == 2, FALSE);
-
-  actor = g_value_get_object (param_values + 0);
-  event = g_value_get_boxed (param_values + 1);
-
-  if (actor == NULL)
-    return TRUE /* stay connected */;
-
-  /* If this event belongs to the corresponding grab for this event
-   * type then the captured-event signal won't be emitted so we have
-   * to manually forward it on */
-
-  switch (event->type)
-    {
-      /* Pointer events */
-    case CLUTTER_MOTION:
-    case CLUTTER_ENTER:
-    case CLUTTER_LEAVE:
-    case CLUTTER_BUTTON_PRESS:
-    case CLUTTER_BUTTON_RELEASE:
-    case CLUTTER_SCROLL:
-      if (actor == clutter_get_pointer_grab ())
-        event_cb (clutter_actor_get_stage (actor),
-                  event,
-                  compositor);
-      break;
-
-      /* Keyboard events */
-    case CLUTTER_KEY_PRESS:
-    case CLUTTER_KEY_RELEASE:
-      if (actor == clutter_get_keyboard_grab ())
-        event_cb (clutter_actor_get_stage (actor),
-                  event,
-                  compositor);
-
-    default:
-      break;
-    }
-
-  return TRUE /* stay connected */;
-}
-
 static void
 on_monitors_changed (MetaMonitorManager    *monitors,
                      MetaWaylandCompositor *compositor)
@@ -722,7 +671,6 @@ void
 meta_wayland_init (void)
 {
   MetaWaylandCompositor *compositor = &_meta_wayland_compositor;
-  guint event_signal;
   MetaMonitorManager *monitors;
   ClutterBackend *backend;
   CoglContext *cogl_context;
@@ -813,20 +761,7 @@ meta_wayland_init (void)
   compositor->seat = meta_wayland_seat_new (compositor->wayland_display,
                                            compositor->drm_fd >= 0);
 
-  g_signal_connect (compositor->stage,
-                    "captured-event",
-                    G_CALLBACK (event_cb),
-                    compositor);
-  /* If something sets a grab on an actor then the captured event
-   * signal won't get emitted but we still want to see these events so
-   * we can update the cursor position. To make sure we see all events
-   * we also install an emission hook on the event signal */
-  event_signal = g_signal_lookup ("event", CLUTTER_TYPE_STAGE);
-  g_signal_add_emission_hook (event_signal,
-                              0 /* detail */,
-                              event_emission_hook_cb,
-                              compositor, /* hook_data */
-                              NULL /* data_destroy */);
+  clutter_event_add_filter (event_filter_cb, compositor);
 
   meta_wayland_init_shell (compositor);
 
@@ -862,6 +797,8 @@ meta_wayland_finalize (void)
 
   compositor = meta_wayland_compositor_get_default ();
 
+  clutter_event_remove_filter (event_filter_cb, compositor);
+
   meta_xwayland_stop (compositor);
   g_clear_object (&compositor->launcher);
 }


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