summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Taiyu <taiyu.len@gmail.com>2015-08-11 01:09:08 -0700
committerLibravatar Taiyu <taiyu.len@gmail.com>2015-08-11 01:09:08 -0700
commita22ba1762194e6592a4d7d5e97ba1b3cb3b1e582 (patch)
tree8531788e7a188a620f53e5633f2280ae332fd0d4
parentsmall fix (diff)
downloadsway-a22ba1762194e6592a4d7d5e97ba1b3cb3b1e582.tar.gz
sway-a22ba1762194e6592a4d7d5e97ba1b3cb3b1e582.tar.zst
sway-a22ba1762194e6592a4d7d5e97ba1b3cb3b1e582.zip
added command repeat on keydown
-rw-r--r--sway/handlers.c25
1 files changed, 13 insertions, 12 deletions
diff --git a/sway/handlers.c b/sway/handlers.c
index ebe3e349..979eb3c8 100644
--- a/sway/handlers.c
+++ b/sway/handlers.c
@@ -61,22 +61,23 @@ bool handle_key(wlc_handle view, uint32_t time, const struct wlc_modifiers
61 enum { QSIZE = 32 }; 61 enum { QSIZE = 32 };
62 static uint8_t head = 0; 62 static uint8_t head = 0;
63 static uint32_t array[QSIZE]; 63 static uint32_t array[QSIZE];
64 bool cmd_success = true;
64 65
65 struct sway_mode *mode = config->current_mode; 66 struct sway_mode *mode = config->current_mode;
66 // Lowercase if necessary 67 // Lowercase if necessary
67 sym = tolower(sym); 68 sym = tolower(sym);
68 //Add or remove key to array 69
69 if (state == WLC_KEY_STATE_PRESSED && head + 1 < QSIZE) { 70 //Find key, if it has been pressed
71 int mid = 0;
72 while (mid < head && array[mid] != sym) {
73 ++mid;
74 }
75 if (state == WLC_KEY_STATE_PRESSED && mid == head && head + 1 < QSIZE) {
70 array[head++] = sym; 76 array[head++] = sym;
71 } else if (state == WLC_KEY_STATE_RELEASED) { 77 } else if (state == WLC_KEY_STATE_RELEASED && mid < head) {
72 uint8_t mid = 0; 78 memmove(array + mid, array + mid + 1, sizeof*array * (--head - mid));
73 while (mid != head && array[mid] != sym) {
74 ++mid;
75 }
76 if (mid < head) {
77 memmove(array + mid, array + mid + 1, sizeof*array * (--head - mid));
78 } /* else { key is not found as its been removed } */
79 } 79 }
80 sway_log(L_INFO,"%d", head);
80 // TODO: reminder to check conflicts with mod+q+a versus mod+q 81 // TODO: reminder to check conflicts with mod+q+a versus mod+q
81 int i; 82 int i;
82 for (i = 0; i < mode->bindings->length; ++i) { 83 for (i = 0; i < mode->bindings->length; ++i) {
@@ -111,14 +112,14 @@ bool handle_key(wlc_handle view, uint32_t time, const struct wlc_modifiers
111 } 112 }
112 } 113 }
113 if (state == WLC_KEY_STATE_PRESSED) { 114 if (state == WLC_KEY_STATE_PRESSED) {
114 handle_command(config, binding->command); 115 cmd_success = !handle_command(config, binding->command);
115 } else if (state == WLC_KEY_STATE_RELEASED) { 116 } else if (state == WLC_KEY_STATE_RELEASED) {
116 // TODO: --released 117 // TODO: --released
117 } 118 }
118 } 119 }
119 } 120 }
120 } 121 }
121 return true; 122 return cmd_success;
122} 123}
123 124
124bool pointer_test(swayc_t *view, void *_origin) { 125bool pointer_test(swayc_t *view, void *_origin) {