aboutsummaryrefslogtreecommitdiffstats
path: root/sway/commands/bar/output.c
diff options
context:
space:
mode:
authorLibravatar Brian Ashworth <bosrsf04@gmail.com>2019-09-02 21:41:11 -0400
committerLibravatar Drew DeVault <sir@cmpwn.com>2019-09-04 16:48:50 -1000
commit1fd2c6ba498e61f4fe823bf552f9d2fce8612de4 (patch)
tree8e2d9adab3451f1f05c76340d466a442c840e558 /sway/commands/bar/output.c
parentseatop_default: only focus container on press (diff)
downloadsway-1fd2c6ba498e61f4fe823bf552f9d2fce8612de4.tar.gz
sway-1fd2c6ba498e61f4fe823bf552f9d2fce8612de4.tar.zst
sway-1fd2c6ba498e61f4fe823bf552f9d2fce8612de4.zip
swaybar: complete barconfig_update event handling
This adds complete support for the barconfig_update ipc event. This also changes the bar command and subcommand handlers to correctly emit the event. This makes it so all bar subcommands other than id and swaybar_command are dynamically changeable at runtime. sway-bar.5 has been updated accordingly
Diffstat (limited to 'sway/commands/bar/output.c')
-rw-r--r--sway/commands/bar/output.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/sway/commands/bar/output.c b/sway/commands/bar/output.c
index 6a78b30d..cac1d056 100644
--- a/sway/commands/bar/output.c
+++ b/sway/commands/bar/output.c
@@ -21,16 +21,19 @@ struct cmd_results *bar_cmd_output(int argc, char **argv) {
21 bool add_output = true; 21 bool add_output = true;
22 if (strcmp("*", output) == 0) { 22 if (strcmp("*", output) == 0) {
23 // remove all previous defined outputs and replace with '*' 23 // remove all previous defined outputs and replace with '*'
24 for (int i = 0; i < outputs->length; ++i) { 24 while (outputs->length) {
25 free(outputs->items[i]); 25 free(outputs->items[0]);
26 list_del(outputs, i); 26 list_del(outputs, 0);
27 } 27 }
28 } else { 28 } else {
29 // only add output if not already defined with either the same 29 // only add output if not already defined, if the list has '*', remove
30 // name or as '*' 30 // it, in favor of a manual list
31 for (int i = 0; i < outputs->length; ++i) { 31 for (int i = 0; i < outputs->length; ++i) {
32 const char *find = outputs->items[i]; 32 const char *find = outputs->items[i];
33 if (strcmp("*", find) == 0 || strcmp(output, find) == 0) { 33 if (strcmp("*", find) == 0) {
34 free(outputs->items[i]);
35 list_del(outputs, i);
36 } else if (strcmp(output, find) == 0) {
34 add_output = false; 37 add_output = false;
35 break; 38 break;
36 } 39 }