]> diplodocus.org Git - xorg-xinput/commitdiff
Test for XI2 functions in libXi, add #ifdefs to build in non-XI2 setups.
authorPeter Hutterer <peter@cs.unisa.edu.au>
Tue, 27 May 2008 02:03:36 +0000 (11:33 +0930)
committerPeter Hutterer <peter@cs.unisa.edu.au>
Tue, 27 May 2008 02:06:07 +0000 (11:36 +0930)
configure.ac
src/Makefile.am
src/list.c
src/xinput.c
src/xinput.h

index f38914f00fc962bb17814cb046fd1b0f20665c23..dfbad9e4b562f6bd3dcaa0f2c89c1ea8e90880bc 100644 (file)
@@ -13,8 +13,16 @@ AC_PROG_INSTALL
 
 # Checks for pkg-config packages
 PKG_CHECK_MODULES(XINPUT, x11 xext xi [inputproto >= 1.4])
 
 # Checks for pkg-config packages
 PKG_CHECK_MODULES(XINPUT, x11 xext xi [inputproto >= 1.4])
+
+LIBS="$XINPUT_LIBS $LIBS"
+AC_CHECK_LIB(Xi, XSetClientPointer,
+             have_xi2=yes AC_DEFINE(HAVE_XI2, 1, [Enabling XI 2 calls]),
+             have_xi2=no)
+AM_CONDITIONAL(HAVE_XI2, test "x$have_xi2" == xyes)
+
 AC_SUBST(XINPUT_CFLAGS)
 AC_SUBST(XINPUT_LIBS)
 AC_SUBST(XINPUT_CFLAGS)
 AC_SUBST(XINPUT_LIBS)
+AC_SUBST(HAVE_XI2)
 
 AC_SUBST(VERSION)
 
 
 AC_SUBST(VERSION)
 
index 39580a5876d89e72b49a0a1837d1bb8d32849083..6a747ef72f952bfadd77360058cd216b422f3a13 100644 (file)
@@ -24,17 +24,22 @@ bin_PROGRAMS = xinput
 AM_CFLAGS = $(XINPUT_CFLAGS)
 xinput_LDADD = $(XINPUT_LIBS)
 
 AM_CFLAGS = $(XINPUT_CFLAGS)
 xinput_LDADD = $(XINPUT_LIBS)
 
+
+if HAVE_XI2
+    xinput2_files = hierarchy.c setcp.c
+endif # HAVE_XI2
+
 xinput_SOURCES = \
     buttonmap.c \
     feedback.c \
 xinput_SOURCES = \
     buttonmap.c \
     feedback.c \
-    hierarchy.c \
     list.c \
     setint.c \
     list.c \
     setint.c \
-    setcp.c \
     setmode.c \
     setptr.c \
     state.c \
     test.c \
     version.c \
     xinput.c \
     setmode.c \
     setptr.c \
     state.c \
     test.c \
     version.c \
     xinput.c \
-    xinput.h
+    xinput.h \
+    $(xinput2_files)
+
index a50987265e9d10b11cc6c22f11e2b290db4c748a..de8aca7981f41a68e49eb105d08e70de3cc0c893 100644 (file)
@@ -34,7 +34,9 @@ print_info(XDeviceInfo        *info, Bool shortformat)
     XButtonInfoPtr     b;
     XValuatorInfoPtr   v;
     XAxisInfoPtr       a;
     XButtonInfoPtr     b;
     XValuatorInfoPtr   v;
     XAxisInfoPtr       a;
+#if HAVE_XI2
     XAttachInfoPtr      att;
     XAttachInfoPtr      att;
+#endif
 
     printf("\"%s\"\tid=%ld\t[", info->name, info->id);
 
 
     printf("\"%s\"\tid=%ld\t[", info->name, info->id);
 
@@ -93,11 +95,12 @@ print_info(XDeviceInfo      *info, Bool shortformat)
                    printf ("\t\tResolution is %d\n", a->resolution);
                }
                break;
                    printf ("\t\tResolution is %d\n", a->resolution);
                }
                break;
