[gtk+/multitouch-for-3.4: 61/89] gdk, xi2: Update to latest XInput2.2 spec



commit 9b4d179d63d00b228c5e33db9ec2b9a3199513d1
Author: Carlos Garnacho <carlosg gnome org>
Date:   Wed Nov 23 23:57:12 2011 +0100

    gdk,xi2: Update to latest XInput2.2 spec

 configure.ac                   |    4 +-
 gdk/x11/Makefile.am            |    2 +
 gdk/x11/gdkdevice-xi2.c        |    4 +-
 gdk/x11/gdkdevicemanager-x11.c |    6 ++--
 gdk/x11/gdkdevicemanager-xi2.c |   46 ++++++++++++++--------------------------
 5 files changed, 25 insertions(+), 37 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 2c247c9..aaeee2d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -935,7 +935,7 @@ if test "x$enable_x11_backend" = xyes; then
     have_base_x_pc=true
     X_PACKAGES="$X_PACKAGES x11 xext"
     x_libs="`$PKG_CONFIG --libs x11 xext`"
-    X_CFLAGS="`$PKG_CONFIG --cflags x11 xext`"
+    X_CFLAGS="`$PKG_CONFIG --cflags x11 xext` -DXINPUT2_1_USE_UNSTABLE_PROTOCOL -DXINPUT2_2_USE_UNSTABLE_PROTOCOL"
 
     # Strip out any .la files that pkg-config might give us (this happens
     # with -uninstalled.pc files)
@@ -1128,7 +1128,7 @@ if test "x$enable_x11_backend" = xyes; then
 
     gtk_save_LIBS="$LIBS"
     LIBS="$LIBS -lXi"
-    AC_CHECK_FUNC(XIAllowTouchEvents, AC_DEFINE(XINPUT_2_1, 1, [Define to 1 if XInput 2.1 is available]))
+    AC_CHECK_FUNC(XIAllowTouchEvents, AC_DEFINE(XINPUT_2_2, 1, [Define to 1 if XInput 2.2 is available]))
     LIBS="$gtk_save_LIBS"
   else
     AC_DEFINE(XINPUT_NONE, 1,
diff --git a/gdk/x11/Makefile.am b/gdk/x11/Makefile.am
index 3b0d1bd..d8abfd5 100644
--- a/gdk/x11/Makefile.am
+++ b/gdk/x11/Makefile.am
@@ -7,6 +7,8 @@ libgdkx11includedir = $(includedir)/gtk-3.0/gdk/x11
 AM_CPPFLAGS = 			\
 	-DG_LOG_DOMAIN=\"Gdk\"	\
 	-DGDK_COMPILATION	\
+	-DXINPUT2_2_USE_UNSTABLE_PROTOCOL \
+	-DXINPUT2_1_USE_UNSTABLE_PROTOCOL \
 	-I$(top_srcdir)		\
 	-I$(top_srcdir)/gdk	\
 	-I$(top_builddir)/gdk	\
diff --git a/gdk/x11/gdkdevice-xi2.c b/gdk/x11/gdkdevice-xi2.c
index 4a1ddb3..f0e65b3 100644
--- a/gdk/x11/gdkdevice-xi2.c
+++ b/gdk/x11/gdkdevice-xi2.c
@@ -690,14 +690,14 @@ _gdk_x11_device_xi2_translate_event_mask (GdkEventMask  event_mask,
       XISetMask (mask, XI_FocusOut);
     }
 
-#ifdef XINPUT_2_1
+#ifdef XINPUT_2_2
   if (event_mask & GDK_TOUCH_MASK)
     {
       XISetMask (mask, XI_TouchBegin);
       XISetMask (mask, XI_TouchUpdate);
       XISetMask (mask, XI_TouchEnd);
     }
-#endif /* XINPUT_2_1 */
+#endif /* XINPUT_2_2 */
 
   return mask;
 }
diff --git a/gdk/x11/gdkdevicemanager-x11.c b/gdk/x11/gdkdevicemanager-x11.c
index d3815eb..c119870 100644
--- a/gdk/x11/gdkdevicemanager-x11.c
+++ b/gdk/x11/gdkdevicemanager-x11.c
@@ -54,11 +54,11 @@ _gdk_x11_device_manager_new (GdkDisplay *display)
           int major, minor;
 
           major = 2;
-#ifdef XINPUT_2_1
-	  minor = 1;
+#ifdef XINPUT_2_2
+	  minor = 2;
 #else
           minor = 0;
-#endif /* XINPUT_2_1 */
+#endif /* XINPUT_2_2 */
 
           if (!_gdk_disable_multidevice &&
               XIQueryVersion (xdisplay, &major, &minor) != BadRequest)
diff --git a/gdk/x11/gdkdevicemanager-xi2.c b/gdk/x11/gdkdevicemanager-xi2.c
index df7381f..05a35c8 100644
--- a/gdk/x11/gdkdevicemanager-xi2.c
+++ b/gdk/x11/gdkdevicemanager-xi2.c
@@ -242,19 +242,6 @@ translate_device_classes (GdkDisplay      *display,
                                       valuator_info->resolution);
           }
           break;
