aboutsummaryrefslogtreecommitdiff
path: root/sway/handlers.c
diff options
context:
space:
mode:
authorTaiyu <taiyu.len@gmail.com>2015-08-10 23:57:25 -0700
committerTaiyu <taiyu.len@gmail.com>2015-08-10 23:57:25 -0700
commitde9cec2e4392ad9428e327f2a79724a620c7a1ef (patch)
tree5dce5072710164584d6b906f02832048f0afc408 /sway/handlers.c
parent737a7421fd32bfd4a451fdd4f210fd7ce7a14695 (diff)
fixed bug
Diffstat (limited to 'sway/handlers.c')
-rw-r--r--sway/handlers.c20
1 files changed, 14 insertions, 6 deletions
diff --git a/sway/handlers.c b/sway/handlers.c
index 0ca1a5be..b5f1b69b 100644
--- a/sway/handlers.c
+++ b/sway/handlers.c
@@ -56,10 +56,11 @@ void handle_view_geometry_request(wlc_handle view, const struct wlc_geometry* ge
// deny that shit
}
+
bool handle_key(wlc_handle view, uint32_t time, const struct wlc_modifiers
*modifiers, uint32_t key, uint32_t sym, enum wlc_key_state state) {
#define QSIZE 32
- static uint8_t head = 1;
+ static uint8_t head = 0;
static uint32_t array[QSIZE];
struct sway_mode *mode = config->current_mode;
@@ -74,11 +75,9 @@ bool handle_key(wlc_handle view, uint32_t time, const struct wlc_modifiers
while (mid != head && array[mid] != sym) {
++mid;
}
- while (mid < head) {
- array[mid] = array[mid+1];
- ++mid;
- }
- --head;
+ if (mid < head) {
+ memmove(array + mid, array + mid + 1, sizeof*array * (--head - mid));
+ } /* else { key is not found as its been removed } */
}
// TODO: reminder to check conflicts with mod+q+a versus mod+q
int i;
@@ -104,6 +103,15 @@ bool handle_key(wlc_handle view, uint32_t time, const struct wlc_modifiers
}
if (match) {
+ //Remove matched keys from array
+ int j;
+ for (j = 0; j < binding->keys->length; ++j) {
+ uint8_t k;
+ for (k = 0; k < head; ++k) {
+ memmove(array + k, array + k + 1, sizeof*array * (--head - k));
+ break;
+ }
+ }
if (state == WLC_KEY_STATE_PRESSED) {
handle_command(config, binding->command);
} else if (state == WLC_KEY_STATE_RELEASED) {