[mutter/wip/focus: 15/16] MetaSurfaceActor: add a generic hook to retrieve the MetaWindow



commit 360d423faa6bea315378b9940e0a210b2dd4b749
Author: Giovanni Campagna <gcampagna src gnome org>
Date:   Thu Feb 27 02:21:51 2014 +0100

    MetaSurfaceActor: add a generic hook to retrieve the MetaWindow
    
    This way we can find the window for a ClutterEvent even when
    running as an x11 compositor.

 src/compositor/meta-surface-actor-wayland.c |   10 ++++++++++
 src/compositor/meta-surface-actor-x11.c     |   10 ++++++++++
 src/compositor/meta-surface-actor.c         |    6 ++++++
 src/compositor/meta-surface-actor.h         |    4 ++++
 src/core/display.c                          |    8 ++------
 5 files changed, 32 insertions(+), 6 deletions(-)
---
diff --git a/src/compositor/meta-surface-actor-wayland.c b/src/compositor/meta-surface-actor-wayland.c
index 9fe1e82..c838193 100644
--- a/src/compositor/meta-surface-actor-wayland.c
+++ b/src/compositor/meta-surface-actor-wayland.c
@@ -97,6 +97,14 @@ meta_surface_actor_wayland_is_unredirected (MetaSurfaceActor *actor)
   return FALSE;
 }
 
+static MetaWindow *
+meta_surface_actor_wayland_get_window (MetaSurfaceActor *actor)
+{
+  MetaSurfaceActorWaylandPrivate *priv = meta_surface_actor_wayland_get_instance_private 
(META_SURFACE_ACTOR_WAYLAND (actor));
+
+  return priv->surface->window;
+}
+
 static void
 meta_surface_actor_wayland_class_init (MetaSurfaceActorWaylandClass *klass)
 {
@@ -110,6 +118,8 @@ meta_surface_actor_wayland_class_init (MetaSurfaceActorWaylandClass *klass)
   surface_actor_class->should_unredirect = meta_surface_actor_wayland_should_unredirect;
   surface_actor_class->set_unredirected = meta_surface_actor_wayland_set_unredirected;
   surface_actor_class->is_unredirected = meta_surface_actor_wayland_is_unredirected;
+
+  surface_actor_class->get_window = meta_surface_actor_wayland_get_window;
 }
 
 static void
diff --git a/src/compositor/meta-surface-actor-x11.c b/src/compositor/meta-surface-actor-x11.c
index cc2f0a5..5cab15f 100644
--- a/src/compositor/meta-surface-actor-x11.c
+++ b/src/compositor/meta-surface-actor-x11.c
@@ -387,6 +387,14 @@ meta_surface_actor_x11_dispose (GObject *object)
   G_OBJECT_CLASS (meta_surface_actor_x11_parent_class)->dispose (object);
 }
 
+static MetaWindow *
+meta_surface_actor_x11_get_window (MetaSurfaceActor *actor)
+{
+  MetaSurfaceActorX11Private *priv = meta_surface_actor_x11_get_instance_private (META_SURFACE_ACTOR_X11 
(actor));
+
+  return priv->window;
+}
+
 static void
 meta_surface_actor_x11_class_init (MetaSurfaceActorX11Class *klass)
 {
@@ -403,6 +411,8 @@ meta_surface_actor_x11_class_init (MetaSurfaceActorX11Class *klass)
   surface_actor_class->should_unredirect = meta_surface_actor_x11_should_unredirect;
   surface_actor_class->set_unredirected = meta_surface_actor_x11_set_unredirected;
   surface_actor_class->is_unredirected = meta_surface_actor_x11_is_unredirected;
+
+  surface_actor_class->get_window = meta_surface_actor_x11_get_window;
 }
 
 static void
diff --git a/src/compositor/meta-surface-actor.c b/src/compositor/meta-surface-actor.c
index 1c795d5..1d9a7ad 100644
--- a/src/compositor/meta-surface-actor.c
+++ b/src/compositor/meta-surface-actor.c
@@ -312,3 +312,9 @@ meta_surface_actor_is_unredirected (MetaSurfaceActor *self)
 {
   return META_SURFACE_ACTOR_GET_CLASS (self)->is_unredirected (self);
 }
+
+MetaWindow *
+meta_surface_actor_get_window (MetaSurfaceActor *self)
+{
+  return META_SURFACE_ACTOR_GET_CLASS (self)->get_window (self);
+}
diff --git a/src/compositor/meta-surface-actor.h b/src/compositor/meta-surface-actor.h
index a92f6f7..c06e183 100644
--- a/src/compositor/meta-surface-actor.h
+++ b/src/compositor/meta-surface-actor.h
@@ -6,6 +6,7 @@
 #include <config.h>
 
 #include <meta/meta-shaped-texture.h>
+#include <meta/window.h>
 
 G_BEGIN_DECLS
 
@@ -35,6 +36,8 @@ struct _MetaSurfaceActorClass
   void     (* set_unredirected)  (MetaSurfaceActor *actor,
                                   gboolean          unredirected);
   gboolean (* is_unredirected)   (MetaSurfaceActor *actor);
+
+  MetaWindow *(* get_window)      (MetaSurfaceActor *actor);
 };
 
 struct _MetaSurfaceActor
@@ -50,6 +53,7 @@ cairo_surface_t *meta_surface_actor_get_image (MetaSurfaceActor      *self,
                                                cairo_rectangle_int_t *clip);
 
 MetaShapedTexture *meta_surface_actor_get_texture (MetaSurfaceActor *self);
+MetaWindow        *meta_surface_actor_get_window  (MetaSurfaceActor *self);
 
 gboolean meta_surface_actor_is_obscured (MetaSurfaceActor *self);
 gboolean meta_surface_actor_get_unobscured_bounds (MetaSurfaceActor      *self,
diff --git a/src/core/display.c b/src/core/display.c
index 4d5631f..9c1e72d 100644
--- a/src/core/display.c
+++ b/src/core/display.c
@@ -1693,12 +1693,8 @@ get_window_for_event (MetaDisplay        *display,
     }
 
   source = clutter_event_get_source (event);
-  if (META_IS_SURFACE_ACTOR_WAYLAND (source))
-    {
-      MetaWaylandSurface *surface = meta_surface_actor_wayland_get_surface (META_SURFACE_ACTOR_WAYLAND 
(source));
-      g_assert (surface != NULL);
-      return surface->window;
-    }
+  if (META_IS_SURFACE_ACTOR (source))
+    return meta_surface_actor_get_window (META_SURFACE_ACTOR (source));
 
   return NULL;
 }


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