aboutsummaryrefslogtreecommitdiff
path: root/sway/tree/workspace.c
diff options
context:
space:
mode:
authorRonan Pigott <rpigott@berkeley.edu>2020-10-25 14:20:11 -0700
committerTudor Brindus <me@tbrindus.ca>2020-12-20 00:58:42 -0500
commitece6a1d408456ade74c88dee7d4b9e0491f0bdaf (patch)
tree09f5a40a02347c927a91ab66da6c794cfd787c97 /sway/tree/workspace.c
parentb4850876dc609830575531fd6e0ca696c956ae94 (diff)
Change workspace_layout to match i3 behavior
In i3, the workspace_layout command does not affect the workspace layout. Instead, new workspace level containers are wrapped in the desired layout and the workspace layout always defaults to the output orientation.
Diffstat (limited to 'sway/tree/workspace.c')
-rw-r--r--sway/tree/workspace.c34
1 files changed, 25 insertions, 9 deletions
diff --git a/sway/tree/workspace.c b/sway/tree/workspace.c
index ffcbe933..e40792ae 100644
--- a/sway/tree/workspace.c
+++ b/sway/tree/workspace.c
@@ -627,6 +627,21 @@ struct sway_container *workspace_find_container(struct sway_workspace *ws,
return NULL;
}
+static void set_workspace(struct sway_container *container, void *data) {
+ container->workspace = container->parent->workspace;
+}
+
+static void workspace_attach_tiling(struct sway_workspace *ws,
+ struct sway_container *con) {
+ list_add(ws->tiling, con);
+ con->workspace = ws;
+ container_for_each_child(con, set_workspace, NULL);
+ container_handle_fullscreen_reparent(con);
+ workspace_update_representation(ws);
+ node_set_dirty(&ws->node);
+ node_set_dirty(&con->node);
+}
+
struct sway_container *workspace_wrap_children(struct sway_workspace *ws) {
struct sway_container *fs = ws->fullscreen;
struct sway_container *middle = container_create(NULL);
@@ -636,7 +651,7 @@ struct sway_container *workspace_wrap_children(struct sway_workspace *ws) {
container_detach(child);
container_add_child(middle, child);
}
- workspace_add_tiling(ws, middle);
+ workspace_attach_tiling(ws, middle);
ws->fullscreen = fs;
return middle;
}
@@ -668,15 +683,14 @@ void workspace_detach(struct sway_workspace *workspace) {
node_set_dirty(&output->node);
}
-static void set_workspace(struct sway_container *container, void *data) {
- container->workspace = container->parent->workspace;
-}
-
-void workspace_add_tiling(struct sway_workspace *workspace,
+struct sway_container *workspace_add_tiling(struct sway_workspace *workspace,
struct sway_container *con) {
if (con->workspace) {
container_detach(con);
}
+ if (config->default_layout != L_NONE) {
+ con = container_split(con, config->default_layout);
+ }
list_add(workspace->tiling, con);
con->workspace = workspace;
container_for_each_child(con, set_workspace, NULL);
@@ -684,6 +698,7 @@ void workspace_add_tiling(struct sway_workspace *workspace,
workspace_update_representation(workspace);
node_set_dirty(&workspace->node);
node_set_dirty(&con->node);
+ return con;
}
void workspace_add_floating(struct sway_workspace *workspace,
@@ -699,13 +714,13 @@ void workspace_add_floating(struct sway_workspace *workspace,
node_set_dirty(&con->node);
}
-void workspace_insert_tiling(struct sway_workspace *workspace,
+struct sway_container *workspace_insert_tiling(struct sway_workspace *workspace,
struct sway_container *con, int index) {
if (con->workspace) {
container_detach(con);
}
- if (workspace->layout == L_STACKED || workspace->layout == L_TABBED) {
- con = container_split(con, workspace->layout);
+ if (config->default_layout != L_NONE) {
+ con = container_split(con, config->default_layout);
}
list_insert(workspace->tiling, index, con);
con->workspace = workspace;
@@ -714,6 +729,7 @@ void workspace_insert_tiling(struct sway_workspace *workspace,
workspace_update_representation(workspace);
node_set_dirty(&workspace->node);
node_set_dirty(&con->node);
+ return con;
}
void workspace_add_gaps(struct sway_workspace *ws) {