X-Git-Url: https://diplodocus.org/git/xorg-xinput/blobdiff_plain/7010a6c924ce6937c8e040c837a118663d6dfdb3..09b075863708e43b9c1202dd052f36d5f865f571:/src/xinput.c?ds=sidebyside 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] ", test }, - {"version", - "", - version - }, #if HAVE_XI2 { "create-master", " [] []", @@ -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;