summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Taiyu <taiyu.len@gmail.com>2015-08-10 23:57:25 -0700
committerLibravatar Taiyu <taiyu.len@gmail.com>2015-08-10 23:57:25 -0700
commitde9cec2e4392ad9428e327f2a79724a620c7a1ef (patch)
tree5dce5072710164584d6b906f02832048f0afc408
parentadded multikey handling for handle_key\(...\) (diff)
downloadsway-de9cec2e4392ad9428e327f2a79724a620c7a1ef.tar.gz
sway-de9cec2e4392ad9428e327f2a79724a620c7a1ef.tar.zst
sway-de9cec2e4392ad9428e327f2a79724a620c7a1ef.zip
fixed bug
-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
56 // deny that shit 56 // deny that shit
57} 57}
58 58
59
59bool handle_key(wlc_handle view, uint32_t time, const struct wlc_modifiers 60bool handle_key(wlc_handle view, uint32_t time, const struct wlc_modifiers
60 *modifiers, uint32_t key, uint32_t sym, enum wlc_key_state state) { 61 *modifiers, uint32_t key, uint32_t sym, enum wlc_key_state state) {
61#define QSIZE 32 62#define QSIZE 32
62 static uint8_t head = 1; 63 static uint8_t head = 0;
63 static uint32_t array[QSIZE]; 64 static uint32_t array[QSIZE];
64 65
65 struct sway_mode *mode = config->current_mode; 66 struct sway_mode *mode = config->current_mode;
@@ -74,11 +75,9 @@ bool handle_key(wlc_handle view, uint32_t time, const struct wlc_modifiers
74 while (mid != head && array[mid] != sym) { 75 while (mid != head && array[mid] != sym) {
75 ++mid; 76 ++mid;
76 } 77 }
77 while (mid < head) { 78 if (mid < head) {
78 array[mid] = array[mid+1]; 79 memmove(array + mid, array + mid + 1, sizeof*array * (--head - mid));
79 ++mid; 80 } /* else { key is not found as its been removed } */
80 }
81 --head;
82 } 81 }
83 // TODO: reminder to check conflicts with mod+q+a versus mod+q 82 // TODO: reminder to check conflicts with mod+q+a versus mod+q
84 int i; 83 int i;
@@ -104,6 +103,15 @@ bool handle_key(wlc_handle view, uint32_t time, const struct wlc_modifiers
104 } 103 }
105 104
106 if (match) { 105 if (match) {
106 //Remove matched keys from array
107 int j;
108 for (j = 0; j < binding->keys->length; ++j) {
109 uint8_t k;
110 for (k = 0; k < head; ++k) {
111 memmove(array + k, array + k + 1, sizeof*array * (--head - k));
112 break;
113 }
114 }
107 if (state == WLC_KEY_STATE_PRESSED) { 115 if (state == WLC_KEY_STATE_PRESSED) {
108 handle_command(config, binding->command); 116 handle_command(config, binding->command);
109 } else if (state == WLC_KEY_STATE_RELEASED) { 117 } else if (state == WLC_KEY_STATE_RELEASED) {