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

+9 -1
View File
@@ -381,6 +381,13 @@ static void grab_command_keys(CommandDevice *device) {
}
}
int set_command_keys(CommandDevice *device, int enabled) {
// Another reader may have changed Caps Lock while command input was
// delegated. Adopt that state before treating Caps as our modifier again.
if (enabled && !device->commands && device->capsCode) {
XkbStateRec state;
if (XkbGetState(device->display, XkbUseCoreKbd, &state) != Success) return -7;
device->capsLocked = (state.locked_mods & LockMask) != 0;
}
pthread_mutex_lock(&error_mutex);
XSync(device->display,False);
error_display=device->display; grab_error=0;
@@ -491,6 +498,7 @@ CommandDevice *open_commands(int useInsert, int useKeypad, int useCaps, int *err
*error=set_command_keys(device,1);
if (*error) { XCloseDisplay(device->display); free(device); return NULL; }
if (device->capsCode) {
device->capsLocked=0;
XkbLockModifiers(device->display,XkbUseCoreKbd,LockMask,0);
XSync(device->display,False);
}
@@ -502,7 +510,7 @@ int command_lock_state(CommandDevice *device) {
int locks=0;
for (int i=0;i<3;i++) if (indicators & device->lockIndicators[i]) locks |= 1<<i;
// Ignore the transient XKB lock action on a grabbed reader modifier.
if (device->capsCode) locks=(locks & ~1) | device->capsLocked;
if (device->commands && device->capsCode) locks=(locks & ~1) | device->capsLocked;
return locks;
}
void toggle_command_caps_lock(CommandDevice *device) {