diff options
author | Peter Hutterer <peter.hutterer@who-t.net> | 2009-10-09 15:28:34 +1000 |
---|---|---|
committer | Peter Hutterer <peter.hutterer@who-t.net> | 2009-10-09 15:53:57 +1000 |
commit | 5f49354072a3d331fe359eac0ebff09506668952 (patch) | |
tree | 4db25920c56b94687f0bfb7736c6ef42b477efb0 /src | |
parent | 7ecd7d55d7a7ab9f5cea5f34f28c7c221171c2bf (diff) |
Clean up --version, don't require a DISPLAY and display the server version too.
version.c was removed, seemed a bit excessive for the 20 lines of code.
--version is integrated separate from the other commands now, checked before
opening the display. xinput now prints its own version in all cases, even if
the display is unavailable. If the display is available, it prints the
server version too. Example output:
$> xinput --version
xinput version 1.4.99.3
XI version on server: 2.0
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Diffstat (limited to 'src')
-rw-r--r-- | src/Makefile.am | 1 | ||||
-rw-r--r-- | src/version.c | 43 | ||||
-rw-r--r-- | src/xinput.c | 45 |
3 files changed, 38 insertions, 51 deletions
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; |