mirror of
https://github.com/hyprwm/Hyprland
synced 2024-11-22 16:25:59 +01:00
dwindle: add swapsplit dispatcher (#4702)
This is distinct from `swapwindow` in that it allows swapping the entire tree node with its neighbour. Fixes: https://github.com/hyprwm/Hyprland/issues/4701
This commit is contained in:
parent
0608791480
commit
d5950f7719
4 changed files with 34 additions and 0 deletions
|
@ -996,6 +996,8 @@ std::any CHyprDwindleLayout::layoutMessage(SLayoutMessageHeader header, std::str
|
|||
const auto ARGS = CVarList(message, 0, ' ');
|
||||
if (ARGS[0] == "togglesplit") {
|
||||
toggleSplit(header.pWindow);
|
||||
} else if (ARGS[0] == "swapsplit") {
|
||||
swapSplit(header.pWindow);
|
||||
} else if (ARGS[0] == "preselect") {
|
||||
std::string direction = ARGS[1];
|
||||
|
||||
|
@ -1049,6 +1051,20 @@ void CHyprDwindleLayout::toggleSplit(CWindow* pWindow) {
|
|||
PNODE->pParent->recalcSizePosRecursive();
|
||||
}
|
||||
|
||||
void CHyprDwindleLayout::swapSplit(CWindow* pWindow) {
|
||||
const auto PNODE = getNodeFromWindow(pWindow);
|
||||
|
||||
if (!PNODE || !PNODE->pParent)
|
||||
return;
|
||||
|
||||
if (pWindow->m_bIsFullscreen)
|
||||
return;
|
||||
|
||||
std::swap(PNODE->pParent->children[0], PNODE->pParent->children[1]);
|
||||
|
||||
PNODE->pParent->recalcSizePosRecursive();
|
||||
}
|
||||
|
||||
void CHyprDwindleLayout::replaceWindowDataWith(CWindow* from, CWindow* to) {
|
||||
const auto PNODE = getNodeFromWindow(from);
|
||||
|
||||
|
|
|
@ -83,6 +83,7 @@ class CHyprDwindleLayout : public IHyprLayout {
|
|||
SDwindleNodeData* getMasterNodeOnWorkspace(const int&);
|
||||
|
||||
void toggleSplit(CWindow*);
|
||||
void swapSplit(CWindow*);
|
||||
|
||||
eDirection overrideDirection = DIRECTION_DEFAULT;
|
||||
|
||||
|
|
|
@ -39,6 +39,7 @@ CKeybindManager::CKeybindManager() {
|
|||
m_mDispatchers["changegroupactive"] = changeGroupActive;
|
||||
m_mDispatchers["movegroupwindow"] = moveGroupWindow;
|
||||
m_mDispatchers["togglesplit"] = toggleSplit;
|
||||
m_mDispatchers["swapsplit"] = swapSplit;
|
||||
m_mDispatchers["splitratio"] = alterSplitRatio;
|
||||
m_mDispatchers["focusmonitor"] = focusMonitor;
|
||||
m_mDispatchers["movecursortocorner"] = moveCursorToCorner;
|
||||
|
@ -1286,6 +1287,21 @@ void CKeybindManager::toggleSplit(std::string args) {
|
|||
g_pLayoutManager->getCurrentLayout()->layoutMessage(header, "togglesplit");
|
||||
}
|
||||
|
||||
void CKeybindManager::swapSplit(std::string args) {
|
||||
SLayoutMessageHeader header;
|
||||
header.pWindow = g_pCompositor->m_pLastWindow;
|
||||
|
||||
if (!header.pWindow)
|
||||
return;
|
||||
|
||||
const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(header.pWindow->m_iWorkspaceID);
|
||||
|
||||
if (PWORKSPACE->m_bHasFullscreenWindow)
|
||||
return;
|
||||
|
||||
g_pLayoutManager->getCurrentLayout()->layoutMessage(header, "swapsplit");
|
||||
}
|
||||
|
||||
void CKeybindManager::alterSplitRatio(std::string args) {
|
||||
std::optional<float> splitResult;
|
||||
bool exact = false;
|
||||
|
|
|
@ -127,6 +127,7 @@ class CKeybindManager {
|
|||
static void alterSplitRatio(std::string);
|
||||
static void focusMonitor(std::string);
|
||||
static void toggleSplit(std::string);
|
||||
static void swapSplit(std::string);
|
||||
static void moveCursorToCorner(std::string);
|
||||
static void moveCursor(std::string);
|
||||
static void workspaceOpt(std::string);
|
||||
|
|
Loading…
Reference in a new issue