From cd0cdc28aa6578d0a8fb0a27c5dd07052320e734 Mon Sep 17 00:00:00 2001 From: taiyu Date: Sat, 15 Aug 2015 08:27:51 -0700 Subject: [PATCH 1/2] fixed focus --- sway/layout.c | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/sway/layout.c b/sway/layout.c index 8b9315b4..66cbde99 100644 --- a/sway/layout.c +++ b/sway/layout.c @@ -223,16 +223,20 @@ void unfocus_all(swayc_t *container) { } void focus_view(swayc_t *view) { - sway_log(L_DEBUG, "Setting focus to %p", view); - if (view->type == C_VIEW) { - wlc_view_set_state(view->handle, WLC_BIT_ACTIVATED, true); - wlc_view_bring_to_front(view->handle); - wlc_view_focus(view->handle); - } - // Propagete focus up - while (view != &root_container) { - view->parent->focused = view; - view = view->parent; + sway_log(L_DEBUG, "Setting focus for %p", view); + if (view == &root_container) { + // Propegate wayland focus down + swayc_t *child = view->focused; + while (child && child->type != C_VIEW) { + child = child->focused; + } + if (child) { + wlc_view_set_state(child->handle, WLC_BIT_ACTIVATED, true); + wlc_view_focus(child->handle); + } + return; } + view->parent->focused = view; + focus_view(view->parent); } From f3a970e24e45ede4671217b4508268dec2314b20 Mon Sep 17 00:00:00 2001 From: taiyu Date: Sat, 15 Aug 2015 08:34:09 -0700 Subject: [PATCH 2/2] fixed focus --- sway/layout.c | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/sway/layout.c b/sway/layout.c index 66cbde99..e2e91593 100644 --- a/sway/layout.c +++ b/sway/layout.c @@ -223,20 +223,17 @@ void unfocus_all(swayc_t *container) { } void focus_view(swayc_t *view) { - sway_log(L_DEBUG, "Setting focus for %p", view); - if (view == &root_container) { - // Propegate wayland focus down - swayc_t *child = view->focused; - while (child && child->type != C_VIEW) { - child = child->focused; - } - if (child) { - wlc_view_set_state(child->handle, WLC_BIT_ACTIVATED, true); - wlc_view_focus(child->handle); - } - return; + sway_log(L_DEBUG, "Setting focus for %p", view); + while (view != &root_container) { + view->parent->focused = view; + view = view->parent; + } + while (view && view->type != C_VIEW) { + view = view->focused; + } + if (view) { + wlc_view_set_state(view->handle, WLC_BIT_ACTIVATED, true); + wlc_view_focus(view->handle); } - view->parent->focused = view; - focus_view(view->parent); }