+#if HAVE_XI2
             case AttachClass:
                 att = (XAttachInfoPtr)any;
                 printf("\tAttached to %d\n", att->attached);
                 break;
             case AttachClass:
                 att = (XAttachInfoPtr)any;
                 printf("\tAttached to %d\n", att->attached);
                 break;
-
+#endif
            default:
                printf ("unknown class\n");
            }
            default:
                printf ("unknown class\n");
            }
@@ -125,12 +128,14 @@ list(Display      *display,
        int             num_devices;
         XEvent  ev;
 
        int             num_devices;
         XEvent  ev;
 
+#if HAVE_XI2
         if (daemon)
         {
             XiSelectEvent(display, DefaultRootWindow(display), NULL,
                           XI_DeviceHierarchyChangedMask |
                           XI_DeviceClassesChangedMask);
         }
         if (daemon)
         {
             XiSelectEvent(display, DefaultRootWindow(display), NULL,
                           XI_DeviceHierarchyChangedMask |
                           XI_DeviceClassesChangedMask);
         }
+#endif
 
         do {
             info = XListInputDevices(display, &num_devices);
 
         do {
             info = XListInputDevices(display, &num_devices);
@@ -138,6 +143,7 @@ list(Display        *display,
                 print_info(info+loop, shortformat);
             }
 
                 print_info(info+loop, shortformat);
             }
 
+#if HAVE_XI2
             /* just wait for the next generic event to come along */
             while (daemon && !XNextEvent(display, &ev))
             {
             /* just wait for the next generic event to come along */
             while (daemon && !XNextEvent(display, &ev))
             {
@@ -157,6 +163,7 @@ list(Display        *display,
                     break;
                 }
             }
                     break;
                 }
             }
+#endif
         } while(daemon);
     } else {
        int     ret = EXIT_SUCCESS;
         } while(daemon);
     } else {
        int     ret = EXIT_SUCCESS;
index c8cc4f917618fda3d908329e100b7045ec8bd4b7..6dd2b25aa5e96cd05170247f68d571d8a555bcfc 100644 (file)
@@ -81,6 +81,7 @@ static entry drivers[] =
      "",
      version
     },
      "",
      version
     },
+#if HAVE_XI2
     { "create-master",
       "<id> [sendCore (dflt:1)] [enable (dflt:1)]",
       create_master
     { "create-master",
       "<id> [sendCore (dflt:1)] [enable (dflt:1)]",
       create_master
@@ -101,6 +102,7 @@ static entry drivers[] =
       "<window> <device>",
       set_clientpointer
     },
       "<window> <device>",
       set_clientpointer
     },
+#endif
     {0, 0, 0
     }
 };
     {0, 0, 0
     }
 };
@@ -111,7 +113,11 @@ is_xinput_present(Display  *display)
     XExtensionVersion  *version;
     Bool               present;
 
     XExtensionVersion  *version;
     Bool               present;
 
+#if HAVE_XI2
     version = XQueryInputVersion(display, XI_2_Major, XI_2_Minor);
     version = XQueryInputVersion(display, XI_2_Major, XI_2_Minor);
+#else
+    version = XGetExtensionVersion(display, INAME);
+#endif
 
     if (version && (version != (XExtensionVersion*) NoSuchExtension)) {
        present = version->present;
 
     if (version && (version != (XExtensionVersion*) NoSuchExtension)) {
        present = version->present;
index add9aab946d3b5e85a6f77d879b4c3957c189fa4..cbab391cd26842e5ee2658e74eb4030cc6366b7d 100644 (file)
  *
  */
 
  *
  */
 
+#if HAVE_CONFIG_H
+#include <config.h>
+#endif
+
 #include <X11/Xlib.h>
 #include <X11/extensions/XInput.h>
 #include <X11/Xutil.h>
 #include <X11/Xlib.h>
 #include <X11/extensions/XInput.h>
 #include <X11/Xutil.h>