diff options
author | Harry Jeffery <harry@exec64.co.uk> | 2019-08-23 23:41:22 +0100 |
---|---|---|
committer | Harry Jeffery <harry@exec64.co.uk> | 2019-08-23 23:41:22 +0100 |
commit | 74189114065c79d85ad0b8f75e34490a802cc2f4 (patch) | |
tree | 17f0070792addc2e92409594f78fc1caad260924 | |
parent | 9e1d6e24a028ec96fb11ba943769764665fb024c (diff) | |
download | imv-74189114065c79d85ad0b8f75e34490a802cc2f4.tar.gz |
x11_window: Maintain keyboard modifiers state
-rw-r--r-- | src/x11_window.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/x11_window.c b/src/x11_window.c index 315f600..69fb244 100644 --- a/src/x11_window.c +++ b/src/x11_window.c @@ -38,6 +38,7 @@ struct imv_window { int pipe_fds[2]; char *keymap; + int last_mod_state; }; static void set_nonblocking(int fd) @@ -297,6 +298,21 @@ void imv_window_pump_events(struct imv_window *window, imv_event_handler handler handler(data, &e); } } else if (xev.type == KeyPress || xev.type == KeyRelease) { + if (window->last_mod_state != (int)xev.xkey.state) { + window->last_mod_state = (int)xev.xkey.state; + /* modifiers have changed, push an event for that first */ + struct imv_event e = { + .type = IMV_EVENT_KEYBOARD_MODS, + .data = { + .keyboard_mods = { + .depressed = (int)xev.xkey.state, + } + } + }; + if (handler) { + handler(data, &e); + } + } struct imv_event e = { .type = IMV_EVENT_KEYBOARD, .data = { |