aboutsummaryrefslogtreecommitdiff
path: root/sway/container.c
diff options
context:
space:
mode:
authorDrew DeVault <sir@cmpwn.com>2015-08-15 15:06:52 -0400
committerDrew DeVault <sir@cmpwn.com>2015-08-15 15:06:52 -0400
commit648675c87a3360949fdccd9947e419214fdc6ff4 (patch)
tree870db1e093ea5d4eb53ec6a5d11a1bfbe46d3baf /sway/container.c
parentf7f739c0576b4cf2fe9e5748fcdf861c0d970523 (diff)
parent9bb2788768d5a52b1947a06dfbed65ec59a6f80c (diff)
Merge pull request #30 from taiyu-len/master
fixed split
Diffstat (limited to 'sway/container.c')
-rw-r--r--sway/container.c34
1 files changed, 25 insertions, 9 deletions
diff --git a/sway/container.c b/sway/container.c
index 1c17e92f..b52ffd8c 100644
--- a/sway/container.c
+++ b/sway/container.c
@@ -26,6 +26,9 @@ static void free_swayc(swayc_t *c) {
list_free(c->children);
}
if (c->parent) {
+ if (c->parent->focused == c) {
+ c->parent->focused = NULL;
+ }
remove_child(c->parent, c);
}
free(c);
@@ -88,9 +91,28 @@ swayc_t *new_container(swayc_t *child, enum swayc_layouts layout) {
cont->y = child->y;
cont->visible = child->visible;
- swayc_t *parent = replace_child(child, cont);
- if (parent) {
- add_child(cont, child);
+ /* Container inherits all of workspaces children, layout and whatnot */
+ if (child->type == C_WORKSPACE) {
+ swayc_t *workspace = child;
+ //reorder focus
+ cont->focused = workspace->focused;
+ workspace->focused = cont;
+ //Swap children
+ list_t *tmp_list = workspace->children;
+ workspace->children = cont->children;
+ cont->children = tmp_list;
+ //add container to workspace chidren
+ add_child(workspace, cont);
+ //give them proper layouts
+ cont->layout = workspace->layout;
+ workspace->layout = layout;
+ }
+ //Or is built around container
+ else {
+ swayc_t *parent = replace_child(child, cont);
+ if (parent) {
+ add_child(cont, child);
+ }
}
return cont;
}
@@ -152,9 +174,6 @@ swayc_t *destroy_container(swayc_t *container) {
swayc_t *parent = container->parent;
free_swayc(container);
- if (parent->focused == container) {
- parent->focused = NULL;
- }
container = parent;
}
return container;
@@ -169,9 +188,6 @@ swayc_t *destroy_view(swayc_t *view) {
swayc_t *parent = view->parent;
free_swayc(view);
- if (parent->focused == view) {
- parent->focused = NULL;
- }
//Destroy empty containers
if (parent->type == C_CONTAINER) {
return destroy_container(parent);