[gtk+] x11: Make selection handling work across screens
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] x11: Make selection handling work across screens
- Date: Tue, 28 Jul 2015 03:21:39 +0000 (UTC)
commit 55edc81c10742bf3e410168f6dc317f8aca05938
Author: Matthias Clasen <mclasen redhat com>
Date: Mon Jul 27 23:18:27 2015 -0400
x11: Make selection handling work across screens
When dealing with selection events, we might see windows from
other screens in the requestor field. The current x11 backend
code fails to wrap these in a foreign GdkWindow, since we
don't have the corresponding GdkScreen anymore. Work around
this by creating such 'foreign screens' on demand. We still
maintain the 1:1 relation between the display and the screen
returned by gdk_display_get_default_screen().
https://bugzilla.gnome.org/show_bug.cgi?id=721398
gdk/x11/gdkdisplay-x11.c | 29 +++++++++++++++++++++++++++--
gdk/x11/gdkdisplay-x11.h | 1 +
2 files changed, 28 insertions(+), 2 deletions(-)
---
diff --git a/gdk/x11/gdkdisplay-x11.c b/gdk/x11/gdkdisplay-x11.c
index f2824b6..9bb27ee 100644
--- a/gdk/x11/gdkdisplay-x11.c
+++ b/gdk/x11/gdkdisplay-x11.c
@@ -1959,6 +1959,7 @@ gdk_x11_display_finalize (GObject *object)
/* Free all GdkScreens */
g_object_unref (display_x11->screen);
+ g_list_free_full (display_x11->screens, g_object_unref);
g_free (display_x11->startup_notification_id);
@@ -2035,12 +2036,36 @@ GdkScreen *
_gdk_x11_display_screen_for_xrootwin (GdkDisplay *display,
Window xrootwin)
{
- GdkScreen *screen = gdk_display_get_default_screen (display);
+ GdkScreen *screen;
+ XWindowAttributes attrs;
+ gboolean result;
+ GdkX11Display *display_x11;
+ GList *l;
+
+ screen = gdk_display_get_default_screen (display);
if (GDK_SCREEN_XROOTWIN (screen) == xrootwin)
return screen;
- return NULL;
+ display_x11 = GDK_X11_DISPLAY (display);
+
+ for (l = display_x11->screens; l; l = l->next)
+ {
+ screen = l->data;
+ if (GDK_SCREEN_XROOTWIN (screen) == xrootwin)
+ return screen;
+ }
+
+ gdk_x11_display_error_trap_push (display);
+ result = XGetWindowAttributes (display_x11->xdisplay, xrootwin, &attrs);
+ if (gdk_x11_display_error_trap_pop (display) || !result)
+ return NULL;
+
+ screen = _gdk_x11_screen_new (display, XScreenNumberOfScreen (attrs.screen));
+
+ display_x11->screens = g_list_prepend (display_x11->screens, screen);
+
+ return screen;
}
/**
diff --git a/gdk/x11/gdkdisplay-x11.h b/gdk/x11/gdkdisplay-x11.h
index aadf255..9b78f61 100644
--- a/gdk/x11/gdkdisplay-x11.h
+++ b/gdk/x11/gdkdisplay-x11.h
@@ -39,6 +39,7 @@ struct _GdkX11Display
GdkDisplay parent_instance;
Display *xdisplay;
GdkScreen *screen;
+ GList *screens;
GSource *event_source;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]