aboutsummaryrefslogtreecommitdiff
path: root/sway/commands/fullscreen.c
diff options
context:
space:
mode:
authorRyan Dwyer <ryandwyer1@gmail.com>2019-01-25 08:29:21 +1000
committerRyan Dwyer <ryandwyer1@gmail.com>2019-01-25 08:29:21 +1000
commit20aa8ee67dc528299dbc8735220a1c081c7ff9f6 (patch)
tree685de48be3db51fc01510ccf051e2b63a4655fba /sway/commands/fullscreen.c
parent75406bb93b96091d30e52922d0f319530fe65471 (diff)
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 @@
+#include <strings.h>
#include "log.h"
#include "sway/commands.h"
#include "sway/config.h"
@@ -7,9 +8,10 @@
#include "sway/tree/workspace.h"
#include "util.h"
+// fullscreen [enable|disable|toggle] [global]
struct cmd_results *cmd_fullscreen(int argc, char **argv) {
struct cmd_results *error = NULL;
- if ((error = checkarg(argc, "fullscreen", EXPECTED_AT_MOST, 1))) {
+ if ((error = checkarg(argc, "fullscreen", EXPECTED_AT_MOST, 2))) {
return error;
}
if (!root->outputs->length) {
@@ -23,20 +25,38 @@ struct cmd_results *cmd_fullscreen(int argc, char **argv) {
return cmd_results_new(CMD_FAILURE,
"Can't fullscreen an empty workspace");
}
- if (node->type == N_WORKSPACE) {
+
+ bool is_fullscreen = container &&
+ container->fullscreen_mode != FULLSCREEN_NONE;
+ bool global = false;
+ bool enable = !is_fullscreen;
+
+ if (argc >= 1) {
+ if (strcasecmp(argv[0], "global") == 0) {
+ global = true;
+ } else {
+ enable = parse_boolean(argv[0], is_fullscreen);
+ }
+ }
+
+ if (argc >= 2) {
+ global = strcasecmp(argv[1], "global") == 0;
+ }
+
+ if (enable && node->type == N_WORKSPACE) {
// Wrap the workspace's children in a container so we can fullscreen it
container = workspace_wrap_children(workspace);
workspace->layout = L_HORIZ;
seat_set_focus_container(config->handler_context.seat, container);
}
- bool enable = !container->is_fullscreen;
- if (argc) {
- enable = parse_boolean(argv[0], container->is_fullscreen);
+ enum sway_fullscreen_mode mode = FULLSCREEN_NONE;
+ if (enable) {
+ mode = global ? FULLSCREEN_GLOBAL : FULLSCREEN_WORKSPACE;
}
- container_set_fullscreen(container, enable);
- arrange_workspace(workspace);
+ container_set_fullscreen(container, mode);
+ arrange_root();
return cmd_results_new(CMD_SUCCESS, NULL);
}