mirror of
https://github.com/swaywm/sway.git
synced 2025-11-05 13:29:51 -05:00
Implement fullscreen global
This commit is contained in:
parent
75406bb93b
commit
20aa8ee67d
22 changed files with 331 additions and 131 deletions
|
|
@ -89,19 +89,23 @@ static struct sway_node *get_node_in_output_direction(
|
|||
|
||||
static struct sway_node *node_get_in_direction(struct sway_container *container,
|
||||
struct sway_seat *seat, enum wlr_direction dir) {
|
||||
if (container->is_fullscreen) {
|
||||
// Fullscreen container with a direction - go straight to outputs
|
||||
struct sway_output *output = container->workspace->output;
|
||||
struct sway_output *new_output = output_get_in_direction(output, dir);
|
||||
if (!new_output) {
|
||||
return NULL;
|
||||
}
|
||||
return get_node_in_output_direction(new_output, dir);
|
||||
}
|
||||
|
||||
struct sway_container *wrap_candidate = NULL;
|
||||
struct sway_container *current = container;
|
||||
while (current) {
|
||||
if (current->fullscreen_mode == FULLSCREEN_WORKSPACE) {
|
||||
// Fullscreen container with a direction - go straight to outputs
|
||||
struct sway_output *output = current->workspace->output;
|
||||
struct sway_output *new_output =
|
||||
output_get_in_direction(output, dir);
|
||||
if (!new_output) {
|
||||
return NULL;
|
||||
}
|
||||
return get_node_in_output_direction(new_output, dir);
|
||||
}
|
||||
if (current->fullscreen_mode == FULLSCREEN_GLOBAL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
bool can_move = false;
|
||||
int desired;
|
||||
int idx = container_sibling_index(current);
|
||||
|
|
@ -227,7 +231,7 @@ static struct cmd_results *focus_output(struct sway_seat *seat,
|
|||
static struct cmd_results *focus_parent(void) {
|
||||
struct sway_seat *seat = config->handler_context.seat;
|
||||
struct sway_container *con = config->handler_context.container;
|
||||
if (!con || con->is_fullscreen) {
|
||||
if (!con || con->fullscreen_mode) {
|
||||
return cmd_results_new(CMD_SUCCESS, NULL);
|
||||
}
|
||||
struct sway_node *parent = node_get_parent(&con->node);
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -191,7 +191,7 @@ static void container_move_to_workspace(struct sway_container *container,
|
|||
workspace_add_floating(workspace, container);
|
||||
container_handle_fullscreen_reparent(container);
|
||||
// If changing output, center it within the workspace
|
||||
if (old_output != workspace->output && !container->is_fullscreen) {
|
||||
if (old_output != workspace->output && !container->fullscreen_mode) {
|
||||
container_floating_move_to_center(container);
|
||||
}
|
||||
} else {
|
||||
|
|
@ -276,7 +276,7 @@ static void workspace_rejigger(struct sway_workspace *ws,
|
|||
static bool container_move_in_direction(struct sway_container *container,
|
||||
enum wlr_direction move_dir) {
|
||||
// If moving a fullscreen view, only consider outputs
|
||||
if (container->is_fullscreen) {
|
||||
if (container->fullscreen_mode == FULLSCREEN_WORKSPACE) {
|
||||
struct sway_output *new_output =
|
||||
output_get_in_direction(container->workspace->output, move_dir);
|
||||
if (!new_output) {
|
||||
|
|
@ -286,6 +286,9 @@ static bool container_move_in_direction(struct sway_container *container,
|
|||
container_move_to_workspace(container, ws);
|
||||
return true;
|
||||
}
|
||||
if (container->fullscreen_mode == FULLSCREEN_GLOBAL) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// If container is in a split container by itself, move out of the split
|
||||
if (container->parent) {
|
||||
|
|
@ -309,13 +312,19 @@ static bool container_move_in_direction(struct sway_container *container,
|
|||
int index = list_find(siblings, current);
|
||||
int desired = index + offs;
|
||||
|
||||
// Don't allow containers to move out of their
|
||||
// fullscreen or floating parent
|
||||
if (current->fullscreen_mode || container_is_floating(current)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (is_parallel(layout, move_dir)) {
|
||||
if (desired == -1 || desired == siblings->length) {
|
||||
if (current->parent == container->parent) {
|
||||
current = current->parent;
|
||||
continue;
|
||||
} else {
|
||||
// Special case
|
||||
// Reparenting
|
||||
if (current->parent) {
|
||||
container_insert_child(current->parent, container,
|
||||
index + (offs < 0 ? 0 : 1));
|
||||
|
|
@ -334,13 +343,6 @@ static bool container_move_in_direction(struct sway_container *container,
|
|||
}
|
||||
|
||||
current = current->parent;
|
||||
|
||||
// Don't allow containers to move out of their
|
||||
// fullscreen or floating parent
|
||||
if (current &&
|
||||
(current->is_fullscreen || container_is_floating(current))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Maybe rejigger the workspace
|
||||
|
|
@ -563,10 +565,14 @@ static struct cmd_results *cmd_move_container(int argc, char **argv) {
|
|||
}
|
||||
|
||||
// arrange windows
|
||||
if (old_ws && !old_ws->node.destroying) {
|
||||
arrange_workspace(old_ws);
|
||||
if (root->fullscreen_global) {
|
||||
arrange_root();
|
||||
} else {
|
||||
if (old_ws && !old_ws->node.destroying) {
|
||||
arrange_workspace(old_ws);
|
||||
}
|
||||
arrange_node(node_get_parent(destination));
|
||||
}
|
||||
arrange_node(node_get_parent(destination));
|
||||
|
||||
return cmd_results_new(CMD_SUCCESS, NULL);
|
||||
}
|
||||
|
|
@ -658,7 +664,7 @@ static struct cmd_results *cmd_move_in_direction(
|
|||
"Cannot move a hidden scratchpad container");
|
||||
}
|
||||
if (container_is_floating(container)) {
|
||||
if (container->is_fullscreen) {
|
||||
if (container->fullscreen_mode) {
|
||||
return cmd_results_new(CMD_FAILURE,
|
||||
"Cannot move fullscreen floating container");
|
||||
}
|
||||
|
|
@ -690,9 +696,13 @@ static struct cmd_results *cmd_move_in_direction(
|
|||
|
||||
struct sway_workspace *new_ws = container->workspace;
|
||||
|
||||
arrange_workspace(old_ws);
|
||||
if (new_ws != old_ws) {
|
||||
arrange_workspace(new_ws);
|
||||
if (root->fullscreen_global) {
|
||||
arrange_root();
|
||||
} else {
|
||||
arrange_workspace(old_ws);
|
||||
if (new_ws != old_ws) {
|
||||
arrange_workspace(new_ws);
|
||||
}
|
||||
}
|
||||
|
||||
if (container->view) {
|
||||
|
|
|
|||
|
|
@ -26,7 +26,11 @@ static struct cmd_results *do_split(int layout) {
|
|||
container_flatten(con->parent->parent);
|
||||
}
|
||||
|
||||
arrange_workspace(ws);
|
||||
if (root->fullscreen_global) {
|
||||
arrange_root();
|
||||
} else {
|
||||
arrange_workspace(ws);
|
||||
}
|
||||
|
||||
return cmd_results_new(CMD_SUCCESS, NULL);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -77,6 +77,11 @@ static void swap_focus(struct sway_container *con1,
|
|||
} else {
|
||||
seat_set_focus_container(seat, focus);
|
||||
}
|
||||
|
||||
if (root->fullscreen_global) {
|
||||
seat_set_focus(seat,
|
||||
seat_get_focus_inactive(seat, &root->fullscreen_global->node));
|
||||
}
|
||||
}
|
||||
|
||||
static void container_swap(struct sway_container *con1,
|
||||
|
|
@ -98,13 +103,13 @@ static void container_swap(struct sway_container *con1,
|
|||
sway_log(SWAY_DEBUG, "Swapping containers %zu and %zu",
|
||||
con1->node.id, con2->node.id);
|
||||
|
||||
bool fs1 = con1->is_fullscreen;
|
||||
bool fs2 = con2->is_fullscreen;
|
||||
enum sway_fullscreen_mode fs1 = con1->fullscreen_mode;
|
||||
enum sway_fullscreen_mode fs2 = con2->fullscreen_mode;
|
||||
if (fs1) {
|
||||
container_set_fullscreen(con1, false);
|
||||
container_fullscreen_disable(con1);
|
||||
}
|
||||
if (fs2) {
|
||||
container_set_fullscreen(con2, false);
|
||||
container_fullscreen_disable(con2);
|
||||
}
|
||||
|
||||
struct sway_seat *seat = config->handler_context.seat;
|
||||
|
|
@ -136,10 +141,10 @@ static void container_swap(struct sway_container *con1,
|
|||
}
|
||||
|
||||
if (fs1) {
|
||||
container_set_fullscreen(con2, true);
|
||||
container_set_fullscreen(con2, fs1);
|
||||
}
|
||||
if (fs2) {
|
||||
container_set_fullscreen(con1, true);
|
||||
container_set_fullscreen(con1, fs2);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -220,9 +225,13 @@ struct cmd_results *cmd_swap(int argc, char **argv) {
|
|||
|
||||
container_swap(current, other);
|
||||
|
||||
arrange_node(node_get_parent(¤t->node));
|
||||
if (node_get_parent(&other->node) != node_get_parent(¤t->node)) {
|
||||
arrange_node(node_get_parent(&other->node));
|
||||
if (root->fullscreen_global) {
|
||||
arrange_root();
|
||||
} else {
|
||||
arrange_node(node_get_parent(¤t->node));
|
||||
if (node_get_parent(&other->node) != node_get_parent(¤t->node)) {
|
||||
arrange_node(node_get_parent(&other->node));
|
||||
}
|
||||
}
|
||||
|
||||
return cmd_results_new(CMD_SUCCESS, NULL);
|
||||
|
|
|
|||
|
|
@ -168,6 +168,11 @@ struct cmd_results *cmd_workspace(int argc, char **argv) {
|
|||
"Can't run this command while there's no outputs connected.");
|
||||
}
|
||||
|
||||
if (root->fullscreen_global) {
|
||||
return cmd_results_new(CMD_FAILURE, "workspace",
|
||||
"Can't switch workspaces while fullscreen global");
|
||||
}
|
||||
|
||||
bool no_auto_back_and_forth = false;
|
||||
while (strcasecmp(argv[0], "--no-auto-back-and-forth") == 0) {
|
||||
no_auto_back_and_forth = true;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue