summaryrefslogtreecommitdiffstats
path: root/sway/focus.c
diff options
context:
space:
mode:
authorLibravatar taiyu <taiyu.len@gmail.com>2015-08-25 13:29:33 -0700
committerLibravatar taiyu <taiyu.len@gmail.com>2015-08-25 13:29:33 -0700
commit225c2fbe5b9219fd848c2d6d11cadef9ef1b42f0 (patch)
tree3099d9e4b4f1b2491bfc0e93d9976e4e8161fd89 /sway/focus.c
parentMerge pull request #131 from nicklaswj/master (diff)
downloadsway-225c2fbe5b9219fd848c2d6d11cadef9ef1b42f0.tar.gz
sway-225c2fbe5b9219fd848c2d6d11cadef9ef1b42f0.tar.zst
sway-225c2fbe5b9219fd848c2d6d11cadef9ef1b42f0.zip
fixed segfault on exit + a little fixup of that floatfocus pr
Diffstat (limited to 'sway/focus.c')
-rw-r--r--sway/focus.c25
1 files changed, 18 insertions, 7 deletions
diff --git a/sway/focus.c b/sway/focus.c
index 1086f1a8..f7b55b27 100644
--- a/sway/focus.c
+++ b/sway/focus.c
@@ -164,14 +164,25 @@ void set_focused_container_for(swayc_t *a, swayc_t *c) {
164} 164}
165 165
166swayc_t *get_focused_view(swayc_t *parent) { 166swayc_t *get_focused_view(swayc_t *parent) {
167 while (parent && parent->type != C_VIEW) { 167 swayc_t *c = parent;
168 if (parent->type == C_WORKSPACE && parent->focused == NULL) { 168 while (c && c->type != C_VIEW) {
169 return parent; 169 if (c->type == C_WORKSPACE && c->focused == NULL) {
170 return c;
170 } 171 }
171 parent = parent->focused; 172 c = c->focused;
172 } 173 }
173 if (parent == NULL) { 174 if (c == NULL) {
174 return swayc_active_workspace_for(parent); 175 c = swayc_active_workspace_for(parent);
175 } 176 }
176 return parent; 177 return c;
178}
179
180swayc_t *get_focused_float(swayc_t *ws) {
181 if(!sway_assert(ws->type == C_WORKSPACE, "must be of workspace type")) {
182 ws = swayc_active_workspace();
183 }
184 if (ws->floating->length) {
185 return ws->floating->items[ws->floating->length - 1];
186 }
187 return NULL;
177} 188}