summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/layout.h2
-rw-r--r--sway/container.c13
-rw-r--r--sway/focus.c2
-rw-r--r--sway/handlers.c6
-rw-r--r--sway/layout.c9
5 files changed, 19 insertions, 13 deletions
diff --git a/include/layout.h b/include/layout.h
index a7f43fda..26d00ce4 100644
--- a/include/layout.h
+++ b/include/layout.h
@@ -13,7 +13,7 @@ void add_child(swayc_t *parent, swayc_t *child);
13//Returns parent container which needs to be rearranged. 13//Returns parent container which needs to be rearranged.
14swayc_t *add_sibling(swayc_t *sibling, swayc_t *child); 14swayc_t *add_sibling(swayc_t *sibling, swayc_t *child);
15swayc_t *replace_child(swayc_t *child, swayc_t *new_child); 15swayc_t *replace_child(swayc_t *child, swayc_t *new_child);
16swayc_t *remove_child(swayc_t *parent, swayc_t *child); 16swayc_t *remove_child(swayc_t *child);
17 17
18//Layout 18//Layout
19void arrange_windows(swayc_t *container, int width, int height); 19void arrange_windows(swayc_t *container, int width, int height);
diff --git a/sway/container.c b/sway/container.c
index 67132a48..2b9f7554 100644
--- a/sway/container.c
+++ b/sway/container.c
@@ -27,10 +27,7 @@ static void free_swayc(swayc_t *c) {
27 list_free(c->children); 27 list_free(c->children);
28 } 28 }
29 if (c->parent) { 29 if (c->parent) {
30 if (c->parent->focused == c) { 30 remove_child(c);
31 c->parent->focused = NULL;
32 }
33 remove_child(c->parent, c);
34 } 31 }
35 if (c->name) { 32 if (c->name) {
36 free(c->name); 33 free(c->name);
@@ -118,6 +115,11 @@ swayc_t *new_container(swayc_t *child, enum swayc_layouts layout) {
118 //reorder focus 115 //reorder focus
119 cont->focused = workspace->focused; 116 cont->focused = workspace->focused;
120 workspace->focused = cont; 117 workspace->focused = cont;
118 //set all children focu to container
119 int i;
120 for (i = 0; i < workspace->children->length; ++i) {
121 ((swayc_t *)workspace->children->items[i])->parent = cont;
122 }
121 //Swap children 123 //Swap children
122 list_t *tmp_list = workspace->children; 124 list_t *tmp_list = workspace->children;
123 workspace->children = cont->children; 125 workspace->children = cont->children;
@@ -204,7 +206,7 @@ swayc_t *destroy_output(swayc_t *output) {
204 if (output->children->length == 0) { 206 if (output->children->length == 0) {
205 //TODO move workspaces to other outputs 207 //TODO move workspaces to other outputs
206 } 208 }
207 sway_log(L_DEBUG, "OUTPUT: Destroying output '%u'", (unsigned int)output->handle); 209 sway_log(L_DEBUG, "OUTPUT: Destroying output '%lu'", output->handle);
208 free_swayc(output); 210 free_swayc(output);
209 return &root_container; 211 return &root_container;
210} 212}
@@ -246,7 +248,6 @@ swayc_t *destroy_view(swayc_t *view) {
246 if (parent->type == C_CONTAINER) { 248 if (parent->type == C_CONTAINER) {
247 return destroy_container(parent); 249 return destroy_container(parent);
248 } 250 }
249
250 return parent; 251 return parent;
251} 252}
252 253
diff --git a/sway/focus.c b/sway/focus.c
index 2999c6d0..4f57f252 100644
--- a/sway/focus.c
+++ b/sway/focus.c
@@ -135,7 +135,7 @@ void set_focused_container(swayc_t *c) {
135 if (!locked_view_focus) { 135 if (!locked_view_focus) {
136 p = get_focused_view(c); 136 p = get_focused_view(c);
137 //Set focus to p 137 //Set focus to p
138 if (p && p != prev_view && !(wlc_view_get_type(p->handle) & WLC_BIT_POPUP)) { 138 if (p && !(wlc_view_get_type(p->handle) & WLC_BIT_POPUP)) {
139 if (prev_view) { 139 if (prev_view) {
140 wlc_view_set_state(prev_view->handle, WLC_BIT_ACTIVATED, false); 140 wlc_view_set_state(prev_view->handle, WLC_BIT_ACTIVATED, false);
141 } 141 }
diff --git a/sway/handlers.c b/sway/handlers.c
index 2a5113cc..24e8e014 100644
--- a/sway/handlers.c
+++ b/sway/handlers.c
@@ -38,6 +38,9 @@ static bool pointer_test(swayc_t *view, void *_origin) {
38 38
39swayc_t *container_under_pointer(void) { 39swayc_t *container_under_pointer(void) {
40 //root.output->workspace 40 //root.output->workspace
41 if (!root_container.focused || !root_container.focused->focused) {
42 return NULL;
43 }
41 swayc_t *lookup = root_container.focused->focused; 44 swayc_t *lookup = root_container.focused->focused;
42 //Case of empty workspace 45 //Case of empty workspace
43 if (lookup->children == 0) { 46 if (lookup->children == 0) {
@@ -174,9 +177,6 @@ static void handle_view_destroyed(wlc_handle handle) {
174 if (view) { 177 if (view) {
175 swayc_t *parent = destroy_view(view); 178 swayc_t *parent = destroy_view(view);
176 arrange_windows(parent, -1, -1); 179 arrange_windows(parent, -1, -1);
177 if (!focused || focused == view) {
178 set_focused_container(container_under_pointer());
179 }
180 } 180 }
181 break; 181 break;
182 //takes keyboard focus 182 //takes keyboard focus
diff --git a/sway/layout.c b/sway/layout.c
index de7ef370..8ff5c4b7 100644
--- a/sway/layout.c
+++ b/sway/layout.c
@@ -60,8 +60,9 @@ swayc_t *replace_child(swayc_t *child, swayc_t *new_child) {
60 return parent; 60 return parent;
61} 61}
62 62
63swayc_t *remove_child(swayc_t *parent, swayc_t *child) { 63swayc_t *remove_child(swayc_t *child) {
64 int i; 64 int i;
65 swayc_t *parent = child->parent;
65 // Special case for floating views 66 // Special case for floating views
66 if (child->is_floating) { 67 if (child->is_floating) {
67 for (i = 0; i < parent->floating->length; ++i) { 68 for (i = 0; i < parent->floating->length; ++i) {
@@ -79,7 +80,11 @@ swayc_t *remove_child(swayc_t *parent, swayc_t *child) {
79 } 80 }
80 } 81 }
81 if (parent->focused == child) { 82 if (parent->focused == child) {
82 parent->focused = NULL; 83 if (parent->children->length > 0) {
84 parent->focused = parent->children->items[i?i-1:0];
85 } else {
86 parent->focused = NULL;
87 }
83 } 88 }
84 return parent; 89 return parent;
85} 90}