diff --git a/src/Hy3Layout.cpp b/src/Hy3Layout.cpp index 42ad550..bc17624 100644 --- a/src/Hy3Layout.cpp +++ b/src/Hy3Layout.cpp @@ -551,10 +551,15 @@ CWindow* Hy3Layout::getNextWindowCandidate(CWindow* window) { void Hy3Layout::onWindowFocusChange(CWindow* window) { Debug::log(LOG, "Switched windows from %p to %p", this->lastActiveWindow, window); - auto* node = this->getNodeFromWindow(this->lastActiveWindow); - if (node != nullptr) Debug::log(LOG, "Switched focused node to %p (parent: %p)", node, node->parent); - this->lastActiveWindow = window; + auto* node = this->getNodeFromWindow(this->lastActiveWindow); + if (node == nullptr) return; + Debug::log(LOG, "Switched focused node to %p (parent: %p)", node, node->parent); + + while (node->parent != nullptr) { + node->parent->data.as_group.lastFocusedChild = node; + node = node->parent; + } } bool Hy3Layout::isWindowTiled(CWindow* window) {