Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Save restore dwindle layout #9054

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
feat:Added dwindle layoutmsg handler for specifying the opening node …
…of a new tile
Natr1x committed Jan 10, 2025
commit 8855934511cd4f14db117cca62b9ded3e51c4daf
67 changes: 66 additions & 1 deletion src/layout/DwindleLayout.cpp
Original file line number Diff line number Diff line change
@@ -244,13 +244,18 @@ void CHyprDwindleLayout::onWindowCreatedTiling(PHLWINDOW pWindow, eDirection dir
const auto MOUSECOORDS = m_vOverrideFocalPoint.value_or(g_pInputManager->getMouseCoordsInternal());
const auto MONFROMCURSOR = g_pCompositor->getMonitorFromVector(MOUSECOORDS);

if (PMONITOR->ID == MONFROMCURSOR->ID &&
if (m_pOpenNextOn && m_pOpenNextOn->valid && m_pOpenNextOn->workspaceID == pWindow->workspaceID()) {
OPENINGON = m_pOpenNextOn;
m_pOpenNextOn = nullptr;

} else if (PMONITOR->ID == MONFROMCURSOR->ID &&
(PNODE->workspaceID == PMONITOR->activeWorkspaceID() || (g_pCompositor->isWorkspaceSpecial(PNODE->workspaceID) && PMONITOR->activeSpecialWorkspace)) && !*PUSEACTIVE) {
OPENINGON = getNodeFromWindow(g_pCompositor->vectorToWindowUnified(MOUSECOORDS, RESERVED_EXTENTS | INPUT_EXTENTS));

if (!OPENINGON && g_pCompositor->isPointOnReservedArea(MOUSECOORDS, PMONITOR))
OPENINGON = getClosestNodeOnWorkspace(PNODE->workspaceID, MOUSECOORDS);


} else if (*PUSEACTIVE) {
if (g_pCompositor->m_pLastWindow.lock() && !g_pCompositor->m_pLastWindow->m_bIsFloating && g_pCompositor->m_pLastWindow.lock() != pWindow &&
g_pCompositor->m_pLastWindow->m_pWorkspace == pWindow->m_pWorkspace && g_pCompositor->m_pLastWindow->m_bIsMapped) {
@@ -455,6 +460,7 @@ void CHyprDwindleLayout::onWindowRemovedTiling(PHLWINDOW pWindow) {
if (!PPARENT) {
Debug::log(LOG, "Removing last node (dwindle)");
m_lDwindleNodesData.remove(*PNODE);
m_pOpenNextOn = nullptr;
return;
}

@@ -479,6 +485,9 @@ void CHyprDwindleLayout::onWindowRemovedTiling(PHLWINDOW pWindow) {
else
PSIBLING->recalcSizePosRecursive();

if (PPARENT == m_pOpenNextOn || PNODE == m_pOpenNextOn)
m_pOpenNextOn = nullptr;

m_lDwindleNodesData.remove(*PPARENT);
m_lDwindleNodesData.remove(*PNODE);
}
@@ -968,6 +977,61 @@ std::any CHyprDwindleLayout::layoutMessage(SLayoutMessageHeader header, std::str
break;
}
}
} else if (ARGS[0] == "opennexton") {
const auto RELATION = ARGS[1];
const auto WINDOW = ARGS[2].empty() ? header.pWindow : g_pCompositor->getWindowByRegex(ARGS[2]);
auto pNode = getNodeFromWindow(WINDOW);
for (const auto c : RELATION) {
if (!pNode || !pNode->valid) break;

switch (c) {
case '^': {
// Step to the parent of the current node
pNode = pNode->pParent;
break;
}

case 'c': {
// Clear anything previously set
m_pOpenNextOn = nullptr;
return "";
}

case '.': {
// Steps nowhere (if you simply want to use the second argument)
break;
}

case '0': {
// Step to the first child
pNode = pNode->children[0];
break;
}

case '1': {
// Step to the second child
pNode = pNode->children[1];
break;
}

case '/': {
// Step to the root of the current node's workspace
pNode = getMasterNodeOnWorkspace(pNode->workspaceID);
break;
}

default: {
Debug::log(ERR, "Unknown relation operator");
return "";
}
}
}

if (pNode && pNode->valid)
m_pOpenNextOn = pNode;
else
Debug::log(ERR, "Invalid dwindle node");

}

return "";
@@ -1065,6 +1129,7 @@ void CHyprDwindleLayout::onEnable() {

void CHyprDwindleLayout::onDisable() {
m_lDwindleNodesData.clear();
m_pOpenNextOn = nullptr;
}

Vector2D CHyprDwindleLayout::predictSizeForNewWindowTiled() {
1 change: 1 addition & 0 deletions src/layout/DwindleLayout.hpp
Original file line number Diff line number Diff line change
@@ -89,6 +89,7 @@ class CHyprDwindleLayout : public IHyprLayout {
void moveToRoot(PHLWINDOW, bool stable = true);

eDirection overrideDirection = DIRECTION_DEFAULT;
SDwindleNodeData* m_pOpenNextOn = nullptr;

friend struct SDwindleNodeData;
};