aboutsummaryrefslogtreecommitdiffstats
path: root/sway/commands/title_align.c
diff options
context:
space:
mode:
authorLibravatar Brian Ashworth <bosrsf04@gmail.com>2018-11-25 22:08:58 -0500
committerLibravatar Brian Ashworth <bosrsf04@gmail.com>2018-11-25 22:08:58 -0500
commite6562c8cd26c2e7caa4c83aaa5d734643fba4015 (patch)
treefb6074dc638c2543e2ed5d3aace86ef74e8d1466 /sway/commands/title_align.c
parentMerge pull request #3184 from kupospelov/fix-resize (diff)
downloadsway-e6562c8cd26c2e7caa4c83aaa5d734643fba4015.tar.gz
sway-e6562c8cd26c2e7caa4c83aaa5d734643fba4015.tar.zst
sway-e6562c8cd26c2e7caa4c83aaa5d734643fba4015.zip
Implement title alignment
This adds support for `i3 4.16`'s ability to set the title alignment. The command is `title_align left|center|right`. When the title is on the right, marks are moved to the left. Otherwise, they are on the right.
Diffstat (limited to 'sway/commands/title_align.c')
-rw-r--r--sway/commands/title_align.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/sway/commands/title_align.c b/sway/commands/title_align.c
new file mode 100644
index 00000000..82578186
--- /dev/null
+++ b/sway/commands/title_align.c
@@ -0,0 +1,30 @@
1#include "sway/commands.h"
2#include "sway/config.h"
3#include "sway/output.h"
4#include "sway/tree/container.h"
5#include "sway/tree/root.h"
6
7struct cmd_results *cmd_title_align(int argc, char **argv) {
8 struct cmd_results *error = NULL;
9 if ((error = checkarg(argc, "title_align", EXPECTED_AT_LEAST, 1))) {
10 return error;
11 }
12
13 if (strcmp(argv[0], "left") == 0) {
14 config->title_align = ALIGN_LEFT;
15 } else if (strcmp(argv[0], "center") == 0) {
16 config->title_align = ALIGN_CENTER;
17 } else if (strcmp(argv[0], "right") == 0) {
18 config->title_align = ALIGN_RIGHT;
19 } else {
20 return cmd_results_new(CMD_INVALID, "title_align",
21 "Expected 'title_align left|center|right'");
22 }
23
24 for (int i = 0; i < root->outputs->length; ++i) {
25 struct sway_output *output = root->outputs->items[i];
26 output_damage_whole(output);
27 }
28
29 return cmd_results_new(CMD_SUCCESS, NULL, NULL);
30}