[recipes] Move window handle exporting to utils
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [recipes] Move window handle exporting to utils
- Date: Tue, 14 Feb 2017 23:52:18 +0000 (UTC)
commit cbce07032e813412059008920fe2c4a6693fe660
Author: Matthias Clasen <mclasen redhat com>
Date: Tue Feb 14 18:29:16 2017 -0500
Move window handle exporting to utils
We need this in multiple places soon.
src/gr-account.c | 84 +-----------------------------------------------------
src/gr-utils.c | 78 ++++++++++++++++++++++++++++++++++++++++++++++++++
src/gr-utils.h | 9 ++++++
3 files changed, 88 insertions(+), 83 deletions(-)
---
diff --git a/src/gr-account.c b/src/gr-account.c
index 0a3d3e9..271663c 100644
--- a/src/gr-account.c
+++ b/src/gr-account.c
@@ -27,88 +27,6 @@
#include <glib/gi18n.h>
-#ifdef GDK_WINDOWING_X11
-#include <gdk/gdkx.h>
-#endif
-
-#ifdef GDK_WINDOWING_WAYLAND
-#include <gdk/gdkwayland.h>
-#endif
-
-
-typedef void (*GtkWindowHandleExported) (GtkWindow *window,
- const char *handle,
- gpointer user_data);
-
-#ifdef GDK_WINDOWING_WAYLAND
-typedef struct {
- GtkWindow *window;
- GtkWindowHandleExported callback;
- gpointer user_data;
-} WaylandWindowHandleExportedData;
-
-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);
-}
-#endif
-
-static gboolean
-gtk_window_export_handle (GtkWindow *window,
- GtkWindowHandleExported callback,
- gpointer user_data)
-{
-
-#ifdef GDK_WINDOWING_X11
- if (GDK_IS_X11_DISPLAY (gtk_widget_get_display (GTK_WIDGET (window)))) {
- GdkWindow *gdk_window = gtk_widget_get_window (GTK_WIDGET (window));
- char *handle_str;
- guint32 xid = (guint32) gdk_x11_window_get_xid (gdk_window);
-
- handle_str = g_strdup_printf ("x11:%x", xid);
- callback (window, handle_str, user_data);
-
- return TRUE;
- }
-#endif
-#ifdef GDK_WINDOWING_WAYLAND
- if (GDK_IS_WAYLAND_DISPLAY (gtk_widget_get_display (GTK_WIDGET (window)))) {
- GdkWindow *gdk_window = gtk_widget_get_window (GTK_WIDGET (window));
- WaylandWindowHandleExportedData *data;
-
- data = g_new0 (WaylandWindowHandleExportedData, 1);
- data->window = window;
- data->callback = callback;
- data->user_data = user_data;
-
- if (!gdk_wayland_window_export_handle (gdk_window,
- wayland_window_handle_exported,
- data,
- g_free)) {
- g_free (data);
- return FALSE;
- }
- else {
- return TRUE;
- }
- }
-#endif
-
- g_warning ("Couldn't export handle, unsupported windowing system");
-
- return FALSE;
-}
-
typedef struct {
AccountInformationCallback callback;
gpointer data;
@@ -259,7 +177,7 @@ gr_account_get_information (GtkWindow *window,
cbdata->data = data;
cbdata->destroy = destroy;
- gtk_window_export_handle (window, window_handle_exported, cbdata);
+ window_export_handle (window, window_handle_exported, cbdata);
}
typedef struct {
diff --git a/src/gr-utils.c b/src/gr-utils.c
index 9f6a4c5..a1b7e60 100644
--- a/src/gr-utils.c
+++ b/src/gr-utils.c
@@ -26,6 +26,14 @@
#include <glib/gi18n.h>
+#ifdef GDK_WINDOWING_X11
+#include <gdk/gdkx.h>
+#endif
+
+#ifdef GDK_WINDOWING_WAYLAND
+#include <gdk/gdkwayland.h>
+#endif
+
#include "gr-utils.h"
#include "gr-app.h"
@@ -535,3 +543,73 @@ all_headers (GtkListBoxRow *row,
header = gtk_separator_new (GTK_ORIENTATION_HORIZONTAL);
gtk_list_box_row_set_header (row, header);
}
+
+#ifdef GDK_WINDOWING_WAYLAND
+typedef struct {
+ GtkWindow *window;
+ WindowHandleExported callback;
+ gpointer user_data;
+} WaylandWindowHandleExportedData;
+
+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);
+}
+#endif
+
+static gboolean
+window_export_handle (GtkWindow *window,
+ WindowHandleExported callback,
+ gpointer user_data)
+{
+
+#ifdef GDK_WINDOWING_X11
+ if (GDK_IS_X11_DISPLAY (gtk_widget_get_display (GTK_WIDGET (window)))) {
+ GdkWindow *gdk_window = gtk_widget_get_window (GTK_WIDGET (window));
+ char *handle_str;
+ guint32 xid = (guint32) gdk_x11_window_get_xid (gdk_window);
+
+ handle_str = g_strdup_printf ("x11:%x", xid);
+ callback (window, handle_str, user_data);
+
+ return TRUE;
+ }
+#endif
+#ifdef GDK_WINDOWING_WAYLAND
+ if (GDK_IS_WAYLAND_DISPLAY (gtk_widget_get_display (GTK_WIDGET (window)))) {
+ GdkWindow *gdk_window = gtk_widget_get_window (GTK_WIDGET (window));
+ WaylandWindowHandleExportedData *data;
+
+ data = g_new0 (WaylandWindowHandleExportedData, 1);
+ data->window = window;
+ data->callback = callback;
+ data->user_data = user_data;
+
+ if (!gdk_wayland_window_export_handle (gdk_window,
+ wayland_window_handle_exported,
+ data,
+ g_free)) {
+ g_free (data);
+ return FALSE;
+ }
+ else {
+ return TRUE;
+ }
+ }
+#endif
+
+ g_warning ("Couldn't export handle, unsupported windowing system");
+
+ return FALSE;
+}
+
diff --git a/src/gr-utils.h b/src/gr-utils.h
index 7802ddb..6c0a8f3 100644
--- a/src/gr-utils.h
+++ b/src/gr-utils.h
@@ -67,3 +67,12 @@ gboolean portals_available (void);
void all_headers (GtkListBoxRow *row,
GtkListBoxRow *before,
gpointer user_data);
+
+typedef void (*WindowHandleExported) (GtkWindow *window,
+ const char *handle,
+ gpointer user_data);
+
+gboolean
+window_export_handle (GtkWindow *window,
+ WindowHandleExported callback,
+ gpointer user_data);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]