aboutsummaryrefslogtreecommitdiffstats
path: root/sway/commands/fullscreen.c
diff options
context:
space:
mode:
authorLibravatar Ryan Dwyer <ryandwyer1@gmail.com>2018-04-16 20:36:40 +1000
committerLibravatar Ryan Dwyer <ryandwyer1@gmail.com>2018-04-16 20:36:40 +1000
commit52420cc24d61db8d22cf0d391f1f84b37bf087d5 (patch)
treef975a3708c0d1562a8d2fcdceaed9a76aadbf1f4 /sway/commands/fullscreen.c
parentMerge pull request #1816 from thejan2009/multi-output-ws-destroy (diff)
downloadsway-52420cc24d61db8d22cf0d391f1f84b37bf087d5.tar.gz
sway-52420cc24d61db8d22cf0d391f1f84b37bf087d5.tar.zst
sway-52420cc24d61db8d22cf0d391f1f84b37bf087d5.zip
Implement fullscreen.
Diffstat (limited to 'sway/commands/fullscreen.c')
-rw-r--r--sway/commands/fullscreen.c40
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
10struct 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}