From 360d423faa6bea315378b9940e0a210b2dd4b749 Mon Sep 17 00:00:00 2001 From: Giovanni Campagna Date: Thu, 27 Feb 2014 02:21:51 +0100 Subject: [PATCH] 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 9fe1e8220..c8381930c 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 cc2f0a5ba..5cab15fd7 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 1c795d52f..1d9a7ad35 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 a92f6f717..c06e1836b 100644 --- a/src/compositor/meta-surface-actor.h +++ b/src/compositor/meta-surface-actor.h @@ -6,6 +6,7 @@ #include #include +#include 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 4d5631f1a..9c1e72d1b 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; }