[mutter/wip/tablet-protocol: 67/83] wayland: Add MetaWaylandSurface::destroy signal
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter/wip/tablet-protocol: 67/83] wayland: Add MetaWaylandSurface::destroy signal
- Date: Tue, 29 Mar 2016 16:31:18 +0000 (UTC)
commit 18701ee2482660a3468406af42f0031b03a9cb07
Author: Carlos Garnacho <carlosg gnome org>
Date: Thu Oct 22 14:07:52 2015 +0200
wayland: Add MetaWaylandSurface::destroy signal
There's places where it would be convenient to add listeners to this,
so add the signal. The signal is only emitted once during destruction,
it is convenient for the places where we want notifications at a time
the object is still alive, as opposed to weak refs which notify after
the fact.
src/wayland/meta-wayland-surface.c | 32 ++++++++++++++++++++++++++++++++
src/wayland/meta-wayland-surface.h | 1 +
2 files changed, 33 insertions(+), 0 deletions(-)
---
diff --git a/src/wayland/meta-wayland-surface.c b/src/wayland/meta-wayland-surface.c
index 90ffd94..1447840 100644
--- a/src/wayland/meta-wayland-surface.c
+++ b/src/wayland/meta-wayland-surface.c
@@ -137,6 +137,13 @@ G_DEFINE_TYPE (MetaWaylandSurfaceRoleDND,
meta_wayland_surface_role_dnd,
META_TYPE_WAYLAND_SURFACE_ROLE);
+enum {
+ SURFACE_DESTROY,
+ N_SURFACE_SIGNALS
+};
+
+guint surface_signals[N_SURFACE_SIGNALS] = { 0 };
+
static void
meta_wayland_surface_role_assigned (MetaWaylandSurfaceRole *surface_role);
@@ -2668,6 +2675,20 @@ meta_wayland_surface_get_absolute_coordinates (MetaWaylandSurface *surface,
}
static void
+meta_wayland_surface_dispose (GObject *object)
+{
+ MetaWaylandSurface *surface = META_WAYLAND_SURFACE (object);
+
+ if (!surface->destroying)
+ {
+ g_signal_emit (object, surface_signals[SURFACE_DESTROY], 0);
+ surface->destroying = TRUE;
+ }
+
+ G_OBJECT_CLASS (meta_wayland_surface_parent_class)->dispose (object);
+}
+
+static void
meta_wayland_surface_init (MetaWaylandSurface *surface)
{
surface->pending = g_object_new (META_TYPE_WAYLAND_PENDING_STATE, NULL);
@@ -2676,6 +2697,17 @@ meta_wayland_surface_init (MetaWaylandSurface *surface)
static void
meta_wayland_surface_class_init (MetaWaylandSurfaceClass *klass)
{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ object_class->dispose = meta_wayland_surface_dispose;
+
+ surface_signals[SURFACE_DESTROY] =
+ g_signal_new ("destroy",
+ G_TYPE_FROM_CLASS (object_class),
+ G_SIGNAL_RUN_LAST,
+ 0, NULL, NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE, 0);
}
static void
diff --git a/src/wayland/meta-wayland-surface.h b/src/wayland/meta-wayland-surface.h
index c817ed7..15be686 100644
--- a/src/wayland/meta-wayland-surface.h
+++ b/src/wayland/meta-wayland-surface.h
@@ -198,6 +198,7 @@ struct _MetaWaylandSurface
MetaWaylandSerial acked_configure_serial;
gboolean has_set_geometry;
gboolean is_modal;
+ gboolean destroying;
/* xdg_popup */
struct {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]