diff options
author | taiyu <taiyu.len@gmail.com> | 2015-08-19 18:59:27 -0700 |
---|---|---|
committer | taiyu <taiyu.len@gmail.com> | 2015-08-19 18:59:27 -0700 |
commit | 470b4dfbae146d83c0061b39534c16b5aad90f1c (patch) | |
tree | 89560b95f1501ecd24036ca69f524771230fe2f0 /sway/handlers.c | |
parent | Deal with more xkb bullshit (diff) | |
download | sway-470b4dfbae146d83c0061b39534c16b5aad90f1c.tar.gz sway-470b4dfbae146d83c0061b39534c16b5aad90f1c.tar.zst sway-470b4dfbae146d83c0061b39534c16b5aad90f1c.zip |
key_state.ch, and command conflicts resolved
Diffstat (limited to 'sway/handlers.c')
-rw-r--r-- | sway/handlers.c | 39 |
1 files changed, 8 insertions, 31 deletions
diff --git a/sway/handlers.c b/sway/handlers.c index 63db972e..c9d7c7ac 100644 --- a/sway/handlers.c +++ b/sway/handlers.c | |||
@@ -13,9 +13,7 @@ | |||
13 | #include "workspace.h" | 13 | #include "workspace.h" |
14 | #include "container.h" | 14 | #include "container.h" |
15 | #include "focus.h" | 15 | #include "focus.h" |
16 | 16 | #include "key_state.h" | |
17 | #define KEY_CACHE_SIZE 32 | ||
18 | uint32_t keys_pressed[KEY_CACHE_SIZE]; | ||
19 | 17 | ||
20 | static struct wlc_origin mouse_origin; | 18 | static struct wlc_origin mouse_origin; |
21 | 19 | ||
@@ -327,7 +325,6 @@ static bool handle_key(wlc_handle view, uint32_t time, const struct wlc_modifier | |||
327 | if (locked_view_focus && state == WLC_KEY_STATE_PRESSED) { | 325 | if (locked_view_focus && state == WLC_KEY_STATE_PRESSED) { |
328 | return false; | 326 | return false; |
329 | } | 327 | } |
330 | bool cmd_success = false; | ||
331 | 328 | ||
332 | // Revert floating container back to original position on keypress | 329 | // Revert floating container back to original position on keypress |
333 | if (state == WLC_KEY_STATE_PRESSED && (dragging || resizing)) { | 330 | if (state == WLC_KEY_STATE_PRESSED && (dragging || resizing)) { |
@@ -356,16 +353,10 @@ static bool handle_key(wlc_handle view, uint32_t time, const struct wlc_modifier | |||
356 | } | 353 | } |
357 | } | 354 | } |
358 | 355 | ||
359 | int total = 0; | 356 | if (state == WLC_KEY_STATE_PRESSED) { |
360 | for (i = 0; i < KEY_CACHE_SIZE && !mod; ++i) { | 357 | press_key(sym); |
361 | total += keys_pressed[i] != 0; | 358 | } else { // WLC_KEY_STATE_RELEASED |
362 | if (state == WLC_KEY_STATE_PRESSED && keys_pressed[i] == 0) { | 359 | release_key(sym); |
363 | keys_pressed[i] = sym; | ||
364 | break; | ||
365 | } else if (state == WLC_KEY_STATE_RELEASED && keys_pressed[i] == sym) { | ||
366 | keys_pressed[i] = 0; | ||
367 | break; | ||
368 | } | ||
369 | } | 360 | } |
370 | 361 | ||
371 | // TODO: reminder to check conflicts with mod+q+a versus mod+q | 362 | // TODO: reminder to check conflicts with mod+q+a versus mod+q |
@@ -376,32 +367,22 @@ static bool handle_key(wlc_handle view, uint32_t time, const struct wlc_modifier | |||
376 | bool match; | 367 | bool match; |
377 | int j; | 368 | int j; |
378 | for (j = 0; j < binding->keys->length; ++j) { | 369 | for (j = 0; j < binding->keys->length; ++j) { |
379 | match = false; | ||
380 | xkb_keysym_t *key = binding->keys->items[j]; | 370 | xkb_keysym_t *key = binding->keys->items[j]; |
381 | int k; | 371 | if ((match = check_key(*key)) == false) { |
382 | for (k = 0; k < KEY_CACHE_SIZE; ++k) { | ||
383 | if (keys_pressed[k] == *key) { | ||
384 | match = true; | ||
385 | break; | ||
386 | } | ||
387 | } | ||
388 | if (match == false) { | ||
389 | break; | 372 | break; |
390 | } | 373 | } |
391 | } | 374 | } |
392 | |||
393 | if (match) { | 375 | if (match) { |
394 | // Remove matched keys from keys_pressed | ||
395 | if (state == WLC_KEY_STATE_PRESSED) { | 376 | if (state == WLC_KEY_STATE_PRESSED) { |
396 | handle_command(config, binding->command); | 377 | handle_command(config, binding->command); |
397 | cmd_success = true; | 378 | return true; |
398 | } else if (state == WLC_KEY_STATE_RELEASED) { | 379 | } else if (state == WLC_KEY_STATE_RELEASED) { |
399 | // TODO: --released | 380 | // TODO: --released |
400 | } | 381 | } |
401 | } | 382 | } |
402 | } | 383 | } |
403 | } | 384 | } |
404 | return cmd_success; | 385 | return false; |
405 | } | 386 | } |
406 | 387 | ||
407 | static bool handle_pointer_motion(wlc_handle handle, uint32_t time, const struct wlc_origin *origin) { | 388 | static bool handle_pointer_motion(wlc_handle handle, uint32_t time, const struct wlc_origin *origin) { |
@@ -590,10 +571,6 @@ static void handle_wlc_ready(void) { | |||
590 | } | 571 | } |
591 | free_flat_list(config->cmd_queue); | 572 | free_flat_list(config->cmd_queue); |
592 | config->active = true; | 573 | config->active = true; |
593 | |||
594 | for (i = 0; i < KEY_CACHE_SIZE; ++i) { | ||
595 | keys_pressed[i] = 0; | ||
596 | } | ||
597 | } | 574 | } |
598 | 575 | ||
599 | 576 | ||