[gtk+/xi2: 908/1239] GdkDeviceXI2: Put function to translate event masks here.



commit 9e7f10e3f41039e5797b348d0a57232183771ef0
Author: Carlos Garnacho <carlos lanedo com>
Date:   Fri Aug 28 01:09:42 2009 +0200

    GdkDeviceXI2: Put function to translate event masks here.

 gdk/x11/gdkdevice-xi2.c        |   57 ++++++++++++++++++++++++++++++++++++
 gdk/x11/gdkdevice-xi2.h        |    3 ++
 gdk/x11/gdkdevicemanager-xi2.c |   63 +--------------------------------------
 3 files changed, 62 insertions(+), 61 deletions(-)
---
diff --git a/gdk/x11/gdkdevice-xi2.c b/gdk/x11/gdkdevice-xi2.c
index ffa04b2..fbedee0 100644
--- a/gdk/x11/gdkdevice-xi2.c
+++ b/gdk/x11/gdkdevice-xi2.c
@@ -322,3 +322,60 @@ gdk_device_xi2_window_at_position (GdkDevice *device,
 
   return window;
 }
+
+guchar *
+gdk_device_xi2_translate_event_mask (GdkEventMask  event_mask,
+                                     int          *len)
+{
+  guchar *mask;
+  int mask_len;
+
+  *len = XIMaskLen (XI_LASTEVENT);
+  mask = g_new0 (guchar, *len);
+
+  if (event_mask & GDK_POINTER_MOTION_MASK ||
+      event_mask & GDK_POINTER_MOTION_HINT_MASK)
+    XISetMask (mask, XI_Motion);
+
+  if (event_mask & GDK_BUTTON_MOTION_MASK ||
+      event_mask & GDK_BUTTON1_MOTION_MASK ||
+      event_mask & GDK_BUTTON2_MOTION_MASK ||
+      event_mask & GDK_BUTTON3_MOTION_MASK)
+    {
+      XISetMask (mask, XI_ButtonPress);
+      XISetMask (mask, XI_ButtonRelease);
+      XISetMask (mask, XI_Motion);
+    }
+
+  if (event_mask & GDK_SCROLL_MASK)
+    {
+      XISetMask (mask, XI_ButtonPress);
+      XISetMask (mask, XI_ButtonRelease);
+    }
+
+  if (event_mask & GDK_BUTTON_PRESS_MASK)
+    XISetMask (mask, XI_ButtonPress);
+
+  if (event_mask & GDK_BUTTON_RELEASE_MASK)
+    XISetMask (mask, XI_ButtonRelease);
+
+  if (event_mask & GDK_KEY_PRESS_MASK)
+    XISetMask (mask, XI_KeyPress);
+
+  if (event_mask & GDK_KEY_RELEASE_MASK)
+    XISetMask (mask, XI_KeyRelease);
+
+  if (event_mask & GDK_ENTER_NOTIFY_MASK)
+    XISetMask (mask, XI_Enter);
+
+  if (event_mask & GDK_LEAVE_NOTIFY_MASK)
+    XISetMask (mask, XI_Leave);
+
+  if (event_mask & GDK_FOCUS_CHANGE_MASK)
+    {
+      XISetMask (mask, XI_FocusIn);
+      XISetMask (mask, XI_FocusOut);
+    }
+
+  return mask;
+}
diff --git a/gdk/x11/gdkdevice-xi2.h b/gdk/x11/gdkdevice-xi2.h
index 103c821..a55070a 100644
--- a/gdk/x11/gdkdevice-xi2.h
+++ b/gdk/x11/gdkdevice-xi2.h
@@ -46,6 +46,9 @@ struct _GdkDeviceXI2Class
 
 GType gdk_device_xi2_get_type (void) G_GNUC_CONST;
 
+guchar * gdk_device_xi2_translate_event_mask (GdkEventMask  event_mask,
+                                              int          *len);
+
 
 G_END_DECLS
 
