mirror of
https://github.com/brl/mutter.git
synced 2024-12-24 12:02:04 +00:00
wayland/inhibit-shortcuts-dialog: Make data life cycle a bit clearer
The 'data' object is attached to the MetaWaylandSurface as a GObject qdata. It is created once, and stays allocated until the surface is destroyed. To make things clearer, connect to the "destroy" signal just after creating, and from a on_surface_destroyed() callback call the .._free() function. https://bugzilla.gnome.org/show_bug.cgi?id=786385
This commit is contained in:
parent
a7915ff8ae
commit
dceb0f1f1f
@ -51,14 +51,23 @@ surface_inhibit_shortcuts_data_set (MetaWaylandSurface *surface,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
surface_inhibit_shortcuts_data_free (MetaWaylandSurface *surface,
|
surface_inhibit_shortcuts_data_free (InhibitShortcutsData *data)
|
||||||
InhibitShortcutsData *data)
|
|
||||||
{
|
{
|
||||||
meta_inhibit_shortcuts_dialog_hide (data->dialog);
|
meta_inhibit_shortcuts_dialog_hide (data->dialog);
|
||||||
|
|
||||||
g_free (data);
|
g_free (data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
on_surface_destroyed (MetaWaylandSurface *surface,
|
||||||
|
InhibitShortcutsData *data)
|
||||||
|
{
|
||||||
|
surface_inhibit_shortcuts_data_free (data);
|
||||||
|
g_object_set_qdata (G_OBJECT (surface),
|
||||||
|
quark_surface_inhibit_shortcuts_data,
|
||||||
|
NULL);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
surface_inhibit_shortcuts_dialog_free (gpointer ptr,
|
surface_inhibit_shortcuts_dialog_free (gpointer ptr,
|
||||||
GClosure *closure)
|
GClosure *closure)
|
||||||
@ -98,14 +107,14 @@ meta_wayland_surface_ensure_inhibit_shortcuts_dialog (MetaWaylandSurface *surfac
|
|||||||
MetaInhibitShortcutsDialog *dialog;
|
MetaInhibitShortcutsDialog *dialog;
|
||||||
|
|
||||||
data = surface_inhibit_shortcuts_data_get (surface);
|
data = surface_inhibit_shortcuts_data_get (surface);
|
||||||
if (data == NULL)
|
if (data)
|
||||||
{
|
return data;
|
||||||
|
|
||||||
data = g_new (InhibitShortcutsData, 1);
|
data = g_new (InhibitShortcutsData, 1);
|
||||||
surface_inhibit_shortcuts_data_set (surface, data);
|
surface_inhibit_shortcuts_data_set (surface, data);
|
||||||
}
|
g_signal_connect (surface, "destroy",
|
||||||
else if (data->dialog != NULL)
|
G_CALLBACK (on_surface_destroyed),
|
||||||
/* There is a dialog already created, nothing to do */
|
data);
|
||||||
return data;
|
|
||||||
|
|
||||||
window = meta_wayland_surface_get_toplevel_window (surface);
|
window = meta_wayland_surface_get_toplevel_window (surface);
|
||||||
display = window->display;
|
display = window->display;
|
||||||
@ -122,10 +131,6 @@ meta_wayland_surface_ensure_inhibit_shortcuts_dialog (MetaWaylandSurface *surfac
|
|||||||
data, surface_inhibit_shortcuts_dialog_free,
|
data, surface_inhibit_shortcuts_dialog_free,
|
||||||
0);
|
0);
|
||||||
|
|
||||||
g_signal_connect (surface, "destroy",
|
|
||||||
G_CALLBACK (surface_inhibit_shortcuts_data_free),
|
|
||||||
data);
|
|
||||||
|
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user