aboutsummaryrefslogtreecommitdiffstats
path: root/sway/input/keyboard.c
diff options
context:
space:
mode:
authorLibravatar frsfnrrg <frsfnrrg@users.noreply.github.com>2018-06-01 06:51:07 -0400
committerLibravatar frsfnrrg <frsfnrrg@users.noreply.github.com>2018-06-01 18:52:36 -0400
commitc53e4e6cdec4a1873d8a0d47fc90e95d2b949d04 (patch)
treea23d134c520ed5bcd6747fbc299ba78fe233504d /sway/input/keyboard.c
parentStyle fixes for bind.c (diff)
downloadsway-c53e4e6cdec4a1873d8a0d47fc90e95d2b949d04.tar.gz
sway-c53e4e6cdec4a1873d8a0d47fc90e95d2b949d04.tar.zst
sway-c53e4e6cdec4a1873d8a0d47fc90e95d2b949d04.zip
Style fixed for keyboard.c
Diffstat (limited to 'sway/input/keyboard.c')
-rw-r--r--sway/input/keyboard.c27
1 files changed, 13 insertions, 14 deletions
diff --git a/sway/input/keyboard.c b/sway/input/keyboard.c
index c0f637f0..27263046 100644
--- a/sway/input/keyboard.c
+++ b/sway/input/keyboard.c
@@ -12,10 +12,9 @@
12/** 12/**
13 * Update the shortcut model state in response to new input 13 * Update the shortcut model state in response to new input
14 */ 14 */
15static void update_shortcut_model(struct sway_shortcut_state* state, 15static void update_shortcut_model(struct sway_shortcut_state *state,
16 struct wlr_event_keyboard_key * event, 16 struct wlr_event_keyboard_key *event, uint32_t new_key,
17 uint32_t new_key, 17 bool last_key_was_a_modifier) {
18 bool last_key_was_a_modifier) {
19 if (event->state == WLR_KEY_PRESSED) { 18 if (event->state == WLR_KEY_PRESSED) {
20 if (last_key_was_a_modifier && state->last_key_index >= 0) { 19 if (last_key_was_a_modifier && state->last_key_index >= 0) {
21 // Last pressed key before this one was a modifier. We nullify 20 // Last pressed key before this one was a modifier. We nullify
@@ -26,7 +25,7 @@ static void update_shortcut_model(struct sway_shortcut_state* state,
26 } 25 }
27 26
28 // Add current key to set; there may be duplicates 27 // Add current key to set; there may be duplicates
29 for (size_t i = 0; i < SWAY_KEYBOARD_PRESSED_KEYS_CAP; i++) { 28 for (size_t i = 0; i < SWAY_KEYBOARD_PRESSED_KEYS_CAP; ++i) {
30 if (!state->pressed_keys[i]) { 29 if (!state->pressed_keys[i]) {
31 state->pressed_keys[i] = new_key; 30 state->pressed_keys[i] = new_key;
32 state->pressed_keycodes[i] = event->keycode; 31 state->pressed_keycodes[i] = event->keycode;
@@ -35,7 +34,7 @@ static void update_shortcut_model(struct sway_shortcut_state* state,
35 } 34 }
36 } 35 }
37 } else { 36 } else {
38 for (size_t i = 0; i < SWAY_KEYBOARD_PRESSED_KEYS_CAP; i++) { 37 for (size_t i = 0; i < SWAY_KEYBOARD_PRESSED_KEYS_CAP; ++i) {
39 // The same keycode may match multiple keysyms. 38 // The same keycode may match multiple keysyms.
40 if (state->pressed_keycodes[i] == event->keycode) { 39 if (state->pressed_keycodes[i] == event->keycode) {
41 state->pressed_keys[i] = 0; 40 state->pressed_keys[i] = 0;
@@ -50,11 +49,11 @@ static void update_shortcut_model(struct sway_shortcut_state* state,
50 * Returns a binding which matches the shortcut model state (ignoring the 49 * Returns a binding which matches the shortcut model state (ignoring the
51 * `release` flag). 50 * `release` flag).
52 */ 51 */
53static struct sway_binding* check_shortcut_model( 52static struct sway_binding *check_shortcut_model(
54 struct sway_shortcut_state* state, list_t* bindings, 53 struct sway_shortcut_state *state, list_t *bindings,
55 uint32_t modifiers, bool locked) { 54 uint32_t modifiers, bool locked) {
56 int npressed_keys = 0; 55 int npressed_keys = 0;
57 for (size_t i = 0; i < SWAY_KEYBOARD_PRESSED_KEYS_CAP; i++) { 56 for (size_t i = 0; i < SWAY_KEYBOARD_PRESSED_KEYS_CAP; ++i) {
58 if (state->pressed_keys[i]) { 57 if (state->pressed_keys[i]) {
59 ++npressed_keys; 58 ++npressed_keys;
60 } 59 }
@@ -70,10 +69,10 @@ static struct sway_binding* check_shortcut_model(
70 69
71 bool match = true; 70 bool match = true;
72 for (int j = 0; j < binding->keys->length; ++j) { 71 for (int j = 0; j < binding->keys->length; ++j) {
73 uint32_t key = *(uint32_t*)binding->keys->items[j]; 72 uint32_t key = *(uint32_t *)binding->keys->items[j];
74 73
75 bool key_found = false; 74 bool key_found = false;
76 for (int k = 0; k < SWAY_KEYBOARD_PRESSED_KEYS_CAP; k++) { 75 for (int k = 0; k < SWAY_KEYBOARD_PRESSED_KEYS_CAP; ++k) {
77 if (state->pressed_keys[k] == key) { 76 if (state->pressed_keys[k] == key) {
78 key_found = true; 77 key_found = true;
79 break; 78 break;
@@ -216,13 +215,13 @@ static void handle_keyboard_key(struct wl_listener *listener, void *data) {
216 215
217 // Update shortcut models 216 // Update shortcut models
218 update_shortcut_model(&keyboard->state_keycodes, event, 217 update_shortcut_model(&keyboard->state_keycodes, event,
219 (uint32_t)keycode, last_key_was_a_modifier); 218 (uint32_t)keycode, last_key_was_a_modifier);
220 for (size_t i=0;i<translated_keysyms_len;i++) { 219 for (size_t i = 0; i < translated_keysyms_len; ++i) {
221 update_shortcut_model(&keyboard->state_keysyms_translated, 220 update_shortcut_model(&keyboard->state_keysyms_translated,
222 event, (uint32_t)translated_keysyms[i], 221 event, (uint32_t)translated_keysyms[i],
223 last_key_was_a_modifier); 222 last_key_was_a_modifier);
224 } 223 }
225 for (size_t i=0;i<raw_keysyms_len;i++) { 224 for (size_t i = 0; i < raw_keysyms_len; ++i) {
226 update_shortcut_model(&keyboard->state_keysyms_raw, 225 update_shortcut_model(&keyboard->state_keysyms_raw,
227 event, (uint32_t)raw_keysyms[i], 226 event, (uint32_t)raw_keysyms[i],
228 last_key_was_a_modifier); 227 last_key_was_a_modifier);