/* * cc -o test test.c -lX11 $(pkg-config --cflags --libs xorg-libinput xi) */ #include #include #include #include #include static int xfce_pointers_is_libinput (Display *xdisplay, XDevice *device) { Atom prop, type; unsigned long n_items, bytes_after; int rc, format; unsigned char *data; prop = XInternAtom (xdisplay, LIBINPUT_PROP_LEFT_HANDED, False); rc = XGetDeviceProperty (xdisplay, device, prop, 0, 1, False, XA_INTEGER, &type, &format, &n_items, &bytes_after, &data); if (rc == Success) { /* Replace the prop with the same value */ XChangeDeviceProperty (xdisplay, device, prop, type, format, PropModeReplace, data, n_items); XFree (data); return (n_items > 0); } return 0; } int main (void) { Display *xdisplay; XDeviceInfo *device_list, *device_info; XDevice *device; int n, ndevices; xdisplay = XOpenDisplay(NULL); if (!xdisplay) { fprintf (stderr, "Cannot open display\n"); return -1; } device_list = XListInputDevices (xdisplay, &ndevices); for (n = 0; n < ndevices; n++) { device_info = &device_list[n]; if (device_info->use != IsXExtensionPointer || device_info->name == NULL) continue; /* open the device */ device = XOpenDevice (xdisplay, device_info->id); if (device == NULL) { fprintf (stderr, "Unable to open device %s\n", device_info->name); continue; } fprintf (stdout, "Device %d (%s) is%s managed by libinput\n", device_info->id, device_info->name, xfce_pointers_is_libinput (xdisplay, device) ? "" : " not"); XCloseDevice (xdisplay, device); } XFreeDeviceList (device_list); XCloseDisplay(xdisplay); }