From 7c45d6594c3878fe1be463c3ab0358b7a3cbb32f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20=C3=85dahl?= Date: Sun, 13 Oct 2013 18:59:30 +0200 Subject: [PATCH] MetaWindowActor: Use allocation changes signals for size changed signals MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When a Wayland compositor, simply rely on the clutter actor allocation changed signal to sync geometry and emit window actor size changed signals. Attaching a wl_buffer to a MetaShapedTexture will signal allocation changed on the corresponding MetaSurfaceActor, which the MetaWindowActor is listening to. Signed-off-by: Jonas Ã…dahl https://bugzilla.gnome.org/show_bug.cgi?id=705502 --- src/compositor/meta-window-actor.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/compositor/meta-window-actor.c b/src/compositor/meta-window-actor.c index 019c1bc63..a03f84f52 100644 --- a/src/compositor/meta-window-actor.c +++ b/src/compositor/meta-window-actor.c @@ -53,6 +53,8 @@ struct _MetaWindowActorPrivate MetaSurfaceActor *surface; + guint surface_allocation_changed_id; + /* MetaShadowFactory only caches shadows that are actually in use; * to avoid unnecessary recomputation we do two things: 1) we store * both a focused and unfocused shadow for the window. If the window @@ -299,6 +301,8 @@ meta_window_actor_init (MetaWindowActor *self) priv = self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, META_TYPE_WINDOW_ACTOR, MetaWindowActorPrivate); + + priv->surface_allocation_changed_id = 0; priv->opacity = 0xff; priv->shadow_class = NULL; } @@ -360,6 +364,17 @@ window_appears_focused_notify (MetaWindow *mw, clutter_actor_queue_redraw (CLUTTER_ACTOR (data)); } +static void +surface_allocation_changed_notify (ClutterActor *actor, + const ClutterActorBox *allocation, + ClutterAllocationFlags flags, + MetaWindowActor *self) +{ + meta_window_actor_sync_actor_geometry (self, FALSE); + + g_signal_emit (self, signals[SIZE_CHANGED], 0); +} + static void meta_window_actor_constructed (GObject *object) { @@ -397,6 +412,12 @@ meta_window_actor_constructed (GObject *object) clutter_actor_add_child (CLUTTER_ACTOR (self), CLUTTER_ACTOR (priv->surface)); clutter_actor_set_reactive (CLUTTER_ACTOR (self), TRUE); + priv->surface_allocation_changed_id = + g_signal_connect (CLUTTER_ACTOR (priv->surface), + "allocation-changed", + G_CALLBACK (surface_allocation_changed_notify), + self); + /* * Since we are holding a pointer to this actor independently of the * ClutterContainer internals, and provide a public API to access it, @@ -482,6 +503,11 @@ meta_window_actor_dispose (GObject *object) g_clear_object (&priv->window); + if (priv->surface != NULL && priv->surface_allocation_changed_id != 0) + g_signal_handler_disconnect (priv->surface, + priv->surface_allocation_changed_id); + priv->surface_allocation_changed_id = 0; + /* * Release the extra reference we took on the actor. */