Put window exporting behind a display protocol agnostic API

Introduce a private API meant for abstracting how to get a handle
of a window that can be shared with other processes. The API is
async, since some implementations will require that. Currently,
only X11 is supported, which doesn't.

Based on a patch by Jonas Adahl.
This commit is contained in:
Matthias Clasen 2016-07-26 15:46:41 -04:00
parent 2233566f48
commit 18aa05110f
2 changed files with 41 additions and 0 deletions

View File

@ -12612,3 +12612,33 @@ gtk_window_set_hardcoded_window (GtkWindow *window,
g_set_object (&priv->hardcoded_window, gdk_window);
}
gboolean
gtk_window_export_handle (GtkWindow *window,
GtkWindowHandleExported callback,
gpointer user_data)
{
GdkWindow *gdk_window = gtk_widget_get_window (GTK_WIDGET (window));
#ifdef GDK_WINDOWING_X11
if (GDK_IS_X11_DISPLAY (gtk_widget_get_display (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
g_warning ("Couldn't export handle, unsupported windowing system");
return FALSE;
}
void
gtk_window_unexport_handle (GtkWindow *window)
{
}

View File

@ -135,6 +135,17 @@ void gtk_window_set_hardcoded_window (GtkWindow *window,
GdkScreen *_gtk_window_get_screen (GtkWindow *window);
/* Exported handles */
typedef void (*GtkWindowHandleExported) (GtkWindow *window,
const char *handle,
gpointer user_data);
gboolean gtk_window_export_handle (GtkWindow *window,
GtkWindowHandleExported callback,
gpointer user_data);
void gtk_window_unexport_handle (GtkWindow *window);
G_END_DECLS
#endif /* __GTK_WINDOW_PRIVATE_H__ */