mirror of
https://github.com/swaywm/sway.git
synced 2024-11-29 03:11:27 +00:00
added command repeat on keydown
This commit is contained in:
parent
5d5a20bf25
commit
a22ba17621
|
@ -61,22 +61,23 @@ bool handle_key(wlc_handle view, uint32_t time, const struct wlc_modifiers
|
||||||
enum { QSIZE = 32 };
|
enum { QSIZE = 32 };
|
||||||
static uint8_t head = 0;
|
static uint8_t head = 0;
|
||||||
static uint32_t array[QSIZE];
|
static uint32_t array[QSIZE];
|
||||||
|
bool cmd_success = true;
|
||||||
|
|
||||||
struct sway_mode *mode = config->current_mode;
|
struct sway_mode *mode = config->current_mode;
|
||||||
// Lowercase if necessary
|
// Lowercase if necessary
|
||||||
sym = tolower(sym);
|
sym = tolower(sym);
|
||||||
//Add or remove key to array
|
|
||||||
if (state == WLC_KEY_STATE_PRESSED && head + 1 < QSIZE) {
|
//Find key, if it has been pressed
|
||||||
array[head++] = sym;
|
int mid = 0;
|
||||||
} else if (state == WLC_KEY_STATE_RELEASED) {
|
while (mid < head && array[mid] != sym) {
|
||||||
uint8_t mid = 0;
|
|
||||||
while (mid != head && array[mid] != sym) {
|
|
||||||
++mid;
|
++mid;
|
||||||
}
|
}
|
||||||
if (mid < head) {
|
if (state == WLC_KEY_STATE_PRESSED && mid == head && head + 1 < QSIZE) {
|
||||||
|
array[head++] = sym;
|
||||||
|
} else if (state == WLC_KEY_STATE_RELEASED && mid < head) {
|
||||||
memmove(array + mid, array + mid + 1, sizeof*array * (--head - mid));
|
memmove(array + mid, array + mid + 1, sizeof*array * (--head - mid));
|
||||||
} /* else { key is not found as its been removed } */
|
|
||||||
}
|
}
|
||||||
|
sway_log(L_INFO,"%d", head);
|
||||||
// TODO: reminder to check conflicts with mod+q+a versus mod+q
|
// TODO: reminder to check conflicts with mod+q+a versus mod+q
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; i < mode->bindings->length; ++i) {
|
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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (state == WLC_KEY_STATE_PRESSED) {
|
if (state == WLC_KEY_STATE_PRESSED) {
|
||||||
handle_command(config, binding->command);
|
cmd_success = !handle_command(config, binding->command);
|
||||||
} else if (state == WLC_KEY_STATE_RELEASED) {
|
} else if (state == WLC_KEY_STATE_RELEASED) {
|
||||||
// TODO: --released
|
// TODO: --released
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return cmd_success;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool pointer_test(swayc_t *view, void *_origin) {
|
bool pointer_test(swayc_t *view, void *_origin) {
|
||||||
|
|
Loading…
Reference in a new issue