diff options
-rw-r--r-- | man/xinput.man | 3 | ||||
-rw-r--r-- | src/Makefile.am | 1 | ||||
-rw-r--r-- | src/version.c | 43 | ||||
-rw-r--r-- | src/xinput.c | 45 |
4 files changed, 40 insertions, 52 deletions
diff --git a/man/xinput.man b/man/xinput.man index 174df27..fbf445e 100644 --- a/man/xinput.man +++ b/man/xinput.man @@ -13,7 +13,8 @@ a device and change input device settings. .TP 8 .B --version Test if the X Input extension is available and return the version number -of the program. This option does not require a device name. +of the program and the version supported by the server. This option does not +require a device name. .PP .TP 8 .B --list [--short || --long] [\fIdevice\fP] diff --git a/src/Makefile.am b/src/Makefile.am index a6dedb7..ba0d325 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -39,7 +39,6 @@ xinput_SOURCES = \ state.c \ property.c \ test.c \ - version.c \ xinput.c \ xinput.h \ $(xinput2_files) diff --git a/src/version.c b/src/version.c deleted file mode 100644 index 93a50d8..0000000 --- a/src/version.c +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright 1996-1997 by Frederic Lepied, France. <Frederic.Lepied@sugix.frmug.org> - * - * Permission to use, copy, modify, distribute, and sell this software and its - * documentation for any purpose is hereby granted without fee, provided that - * the above copyright notice appear in all copies and that both that - * copyright notice and this permission notice appear in supporting - * documentation, and that the name of the authors not be used in - * advertising or publicity pertaining to distribution of the software without - * specific, written prior permission. The authors make no - * representations about the suitability of this software for any purpose. It - * is provided "as is" without express or implied warranty. - * - * THE AUTHORS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO - * EVENT SHALL THE AUTHORS BE LIABLE FOR ANY SPECIAL, INDIRECT OR - * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, - * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER - * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. - * - */ - -#include "xinput.h" - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -static const char version_id[] = VERSION; - -int -version(Display *display, - int argc, - char *argv[], - char *name, - char *desc) -{ - printf("%s %s\n", name, version_id); - return EXIT_SUCCESS; -} - -/* end of version.c */ diff --git a/src/xinput.c b/src/xinput.c index 3c8b23c..149662d 100644 --- a/src/xinput.c +++ b/src/xinput.c @@ -79,10 +79,6 @@ static entry drivers[] = "[-proximity] <device name>", test }, - {"version", - "", - version - }, #if HAVE_XI2 { "create-master", "<id> [<sendCore (dflt:1)>] [<enable (dflt:1)>]", @@ -141,6 +137,37 @@ static entry drivers[] = } }; +static const char version_id[] = VERSION; + +int +print_version() +{ + XExtensionVersion *version; + Display *display; + + printf("xinput version %s\n", version_id); + + display = XOpenDisplay(NULL); + + printf("XI version on server: "); + + if (display == NULL) + printf("Failed to open display.\n"); + else { + version = XGetExtensionVersion(display, INAME); + if (!version || (version == (XExtensionVersion*) NoSuchExtension)) + printf(" Extension not supported.\n"); + else { + printf("%d.%d\n", version->major_version, + version->minor_version); + XFree(version); + return 0; + } + } + + return 1; +} + int xinput_version(Display *display) { @@ -266,6 +293,13 @@ main(int argc, char * argv[]) return EXIT_FAILURE; } + func = argv[1]; + while((*func) == '-') func++; + + if (strcmp("version", func) == 0) { + return print_version(argv[0]); + } + display = XOpenDisplay(NULL); if (display == NULL) { @@ -278,9 +312,6 @@ main(int argc, char * argv[]) return EXIT_FAILURE; } - func = argv[1]; - while((*func) == '-') func++; - if (!xinput_version(display)) { fprintf(stderr, "%s extension not available\n", INAME); return EXIT_FAILURE; |