summaryrefslogtreecommitdiff
path: root/src/wayland
diff options
context:
space:
mode:
authorJonas Ådahl <jadahl@gmail.com>2017-08-19 00:22:08 +0800
committerJonas Ådahl <jadahl@gmail.com>2017-08-19 17:24:02 +0800
commitc1439e141e7a4b02c073b9ce1b659fc3d06b00d1 (patch)
tree0b4a3d6e5754b084c46ced3e3ca0e9fbdfd873a3 /src/wayland
parentdceb0f1f1f35f9d330a0ecfc2519aa3892740201 (diff)
downloadmutter-c1439e141e7a4b02c073b9ce1b659fc3d06b00d1.tar.gz
wayland/inhibit-shortcuts-dialog: Make the dialog ownership clearer
Make it clear that the data object is the owner of the dialog; it creates it, and eventually destroys it. https://bugzilla.gnome.org/show_bug.cgi?id=786385
Diffstat (limited to 'src/wayland')
-rw-r--r--src/wayland/meta-wayland-inhibit-shortcuts-dialog.c29
1 files changed, 14 insertions, 15 deletions
diff --git a/src/wayland/meta-wayland-inhibit-shortcuts-dialog.c b/src/wayland/meta-wayland-inhibit-shortcuts-dialog.c
index 6ae1eb8ff..aff067aef 100644
--- a/src/wayland/meta-wayland-inhibit-shortcuts-dialog.c
+++ b/src/wayland/meta-wayland-inhibit-shortcuts-dialog.c
@@ -30,6 +30,7 @@ typedef struct _InhibitShortcutsData
MetaWaylandSurface *surface;
MetaWaylandSeat *seat;
MetaInhibitShortcutsDialog *dialog;
+ gulong response_handler_id;
gboolean has_last_response;
MetaInhibitShortcutsDialogResponse last_response;
} InhibitShortcutsData;
@@ -51,10 +52,18 @@ surface_inhibit_shortcuts_data_set (MetaWaylandSurface *surface,
}
static void
-surface_inhibit_shortcuts_data_free (InhibitShortcutsData *data)
+surface_inhibit_shortcuts_data_destroy_dialog (InhibitShortcutsData *data)
{
+ g_signal_handler_disconnect (data->dialog, data->response_handler_id);
meta_inhibit_shortcuts_dialog_hide (data->dialog);
+ g_clear_object (&data->dialog);
+}
+static void
+surface_inhibit_shortcuts_data_free (InhibitShortcutsData *data)
+{
+ if (data->dialog)
+ surface_inhibit_shortcuts_data_destroy_dialog (data);
g_free (data);
}
@@ -69,15 +78,6 @@ on_surface_destroyed (MetaWaylandSurface *surface,
}
static void
-surface_inhibit_shortcuts_dialog_free (gpointer ptr,
- GClosure *closure)
-{
- InhibitShortcutsData *data = ptr;
-
- meta_wayland_surface_hide_inhibit_shortcuts_dialog (data->surface);
-}
-
-static void
inhibit_shortcuts_dialog_response_apply (InhibitShortcutsData *data)
{
if (data->last_response == META_INHIBIT_SHORTCUTS_DIALOG_RESPONSE_ALLOW)
@@ -125,11 +125,10 @@ meta_wayland_surface_ensure_inhibit_shortcuts_dialog (MetaWaylandSurface *surfac
data->surface = surface;
data->seat = seat;
data->dialog = dialog;
-
- g_signal_connect_data (dialog, "response",
- G_CALLBACK (inhibit_shortcuts_dialog_response_cb),
- data, surface_inhibit_shortcuts_dialog_free,
- 0);
+ data->response_handler_id =
+ g_signal_connect (dialog, "response",
+ G_CALLBACK (inhibit_shortcuts_dialog_response_cb),
+ data);
return data;
}