diff options
Diffstat (limited to 'sway/focus.c')
-rw-r--r-- | sway/focus.c | 25 |
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 | ||
166 | swayc_t *get_focused_view(swayc_t *parent) { | 166 | swayc_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 | |||
180 | swayc_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 | } |