diff options
Diffstat (limited to 'sway/commands')
30 files changed, 141 insertions, 37 deletions
diff --git a/sway/commands/assign.c b/sway/commands/assign.c index 04582e88..716d70cf 100644 --- a/sway/commands/assign.c +++ b/sway/commands/assign.c | |||
@@ -1,4 +1,4 @@ | |||
1 | #define _XOPEN_SOURCE 700 | 1 | #define _POSIX_C_SOURCE 200809L |
2 | #include <stdio.h> | 2 | #include <stdio.h> |
3 | #include <string.h> | 3 | #include <string.h> |
4 | #include "sway/commands.h" | 4 | #include "sway/commands.h" |
diff --git a/sway/commands/bar/bindsym.c b/sway/commands/bar/bindsym.c index 965c8903..e6d6220e 100644 --- a/sway/commands/bar/bindsym.c +++ b/sway/commands/bar/bindsym.c | |||
@@ -1,4 +1,3 @@ | |||
1 | #define _XOPEN_SOURCE 500 | ||
2 | #include <stdlib.h> | 1 | #include <stdlib.h> |
3 | #include <string.h> | 2 | #include <string.h> |
4 | #include <strings.h> | 3 | #include <strings.h> |
diff --git a/sway/commands/bar/hidden_state.c b/sway/commands/bar/hidden_state.c index 5be6c2dc..79eaf01c 100644 --- a/sway/commands/bar/hidden_state.c +++ b/sway/commands/bar/hidden_state.c | |||
@@ -1,4 +1,4 @@ | |||
1 | #define _XOPEN_SOURCE 500 | 1 | #define _POSIX_C_SOURCE 200809L |
2 | #include <string.h> | 2 | #include <string.h> |
3 | #include <strings.h> | 3 | #include <strings.h> |
4 | #include "sway/commands.h" | 4 | #include "sway/commands.h" |
diff --git a/sway/commands/bar/icon_theme.c b/sway/commands/bar/icon_theme.c index 44cd3076..0e30409b 100644 --- a/sway/commands/bar/icon_theme.c +++ b/sway/commands/bar/icon_theme.c | |||
@@ -1,4 +1,3 @@ | |||
1 | #define _XOPEN_SOURCE 500 | ||
2 | #include <string.h> | 1 | #include <string.h> |
3 | #include "sway/commands.h" | 2 | #include "sway/commands.h" |
4 | 3 | ||
diff --git a/sway/commands/bar/id.c b/sway/commands/bar/id.c index 7690a852..35509459 100644 --- a/sway/commands/bar/id.c +++ b/sway/commands/bar/id.c | |||
@@ -1,4 +1,4 @@ | |||
1 | #define _XOPEN_SOURCE 500 | 1 | #define _POSIX_C_SOURCE 200809L |
2 | #include <string.h> | 2 | #include <string.h> |
3 | #include "sway/commands.h" | 3 | #include "sway/commands.h" |
4 | #include "log.h" | 4 | #include "log.h" |
diff --git a/sway/commands/bar/mode.c b/sway/commands/bar/mode.c index 2cba785e..dcaf6da9 100644 --- a/sway/commands/bar/mode.c +++ b/sway/commands/bar/mode.c | |||
@@ -1,4 +1,4 @@ | |||
1 | #define _XOPEN_SOURCE 500 | 1 | #define _POSIX_C_SOURCE 200809L |
2 | #include <string.h> | 2 | #include <string.h> |
3 | #include <strings.h> | 3 | #include <strings.h> |
4 | #include "sway/commands.h" | 4 | #include "sway/commands.h" |
diff --git a/sway/commands/bar/output.c b/sway/commands/bar/output.c index 72754e05..930d779d 100644 --- a/sway/commands/bar/output.c +++ b/sway/commands/bar/output.c | |||
@@ -1,4 +1,4 @@ | |||
1 | #define _XOPEN_SOURCE 500 | 1 | #define _POSIX_C_SOURCE 200809L |
2 | #include <stdbool.h> | 2 | #include <stdbool.h> |
3 | #include <string.h> | 3 | #include <string.h> |
4 | #include "sway/commands.h" | 4 | #include "sway/commands.h" |
diff --git a/sway/commands/bar/separator_symbol.c b/sway/commands/bar/separator_symbol.c index 392ab730..060b8f52 100644 --- a/sway/commands/bar/separator_symbol.c +++ b/sway/commands/bar/separator_symbol.c | |||
@@ -1,4 +1,4 @@ | |||
1 | #define _XOPEN_SOURCE 500 | 1 | #define _POSIX_C_SOURCE 200809L |
2 | #include <string.h> | 2 | #include <string.h> |
3 | #include "sway/commands.h" | 3 | #include "sway/commands.h" |
4 | #include "log.h" | 4 | #include "log.h" |
diff --git a/sway/commands/bar/tray_output.c b/sway/commands/bar/tray_output.c index 6ab16731..e6c77128 100644 --- a/sway/commands/bar/tray_output.c +++ b/sway/commands/bar/tray_output.c | |||
@@ -1,4 +1,3 @@ | |||
1 | #define _XOPEN_SOURCE 500 | ||
2 | #include <string.h> | 1 | #include <string.h> |
3 | #include "sway/commands.h" | 2 | #include "sway/commands.h" |
4 | 3 | ||
diff --git a/sway/commands/bind.c b/sway/commands/bind.c index a9de227f..08acbe7a 100644 --- a/sway/commands/bind.c +++ b/sway/commands/bind.c | |||
@@ -1,4 +1,4 @@ | |||
1 | #define _XOPEN_SOURCE 500 | 1 | #define _POSIX_C_SOURCE 200809L |
2 | #ifdef __linux__ | 2 | #ifdef __linux__ |
3 | #include <linux/input-event-codes.h> | 3 | #include <linux/input-event-codes.h> |
4 | #elif __FreeBSD__ | 4 | #elif __FreeBSD__ |
diff --git a/sway/commands/exec_always.c b/sway/commands/exec_always.c index 7a15709b..9ec28d81 100644 --- a/sway/commands/exec_always.c +++ b/sway/commands/exec_always.c | |||
@@ -1,4 +1,4 @@ | |||
1 | #define _XOPEN_SOURCE 500 | 1 | #define _POSIX_C_SOURCE 200809L |
2 | #include <stdlib.h> | 2 | #include <stdlib.h> |
3 | #include <stdint.h> | 3 | #include <stdint.h> |
4 | #include <string.h> | 4 | #include <string.h> |
diff --git a/sway/commands/for_window.c b/sway/commands/for_window.c index ac4d6563..7c0f7d7f 100644 --- a/sway/commands/for_window.c +++ b/sway/commands/for_window.c | |||
@@ -1,4 +1,3 @@ | |||
1 | #define _XOPEN_SOURCE 500 | ||
2 | #include <string.h> | 1 | #include <string.h> |
3 | #include "sway/commands.h" | 2 | #include "sway/commands.h" |
4 | #include "sway/criteria.h" | 3 | #include "sway/criteria.h" |
diff --git a/sway/commands/input/xkb_layout.c b/sway/commands/input/xkb_layout.c index 5fccd4a3..43166401 100644 --- a/sway/commands/input/xkb_layout.c +++ b/sway/commands/input/xkb_layout.c | |||
@@ -1,4 +1,4 @@ | |||
1 | #define _XOPEN_SOURCE 700 | 1 | #define _POSIX_C_SOURCE 200809L |
2 | #include "sway/config.h" | 2 | #include "sway/config.h" |
3 | #include "sway/commands.h" | 3 | #include "sway/commands.h" |
4 | #include "sway/input/input-manager.h" | 4 | #include "sway/input/input-manager.h" |
diff --git a/sway/commands/input/xkb_model.c b/sway/commands/input/xkb_model.c index c4d04638..066f632b 100644 --- a/sway/commands/input/xkb_model.c +++ b/sway/commands/input/xkb_model.c | |||
@@ -1,4 +1,4 @@ | |||
1 | #define _XOPEN_SOURCE 700 | 1 | #define _POSIX_C_SOURCE 200809L |
2 | #include "sway/config.h" | 2 | #include "sway/config.h" |
3 | #include "sway/commands.h" | 3 | #include "sway/commands.h" |
4 | #include "sway/input/input-manager.h" | 4 | #include "sway/input/input-manager.h" |
diff --git a/sway/commands/input/xkb_options.c b/sway/commands/input/xkb_options.c index 794ab6e9..09dc4a5c 100644 --- a/sway/commands/input/xkb_options.c +++ b/sway/commands/input/xkb_options.c | |||
@@ -1,4 +1,4 @@ | |||
1 | #define _XOPEN_SOURCE 700 | 1 | #define _POSIX_C_SOURCE 200809L |
2 | #include "sway/config.h" | 2 | #include "sway/config.h" |
3 | #include "sway/commands.h" | 3 | #include "sway/commands.h" |
4 | #include "sway/input/input-manager.h" | 4 | #include "sway/input/input-manager.h" |
diff --git a/sway/commands/input/xkb_rules.c b/sway/commands/input/xkb_rules.c index 257c3288..d3e576e6 100644 --- a/sway/commands/input/xkb_rules.c +++ b/sway/commands/input/xkb_rules.c | |||
@@ -1,4 +1,4 @@ | |||
1 | #define _XOPEN_SOURCE 700 | 1 | #define _POSIX_C_SOURCE 200809L |
2 | #include "sway/config.h" | 2 | #include "sway/config.h" |
3 | #include "sway/commands.h" | 3 | #include "sway/commands.h" |
4 | #include "sway/input/input-manager.h" | 4 | #include "sway/input/input-manager.h" |
diff --git a/sway/commands/input/xkb_variant.c b/sway/commands/input/xkb_variant.c index 3832dc8e..2d7581d1 100644 --- a/sway/commands/input/xkb_variant.c +++ b/sway/commands/input/xkb_variant.c | |||
@@ -1,4 +1,4 @@ | |||
1 | #define _XOPEN_SOURCE 700 | 1 | #define _POSIX_C_SOURCE 200809L |
2 | #include "sway/config.h" | 2 | #include "sway/config.h" |
3 | #include "sway/commands.h" | 3 | #include "sway/commands.h" |
4 | #include "sway/input/input-manager.h" | 4 | #include "sway/input/input-manager.h" |
diff --git a/sway/commands/mode.c b/sway/commands/mode.c index 637ca45e..189e3c1a 100644 --- a/sway/commands/mode.c +++ b/sway/commands/mode.c | |||
@@ -1,4 +1,4 @@ | |||
1 | #define _XOPEN_SOURCE 500 | 1 | #define _POSIX_C_SOURCE 200809L |
2 | #include <stdbool.h> | 2 | #include <stdbool.h> |
3 | #include <string.h> | 3 | #include <string.h> |
4 | #include <strings.h> | 4 | #include <strings.h> |
diff --git a/sway/commands/move.c b/sway/commands/move.c index 7d8c1f1a..240b9f04 100644 --- a/sway/commands/move.c +++ b/sway/commands/move.c | |||
@@ -1,4 +1,4 @@ | |||
1 | #define _XOPEN_SOURCE 500 | 1 | #define _POSIX_C_SOURCE 200809L |
2 | #include <ctype.h> | 2 | #include <ctype.h> |
3 | #include <stdbool.h> | 3 | #include <stdbool.h> |
4 | #include <string.h> | 4 | #include <string.h> |
diff --git a/sway/commands/no_focus.c b/sway/commands/no_focus.c index 61a8de7e..cb81a445 100644 --- a/sway/commands/no_focus.c +++ b/sway/commands/no_focus.c | |||
@@ -1,4 +1,3 @@ | |||
1 | #define _XOPEN_SOURCE 500 | ||
2 | #include <string.h> | 1 | #include <string.h> |
3 | #include "sway/commands.h" | 2 | #include "sway/commands.h" |
4 | #include "sway/criteria.h" | 3 | #include "sway/criteria.h" |
diff --git a/sway/commands/reload.c b/sway/commands/reload.c index 62105cdc..c64de4bd 100644 --- a/sway/commands/reload.c +++ b/sway/commands/reload.c | |||
@@ -1,4 +1,4 @@ | |||
1 | #define _XOPEN_SOURCE 500 | 1 | #define _POSIX_C_SOURCE 200809L |
2 | #include <string.h> | 2 | #include <string.h> |
3 | #include "sway/commands.h" | 3 | #include "sway/commands.h" |
4 | #include "sway/config.h" | 4 | #include "sway/config.h" |
diff --git a/sway/commands/rename.c b/sway/commands/rename.c index 0cee9293..29f90d81 100644 --- a/sway/commands/rename.c +++ b/sway/commands/rename.c | |||
@@ -1,4 +1,3 @@ | |||
1 | #define _XOPEN_SOURCE 500 | ||
2 | #include <ctype.h> | 1 | #include <ctype.h> |
3 | #include <string.h> | 2 | #include <string.h> |
4 | #include <strings.h> | 3 | #include <strings.h> |
diff --git a/sway/commands/resize.c b/sway/commands/resize.c index a90d578e..cf5dea02 100644 --- a/sway/commands/resize.c +++ b/sway/commands/resize.c | |||
@@ -512,34 +512,42 @@ static struct cmd_results *resize_set_floating(struct sway_container *con, | |||
512 | calculate_constraints(&min_width, &max_width, &min_height, &max_height); | 512 | calculate_constraints(&min_width, &max_width, &min_height, &max_height); |
513 | 513 | ||
514 | if (width->amount) { | 514 | if (width->amount) { |
515 | if (width->unit == RESIZE_UNIT_PPT || | 515 | switch (width->unit) { |
516 | width->unit == RESIZE_UNIT_DEFAULT) { | 516 | case RESIZE_UNIT_PPT: |
517 | // Convert to px | 517 | // Convert to px |
518 | width->amount = con->workspace->width * width->amount / 100; | 518 | width->amount = con->workspace->width * width->amount / 100; |
519 | width->unit = RESIZE_UNIT_PX; | 519 | width->unit = RESIZE_UNIT_PX; |
520 | } | 520 | // Falls through |
521 | if (width->unit == RESIZE_UNIT_PX) { | 521 | case RESIZE_UNIT_PX: |
522 | case RESIZE_UNIT_DEFAULT: | ||
522 | width->amount = fmax(min_width, fmin(width->amount, max_width)); | 523 | width->amount = fmax(min_width, fmin(width->amount, max_width)); |
523 | grow_width = width->amount - con->width; | 524 | grow_width = width->amount - con->width; |
524 | |||
525 | con->x -= grow_width / 2; | 525 | con->x -= grow_width / 2; |
526 | con->width = width->amount; | 526 | con->width = width->amount; |
527 | break; | ||
528 | case RESIZE_UNIT_INVALID: | ||
529 | sway_assert(false, "invalid width unit"); | ||
530 | break; | ||
527 | } | 531 | } |
528 | } | 532 | } |
529 | 533 | ||
530 | if (height->amount) { | 534 | if (height->amount) { |
531 | if (height->unit == RESIZE_UNIT_PPT || | 535 | switch (height->unit) { |
532 | height->unit == RESIZE_UNIT_DEFAULT) { | 536 | case RESIZE_UNIT_PPT: |
533 | // Convert to px | 537 | // Convert to px |
534 | height->amount = con->workspace->height * height->amount / 100; | 538 | height->amount = con->workspace->height * height->amount / 100; |
535 | height->unit = RESIZE_UNIT_PX; | 539 | height->unit = RESIZE_UNIT_PX; |
536 | } | 540 | // Falls through |
537 | if (height->unit == RESIZE_UNIT_PX) { | 541 | case RESIZE_UNIT_PX: |
542 | case RESIZE_UNIT_DEFAULT: | ||
538 | height->amount = fmax(min_height, fmin(height->amount, max_height)); | 543 | height->amount = fmax(min_height, fmin(height->amount, max_height)); |
539 | grow_height = height->amount - con->height; | 544 | grow_height = height->amount - con->height; |
540 | |||
541 | con->y -= grow_height / 2; | 545 | con->y -= grow_height / 2; |
542 | con->height = height->amount; | 546 | con->height = height->amount; |
547 | break; | ||
548 | case RESIZE_UNIT_INVALID: | ||
549 | sway_assert(false, "invalid height unit"); | ||
550 | break; | ||
543 | } | 551 | } |
544 | } | 552 | } |
545 | 553 | ||
diff --git a/sway/commands/seat/attach.c b/sway/commands/seat/attach.c index 6b4bcf1f..8d646c2d 100644 --- a/sway/commands/seat/attach.c +++ b/sway/commands/seat/attach.c | |||
@@ -1,4 +1,4 @@ | |||
1 | #define _XOPEN_SOURCE 700 | 1 | #define _POSIX_C_SOURCE 200809L |
2 | #include <string.h> | 2 | #include <string.h> |
3 | #include <strings.h> | 3 | #include <strings.h> |
4 | #include "sway/input/input-manager.h" | 4 | #include "sway/input/input-manager.h" |
diff --git a/sway/commands/seat/cursor.c b/sway/commands/seat/cursor.c index 1d41a94e..495c2338 100644 --- a/sway/commands/seat/cursor.c +++ b/sway/commands/seat/cursor.c | |||
@@ -1,4 +1,4 @@ | |||
1 | #define _XOPEN_SOURCE 700 | 1 | #define _POSIX_C_SOURCE 200809L |
2 | #ifdef __linux__ | 2 | #ifdef __linux__ |
3 | #include <linux/input-event-codes.h> | 3 | #include <linux/input-event-codes.h> |
4 | #elif __FreeBSD__ | 4 | #elif __FreeBSD__ |
diff --git a/sway/commands/set.c b/sway/commands/set.c index be51230b..d912e4fd 100644 --- a/sway/commands/set.c +++ b/sway/commands/set.c | |||
@@ -1,4 +1,4 @@ | |||
1 | #define _XOPEN_SOURCE 700 | 1 | #define _POSIX_C_SOURCE 200809L |
2 | #include <stdio.h> | 2 | #include <stdio.h> |
3 | #include <string.h> | 3 | #include <string.h> |
4 | #include <strings.h> | 4 | #include <strings.h> |
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 | |||
7 | struct 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 | } | ||
diff --git a/sway/commands/titlebar_border_thickness.c b/sway/commands/titlebar_border_thickness.c new file mode 100644 index 00000000..c1e9bb52 --- /dev/null +++ b/sway/commands/titlebar_border_thickness.c | |||
@@ -0,0 +1,30 @@ | |||
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_border_thickness(int argc, char **argv) { | ||
9 | struct cmd_results *error = NULL; | ||
10 | if ((error = checkarg(argc, "titlebar_border_thickness", EXPECTED_EQUAL_TO, 1))) { | ||
11 | return error; | ||
12 | } | ||
13 | |||
14 | char *inv; | ||
15 | int value = strtol(argv[0], &inv, 10); | ||
16 | if (*inv != '\0' || value < 0 || value > config->titlebar_v_padding) { | ||
17 | return cmd_results_new(CMD_FAILURE, "titlebar_border_thickness", | ||
18 | "Invalid size specified"); | ||
19 | } | ||
20 | |||
21 | config->titlebar_border_thickness = value; | ||
22 | |||
23 | for (int i = 0; i < root->outputs->length; ++i) { | ||
24 | struct sway_output *output = root->outputs->items[i]; | ||
25 | arrange_workspace(output_get_active_workspace(output)); | ||
26 | output_damage_whole(output); | ||
27 | } | ||
28 | |||
29 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); | ||
30 | } | ||
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 | } | ||
diff --git a/sway/commands/workspace.c b/sway/commands/workspace.c index 92118ecf..7d32e65b 100644 --- a/sway/commands/workspace.c +++ b/sway/commands/workspace.c | |||
@@ -1,4 +1,4 @@ | |||
1 | #define _XOPEN_SOURCE 500 | 1 | #define _POSIX_C_SOURCE 200809L |
2 | #include <ctype.h> | 2 | #include <ctype.h> |
3 | #include <limits.h> | 3 | #include <limits.h> |
4 | #include <string.h> | 4 | #include <string.h> |
@@ -38,7 +38,7 @@ void free_workspace_config(struct workspace_config *wsc) { | |||
38 | } | 38 | } |
39 | 39 | ||
40 | static void prevent_invalid_outer_gaps(struct workspace_config *wsc) { | 40 | static void prevent_invalid_outer_gaps(struct workspace_config *wsc) { |
41 | if (wsc->gaps_outer.top != INT_MIN && | 41 | if (wsc->gaps_outer.top != INT_MIN && |
42 | wsc->gaps_outer.top < -wsc->gaps_inner) { | 42 | wsc->gaps_outer.top < -wsc->gaps_inner) { |
43 | wsc->gaps_outer.top = -wsc->gaps_inner; | 43 | wsc->gaps_outer.top = -wsc->gaps_inner; |
44 | } | 44 | } |