]> diplodocus.org Git - xorg-xinput/commitdiff
Register for DeviceClassesChangedEvents, reprint the list when we get one.
authorPeter Hutterer <peter@cs.unisa.edu.au>
Thu, 20 Dec 2007 01:57:32 +0000 (12:27 +1030)
committerPeter Hutterer <peter@cs.unisa.edu.au>
Thu, 20 Dec 2007 01:57:32 +0000 (12:27 +1030)
Only in list --loop mode though.

src/list.c

index 85b766da7eac3c4fd3f43f461eb61b794c6c824c..e2886424c996a01c7fde28a7638fd5cbb59e140b 100644 (file)
@@ -23,6 +23,7 @@
 
 #include "xinput.h"
 #include <string.h>
 
 #include "xinput.h"
 #include <string.h>
+#include <X11/extensions/XIproto.h> /* for XI_Device***ChangedNotify */
 
 static void
 print_info(XDeviceInfo *info, Bool shortformat)
 
 static void
 print_info(XDeviceInfo *info, Bool shortformat)
@@ -128,7 +129,8 @@ list(Display        *display,
         if (daemon)
         {
             XiSelectEvent(display, DefaultRootWindow(display),
         if (daemon)
         {
             XiSelectEvent(display, DefaultRootWindow(display),
-                          XI_DeviceHierarchyChangedMask);
+                          XI_DeviceHierarchyChangedMask |
+                          XI_DeviceClassesChangedMask);
         }
 
         do {
         }
 
         do {
@@ -141,7 +143,20 @@ list(Display       *display,
             while (daemon && !XNextEvent(display, &ev))
             {
                 if (ev.type == GenericEvent)
             while (daemon && !XNextEvent(display, &ev))
             {
                 if (ev.type == GenericEvent)
+                {
+                    XGenericEvent* gev = (XGenericEvent*)&ev;
+                    /* we just assume that extension is IReqCode, pretty save
+                       since we don't register for other events. */
+                    if (gev->evtype == XI_DeviceHierarchyChangedNotify)
+                    {
+                        printf("Hierarchy change.\n");
+                    } else if (gev->evtype == XI_DeviceClassesChangedNotify)
+                    {
+                        printf("Device classes changed.\n");
+                        free(((XDeviceClassesChangedEvent*)&ev)->inputclassinfo);
+                    }
                     break;
                     break;
+                }
             }
         } while(daemon);
     } else {
             }
         } while(daemon);
     } else {