From: Peter Hutterer Date: Tue, 27 May 2008 02:03:36 +0000 (+0930) Subject: Test for XI2 functions in libXi, add #ifdefs to build in non-XI2 setups. X-Git-Url: https://diplodocus.org/git/xorg-xinput/commitdiff_plain/8578813fda6787866b6a23b265696a673b213724?ds=sidebyside;hp=--cc Test for XI2 functions in libXi, add #ifdefs to build in non-XI2 setups. --- 8578813fda6787866b6a23b265696a673b213724 diff --git a/configure.ac b/configure.ac index f38914f..dfbad9e 100644 --- a/configure.ac +++ b/configure.ac @@ -13,8 +13,16 @@ AC_PROG_INSTALL # 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(HAVE_XI2) AC_SUBST(VERSION) diff --git a/src/Makefile.am b/src/Makefile.am index 39580a5..6a747ef 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -24,17 +24,22 @@ bin_PROGRAMS = xinput 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 \ - hierarchy.c \ list.c \ setint.c \ - setcp.c \ setmode.c \ setptr.c \ state.c \ test.c \ version.c \ xinput.c \ - xinput.h + xinput.h \ + $(xinput2_files) + diff --git a/src/list.c b/src/list.c index a509872..de8aca7 100644 --- a/src/list.c +++ b/src/list.c @@ -34,7 +34,9 @@ print_info(XDeviceInfo *info, Bool shortformat) XButtonInfoPtr b; XValuatorInfoPtr v; XAxisInfoPtr a; +#if HAVE_XI2 XAttachInfoPtr att; +#endif 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; +#if HAVE_XI2 case AttachClass: att = (XAttachInfoPtr)any; printf("\tAttached to %d\n", att->attached); break; - +#endif default: printf ("unknown class\n"); } @@ -125,12 +128,14 @@ list(Display *display, int num_devices; XEvent ev; +#if HAVE_XI2 if (daemon) { XiSelectEvent(display, DefaultRootWindow(display), NULL, XI_DeviceHierarchyChangedMask | XI_DeviceClassesChangedMask); } +#endif do { info = XListInputDevices(display, &num_devices); @@ -138,6 +143,7 @@ list(Display *display, print_info(info+loop, shortformat); } +#if HAVE_XI2 /* just wait for the next generic event to come along */ while (daemon && !XNextEvent(display, &ev)) { @@ -157,6 +163,7 @@ list(Display *display, break; } } +#endif } while(daemon); } else { int ret = EXIT_SUCCESS; diff --git a/src/xinput.c b/src/xinput.c index c8cc4f9..6dd2b25 100644 --- a/src/xinput.c +++ b/src/xinput.c @@ -81,6 +81,7 @@ static entry drivers[] = "", version }, +#if HAVE_XI2 { "create-master", " [sendCore (dflt:1)] [enable (dflt:1)]", create_master @@ -101,6 +102,7 @@ static entry drivers[] = " ", set_clientpointer }, +#endif {0, 0, 0 } }; @@ -111,7 +113,11 @@ is_xinput_present(Display *display) XExtensionVersion *version; Bool present; +#if HAVE_XI2 version = XQueryInputVersion(display, XI_2_Major, XI_2_Minor); +#else + version = XGetExtensionVersion(display, INAME); +#endif if (version && (version != (XExtensionVersion*) NoSuchExtension)) { present = version->present; diff --git a/src/xinput.h b/src/xinput.h index add9aab..cbab391 100644 --- a/src/xinput.h +++ b/src/xinput.h @@ -21,6 +21,10 @@ * */ +#if HAVE_CONFIG_H +#include +#endif + #include #include #include