aboutsummaryrefslogtreecommitdiffstats
path: root/sway/commands/fullscreen.c
diff options
context:
space:
mode:
authorLibravatar Ryan Dwyer <ryandwyer1@gmail.com>2019-01-25 08:29:21 +1000
committerLibravatar Ryan Dwyer <ryandwyer1@gmail.com>2019-01-25 08:29:21 +1000
commit20aa8ee67dc528299dbc8735220a1c081c7ff9f6 (patch)
tree685de48be3db51fc01510ccf051e2b63a4655fba /sway/commands/fullscreen.c
parentUpdate for swaywm/wlroots#1402 (diff)
downloadsway-20aa8ee67dc528299dbc8735220a1c081c7ff9f6.tar.gz
sway-20aa8ee67dc528299dbc8735220a1c081c7ff9f6.tar.zst
sway-20aa8ee67dc528299dbc8735220a1c081c7ff9f6.zip
Implement fullscreen global
Diffstat (limited to 'sway/commands/fullscreen.c')
-rw-r--r--sway/commands/fullscreen.c34
1 files changed, 27 insertions, 7 deletions
diff --git a/sway/commands/fullscreen.c b/sway/commands/fullscreen.c
index 920b9bd0..52248ce4 100644
--- a/sway/commands/fullscreen.c
+++ b/sway/commands/fullscreen.c
@@ -1,3 +1,4 @@
1#include <strings.h>
1#include "log.h" 2#include "log.h"
2#include "sway/commands.h" 3#include "sway/commands.h"
3#include "sway/config.h" 4#include "sway/config.h"
@@ -7,9 +8,10 @@
7#include "sway/tree/workspace.h" 8#include "sway/tree/workspace.h"
8#include "util.h" 9#include "util.h"
9 10
11// fullscreen [enable|disable|toggle] [global]
10struct cmd_results *cmd_fullscreen(int argc, char **argv) { 12struct cmd_results *cmd_fullscreen(int argc, char **argv) {
11 struct cmd_results *error = NULL; 13 struct cmd_results *error = NULL;
12 if ((error = checkarg(argc, "fullscreen", EXPECTED_AT_MOST, 1))) { 14 if ((error = checkarg(argc, "fullscreen", EXPECTED_AT_MOST, 2))) {
13 return error; 15 return error;
14 } 16 }
15 if (!root->outputs->length) { 17 if (!root->outputs->length) {
@@ -23,20 +25,38 @@ struct cmd_results *cmd_fullscreen(int argc, char **argv) {
23 return cmd_results_new(CMD_FAILURE, 25 return cmd_results_new(CMD_FAILURE,
24 "Can't fullscreen an empty workspace"); 26 "Can't fullscreen an empty workspace");
25 } 27 }
26 if (node->type == N_WORKSPACE) { 28
29 bool is_fullscreen = container &&
30 container->fullscreen_mode != FULLSCREEN_NONE;
31 bool global = false;
32 bool enable = !is_fullscreen;
33
34 if (argc >= 1) {
35 if (strcasecmp(argv[0], "global") == 0) {
36 global = true;
37 } else {
38 enable = parse_boolean(argv[0], is_fullscreen);
39 }
40 }
41
42 if (argc >= 2) {
43 global = strcasecmp(argv[1], "global") == 0;
44 }
45
46 if (enable && node->type == N_WORKSPACE) {
27 // Wrap the workspace's children in a container so we can fullscreen it 47 // Wrap the workspace's children in a container so we can fullscreen it
28 container = workspace_wrap_children(workspace); 48 container = workspace_wrap_children(workspace);
29 workspace->layout = L_HORIZ; 49 workspace->layout = L_HORIZ;
30 seat_set_focus_container(config->handler_context.seat, container); 50 seat_set_focus_container(config->handler_context.seat, container);
31 } 51 }
32 bool enable = !container->is_fullscreen;
33 52
34 if (argc) { 53 enum sway_fullscreen_mode mode = FULLSCREEN_NONE;
35 enable = parse_boolean(argv[0], container->is_fullscreen); 54 if (enable) {
55 mode = global ? FULLSCREEN_GLOBAL : FULLSCREEN_WORKSPACE;
36 } 56 }
37 57
38 container_set_fullscreen(container, enable); 58 container_set_fullscreen(container, mode);
39 arrange_workspace(workspace); 59 arrange_root();
40 60
41 return cmd_results_new(CMD_SUCCESS, NULL); 61 return cmd_results_new(CMD_SUCCESS, NULL);
42} 62}