[recipes] Defer unexporting handles to an idle
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [recipes] Defer unexporting handles to an idle
- Date: Fri, 3 Mar 2017 18:35:53 +0000 (UTC)
commit d113e5353fe855289378fb827f67c9a59efddcb6
Author: Matthias Clasen <mclasen redhat com>
Date: Fri Mar 3 13:25:45 2017 -0500
Defer unexporting handles to an idle
We were seeing unexpected effects when calling
gdk_window_unexport_handle out of the export_handle
callback. Avoid that by deferring the unexport
to an idle. This is really just a workaround for
deficiencies in the handle export API.
src/gr-utils.c | 33 +++++++++++++++++++++++++--------
1 files changed, 25 insertions(+), 8 deletions(-)
---
diff --git a/src/gr-utils.c b/src/gr-utils.c
index 62d0d41..640c8dc 100644
--- a/src/gr-utils.c
+++ b/src/gr-utils.c
@@ -479,23 +479,40 @@ all_headers (GtkListBoxRow *row,
#ifdef GDK_WINDOWING_WAYLAND
typedef struct {
GtkWindow *window;
+ char *handle_str;
WindowHandleExported callback;
gpointer user_data;
} WaylandWindowHandleExportedData;
static void
+free_exported_data (gpointer data)
+{
+ WaylandWindowHandleExportedData *d = data;
+
+ g_free (d->handle_str);
+ g_free (d);
+}
+
+static gboolean
+handle_exported_idle (gpointer user_data)
+{
+ WaylandWindowHandleExportedData *data = user_data;
+
+ data->callback (data->window, data->handle_str, data->user_data);
+ free_exported_data (data);
+
+ return G_SOURCE_REMOVE;
+}
+
+static void
wayland_window_handle_exported (GdkWindow *window,
const char *wayland_handle_str,
gpointer user_data)
{
WaylandWindowHandleExportedData *data = user_data;
- char *handle_str;
-
- handle_str = g_strdup_printf ("wayland:%s", wayland_handle_str);
- data->callback (data->window, handle_str, data->user_data);
- g_free (handle_str);
- g_free (data);
+ data->handle_str = g_strdup_printf ("wayland:%s", wayland_handle_str);
+ g_idle_add (handle_exported_idle, data);
}
#endif
@@ -529,8 +546,8 @@ window_export_handle (GtkWindow *window,
if (!gdk_wayland_window_export_handle (gdk_window,
wayland_window_handle_exported,
data,
- g_free)) {
- g_free (data);
+ free_exported_data)) {
+ free_exported_data (data);
return FALSE;
}
else {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]