aboutsummaryrefslogtreecommitdiff
path: root/sway/tree
diff options
context:
space:
mode:
Diffstat (limited to 'sway/tree')
-rw-r--r--sway/tree/container.c7
-rw-r--r--sway/tree/output.c3
-rw-r--r--sway/tree/view.c23
-rw-r--r--sway/tree/workspace.c34
4 files changed, 41 insertions, 26 deletions
diff --git a/sway/tree/container.c b/sway/tree/container.c
index b0d23700..23b6c997 100644
--- a/sway/tree/container.c
+++ b/sway/tree/container.c
@@ -804,9 +804,10 @@ void container_set_floating(struct sway_container *container, bool enable) {
container->width = reference->width;
container->height = reference->height;
} else {
- workspace_add_tiling(workspace, container);
- container->width = workspace->width;
- container->height = workspace->height;
+ struct sway_container *other =
+ workspace_add_tiling(workspace, container);
+ other->width = workspace->width;
+ other->height = workspace->height;
}
if (container->view) {
view_set_tiled(container->view, true);
diff --git a/sway/tree/output.c b/sway/tree/output.c
index f15a84b3..a8ae30f7 100644
--- a/sway/tree/output.c
+++ b/sway/tree/output.c
@@ -395,9 +395,6 @@ void output_get_box(struct sway_output *output, struct wlr_box *box) {
enum sway_container_layout output_get_default_layout(
struct sway_output *output) {
- if (config->default_layout != L_NONE) {
- return config->default_layout;
- }
if (config->default_orientation != L_NONE) {
return config->default_orientation;
}
diff --git a/sway/tree/view.c b/sway/tree/view.c
index 354f2d34..e690c334 100644
--- a/sway/tree/view.c
+++ b/sway/tree/view.c
@@ -732,10 +732,11 @@ void view_map(struct sway_view *view, struct wlr_surface *wlr_surface,
ws = seat_get_last_known_workspace(seat);
}
+ struct sway_container *container = view->container;
if (target_sibling) {
- container_add_sibling(target_sibling, view->container, 1);
+ container_add_sibling(target_sibling, container, 1);
} else if (ws) {
- workspace_add_tiling(ws, view->container);
+ container = workspace_add_tiling(ws, container);
}
ipc_event_window(view->container, "new");
@@ -759,26 +760,26 @@ void view_map(struct sway_view *view, struct wlr_surface *wlr_surface,
}
if (config->popup_during_fullscreen == POPUP_LEAVE &&
- view->container->workspace &&
- view->container->workspace->fullscreen &&
- view->container->workspace->fullscreen->view) {
- struct sway_container *fs = view->container->workspace->fullscreen;
+ container->workspace &&
+ container->workspace->fullscreen &&
+ container->workspace->fullscreen->view) {
+ struct sway_container *fs = container->workspace->fullscreen;
if (view_is_transient_for(view, fs->view)) {
container_set_fullscreen(fs, false);
}
}
view_update_title(view, false);
- container_update_representation(view->container);
+ container_update_representation(container);
if (fullscreen) {
container_set_fullscreen(view->container, true);
arrange_workspace(view->container->workspace);
} else {
- if (view->container->parent) {
- arrange_container(view->container->parent);
- } else if (view->container->workspace) {
- arrange_workspace(view->container->workspace);
+ if (container->parent) {
+ arrange_container(container->parent);
+ } else if (container->workspace) {
+ arrange_workspace(container->workspace);
}
}
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) {