diff options
author | dec05eba <dec05eba@protonmail.com> | 2024-12-16 21:48:35 +0100 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2024-12-16 21:48:35 +0100 |
commit | 14b0d376a8191a8873b1f866a3cfe777bbe091ce (patch) | |
tree | 6fc370efbb84ea2585cf867da4137c9a39561472 /tools/gsr-global-hotkeys/keyboard_event.h | |
parent | eb3660a4d81ede493943c13cba959ea061f2d536 (diff) |
Prevent focused application from receiving global hotkey keys on wayland as well (massive hack)
Diffstat (limited to 'tools/gsr-global-hotkeys/keyboard_event.h')
-rw-r--r-- | tools/gsr-global-hotkeys/keyboard_event.h | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/tools/gsr-global-hotkeys/keyboard_event.h b/tools/gsr-global-hotkeys/keyboard_event.h index 5084659..ca96cab 100644 --- a/tools/gsr-global-hotkeys/keyboard_event.h +++ b/tools/gsr-global-hotkeys/keyboard_event.h @@ -30,12 +30,18 @@ typedef enum { } keyboard_button_state; typedef struct { - struct pollfd event_polls[MAX_EVENT_POLLS]; /* Current size is |num_event_polls| */ - int dev_input_ids[MAX_EVENT_POLLS]; /* Current size is |num_event_polls| */ + int dev_input_id; + bool grabbed; +} event_extra_data; + +typedef struct { + struct pollfd event_polls[MAX_EVENT_POLLS]; /* Current size is |num_event_polls| */ + event_extra_data event_extra_data[MAX_EVENT_POLLS]; /* Current size is |num_event_polls| */ int num_event_polls; int stdout_event_index; int hotplug_event_index; + int uinput_fd; bool stdout_failed; hotplug_event hotplug_ev; @@ -51,13 +57,14 @@ typedef struct { } keyboard_event; /* |key| is a KEY_ from linux/input-event-codes.h. |modifiers| is a bitmask of keyboard_modkeys. |press_status| is 0 for released, 1 for pressed and 2 for repeat */ -typedef void (*key_callback)(uint32_t key, uint32_t modifiers, int press_status, void *userdata); +/* Return true to allow other applications to receive the key input (when using exclusive grab) */ +typedef bool (*key_callback)(uint32_t key, uint32_t modifiers, int press_status, void *userdata); -bool keyboard_event_init(keyboard_event *self, bool poll_stdout_error); +bool keyboard_event_init(keyboard_event *self, bool poll_stdout_error, bool exclusive_grab); void keyboard_event_deinit(keyboard_event *self); /* If |timeout_milliseconds| is -1 then wait until an event is received */ void keyboard_event_poll_events(keyboard_event *self, int timeout_milliseconds, key_callback callback, void *userdata); -bool keyboard_event_stdout_has_failed(keyboard_event *self); +bool keyboard_event_stdout_has_failed(const keyboard_event *self); #endif /* KEYBOARD_EVENT_H */ |