/* * Minimal program to test XkbSetDetectableAutoRepeat */ #include #include #include Display *display; Window root_window, window; int screen; int main(int argc, char **argv) { Bool ar_set, ar_supp; display = XOpenDisplay(NULL); root_window = DefaultRootWindow(display); screen = DefaultScreen(display); window = XCreateSimpleWindow(display, root_window, 400, 400, 200, 200, 1, BlackPixel(display, screen), WhitePixel(display, screen)); XSelectInput(display, window, KeyPressMask | KeyReleaseMask); XMapWindow(display, window); ar_set = XAutoRepeatOn(display); printf("XAutoRepeatOn returns %u\n", ar_set); ar_set = XkbSetDetectableAutoRepeat(display, True, &ar_supp); printf("XkbSetDetectableAutoRepeat returns %u, supported = %u\n", ar_set, ar_supp); /* * If DetectableAutoRepeat is set, holding down a key should produce * multiple KeyPress events, followed by *one* KeyRelease when the * key is released. (If it is not set, holding down a key produces * a sequence of alternating KeyPress and KeyRelease events.) */ while (1) { XEvent event; XNextEvent(display, &event); switch (event.type) { case KeyPress: printf("KeyPress keycode %#x time %#lx\n", event.xkey.keycode, event.xkey.time); break; case KeyRelease: printf("KeyRelease keycode %#x time %#lx\n", event.xkey.keycode, event.xkey.time); break; } } }