Merged changes from hunter. Attempt to fix cthulhu announcing modifiers when suspended for xterm.

This commit is contained in:
Storm Dragon committed 2026-10-31 16:07:29 -04:00
1 parent 27867a48cb
commit f2cc47c8a0
24 files changed
+679 -67

No files matched your search

+20 -2
View File
@@ -2,15 +2,33 @@
// but remains in Xlib's queue when the Go owner gives the keyboard back.
#include "commands_native.h"
#include <X11/keysym.h>
#include <X11/XKBlib.h>
#include <X11/extensions/XTest.h>
#include <stdio.h>
#include <string.h>
int main(int argc, char **argv) {
int error = 0, failed = 0;
CommandDevice *device = open_commands(1, 0, 0, &error);
int capsHandoff = argc == 2 && strcmp(argv[1], "caps-handoff") == 0;
CommandDevice *device = open_commands(1, 0, capsHandoff, &error);
if (!device) { fprintf(stderr, "open: %d\n", error); return 1; }
if (argc == 2 && strcmp(argv[1], "queued") == 0) {
if (capsHandoff) {
set_command_keys(device, 0);
// A terminal reader changes the real lock while Cthulhu is suspended.
XkbLockModifiers(device->display, XkbUseCoreKbd, LockMask, LockMask);
XSync(device->display, False);
if (!(command_lock_state(device) & 1)) {
fprintf(stderr, "suspended lock read used stale reader state\n");
failed = 1;
}
set_command_keys(device, 1);
if (!device->capsLocked) {
fprintf(stderr, "resumed reader did not adopt external Caps Lock state\n");
failed = 1;
}
XkbLockModifiers(device->display, XkbUseCoreKbd, LockMask, 0);
XSync(device->display, False);
} else if (argc == 2 && strcmp(argv[1], "queued") == 0) {
if (XGrabKeyboard(device->display, device->root, False,
GrabModeAsync, GrabModeAsync, CurrentTime) != GrabSuccess) return 1;
device->active = 1;