Skip to content

Commit

Permalink
UI: ignore scroll lock in hotkeys/keyboard handling
Browse files Browse the repository at this point in the history
Also warn if a hotkey uses a modifier that is masked out.
  • Loading branch information
black-sliver committed Sep 3, 2024
1 parent 8f51c4b commit feaf1f4
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/uilib/ui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -250,12 +250,17 @@ bool Ui::render()
EVENT_LOCK(this);
if (!ev.key.repeat) {
int key = (int)ev.key.keysym.sym;
int mod = (int)(ev.key.keysym.mod & ~(KMOD_NUM | KMOD_CAPS));
const uint16_t mask = KMOD_CTRL | KMOD_SHIFT | KMOD_GUI;
int mod = (int)(ev.key.keysym.mod & mask);
for (const auto& hotkey: _hotkeys) {
if (key == hotkey.key && mod == hotkey.mod) {
onHotkey.emit(this, hotkey);
break;
}
if (hotkey.mod & ~mask) {
fprintf(stderr, "Invalid hotkey %d+%d: modifier masked out\n",
hotkey.key, hotkey.mod);
}
}
}
EVENT_UNLOCK(this);
Expand Down

0 comments on commit feaf1f4

Please sign in to comment.