aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Brian Ashworth <bosrsf04@gmail.com>2019-04-19 23:12:35 -0400
committerLibravatar Drew DeVault <sir@cmpwn.com>2019-04-20 09:09:11 -0600
commit59d9a991b425f7cf1ea05a1def7632fa4395c5a7 (patch)
tree7f80948b4139a180738ef8bc93cca18f903a5828
parentcmd_move: allow for all i3 syntax options (diff)
downloadsway-59d9a991b425f7cf1ea05a1def7632fa4395c5a7.tar.gz
sway-59d9a991b425f7cf1ea05a1def7632fa4395c5a7.tar.zst
sway-59d9a991b425f7cf1ea05a1def7632fa4395c5a7.zip
ipc: fix criteria for emitting bar_state_update
This fixes the criteria for emitting a `bar_state_update` event to notify swaybar (and any other bars utilizing the event) on whether the bar is visible by modifier. It is not enough to only emit the event when both the bar mode and bar hidden state are `hide` since it is possible to release the modifier while hidden state is `show` and then change hidden state to `hide` without pressing the modifier. This also emits the event whenever visible by modifier is set and should no longer be regardless of the mode and state to ensure that it gets properly cleared. If visible by modifier is not set and the bar is not in `hide`/`hide`, then no events will be sent and visible by modifier will not be set
-rw-r--r--sway/input/keyboard.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/sway/input/keyboard.c b/sway/input/keyboard.c
index 06ae99c4..5a965185 100644
--- a/sway/input/keyboard.c
+++ b/sway/input/keyboard.c
@@ -424,11 +424,18 @@ static int handle_keyboard_repeat(void *data) {
424static void determine_bar_visibility(uint32_t modifiers) { 424static void determine_bar_visibility(uint32_t modifiers) {
425 for (int i = 0; i < config->bars->length; ++i) { 425 for (int i = 0; i < config->bars->length; ++i) {
426 struct bar_config *bar = config->bars->items[i]; 426 struct bar_config *bar = config->bars->items[i];
427 if (strcmp(bar->mode, bar->hidden_state) == 0) { // both are "hide" 427 if (bar->modifier == 0) {
428 bool should_be_visible = 428 continue;
429 bar->modifier != 0 && (~modifiers & bar->modifier) == 0; 429 }
430 if (bar->visible_by_modifier != should_be_visible) { 430
431 bar->visible_by_modifier = should_be_visible; 431 bool vis_by_mod = (~modifiers & bar->modifier) == 0;
432 if (bar->visible_by_modifier != vis_by_mod) {
433 // If visible by modifier is set, send that it is no longer visible
434 // by modifier (regardless of bar mode and state). Otherwise, only
435 // send the visible by modifier status if mode and state are hide
436 if (bar->visible_by_modifier
437 || strcmp(bar->mode, bar->hidden_state) == 0) {
438 bar->visible_by_modifier = vis_by_mod;
432 ipc_event_bar_state_update(bar); 439 ipc_event_bar_state_update(bar);
433 } 440 }
434 } 441 }