aboutsummaryrefslogtreecommitdiffstats
path: root/sway/commands/bar/hidden_state.c
diff options
context:
space:
mode:
Diffstat (limited to 'sway/commands/bar/hidden_state.c')
-rw-r--r--sway/commands/bar/hidden_state.c24
1 files changed, 9 insertions, 15 deletions
diff --git a/sway/commands/bar/hidden_state.c b/sway/commands/bar/hidden_state.c
index 0b49aa6b..6641f184 100644
--- a/sway/commands/bar/hidden_state.c
+++ b/sway/commands/bar/hidden_state.c
@@ -6,7 +6,8 @@
6#include "sway/ipc-server.h" 6#include "sway/ipc-server.h"
7#include "log.h" 7#include "log.h"
8 8
9static struct cmd_results *bar_set_hidden_state(struct bar_config *bar, const char *hidden_state) { 9static struct cmd_results *bar_set_hidden_state(struct bar_config *bar,
10 const char *hidden_state) {
10 char *old_state = bar->hidden_state; 11 char *old_state = bar->hidden_state;
11 if (strcasecmp("toggle", hidden_state) == 0 && !config->reading) { 12 if (strcasecmp("toggle", hidden_state) == 0 && !config->reading) {
12 if (strcasecmp("hide", bar->hidden_state) == 0) { 13 if (strcasecmp("hide", bar->hidden_state) == 0) {
@@ -19,16 +20,16 @@ static struct cmd_results *bar_set_hidden_state(struct bar_config *bar, const ch
19 } else if (strcasecmp("show", hidden_state) == 0) { 20 } else if (strcasecmp("show", hidden_state) == 0) {
20 bar->hidden_state = strdup("show"); 21 bar->hidden_state = strdup("show");
21 } else { 22 } else {
22 return cmd_results_new(CMD_INVALID, "hidden_state", "Invalid value %s", hidden_state); 23 return cmd_results_new(CMD_INVALID, "hidden_state",
24 "Invalid value %s", hidden_state);
23 } 25 }
24
25 if (strcmp(old_state, bar->hidden_state) != 0) { 26 if (strcmp(old_state, bar->hidden_state) != 0) {
26 if (!config->reading) { 27 if (!config->reading) {
27 ipc_event_barconfig_update(bar); 28 ipc_event_barconfig_update(bar);
28 } 29 }
29 sway_log(L_DEBUG, "Setting hidden_state: '%s' for bar: %s", bar->hidden_state, bar->id); 30 wlr_log(L_DEBUG, "Setting hidden_state: '%s' for bar: %s",
31 bar->hidden_state, bar->id);
30 } 32 }
31
32 // free old mode 33 // free old mode
33 free(old_state); 34 free(old_state);
34 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 35 return cmd_results_new(CMD_SUCCESS, NULL, NULL);
@@ -42,13 +43,12 @@ struct cmd_results *bar_cmd_hidden_state(int argc, char **argv) {
42 if ((error = checkarg(argc, "hidden_state", EXPECTED_LESS_THAN, 3))) { 43 if ((error = checkarg(argc, "hidden_state", EXPECTED_LESS_THAN, 3))) {
43 return error; 44 return error;
44 } 45 }
45
46 if (config->reading && argc > 1) { 46 if (config->reading && argc > 1) {
47 return cmd_results_new(CMD_INVALID, "hidden_state", "Unexpected value %s in config mode", argv[1]); 47 return cmd_results_new(CMD_INVALID, "hidden_state",
48 "Unexpected value %s in config mode", argv[1]);
48 } 49 }
49 50
50 const char *state = argv[0]; 51 const char *state = argv[0];
51
52 if (config->reading) { 52 if (config->reading) {
53 return bar_set_hidden_state(config->current_bar, state); 53 return bar_set_hidden_state(config->current_bar, state);
54 } 54 }
@@ -57,10 +57,8 @@ struct cmd_results *bar_cmd_hidden_state(int argc, char **argv) {
57 if (argc == 2) { 57 if (argc == 2) {
58 id = argv[1]; 58 id = argv[1];
59 } 59 }
60
61 int i;
62 struct bar_config *bar; 60 struct bar_config *bar;
63 for (i = 0; i < config->bars->length; ++i) { 61 for (int i = 0; i < config->bars->length; ++i) {
64 bar = config->bars->items[i]; 62 bar = config->bars->items[i];
65 if (id && strcmp(id, bar->id) == 0) { 63 if (id && strcmp(id, bar->id) == 0) {
66 return bar_set_hidden_state(bar, state); 64 return bar_set_hidden_state(bar, state);
@@ -71,9 +69,5 @@ struct cmd_results *bar_cmd_hidden_state(int argc, char **argv) {
71 return error; 69 return error;
72 } 70 }
73 } 71 }
74
75 // active bar modifiers might have changed.
76 update_active_bar_modifiers();
77
78 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 72 return cmd_results_new(CMD_SUCCESS, NULL, NULL);
79} 73}