diff options
author | Drew DeVault <sir@cmpwn.com> | 2015-12-14 11:25:31 -0500 |
---|---|---|
committer | Drew DeVault <sir@cmpwn.com> | 2015-12-14 11:25:31 -0500 |
commit | 2be742d02d8dd26e111713d9bb52cd240d7d630b (patch) | |
tree | 84a5091db97f6c14515ce871922c431c0fe9eaca /sway | |
parent | Merge pull request #316 from Streetwalrus/fglrx (diff) | |
parent | Add bar id to debug logs (diff) | |
download | sway-2be742d02d8dd26e111713d9bb52cd240d7d630b.tar.gz sway-2be742d02d8dd26e111713d9bb52cd240d7d630b.tar.zst sway-2be742d02d8dd26e111713d9bb52cd240d7d630b.zip |
Merge pull request #314 from mikkeloscar/bar-id
Add initial support for custom bar-id
Diffstat (limited to 'sway')
-rw-r--r-- | sway/CMakeLists.txt | 1 | ||||
-rw-r--r-- | sway/commands.c | 26 | ||||
-rw-r--r-- | sway/util.c | 5 |
3 files changed, 19 insertions, 13 deletions
diff --git a/sway/CMakeLists.txt b/sway/CMakeLists.txt index aa553492..894163b8 100644 --- a/sway/CMakeLists.txt +++ b/sway/CMakeLists.txt | |||
@@ -21,7 +21,6 @@ add_executable(sway | |||
21 | main.c | 21 | main.c |
22 | output.c | 22 | output.c |
23 | resize.c | 23 | resize.c |
24 | util.c | ||
25 | workspace.c | 24 | workspace.c |
26 | ) | 25 | ) |
27 | 26 | ||
diff --git a/sway/commands.c b/sway/commands.c index 604e10aa..c565adbb 100644 --- a/sway/commands.c +++ b/sway/commands.c | |||
@@ -15,6 +15,7 @@ | |||
15 | #include "layout.h" | 15 | #include "layout.h" |
16 | #include "focus.h" | 16 | #include "focus.h" |
17 | #include "log.h" | 17 | #include "log.h" |
18 | #include "util.h" | ||
18 | #include "workspace.h" | 19 | #include "workspace.h" |
19 | #include "commands.h" | 20 | #include "commands.h" |
20 | #include "container.h" | 21 | #include "container.h" |
@@ -1124,9 +1125,20 @@ static struct cmd_results *cmd_bar(int argc, char **argv) { | |||
1124 | bar->tray_padding = config->bar.tray_padding; | 1125 | bar->tray_padding = config->bar.tray_padding; |
1125 | list_add(config->bars, bar); | 1126 | list_add(config->bars, bar); |
1126 | 1127 | ||
1128 | // set bar id | ||
1129 | int i; | ||
1130 | for (i = 0; i < config->bars->length; ++i) { | ||
1131 | if (bar == config->bars->items[i]) { | ||
1132 | const int len = 5 + numlen(i); // "bar-" + i + \0 | ||
1133 | bar->id = malloc(len * sizeof(char)); | ||
1134 | snprintf(bar->id, len, "bar-%d", i); | ||
1135 | break; | ||
1136 | } | ||
1137 | } | ||
1138 | |||
1127 | // Set current bar | 1139 | // Set current bar |
1128 | config->current_bar = bar; | 1140 | config->current_bar = bar; |
1129 | sway_log(L_DEBUG, "Configuring bar"); | 1141 | sway_log(L_DEBUG, "Configuring bar %s", bar->id); |
1130 | return cmd_results_new(CMD_BLOCK_BAR, NULL, NULL); | 1142 | return cmd_results_new(CMD_BLOCK_BAR, NULL, NULL); |
1131 | } | 1143 | } |
1132 | 1144 | ||
@@ -1534,7 +1546,7 @@ static struct cmd_results *bar_cmd_position(int argc, char **argv) { | |||
1534 | return error; | 1546 | return error; |
1535 | } | 1547 | } |
1536 | 1548 | ||
1537 | sway_log(L_DEBUG, "Setting bar position '%s'", argv[0]); | 1549 | sway_log(L_DEBUG, "Setting bar position '%s' for bar: %s", argv[0], config->current_bar->id); |
1538 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); | 1550 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); |
1539 | } | 1551 | } |
1540 | 1552 | ||
@@ -1550,10 +1562,10 @@ static struct cmd_results *bar_cmd_strip_workspace_numbers(int argc, char **argv | |||
1550 | 1562 | ||
1551 | if (strcasecmp("yes", argv[0]) == 0) { | 1563 | if (strcasecmp("yes", argv[0]) == 0) { |
1552 | config->current_bar->strip_workspace_numbers = true; | 1564 | config->current_bar->strip_workspace_numbers = true; |
1553 | sway_log(L_DEBUG, "Stripping workspace numbers on bar"); | 1565 | sway_log(L_DEBUG, "Stripping workspace numbers on bar: %s", config->current_bar->id); |
1554 | } else if (strcasecmp("no", argv[0]) == 0) { | 1566 | } else if (strcasecmp("no", argv[0]) == 0) { |
1555 | config->current_bar->strip_workspace_numbers = false; | 1567 | config->current_bar->strip_workspace_numbers = false; |
1556 | sway_log(L_DEBUG, "Enabling workspace numbers on bar"); | 1568 | sway_log(L_DEBUG, "Enabling workspace numbers on bar: %s", config->current_bar->id); |
1557 | } else { | 1569 | } else { |
1558 | error = cmd_results_new(CMD_INVALID, "strip_workspace_numbers", "Invalid value %s", argv[0]); | 1570 | error = cmd_results_new(CMD_INVALID, "strip_workspace_numbers", "Invalid value %s", argv[0]); |
1559 | return error; | 1571 | return error; |
@@ -1587,7 +1599,7 @@ static struct cmd_results *bar_cmd_tray_padding(int argc, char **argv) { | |||
1587 | "Unknown unit %s", argv[1]); | 1599 | "Unknown unit %s", argv[1]); |
1588 | } | 1600 | } |
1589 | config->current_bar->tray_padding = padding; | 1601 | config->current_bar->tray_padding = padding; |
1590 | sway_log(L_DEBUG, "Enabling tray padding of %d px", padding); | 1602 | sway_log(L_DEBUG, "Enabling tray padding of %d px on bar: %s", padding, config->current_bar->id); |
1591 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); | 1603 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); |
1592 | } | 1604 | } |
1593 | 1605 | ||
@@ -1603,10 +1615,10 @@ static struct cmd_results *bar_cmd_workspace_buttons(int argc, char **argv) { | |||
1603 | 1615 | ||
1604 | if (strcasecmp("yes", argv[0]) == 0) { | 1616 | if (strcasecmp("yes", argv[0]) == 0) { |
1605 | config->current_bar->workspace_buttons = true; | 1617 | config->current_bar->workspace_buttons = true; |
1606 | sway_log(L_DEBUG, "Enabling workspace buttons on bar"); | 1618 | sway_log(L_DEBUG, "Enabling workspace buttons on bar: %s", config->current_bar->id); |
1607 | } else if (strcasecmp("no", argv[0]) == 0) { | 1619 | } else if (strcasecmp("no", argv[0]) == 0) { |
1608 | config->current_bar->workspace_buttons = false; | 1620 | config->current_bar->workspace_buttons = false; |
1609 | sway_log(L_DEBUG, "Disabling workspace buttons on bar"); | 1621 | sway_log(L_DEBUG, "Disabling workspace buttons on bar: %s", config->current_bar->id); |
1610 | } else { | 1622 | } else { |
1611 | error = cmd_results_new(CMD_INVALID, "workspace_buttons", "Invalid value %s", argv[0]); | 1623 | error = cmd_results_new(CMD_INVALID, "workspace_buttons", "Invalid value %s", argv[0]); |
1612 | return error; | 1624 | return error; |
diff --git a/sway/util.c b/sway/util.c deleted file mode 100644 index 9a59ddf9..00000000 --- a/sway/util.c +++ /dev/null | |||
@@ -1,5 +0,0 @@ | |||
1 | #include "util.h" | ||
2 | |||
3 | int wrap(int i, int max) { | ||
4 | return ((i % max) + max) % max; | ||
5 | } | ||