[libwnck] core: Add Screen argument to _wnck_select_input()



commit a5cc0e1f4a27286878eb65a142395fb0b43e9827
Author: Vincent Untz <vuntz gnome org>
Date:   Wed Jan 19 23:57:34 2011 +0100

    core: Add Screen argument to _wnck_select_input()
    
    If we can't find a GdkDisplay matching the Display of the Screen, then
    we just skip the GDK integration code: using gdk_display_get_default()
    would be just wrong. And this shouldn't happen anyway.

 libwnck/application.c |    3 ++-
 libwnck/screen.c      |    3 ++-
 libwnck/window.c      |    3 ++-
 libwnck/xutils.c      |   26 +++++++++++++++++++-------
 libwnck/xutils.h      |    5 +++--
 5 files changed, 28 insertions(+), 12 deletions(-)
---
diff --git a/libwnck/application.c b/libwnck/application.c
index 4b1c343..a7349ce 100644
--- a/libwnck/application.c
+++ b/libwnck/application.c
@@ -554,7 +554,8 @@ _wnck_application_create (Window      xwindow,
   /* Note that xwindow may correspond to a WnckWindow's xwindow,
    * so we select events needed by either
    */
-  _wnck_select_input (application->priv->xwindow,
+  _wnck_select_input (xscreen,
+                      application->priv->xwindow,
                       WNCK_APP_WINDOW_EVENT_MASK);
 
   return application;
diff --git a/libwnck/screen.c b/libwnck/screen.c
index 8c73599..d9b7767 100644
--- a/libwnck/screen.c
+++ b/libwnck/screen.c
@@ -598,7 +598,8 @@ wnck_screen_construct (WnckScreen *screen,
 
   screen->priv->bg_pixmap = None;
 
-  _wnck_select_input (screen->priv->xroot,
+  _wnck_select_input (WNCK_SCREEN_XSCREEN (screen),
+                      screen->priv->xroot,
                       PropertyChangeMask);
 
   screen->priv->need_update_workspace_list = TRUE;
diff --git a/libwnck/window.c b/libwnck/window.c
index ce10c3e..ca98a53 100644
--- a/libwnck/window.c
+++ b/libwnck/window.c
@@ -521,7 +521,8 @@ _wnck_window_create (Window      xwindow,
    * that's why we select the union of the mask we want for Application
    * and the one we want for window
    */
-  _wnck_select_input (window->priv->xwindow,
+  _wnck_select_input (xscreen,
+                      window->priv->xwindow,
                       WNCK_APP_WINDOW_EVENT_MASK);
 
   /* Default the group leader to the window itself; it is set in
diff --git a/libwnck/xutils.c b/libwnck/xutils.c
index 292165b..54cb6e6 100644
--- a/libwnck/xutils.c
+++ b/libwnck/xutils.c
@@ -1358,13 +1358,25 @@ _wnck_get_frame_extents (Screen *screen,
 }
 
 void
-_wnck_select_input (Window xwindow,
-                    int    mask)
+_wnck_select_input (Screen *screen,
+                    Window  xwindow,
+                    int     mask)
 {
-  GdkWindow *gdkwindow;
+  Display    *display;
+  GdkDisplay *gdkdisplay;
+  GdkWindow  *gdkwindow;
 
-  gdkwindow = gdk_x11_window_lookup_for_display (gdk_display_get_default (),
-                                                 xwindow);
+  display = DisplayOfScreen (screen);
+  gdkdisplay = gdk_x11_lookup_xdisplay (display);
+
+  if (gdkdisplay)
+    gdkwindow = gdk_x11_window_lookup_for_display (gdkdisplay, xwindow);
+  else
+    {
+      g_warning ("No GdkDisplay matching Display \"%s\" was found.\n",
+                 DisplayString (display));
+      gdkwindow = NULL;
+    }
 
   _wnck_error_trap_push ();
   if (gdkwindow)
@@ -1375,11 +1387,11 @@ _wnck_select_input (Window xwindow,
        * and not changing them again
        */
       XWindowAttributes attrs;
-      XGetWindowAttributes (_wnck_get_default_display (), xwindow, &attrs);
+      XGetWindowAttributes (display, xwindow, &attrs);
       mask |= attrs.your_event_mask;
     }
 
-  XSelectInput (_wnck_get_default_display (), xwindow, mask);
+  XSelectInput (display, xwindow, mask);
   _wnck_error_trap_pop ();
 }
 
diff --git a/libwnck/xutils.h b/libwnck/xutils.h
index 7f337a9..ea80e23 100644
--- a/libwnck/xutils.h
+++ b/libwnck/xutils.h
@@ -146,8 +146,9 @@ gboolean _wnck_get_frame_extents  (Screen *screen,
                                    int    *top_frame,
                                    int    *bottom_frame);
 
-void   _wnck_select_input     (Window xwindow,
-                               int    mask);
+void   _wnck_select_input     (Screen *screen,
+                               Window  xwindow,
+                               int     mask);
 
 void   _wnck_keyboard_move    (Screen *screen,
                                Window  xwindow);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]