[mutter/wip/wayland] wayland-input-device: remove need for "current stage"



commit 28a341698708c98007fd928564756b1eba9335e8
Author: Robert Bragg <robert linux intel com>
Date:   Wed Jan 18 19:13:12 2012 +0000

    wayland-input-device: remove need for "current stage"
    
    Instead of having a current stage which can be reset to NULL if we fail
    to find an actor when picking we now just associate compositor->stage
    with the device and never change that reference. This patch also
    ensures device->stage is initialize when creating the input device.

 src/wayland/meta-wayland-input-device.c |   15 ++++++---------
 src/wayland/meta-wayland-input-device.h |    3 ++-
 src/wayland/meta-wayland.c              |    7 ++++---
 3 files changed, 12 insertions(+), 13 deletions(-)
---
diff --git a/src/wayland/meta-wayland-input-device.c b/src/wayland/meta-wayland-input-device.c
index 205532f..adba30c 100644
--- a/src/wayland/meta-wayland-input-device.c
+++ b/src/wayland/meta-wayland-input-device.c
@@ -34,7 +34,7 @@ struct _MetaWaylandInputDevice
 {
   struct wl_input_device parent;
 
-  ClutterActor *current_stage;
+  ClutterActor *stage;
 };
 
 static void
@@ -81,11 +81,13 @@ bind_input_device (struct wl_client *client,
 }
 
 MetaWaylandInputDevice *
-meta_wayland_input_device_new (struct wl_display *display)
+meta_wayland_input_device_new (struct wl_display *display,
+                               ClutterActor *stage)
 {
   MetaWaylandInputDevice *device = g_new (MetaWaylandInputDevice, 1);
 
   wl_input_device_init (&device->parent);
+  device->stage = stage;
 
   wl_display_add_global (display,
                          &wl_input_device_interface,
@@ -265,19 +267,14 @@ meta_wayland_input_device_repick (MetaWaylandInputDevice *device,
   struct wl_surface *surface;
   MetaWaylandSurface *focus;
 
-  if (actor == NULL && device->current_stage)
+  if (actor == NULL)
     {
-      ClutterStage *stage = CLUTTER_STAGE (device->current_stage);
+      ClutterStage *stage = CLUTTER_STAGE (device->stage);
       actor = clutter_stage_get_actor_at_pos (stage,
                                               CLUTTER_PICK_REACTIVE,
                                               input_device->x, input_device->y);
     }
 
-  if (actor)
-    device->current_stage = clutter_actor_get_stage (actor);
-  else
-    device->current_stage = NULL;
-
   if (CLUTTER_WAYLAND_IS_SURFACE (actor))
     {
       ClutterWaylandSurface *wl_surface = CLUTTER_WAYLAND_SURFACE (actor);
diff --git a/src/wayland/meta-wayland-input-device.h b/src/wayland/meta-wayland-input-device.h
index 12a0e9f..91315cc 100644
--- a/src/wayland/meta-wayland-input-device.h
+++ b/src/wayland/meta-wayland-input-device.h
@@ -24,7 +24,8 @@
 
 typedef struct _MetaWaylandInputDevice MetaWaylandInputDevice;
 
-MetaWaylandInputDevice *meta_wayland_input_device_new          (struct wl_display      *display);
+MetaWaylandInputDevice *meta_wayland_input_device_new          (struct wl_display      *display,
+                                                                ClutterActor           *stage);
 
 void                    meta_wayland_input_device_handle_event (MetaWaylandInputDevice *input_device,
                                                                 const ClutterEvent     *event);
diff --git a/src/wayland/meta-wayland.c b/src/wayland/meta-wayland.c
index b222e0e..861f77f 100644
--- a/src/wayland/meta-wayland.c
+++ b/src/wayland/meta-wayland.c
@@ -1192,9 +1192,6 @@ meta_wayland_init (void)
   if (clutter_init (NULL, NULL) != CLUTTER_INIT_SUCCESS)
     g_error ("Failed to initialize Clutter");
 
-  compositor->input_device =
-    meta_wayland_input_device_new (compositor->wayland_display);
-
   compositor->stage = clutter_stage_new ();
   clutter_stage_set_user_resizable (CLUTTER_STAGE (compositor->stage), FALSE);
   g_signal_connect_after (compositor->stage, "paint",
@@ -1204,6 +1201,10 @@ meta_wayland_init (void)
   g_signal_connect (compositor->stage, "event",
                     G_CALLBACK (event_cb), compositor);
 
+  compositor->input_device =
+    meta_wayland_input_device_new (compositor->wayland_display,
+                                   compositor->stage);
+
   meta_wayland_compositor_create_output (compositor, 0, 0, 800, 600, 800, 600);
 
   if (wl_display_add_global (compositor->wayland_display, &wl_shell_interface,



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