-#ifdef XINPUT_2_1
-        case XITouchValuatorClass:
-          {
-            XITouchValuatorClassInfo *valuator_info = (XITouchValuatorClassInfo *) class_info;
-
-            translate_valuator_class (display, device,
-                                      valuator_info->label,
-                                      valuator_info->min,
-                                      valuator_info->max,
-                                      valuator_info->resolution);
-          }
-          break;
-#endif /* XINPUT_2_1 */
         default:
           /* Ignore */
           break;
@@ -268,22 +255,21 @@ static gint
 count_device_touches (XIAnyClassInfo **classes,
 		      guint            n_classes)
 {
-  gint n_touches = 0;
-#ifdef XINPUT_2_1
+#ifdef XINPUT_2_2
   guint i;
 
   for (i = 0; i < n_classes; i++)
     {
-      XITouchValuatorClassInfo *valuator_info = (XITouchValuatorClassInfo *) classes[i];
+      XITouchClassInfo *valuator_info = (XITouchClassInfo *) classes[i];
 
-      if (valuator_info->type != XITouchValuatorClass)
+      if (valuator_info->type != XITouchClass)
         continue;
 
-      n_touches = MAX (n_touches, valuator_info->number);
+      return valuator_info->num_touches;
     }
 #endif
 
-  return n_touches;
+  return 0;
 }
 
 static GdkDevice *
@@ -898,11 +884,11 @@ get_event_window (GdkEventTranslator *translator,
     case XI_ButtonPress:
     case XI_ButtonRelease:
     case XI_Motion:
-#ifdef XINPUT_2_1
+#ifdef XINPUT_2_2
     case XI_TouchUpdate:
     case XI_TouchBegin:
     case XI_TouchEnd:
-#endif /* XINPUT_2_1 */
+#endif /* XINPUT_2_2 */
       {
         XIDeviceEvent *xev = (XIDeviceEvent *) ev;
 
@@ -1123,10 +1109,10 @@ gdk_x11_device_manager_xi2_translate_event (GdkEventTranslator *translator,
       break;
     case XI_ButtonPress:
     case XI_ButtonRelease:
-#ifdef XINPUT_2_1
+#ifdef XINPUT_2_2
     case XI_TouchBegin:
     case XI_TouchEnd:
-#endif /* XINPUT_2_1 */
+#endif /* XINPUT_2_2 */
       {
         XIDeviceEvent *xev = (XIDeviceEvent *) ev;
         GdkDevice *source_device;
@@ -1164,13 +1150,13 @@ gdk_x11_device_manager_xi2_translate_event (GdkEventTranslator *translator,
           }
         else
           {
-#ifdef XINPUT_2_1
+#ifdef XINPUT_2_2
             if (ev->evtype == XI_TouchBegin)
               event->button.type = GDK_TOUCH_PRESS;
 	    else if (ev->evtype == XI_TouchEnd)
               event->button.type = GDK_TOUCH_RELEASE;
             else
-#endif /* XINPUT_2_1 */
+#endif /* XINPUT_2_2 */
               event->button.type = (ev->evtype == XI_ButtonPress) ? GDK_BUTTON_PRESS : GDK_BUTTON_RELEASE;
 
             event->button.window = window;
@@ -1204,7 +1190,7 @@ gdk_x11_device_manager_xi2_translate_event (GdkEventTranslator *translator,
 
             event->button.state = _gdk_x11_device_xi2_translate_state (&xev->mods, &xev->buttons, &xev->group);
 
-#ifdef XINPUT_2_1
+#ifdef XINPUT_2_2
             if (ev->evtype == XI_TouchBegin ||
                 ev->evtype == XI_TouchEnd)
               {
@@ -1212,7 +1198,7 @@ gdk_x11_device_manager_xi2_translate_event (GdkEventTranslator *translator,
                 event->button.touch_id = xev->detail;
               }
             else
-#endif /* XINPUT_2_1 */
+#endif /* XINPUT_2_2 */
               event->button.button = xev->detail;
           }
 
@@ -1231,9 +1217,9 @@ gdk_x11_device_manager_xi2_translate_event (GdkEventTranslator *translator,
         break;
       }
     case XI_Motion:
-#ifdef XINPUT_2_1
+#ifdef XINPUT_2_2
     case XI_TouchUpdate:
-#endif /* XINPUT_2_1 */
+#endif /* XINPUT_2_2 */
       {
         XIDeviceEvent *xev = (XIDeviceEvent *) ev;
         GdkDevice *source_device;
@@ -1243,7 +1229,7 @@ gdk_x11_device_manager_xi2_translate_event (GdkEventTranslator *translator,
             event->motion.touch_id = 0;
             event->motion.type = GDK_MOTION_NOTIFY;
           }
-#ifdef XINPUT_2_1
+#ifdef XINPUT_2_2
         else
           {
             event->motion.touch_id = xev->detail;



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