diff options
Diffstat (limited to 'sway/input/keyboard.c')
-rw-r--r-- | sway/input/keyboard.c | 28 |
1 files changed, 22 insertions, 6 deletions
diff --git a/sway/input/keyboard.c b/sway/input/keyboard.c index fb1fe7b5..2c8b41cd 100644 --- a/sway/input/keyboard.c +++ b/sway/input/keyboard.c | |||
@@ -9,6 +9,7 @@ | |||
9 | #include "sway/input/input-manager.h" | 9 | #include "sway/input/input-manager.h" |
10 | #include "sway/input/keyboard.h" | 10 | #include "sway/input/keyboard.h" |
11 | #include "sway/input/seat.h" | 11 | #include "sway/input/seat.h" |
12 | #include "sway/ipc-server.h" | ||
12 | #include "log.h" | 13 | #include "log.h" |
13 | 14 | ||
14 | /** | 15 | /** |
@@ -66,10 +67,10 @@ static void update_shortcut_state(struct sway_shortcut_state *state, | |||
66 | bool last_key_was_a_modifier = raw_modifiers != state->last_raw_modifiers; | 67 | bool last_key_was_a_modifier = raw_modifiers != state->last_raw_modifiers; |
67 | state->last_raw_modifiers = raw_modifiers; | 68 | state->last_raw_modifiers = raw_modifiers; |
68 | 69 | ||
69 | if (last_key_was_a_modifier && state->last_keycode) { | 70 | if (last_key_was_a_modifier && state->last_keycode) { |
70 | // Last pressed key before this one was a modifier | 71 | // Last pressed key before this one was a modifier |
71 | state_erase_key(state, state->last_keycode); | 72 | state_erase_key(state, state->last_keycode); |
72 | } | 73 | } |
73 | 74 | ||
74 | if (event->state == WLR_KEY_PRESSED) { | 75 | if (event->state == WLR_KEY_PRESSED) { |
75 | // Add current key to set; there may be duplicates | 76 | // Add current key to set; there may be duplicates |
@@ -235,7 +236,6 @@ static void handle_keyboard_key(struct wl_listener *listener, void *data) { | |||
235 | code_modifiers); | 236 | code_modifiers); |
236 | } | 237 | } |
237 | 238 | ||
238 | |||
239 | bool handled = false; | 239 | bool handled = false; |
240 | 240 | ||
241 | // Identify active release binding | 241 | // Identify active release binding |
@@ -337,6 +337,19 @@ static int handle_keyboard_repeat(void *data) { | |||
337 | return 0; | 337 | return 0; |
338 | } | 338 | } |
339 | 339 | ||
340 | static void determine_bar_visibility(uint32_t modifiers) { | ||
341 | for (int i = 0; i < config->bars->length; ++i) { | ||
342 | struct bar_config *bar = config->bars->items[i]; | ||
343 | if (strcmp(bar->mode, bar->hidden_state) == 0) { // both are "hide" | ||
344 | bool should_be_visible = (~modifiers & bar->modifier) == 0; | ||
345 | if (bar->visible_by_modifier != should_be_visible) { | ||
346 | bar->visible_by_modifier = should_be_visible; | ||
347 | ipc_event_bar_state_update(bar); | ||
348 | } | ||
349 | } | ||
350 | } | ||
351 | } | ||
352 | |||
340 | static void handle_keyboard_modifiers(struct wl_listener *listener, | 353 | static void handle_keyboard_modifiers(struct wl_listener *listener, |
341 | void *data) { | 354 | void *data) { |
342 | struct sway_keyboard *keyboard = | 355 | struct sway_keyboard *keyboard = |
@@ -346,6 +359,9 @@ static void handle_keyboard_modifiers(struct wl_listener *listener, | |||
346 | keyboard->seat_device->input_device->wlr_device; | 359 | keyboard->seat_device->input_device->wlr_device; |
347 | wlr_seat_set_keyboard(wlr_seat, wlr_device); | 360 | wlr_seat_set_keyboard(wlr_seat, wlr_device); |
348 | wlr_seat_keyboard_notify_modifiers(wlr_seat, &wlr_device->keyboard->modifiers); | 361 | wlr_seat_keyboard_notify_modifiers(wlr_seat, &wlr_device->keyboard->modifiers); |
362 | |||
363 | uint32_t modifiers = wlr_keyboard_get_modifiers(wlr_device->keyboard); | ||
364 | determine_bar_visibility(modifiers); | ||
349 | } | 365 | } |
350 | 366 | ||
351 | struct sway_keyboard *sway_keyboard_create(struct sway_seat *seat, | 367 | struct sway_keyboard *sway_keyboard_create(struct sway_seat *seat, |
@@ -464,7 +480,7 @@ void sway_keyboard_configure(struct sway_keyboard *keyboard) { | |||
464 | keyboard->keyboard_key.notify = handle_keyboard_key; | 480 | keyboard->keyboard_key.notify = handle_keyboard_key; |
465 | 481 | ||
466 | wl_list_remove(&keyboard->keyboard_modifiers.link); | 482 | wl_list_remove(&keyboard->keyboard_modifiers.link); |
467 | wl_signal_add( &wlr_device->keyboard->events.modifiers, | 483 | wl_signal_add(&wlr_device->keyboard->events.modifiers, |
468 | &keyboard->keyboard_modifiers); | 484 | &keyboard->keyboard_modifiers); |
469 | keyboard->keyboard_modifiers.notify = handle_keyboard_modifiers; | 485 | keyboard->keyboard_modifiers.notify = handle_keyboard_modifiers; |
470 | } | 486 | } |