mirror of
https://github.com/brl/mutter.git
synced 2024-12-25 04:22:05 +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,15 +107,15 @@ 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)
|
||||||
{
|
|
||||||
data = g_new (InhibitShortcutsData, 1);
|
|
||||||
surface_inhibit_shortcuts_data_set (surface, data);
|
|
||||||
}
|
|
||||||
else if (data->dialog != NULL)
|
|
||||||
/* There is a dialog already created, nothing to do */
|
|
||||||
return data;
|
return data;
|
||||||
|
|
||||||
|
data = g_new (InhibitShortcutsData, 1);
|
||||||
|
surface_inhibit_shortcuts_data_set (surface, data);
|
||||||
|
g_signal_connect (surface, "destroy",
|
||||||
|
G_CALLBACK (on_surface_destroyed),
|
||||||
|
data);
|
||||||
|
|
||||||
window = meta_wayland_surface_get_toplevel_window (surface);
|
window = meta_wayland_surface_get_toplevel_window (surface);
|
||||||
display = window->display;
|
display = window->display;
|
||||||
dialog =
|
dialog =
|
||||||
@ -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