aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTony Crisci <tony@dubstepdish.com>2017-12-27 19:07:17 -0500
committerTony Crisci <tony@dubstepdish.com>2017-12-27 19:07:17 -0500
commit27cd633b409bbe6692538a26738e052e7d865be0 (patch)
treeab4a259b1af037ff4c3971157074d65cbef5470e
parentccaedf5b1535db37f36d7eb1424d6fae5b1ac12a (diff)
run compositor bindings last
-rw-r--r--sway/input/keyboard.c82
1 files changed, 49 insertions, 33 deletions
diff --git a/sway/input/keyboard.c b/sway/input/keyboard.c
index 8b43df82..032083e9 100644
--- a/sway/input/keyboard.c
+++ b/sway/input/keyboard.c
@@ -34,18 +34,22 @@ static ssize_t pressed_keysyms_index(xkb_keysym_t *pressed_keysyms,
* Returns true if the keysym was handled by a binding and false if the event
* should be propagated to clients.
*/
-static bool keyboard_execute_compositor_binding(xkb_keysym_t keysym) {
- if (keysym >= XKB_KEY_XF86Switch_VT_1 &&
- keysym <= XKB_KEY_XF86Switch_VT_12) {
- if (wlr_backend_is_multi(server.backend)) {
- struct wlr_session *session =
- wlr_multi_get_session(server.backend);
- if (session) {
- unsigned vt = keysym - XKB_KEY_XF86Switch_VT_1 + 1;
- wlr_session_change_vt(session, vt);
+static bool keyboard_execute_compositor_binding(struct sway_keyboard *keyboard,
+ xkb_keysym_t *pressed_keysyms, uint32_t modifiers, size_t keysyms_len) {
+ for (size_t i = 0; i < keysyms_len; ++i) {
+ xkb_keysym_t keysym = pressed_keysyms[i];
+ if (keysym >= XKB_KEY_XF86Switch_VT_1 &&
+ keysym <= XKB_KEY_XF86Switch_VT_12) {
+ if (wlr_backend_is_multi(server.backend)) {
+ struct wlr_session *session =
+ wlr_multi_get_session(server.backend);
+ if (session) {
+ unsigned vt = keysym - XKB_KEY_XF86Switch_VT_1 + 1;
+ wlr_session_change_vt(session, vt);
+ }
}
+ return true;
}
- return true;
}
return false;
@@ -58,16 +62,8 @@ static bool keyboard_execute_compositor_binding(xkb_keysym_t keysym) {
* Returns true if the keysym was handled by a binding and false if the event
* should be propagated to clients.
*/
-static bool keyboard_execute_binding(struct sway_keyboard *keyboard,
- xkb_keysym_t *pressed_keysyms, uint32_t modifiers,
- const xkb_keysym_t *keysyms, size_t keysyms_len) {
- // compositor bindings
- for (size_t i = 0; i < keysyms_len; ++i) {
- if (keyboard_execute_compositor_binding(keysyms[i])) {
- return true;
- }
- }
-
+static bool keyboard_execute_bindsym(struct sway_keyboard *keyboard,
+ xkb_keysym_t *pressed_keysyms, uint32_t modifiers, size_t keysyms_len) {
// configured bindings
int n = pressed_keysyms_length(pressed_keysyms);
list_t *keysym_bindings = config->current_mode->keysym_bindings;
@@ -208,28 +204,48 @@ static void handle_keyboard_key(struct wl_listener *listener, void *data) {
xkb_keycode_t keycode = event->keycode + 8;
bool handled = false;
- uint32_t modifiers;
const xkb_keysym_t *keysyms;
- size_t keysyms_len;
+
+ // handle keycodes
+ // TODO
+ handled = keyboard_execute_bindcode(keyboard);
// handle translated keysyms
- keysyms_len = keyboard_keysyms_translated(keyboard, keycode, &keysyms,
- &modifiers);
+ uint32_t translated_modifiers;
+ size_t translated_keysyms_len =
+ keyboard_keysyms_translated(keyboard, keycode, &keysyms,
+ &translated_modifiers);
pressed_keysyms_update(keyboard->pressed_keysyms_translated, keysyms,
- keysyms_len, event->state);
- if (event->state == WLR_KEY_PRESSED) {
- handled = keyboard_execute_binding(keyboard,
- keyboard->pressed_keysyms_translated, modifiers, keysyms,
- keysyms_len);
+ translated_keysyms_len, event->state);
+ if (event->state == WLR_KEY_PRESSED && !handled) {
+ handled = keyboard_execute_bindsym(keyboard,
+ keyboard->pressed_keysyms_translated, translated_modifiers,
+ translated_keysyms_len);
}
// Handle raw keysyms
- keysyms_len = keyboard_keysyms_raw(keyboard, keycode, &keysyms, &modifiers);
- pressed_keysyms_update(keyboard->pressed_keysyms_raw, keysyms, keysyms_len,
+ uint32_t raw_modifiers;
+ size_t raw_keysyms_len = keyboard_keysyms_raw(keyboard, keycode, &keysyms, &raw_modifiers);
+ pressed_keysyms_update(keyboard->pressed_keysyms_raw, keysyms, raw_keysyms_len,
event->state);
if (event->state == WLR_KEY_PRESSED && !handled) {
- handled = keyboard_execute_binding(keyboard,
- keyboard->pressed_keysyms_raw, modifiers, keysyms, keysyms_len);
+ handled = keyboard_execute_bindsym(keyboard,
+ keyboard->pressed_keysyms_raw, raw_modifiers,
+ raw_keysyms_len);
+ }
+
+ // Compositor bindings
+ if (event->state == WLR_KEY_PRESSED && !handled) {
+ handled =
+ keyboard_execute_compositor_binding(keyboard,
+ keyboard->pressed_keysyms_translated, translated_modifiers,
+ translated_keysyms_len);
+ }
+ if (event->state == WLR_KEY_PRESSED && !handled) {
+ handled =
+ keyboard_execute_compositor_binding(keyboard,
+ keyboard->pressed_keysyms_raw, raw_modifiers,
+ raw_keysyms_len);
}
if (!handled) {