aboutsummaryrefslogtreecommitdiff
path: root/tools/gsr-global-hotkeys/keyboard_event.h
diff options
context:
space:
mode:
Diffstat (limited to 'tools/gsr-global-hotkeys/keyboard_event.h')
-rw-r--r--tools/gsr-global-hotkeys/keyboard_event.h38
1 files changed, 33 insertions, 5 deletions
diff --git a/tools/gsr-global-hotkeys/keyboard_event.h b/tools/gsr-global-hotkeys/keyboard_event.h
index d12b684..9904237 100644
--- a/tools/gsr-global-hotkeys/keyboard_event.h
+++ b/tools/gsr-global-hotkeys/keyboard_event.h
@@ -17,11 +17,32 @@
#define MAX_EVENT_POLLS 32
+typedef struct {
+ union {
+ int type;
+ unsigned char data[192];
+ };
+} XEvent;
+
+typedef unsigned long (*XKeycodeToKeysym_FUNC)(void *display, unsigned char keycode, int index);
+typedef int (*XPending_FUNC)(void *display);
+typedef int (*XNextEvent_FUNC)(void *display, XEvent *event_return);
+typedef int (*XRefreshKeyboardMapping_FUNC)(void* event_map);
+
+typedef struct {
+ void *display;
+ XKeycodeToKeysym_FUNC XKeycodeToKeysym;
+ XPending_FUNC XPending;
+ XNextEvent_FUNC XNextEvent;
+ XRefreshKeyboardMapping_FUNC XRefreshKeyboardMapping;
+} x11_context;
+
typedef enum {
- KEYBOARD_MODKEY_ALT = 1 << 0,
- KEYBOARD_MODKEY_SUPER = 1 << 1,
- KEYBOARD_MODKEY_CTRL = 1 << 2,
- KEYBOARD_MODKEY_SHIFT = 1 << 3
+ KEYBOARD_MODKEY_LALT = 1 << 0,
+ KEYBOARD_MODKEY_RALT = 1 << 2,
+ KEYBOARD_MODKEY_SUPER = 1 << 3,
+ KEYBOARD_MODKEY_CTRL = 1 << 4,
+ KEYBOARD_MODKEY_SHIFT = 1 << 5
} keyboard_modkeys;
typedef enum {
@@ -36,6 +57,11 @@ typedef struct {
int num_keys_pressed;
} event_extra_data;
+typedef enum {
+ KEYBOARD_GRAB_TYPE_ALL,
+ KEYBOARD_GRAB_TYPE_VIRTUAL
+} keyboard_grab_type;
+
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| */
@@ -45,6 +71,8 @@ typedef struct {
int hotplug_event_index;
int uinput_fd;
bool stdout_failed;
+ keyboard_grab_type grab_type;
+ x11_context x_context;
hotplug_event hotplug_ev;
@@ -62,7 +90,7 @@ typedef struct {
/* 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 exclusive_grab);
+bool keyboard_event_init(keyboard_event *self, bool poll_stdout_error, bool exclusive_grab, keyboard_grab_type grab_type, x11_context x_context);
void keyboard_event_deinit(keyboard_event *self);
/* If |timeout_milliseconds| is -1 then wait until an event is received */