diff options
Diffstat (limited to 'sway/commands/titlebar_padding.c')
-rw-r--r-- | sway/commands/titlebar_padding.c | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/sway/commands/titlebar_padding.c b/sway/commands/titlebar_padding.c new file mode 100644 index 00000000..a642e945 --- /dev/null +++ b/sway/commands/titlebar_padding.c | |||
@@ -0,0 +1,42 @@ | |||
1 | #include <string.h> | ||
2 | #include "sway/commands.h" | ||
3 | #include "sway/config.h" | ||
4 | #include "sway/output.h" | ||
5 | #include "sway/tree/arrange.h" | ||
6 | #include "log.h" | ||
7 | |||
8 | struct cmd_results *cmd_titlebar_padding(int argc, char **argv) { | ||
9 | struct cmd_results *error = NULL; | ||
10 | if ((error = checkarg(argc, "titlebar_padding", EXPECTED_AT_LEAST, 1))) { | ||
11 | return error; | ||
12 | } | ||
13 | |||
14 | char *inv; | ||
15 | int h_value = strtol(argv[0], &inv, 10); | ||
16 | if (*inv != '\0' || h_value < 0 || h_value < config->titlebar_border_thickness) { | ||
17 | return cmd_results_new(CMD_FAILURE, "titlebar_padding", | ||
18 | "Invalid size specified"); | ||
19 | } | ||
20 | |||
21 | int v_value; | ||
22 | if (argc == 1) { | ||
23 | v_value = h_value; | ||
24 | } else { | ||
25 | v_value = strtol(argv[1], &inv, 10); | ||
26 | if (*inv != '\0' || v_value < 0 || v_value < config->titlebar_border_thickness) { | ||
27 | return cmd_results_new(CMD_FAILURE, "titlebar_padding", | ||
28 | "Invalid size specified"); | ||
29 | } | ||
30 | } | ||
31 | |||
32 | config->titlebar_v_padding = v_value; | ||
33 | config->titlebar_h_padding = h_value; | ||
34 | |||
35 | for (int i = 0; i < root->outputs->length; ++i) { | ||
36 | struct sway_output *output = root->outputs->items[i]; | ||
37 | arrange_workspace(output_get_active_workspace(output)); | ||
38 | output_damage_whole(output); | ||
39 | } | ||
40 | |||
41 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); | ||
42 | } | ||