Ungrab devices if there is a keyboard lock (if an input remapping software runs and grabs gsr-ui virtual keyboard)

This commit is contained in:
dec05eba
2025-11-07 19:23:38 +01:00
parent 2bc2252d30
commit be07070789
11 changed files with 166 additions and 24 deletions

View File

@@ -13,6 +13,7 @@ static void usage(void) {
fprintf(stderr, "OPTIONS:\n");
fprintf(stderr, " --all Grab all devices.\n");
fprintf(stderr, " --virtual Grab all virtual devices only.\n");
fprintf(stderr, " --no-grab Don't grab devices, only listen to them.\n");
}
static bool is_gsr_global_hotkeys_already_running(void) {
@@ -43,8 +44,10 @@ int main(int argc, char **argv) {
grab_type = KEYBOARD_GRAB_TYPE_ALL;
} else if(strcmp(grab_type_arg, "--virtual") == 0) {
grab_type = KEYBOARD_GRAB_TYPE_VIRTUAL;
} else if(strcmp(grab_type_arg, "--no-grab") == 0) {
grab_type = KEYBOARD_GRAB_TYPE_NO_GRAB;
} else {
fprintf(stderr, "gsr-global-hotkeys error: expected --all or --virtual, got %s\n", grab_type_arg);
fprintf(stderr, "gsr-global-hotkeys error: expected --all, --virtual or --no-grab, got %s\n", grab_type_arg);
usage();
return 1;
}
@@ -68,7 +71,7 @@ int main(int argc, char **argv) {
}
keyboard_event keyboard_ev;
if(!keyboard_event_init(&keyboard_ev, true, grab_type)) {
if(!keyboard_event_init(&keyboard_ev, grab_type != KEYBOARD_GRAB_TYPE_NO_GRAB, grab_type)) {
fprintf(stderr, "gsr-global-hotkeys error: failed to setup hotplugging and no keyboard input devices were found\n");
setuid(user_id);
return 1;