]> diplodocus.org Git - xorg-xinput/commitdiff
Clean up --version, don't require a DISPLAY and display the server version too.
authorPeter Hutterer <peter.hutterer@who-t.net>
Fri, 9 Oct 2009 05:28:34 +0000 (15:28 +1000)
committerPeter Hutterer <peter.hutterer@who-t.net>
Fri, 9 Oct 2009 05:53:57 +0000 (15:53 +1000)
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>
man/xinput.man
src/Makefile.am
src/version.c [deleted file]
src/xinput.c

index 174df2797efe2aaa6fe0b10a86ae65791d29361e..fbf445e656e925f144a13176fe1bf5ef458f4477 100644 (file)
@@ -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
 .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]
 .PP
 .TP 8
 .B --list [--short || --long] [\fIdevice\fP]
index a6dedb7662604e086ee5b0062f085b5d7a4224c0..ba0d325ac5d5b3c6679b2c7404e28136158b4eca 100644 (file)
@@ -39,7 +39,6 @@ xinput_SOURCES = \
     state.c \
     property.c \
     test.c \
     state.c \
     property.c \
     test.c \
-    version.c \
     xinput.c \
     xinput.h \
     $(xinput2_files)
     xinput.c \
     xinput.h \
     $(xinput2_files)
diff --git a/src/version.c b/src/version.c
deleted file mode 100644 (file)
index 93a50d8..0000000
+++ /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 */
index 3c8b23ca17413152a474547dd50d1e4ab284afb7..149662d2068c4fb8878e91fa565aa65962afc0a0 100644 (file)
@@ -79,10 +79,6 @@ static entry drivers[] =
      "[-proximity] <device name>",
      test
     },
      "[-proximity] <device name>",
      test
     },
-    {"version",
-     "",
-     version
-    },
 #if HAVE_XI2
     { "create-master",
       "<id> [<sendCore (dflt:1)>] [<enable (dflt:1)>]",
 #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)
 {
 int
 xinput_version(Display *display)
 {
@@ -266,6 +293,13 @@ main(int argc, char * argv[])
        return EXIT_FAILURE;
     }
 
        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) {
     display = XOpenDisplay(NULL);
 
     if (display == NULL) {
@@ -278,9 +312,6 @@ main(int argc, char * argv[])
         return EXIT_FAILURE;
     }
 
         return EXIT_FAILURE;
     }
 
-    func = argv[1];
-    while((*func) == '-') func++;
-
     if (!xinput_version(display)) {
        fprintf(stderr, "%s extension not available\n", INAME);
        return EXIT_FAILURE;
     if (!xinput_version(display)) {
        fprintf(stderr, "%s extension not available\n", INAME);
        return EXIT_FAILURE;