]> diplodocus.org Git - xorg-xinput/blobdiff - src/xinput.c
xinput 1.5.0
[xorg-xinput] / src / xinput.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;