diff --git a/gdk/x11/gdkdevicemanager-xi2.c b/gdk/x11/gdkdevicemanager-xi2.c
index 61b260b..98d2d71 100644
--- a/gdk/x11/gdkdevicemanager-xi2.c
+++ b/gdk/x11/gdkdevicemanager-xi2.c
@@ -77,57 +77,6 @@ gdk_device_manager_xi2_init (GdkDeviceManagerXI2 *device_manager)
 }
 
 static void
-translate_event_mask (GdkEventMask   event_mask,
-                      unsigned char *mask)
-{
-  if (event_mask & GDK_POINTER_MOTION_MASK ||
-      event_mask & GDK_POINTER_MOTION_HINT_MASK)
-    XISetMask (mask, XI_Motion);
-
-  if (event_mask & GDK_BUTTON_MOTION_MASK ||
-      event_mask & GDK_BUTTON1_MOTION_MASK ||
-      event_mask & GDK_BUTTON2_MOTION_MASK ||
-      event_mask & GDK_BUTTON3_MOTION_MASK)
-    {
-      XISetMask (mask, XI_ButtonPress);
-      XISetMask (mask, XI_ButtonRelease);
-      XISetMask (mask, XI_Motion);
-    }
-
-  if (event_mask & GDK_SCROLL_MASK)
-    {
-      XISetMask (mask, XI_ButtonPress);
-      XISetMask (mask, XI_ButtonRelease);
-    }
-
-  if (event_mask & GDK_BUTTON_PRESS_MASK)
-    XISetMask (mask, XI_ButtonPress);
-
-  if (event_mask & GDK_BUTTON_RELEASE_MASK)
-    XISetMask (mask, XI_ButtonRelease);
-
-  if (event_mask & GDK_KEY_PRESS_MASK)
-    XISetMask (mask, XI_KeyPress);
-
-  if (event_mask & GDK_KEY_RELEASE_MASK)
-    XISetMask (mask, XI_KeyRelease);
-
-  if (event_mask & GDK_ENTER_NOTIFY_MASK)
-    XISetMask (mask, XI_Enter);
-
-  if (event_mask & GDK_LEAVE_NOTIFY_MASK)
-    XISetMask (mask, XI_Leave);
-
-  if (event_mask & GDK_FOCUS_CHANGE_MASK)
-    {
-      XISetMask (mask, XI_FocusIn);
-      XISetMask (mask, XI_FocusOut);
-    }
-
-  /* FIXME: Proximity in/out mask */
-}
-
-static void
 _gdk_device_manager_xi2_select_events (GdkDeviceManager *device_manager,
                                        Window            xwindow,
                                        XIEventMask      *event_mask)
@@ -421,14 +370,10 @@ gdk_device_manager_xi2_set_window_events (GdkDeviceManager *device_manager,
                                           GdkWindow        *window,
                                           GdkEventMask      evmask)
 {
-  unsigned char mask[2] = { 0 };
   XIEventMask event_mask;
 
-  translate_event_mask (evmask, mask);
-
   event_mask.deviceid = XIAllMasterDevices;
-  event_mask.mask_len = sizeof (mask);
-  event_mask.mask = mask;
+  event_mask.mask = gdk_device_xi2_translate_event_mask (evmask, &event_mask.mask_len);
 
   _gdk_device_manager_xi2_select_events (device_manager,
                                          GDK_WINDOW_XWINDOW (window),
@@ -1144,16 +1089,12 @@ gdk_device_manager_xi2_select_window_events (GdkEventTranslator *translator,
                                              GdkEventMask        evmask)
 {
   GdkDeviceManager *device_manager;
-  unsigned char mask[2] = { 0 };
   XIEventMask event_mask;
 
   device_manager = GDK_DEVICE_MANAGER (translator);
 
-  translate_event_mask (evmask, mask);
-
   event_mask.deviceid = XIAllMasterDevices;
-  event_mask.mask_len = sizeof (mask);
-  event_mask.mask = mask;
+  event_mask.mask = gdk_device_xi2_translate_event_mask (evmask, &event_mask.mask_len);
 
   _gdk_device_manager_xi2_select_events (device_manager, window, &event_mask);
 }



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