static int xwinfs_readdir(const char *path, void *buf, fuse_fill_dir_t filler, off_t offset, struct fuse_file_info *fi) { (void) offset; (void) fi; char *name; name = winfs_basename(path); if(strcmp(path, "/") == 0) { filler(buf, ".", NULL, 0); filler(buf, "..", NULL, 0); filler(buf, clients_path + 1, NULL, 0); } else if(strcmp(path, clients_path) == 0) { filler(buf, ".", NULL, 0); filler(buf, "..", NULL, 0); list_clients(buf, filler); } else if(strncmp(path, clients_path, 7) == 0) { if(!valid_client(name)) return -ENOENT; filler(buf, ".", NULL, 0); filler(buf, "..", NULL, 0); list_props(buf, filler, valid_client(name)); } else return -ENOENT; return 0; }
int watch_props(Display *dpy, int argc, char** argv, char* n, char *desc) { XDevice *dev; XDeviceInfo *info; XEvent ev; XDevicePropertyNotifyEvent *dpev; char *name; int type_prop; XEventClass cls_prop; if (list_props(dpy, argc, argv, n, desc) != EXIT_SUCCESS) return EXIT_FAILURE; info = find_device_info(dpy, argv[0], False); if (!info) { fprintf(stderr, "unable to find device %s\n", argv[0]); return EXIT_FAILURE; } dev = XOpenDevice(dpy, info->id); if (!dev) { fprintf(stderr, "unable to open device '%s'\n", info->name); return EXIT_FAILURE; } DevicePropertyNotify(dev, type_prop, cls_prop); XSelectExtensionEvent(dpy, DefaultRootWindow(dpy), &cls_prop, 1); while(1) { XNextEvent(dpy, &ev); dpev = (XDevicePropertyNotifyEvent*)&ev; if (dpev->type != type_prop) continue; name = XGetAtomName(dpy, dpev->atom); printf("Property '%s' changed.\n", name); print_property(dpy, dev, dpev->atom); } XCloseDevice(dpy, dev); }