From 120a9c33d1966cd7965a57b7c759c44276ccc2eb Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Sat, 22 Jul 2023 23:11:07 +0200 Subject: [PATCH] Don't focus a window when inserting to group The changes the behavior of groupCreate function when adding each of the dwindle child node windows into a group, to no longer also focus them, only to later refocus back on the original group's head/visible window. This was impossible before, as the CWindow::insertWindowToGroup function automatically made the inserted window the group's head/current window, however since that's no longer the case - see the previous commit: c1c883a237c58b8736f1f46f383490f0621b136c it is now possible to remove this janky behavior for a much cleaner one, where the window is simply moved into a group and marked as hidden immediately. --- src/main.cpp | 28 +++++++--------------------- 1 file changed, 7 insertions(+), 21 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 03ee7da..a45e4e7 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -73,34 +73,20 @@ void groupCreate(const SDwindleNodeData* PNODE, CHyprDwindleLayout* layout) } // Add all of the children nodes into the group - // (This is mostly copied logic from CKeybindManager::moveIntoGroup. Note that it - // includes support for the child node to be in another group, in which case only - // this window if moved out of that group and into this one. We don't actually - // need this logic now, because we don't support nested groups though) + // This is partially from CKeybindManager::moveIntoGroup (dispatcher) function + // but without making the new window focused. for (auto& n : newGroupMembers) { auto window = n->pWindow; - // Create a group bar decoration for the window - // (assuming it's not already in a group, in which case it should have one) - if (!window->m_sGroupData.pNextWindow) - window->m_dWindowDecorations.emplace_back(std::make_unique(window)); - - g_pLayoutManager->getCurrentLayout()->onWindowRemoved(window); // This removes groupped property! - - window->m_sGroupData.locked = false; - window->m_sGroupData.head = false; + // Remove this window from being shown by layout (it will become a part of a group) + g_pLayoutManager->getCurrentLayout()->onWindowRemoved(window); PWINDOW->insertWindowToGroup(window); - PWINDOW->setGroupCurrent(window); - window->updateWindowDecos(); - g_pLayoutManager->getCurrentLayout()->recalculateWindow(window); - g_pCompositor->focusWindow(window); + // Make sure to treat this window as hidden (will focus the group instead of this window + // on request activate). This is the behavior CWindow::setGroupCurrent uses. + window->setHidden(true); } - - // Moving new windows into group makes them the active window in that group, - // refocus the original window - PWINDOW->setGroupCurrent(PWINDOW); } void toggleGroup(std::string args)