aboutsummaryrefslogtreecommitdiff
path: root/sway/focus.c
diff options
context:
space:
mode:
authortaiyu <taiyu.len@gmail.com>2015-08-25 13:29:33 -0700
committertaiyu <taiyu.len@gmail.com>2015-08-25 13:29:33 -0700
commit225c2fbe5b9219fd848c2d6d11cadef9ef1b42f0 (patch)
tree3099d9e4b4f1b2491bfc0e93d9976e4e8161fd89 /sway/focus.c
parent0bf380a0b1a83f49e2e33066ab6504d308dcec89 (diff)
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) {
}
swayc_t *get_focused_view(swayc_t *parent) {
- while (parent && parent->type != C_VIEW) {
- if (parent->type == C_WORKSPACE && parent->focused == NULL) {
- return parent;
+ swayc_t *c = parent;
+ while (c && c->type != C_VIEW) {
+ if (c->type == C_WORKSPACE && c->focused == NULL) {
+ return c;
}
- parent = parent->focused;
+ c = c->focused;
}
- if (parent == NULL) {
- return swayc_active_workspace_for(parent);
+ if (c == NULL) {
+ c = swayc_active_workspace_for(parent);
}
- return parent;
+ return c;
+}
+
+swayc_t *get_focused_float(swayc_t *ws) {
+ if(!sway_assert(ws->type == C_WORKSPACE, "must be of workspace type")) {
+ ws = swayc_active_workspace();
+ }
+ if (ws->floating->length) {
+ return ws->floating->items[ws->floating->length - 1];
+ }
+ return NULL;
}