From f8b260d4a1295df68ef1ff7db89f21e6032d64c7 Mon Sep 17 00:00:00 2001 From: Mikkel Oscar Lyderik Date: Sat, 9 Jan 2016 17:40:19 +0100 Subject: Add support for bincode command If a bindsym and bincode maps to the same combination, the last one will overwrite any previous mappings. --- sway/config.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) (limited to 'sway/config.c') diff --git a/sway/config.c b/sway/config.c index d923eea5..ae6a02b1 100644 --- a/sway/config.c +++ b/sway/config.c @@ -652,15 +652,27 @@ int sway_binding_cmp_keys(const void *a, const void *b) { } else if (binda->modifiers < bindb->modifiers) { return -1; } + struct wlc_modifiers no_mods = { 0, 0 }; for (int i = 0; i < binda->keys->length; i++) { - xkb_keysym_t *ka = binda->keys->items[i], - *kb = bindb->keys->items[i]; - if (*ka > *kb) { + xkb_keysym_t ka = *(xkb_keysym_t *)binda->keys->items[i], + kb = *(xkb_keysym_t *)bindb->keys->items[i]; + if (binda->bindcode) { + uint32_t *keycode = binda->keys->items[i]; + ka = wlc_keyboard_get_keysym_for_key(*keycode, &no_mods); + } + + if (bindb->bindcode) { + uint32_t *keycode = bindb->keys->items[i]; + kb = wlc_keyboard_get_keysym_for_key(*keycode, &no_mods); + } + + if (ka > kb) { return 1; - } else if (*ka < *kb) { + } else if (ka < kb) { return -1; } } + return 0; } -- cgit v1.2.3