diff options
Diffstat (limited to 'sway/commands/fullscreen.c')
-rw-r--r-- | sway/commands/fullscreen.c | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/sway/commands/fullscreen.c b/sway/commands/fullscreen.c new file mode 100644 index 00000000..3e256282 --- /dev/null +++ b/sway/commands/fullscreen.c | |||
@@ -0,0 +1,40 @@ | |||
1 | #include <wlr/types/wlr_wl_shell.h> | ||
2 | #include "log.h" | ||
3 | #include "sway/commands.h" | ||
4 | #include "sway/config.h" | ||
5 | #include "sway/tree/container.h" | ||
6 | #include "sway/tree/view.h" | ||
7 | #include "sway/tree/layout.h" | ||
8 | |||
9 | // fullscreen toggle|enable|disable | ||
10 | struct cmd_results *cmd_fullscreen(int argc, char **argv) { | ||
11 | struct cmd_results *error = NULL; | ||
12 | if (config->reading) return cmd_results_new(CMD_FAILURE, "fullscreen", "Can't be used in config file."); | ||
13 | if (!config->active) return cmd_results_new(CMD_FAILURE, "fullscreen", "Can only be used when sway is running."); | ||
14 | if ((error = checkarg(argc, "fullscreen", EXPECTED_AT_LEAST, 1))) { | ||
15 | return error; | ||
16 | } | ||
17 | struct sway_container *container = | ||
18 | config->handler_context.current_container; | ||
19 | if (container->type != C_VIEW) { | ||
20 | return cmd_results_new(CMD_INVALID, "fullscreen", | ||
21 | "Only views can fullscreen"); | ||
22 | } | ||
23 | struct sway_view *view = container->sway_view; | ||
24 | bool wants_fullscreen; | ||
25 | |||
26 | if (strcmp(argv[0], "enable") == 0) { | ||
27 | wants_fullscreen = true; | ||
28 | } else if (strcmp(argv[0], "disable") == 0) { | ||
29 | wants_fullscreen = false; | ||
30 | } else if (strcmp(argv[0], "toggle") == 0) { | ||
31 | wants_fullscreen = !view->is_fullscreen; | ||
32 | } else { | ||
33 | return cmd_results_new(CMD_INVALID, "fullscreen", | ||
34 | "Expected 'fullscreen <enable|disable|toggle>'"); | ||
35 | } | ||
36 | |||
37 | view_set_fullscreen(view, wants_fullscreen); | ||
38 | |||
39 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); | ||
40 | } | ||