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.
This commit is contained in:
Giovanni Campagna 2014-02-27 02:21:51 +01:00
parent 394b44a2c2
commit 360d423faa
5 changed files with 32 additions and 6 deletions

View File

@ -97,6 +97,14 @@ meta_surface_actor_wayland_is_unredirected (MetaSurfaceActor *actor)
return FALSE; 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 static void
meta_surface_actor_wayland_class_init (MetaSurfaceActorWaylandClass *klass) 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->should_unredirect = meta_surface_actor_wayland_should_unredirect;
surface_actor_class->set_unredirected = meta_surface_actor_wayland_set_unredirected; 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->is_unredirected = meta_surface_actor_wayland_is_unredirected;
surface_actor_class->get_window = meta_surface_actor_wayland_get_window;
} }
static void static void

View File

@ -387,6 +387,14 @@ meta_surface_actor_x11_dispose (GObject *object)
G_OBJECT_CLASS (meta_surface_actor_x11_parent_class)->dispose (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 static void
meta_surface_actor_x11_class_init (MetaSurfaceActorX11Class *klass) 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->should_unredirect = meta_surface_actor_x11_should_unredirect;
surface_actor_class->set_unredirected = meta_surface_actor_x11_set_unredirected; 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->is_unredirected = meta_surface_actor_x11_is_unredirected;
surface_actor_class->get_window = meta_surface_actor_x11_get_window;
} }
static void static void

View File

@ -312,3 +312,9 @@ meta_surface_actor_is_unredirected (MetaSurfaceActor *self)
{ {
return META_SURFACE_ACTOR_GET_CLASS (self)->is_unredirected (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);
}

View File

@ -6,6 +6,7 @@
#include <config.h> #include <config.h>
#include <meta/meta-shaped-texture.h> #include <meta/meta-shaped-texture.h>
#include <meta/window.h>
G_BEGIN_DECLS G_BEGIN_DECLS
@ -35,6 +36,8 @@ struct _MetaSurfaceActorClass
void (* set_unredirected) (MetaSurfaceActor *actor, void (* set_unredirected) (MetaSurfaceActor *actor,
gboolean unredirected); gboolean unredirected);
gboolean (* is_unredirected) (MetaSurfaceActor *actor); gboolean (* is_unredirected) (MetaSurfaceActor *actor);
MetaWindow *(* get_window) (MetaSurfaceActor *actor);
}; };
struct _MetaSurfaceActor struct _MetaSurfaceActor
@ -50,6 +53,7 @@ cairo_surface_t *meta_surface_actor_get_image (MetaSurfaceActor *self,
cairo_rectangle_int_t *clip); cairo_rectangle_int_t *clip);
MetaShapedTexture *meta_surface_actor_get_texture (MetaSurfaceActor *self); 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_is_obscured (MetaSurfaceActor *self);
gboolean meta_surface_actor_get_unobscured_bounds (MetaSurfaceActor *self, gboolean meta_surface_actor_get_unobscured_bounds (MetaSurfaceActor *self,

View File

@ -1693,12 +1693,8 @@ get_window_for_event (MetaDisplay *display,
} }
source = clutter_event_get_source (event); source = clutter_event_get_source (event);
if (META_IS_SURFACE_ACTOR_WAYLAND (source)) if (META_IS_SURFACE_ACTOR (source))
{ return meta_surface_actor_get_window (META_SURFACE_ACTOR (source));
MetaWaylandSurface *surface = meta_surface_actor_wayland_get_surface (META_SURFACE_ACTOR_WAYLAND (source));
g_assert (surface != NULL);
return surface->window;
}
return NULL; return NULL;
} }