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:
c1c883a237 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.
This commit is contained in:
ItsDrike 2023-07-22 23:11:07 +02:00
parent c1c883a237
commit 120a9c33d1
Signed by: ItsDrike
GPG key ID: FA2745890B7048C0

View file

@ -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<CHyprGroupBarDecoration>(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)