summaryrefslogtreecommitdiffstats
path: root/sway/layout.c
diff options
context:
space:
mode:
Diffstat (limited to 'sway/layout.c')
-rw-r--r--sway/layout.c31
1 files changed, 25 insertions, 6 deletions
diff --git a/sway/layout.c b/sway/layout.c
index 20b5999c..a6d6fcbb 100644
--- a/sway/layout.c
+++ b/sway/layout.c
@@ -238,15 +238,17 @@ void unfocus_all(swayc_t *container) {
238 238
239void focus_view(swayc_t *view) { 239void focus_view(swayc_t *view) {
240 sway_log(L_DEBUG, "Setting focus for %p", view); 240 sway_log(L_DEBUG, "Setting focus for %p", view);
241 while (view != &root_container) { 241 swayc_t *c = view;
242 view->parent->focused = view; 242 //Set focus from root to view
243 view = view->parent; 243 while (c != &root_container) {
244 c->parent->focused = c;
245 c = c->parent;
244 } 246 }
247 //Set output
248 wlc_output_focus(c->focused->handle);
249 //get focus for views focused window
245 while (view && view->type != C_VIEW) { 250 while (view && view->type != C_VIEW) {
246 view = view->focused; 251 view = view->focused;
247 if (view && view->type == C_OUTPUT) {
248 wlc_output_focus(view->handle);
249 }
250 } 252 }
251 if (view) { 253 if (view) {
252 wlc_view_set_state(view->handle, WLC_BIT_ACTIVATED, true); 254 wlc_view_set_state(view->handle, WLC_BIT_ACTIVATED, true);
@@ -254,3 +256,20 @@ void focus_view(swayc_t *view) {
254 } 256 }
255} 257}
256 258
259void focus_view_for(swayc_t *top, swayc_t *view) {
260 swayc_t *find = view;
261 //Make sure top is a ancestor of view
262 while (find != top) {
263 if (find == &root_container) {
264 return;
265 }
266 find = find->parent;
267 }
268 //Set focus for top to go to view
269 while (view != top) {
270 view->parent->focused = view;
271 view = view->parent;
272 }
273}
274
275