69a1a0ff99
When setting fullscreen on a hidden scratchpad container, there was a check to see if there was an existing fullscreen container on the workspace so it could be fullscreen disabled first. Since the workspace is NULL, it would cause a SIGSEGV. This adds a NULL check to avoid the crash. This also changes the behavior of how fullscreen is handled when adding a container to the scratchpad or changing visibility of a scratchpad container to match i3's. The behavior is as follows: - When adding a container to the scratchpad or hiding a container back into the scratchpad, there is an implicit fullscreen disable - When setting fullscreen on a container that is hidden in the scratchpad, it will be fullscreen when shown (and fullscreen disabled when hidden as stated above) - When setting fullscreen global on a container that is hidden in the scratchpad, it will be shown immediately as fullscreen global. The container is not moved to a workspace and remains in the scratchpad. The container will be visible until fullscreen disabled or killed. Since the container is in the scratchpad, running `scratchpad show` or `move container to scratchpad` will have no effect This also changes `container_replace` to transfer fullscreen and scratchpad status.
99 lines
2.7 KiB
C
99 lines
2.7 KiB
C
#include <string.h>
|
|
#include <strings.h>
|
|
#include "sway/commands.h"
|
|
#include "sway/tree/arrange.h"
|
|
#include "sway/tree/container.h"
|
|
#include "sway/tree/view.h"
|
|
#include "sway/tree/workspace.h"
|
|
#include "sway/input/input-manager.h"
|
|
#include "sway/input/seat.h"
|
|
#include "log.h"
|
|
|
|
static struct cmd_results *do_split(int layout) {
|
|
struct sway_container *con = config->handler_context.container;
|
|
struct sway_workspace *ws = config->handler_context.workspace;
|
|
if (con) {
|
|
if (container_is_scratchpad_hidden(con) &&
|
|
con->fullscreen_mode != FULLSCREEN_GLOBAL) {
|
|
return cmd_results_new(CMD_FAILURE,
|
|
"Cannot split a hidden scratchpad container");
|
|
}
|
|
container_split(con, layout);
|
|
} else {
|
|
workspace_split(ws, layout);
|
|
}
|
|
|
|
if (con && con->parent && con->parent->parent) {
|
|
container_flatten(con->parent->parent);
|
|
}
|
|
|
|
if (root->fullscreen_global) {
|
|
arrange_root();
|
|
} else {
|
|
arrange_workspace(ws);
|
|
}
|
|
|
|
return cmd_results_new(CMD_SUCCESS, NULL);
|
|
}
|
|
|
|
struct cmd_results *cmd_split(int argc, char **argv) {
|
|
struct cmd_results *error = NULL;
|
|
if ((error = checkarg(argc, "split", EXPECTED_EQUAL_TO, 1))) {
|
|
return error;
|
|
}
|
|
if (!root->outputs->length) {
|
|
return cmd_results_new(CMD_INVALID,
|
|
"Can't run this command while there's no outputs connected.");
|
|
}
|
|
if (strcasecmp(argv[0], "v") == 0 || strcasecmp(argv[0], "vertical") == 0) {
|
|
return do_split(L_VERT);
|
|
} else if (strcasecmp(argv[0], "h") == 0 ||
|
|
strcasecmp(argv[0], "horizontal") == 0) {
|
|
return do_split(L_HORIZ);
|
|
} else if (strcasecmp(argv[0], "t") == 0 ||
|
|
strcasecmp(argv[0], "toggle") == 0) {
|
|
struct sway_container *focused = config->handler_context.container;
|
|
|
|
if (focused && container_parent_layout(focused) == L_VERT) {
|
|
return do_split(L_HORIZ);
|
|
} else {
|
|
return do_split(L_VERT);
|
|
}
|
|
} else {
|
|
return cmd_results_new(CMD_FAILURE,
|
|
"Invalid split command (expected either horizontal or vertical).");
|
|
}
|
|
return cmd_results_new(CMD_SUCCESS, NULL);
|
|
}
|
|
|
|
struct cmd_results *cmd_splitv(int argc, char **argv) {
|
|
struct cmd_results *error = NULL;
|
|
if ((error = checkarg(argc, "splitv", EXPECTED_EQUAL_TO, 0))) {
|
|
return error;
|
|
}
|
|
return do_split(L_VERT);
|
|
}
|
|
|
|
struct cmd_results *cmd_splith(int argc, char **argv) {
|
|
struct cmd_results *error = NULL;
|
|
if ((error = checkarg(argc, "splitv", EXPECTED_EQUAL_TO, 0))) {
|
|
return error;
|
|
}
|
|
return do_split(L_HORIZ);
|
|
}
|
|
|
|
struct cmd_results *cmd_splitt(int argc, char **argv) {
|
|
struct cmd_results *error = NULL;
|
|
if ((error = checkarg(argc, "splitv", EXPECTED_EQUAL_TO, 0))) {
|
|
return error;
|
|
}
|
|
|
|
struct sway_container *con = config->handler_context.container;
|
|
|
|
if (con && container_parent_layout(con) == L_VERT) {
|
|
return do_split(L_HORIZ);
|
|
} else {
|
|
return do_split(L_VERT);
|
|
}
|
|
}
|