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.
This commit is contained in:
Carlos Garnacho 2015-10-22 14:07:52 +02:00
parent 5774875ab9
commit c28fc68df1
2 changed files with 33 additions and 0 deletions

View File

@ -137,6 +137,13 @@ G_DEFINE_TYPE (MetaWaylandSurfaceRoleDND,
meta_wayland_surface_role_dnd, meta_wayland_surface_role_dnd,
META_TYPE_WAYLAND_SURFACE_ROLE); META_TYPE_WAYLAND_SURFACE_ROLE);
enum {
SURFACE_DESTROY,
N_SURFACE_SIGNALS
};
guint surface_signals[N_SURFACE_SIGNALS] = { 0 };
static void static void
meta_wayland_surface_role_assigned (MetaWaylandSurfaceRole *surface_role); meta_wayland_surface_role_assigned (MetaWaylandSurfaceRole *surface_role);
@ -2670,6 +2677,20 @@ meta_wayland_surface_get_absolute_coordinates (MetaWaylandSurface *surface,
*y = v.y; *y = v.y;
} }
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 static void
meta_wayland_surface_init (MetaWaylandSurface *surface) meta_wayland_surface_init (MetaWaylandSurface *surface)
{ {
@ -2679,6 +2700,17 @@ meta_wayland_surface_init (MetaWaylandSurface *surface)
static void static void
meta_wayland_surface_class_init (MetaWaylandSurfaceClass *klass) 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 static void

View File

@ -198,6 +198,7 @@ struct _MetaWaylandSurface
MetaWaylandSerial acked_configure_serial; MetaWaylandSerial acked_configure_serial;
gboolean has_set_geometry; gboolean has_set_geometry;
gboolean is_modal; gboolean is_modal;
gboolean destroying;
/* xdg_popup */ /* xdg_popup */
struct { struct {