[mutter/wip/multitouch: 50/73] window: set the corresponding client pointer on focused windows.



commit 74520ab20bbe74f25d810ed908bfa6c7f294e9b4
Author: Carlos Garnacho <carlosg gnome org>
Date:   Tue Jul 19 20:55:05 2011 +0200

    window: set the corresponding client pointer on focused windows.
    
    The client window determines the device pair that is used for
    core protocol calls such as XQueryPointer(), so different
    clients using the core protocol can be focused by different
    devices simultaneously.

 src/core/window-private.h |    4 ++++
 src/core/window.c         |   28 ++++++++++++++++++++++++++++
 2 files changed, 32 insertions(+), 0 deletions(-)
---
diff --git a/src/core/window-private.h b/src/core/window-private.h
index 022d4be..1ab0ed7 100644
--- a/src/core/window-private.h
+++ b/src/core/window-private.h
@@ -667,6 +667,10 @@ void meta_window_propagate_focus_appearance (MetaWindow *window,
 
 gboolean meta_window_should_attach_to_parent (MetaWindow *window);
 
+void         meta_window_set_client_pointer (MetaWindow *window,
+                                             MetaDevice *pointer);
+MetaDevice * meta_window_get_client_pointer (MetaWindow *window);
+
 MetaDevice * meta_window_guess_grab_pointer (MetaWindow *window);
 
 #endif
diff --git a/src/core/window.c b/src/core/window.c
index be1a650..cebc673 100644
--- a/src/core/window.c
+++ b/src/core/window.c
@@ -6929,6 +6929,8 @@ meta_window_notify_focus (MetaWindow *window,
               !meta_prefs_get_raise_on_click())
             meta_display_ungrab_focus_window_button (window->display, window);
 
+          meta_window_set_client_pointer (window,
+                                          meta_device_get_paired_device (keyboard));
           g_signal_emit (window, window_signals[FOCUS], 0);
 
           if (meta_device_get_id (keyboard) == META_CORE_KEYBOARD_ID)
@@ -10725,6 +10727,32 @@ meta_window_is_attached_dialog (MetaWindow *window)
   return window->attached;
 }
 
+void
+meta_window_set_client_pointer (MetaWindow *window,
+                                MetaDevice *pointer)
+{
+#ifdef HAVE_XINPUT2
+  XISetClientPointer (window->display->xdisplay,
+                      window->xwindow,
+                      meta_device_get_id (pointer));
+#endif
+}
+
+MetaDevice *
+meta_window_get_client_pointer (MetaWindow *window)
+{
+  int device_id = META_CORE_POINTER_ID;
+
+#ifdef HAVE_XINPUT2
+  if (window->display->have_xinput2)
+    XIGetClientPointer (window->display->xdisplay,
+                        window->xwindow, &device_id);
+#endif
+
+  return meta_device_map_lookup (window->display->device_map,
+                                 device_id);
+}
+
 /* Guesses the better device to grab on if a grab is to be started,
  * only should be be used in circumstances where we don't know a
  * device at all.



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