From a681e10436d7be6227586ceda530e467c6eaf2b5 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jonas=20=C3=85dahl?= <jadahl@gmail.com>
Date: Fri, 10 Jul 2015 16:14:51 +0800
Subject: [PATCH] wayland: Add "painting" signal to surface actor

Make MetaWaylandSurface a listener and move output state updating to
the handlen function.

https://bugzilla.gnome.org/show_bug.cgi?id=744104
---
 src/compositor/meta-surface-actor-wayland.c | 22 ++++++++++++++++------
 src/wayland/meta-wayland-surface.c          | 13 +++++++++++++
 2 files changed, 29 insertions(+), 6 deletions(-)

diff --git a/src/compositor/meta-surface-actor-wayland.c b/src/compositor/meta-surface-actor-wayland.c
index 069c511..dfd0451 100644
--- a/src/compositor/meta-surface-actor-wayland.c
+++ b/src/compositor/meta-surface-actor-wayland.c
@@ -36,6 +36,14 @@
 
 #include "compositor/region-utils.h"
 
+enum {
+  PAINTING,
+
+  LAST_SIGNAL
+};
+
+static guint signals[LAST_SIGNAL];
+
 struct _MetaSurfaceActorWaylandPrivate
 {
   MetaWaylandSurface *surface;
@@ -318,12 +326,7 @@ meta_surface_actor_wayland_get_preferred_height  (ClutterActor *self,
 static void
 meta_surface_actor_wayland_paint (ClutterActor *actor)
 {
-  MetaSurfaceActorWayland *self = META_SURFACE_ACTOR_WAYLAND (actor);
-  MetaSurfaceActorWaylandPrivate *priv =
-    meta_surface_actor_wayland_get_instance_private (self);
-
-  if (priv->surface)
-    meta_wayland_surface_update_outputs (priv->surface);
+  g_signal_emit (actor, signals[PAINTING], 0);
 
   CLUTTER_ACTOR_CLASS (meta_surface_actor_wayland_parent_class)->paint (actor);
 }
@@ -360,6 +363,13 @@ meta_surface_actor_wayland_class_init (MetaSurfaceActorWaylandClass *klass)
   surface_actor_class->get_window = meta_surface_actor_wayland_get_window;
 
   object_class->dispose = meta_surface_actor_wayland_dispose;
+
+  signals[PAINTING] = g_signal_new ("painting",
+                                    G_TYPE_FROM_CLASS (object_class),
+                                    G_SIGNAL_RUN_LAST,
+                                    0,
+                                    NULL, NULL, NULL,
+                                    G_TYPE_NONE, 0);
 }
 
 static void
diff --git a/src/wayland/meta-wayland-surface.c b/src/wayland/meta-wayland-surface.c
index 0ac89a1..7cd5711 100644
--- a/src/wayland/meta-wayland-surface.c
+++ b/src/wayland/meta-wayland-surface.c
@@ -953,6 +953,13 @@ wl_surface_destructor (struct wl_resource *resource)
   meta_wayland_compositor_repick (compositor);
 }
 
+static void
+surface_actor_painting (MetaSurfaceActorWayland *surface_actor,
+                        MetaWaylandSurface *surface)
+{
+  meta_wayland_surface_update_outputs (surface);
+}
+
 MetaWaylandSurface *
 meta_wayland_surface_create (MetaWaylandCompositor *compositor,
                              struct wl_client      *client,
@@ -970,6 +977,12 @@ meta_wayland_surface_create (MetaWaylandCompositor *compositor,
   surface->buffer_destroy_listener.notify = surface_handle_buffer_destroy;
   surface->surface_actor = g_object_ref_sink (meta_surface_actor_wayland_new (surface));
 
+  g_signal_connect_object (surface->surface_actor,
+                           "painting",
+                           G_CALLBACK (surface_actor_painting),
+                           surface,
+                           0);
+
   sync_drag_dest_funcs (surface);
 
   surface->outputs = g_hash_table_new (NULL, NULL);
-- 
2.1.0