mirror of
https://github.com/hyprwm/Hyprland
synced 2024-12-23 09:29:49 +01:00
Added togglesplit dispatcher
This commit is contained in:
parent
e90c1f7022
commit
50f978e518
5 changed files with 46 additions and 13 deletions
|
@ -834,3 +834,23 @@ void CHyprDwindleLayout::alterSplitRatioBy(CWindow* pWindow, float ratio) {
|
||||||
|
|
||||||
PNODE->pParent->recalcSizePosRecursive();
|
PNODE->pParent->recalcSizePosRecursive();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CHyprDwindleLayout::layoutMessage(SLayoutMessageHeader header, std::string message) {
|
||||||
|
if (message == "togglegroup")
|
||||||
|
toggleWindowGroup(header.pWindow);
|
||||||
|
else if (message == "changegroupactive")
|
||||||
|
switchGroupWindow(header.pWindow);
|
||||||
|
else if (message == "togglesplit")
|
||||||
|
toggleSplit(header.pWindow);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CHyprDwindleLayout::toggleSplit(CWindow* pWindow) {
|
||||||
|
const auto PNODE = getNodeFromWindow(pWindow);
|
||||||
|
|
||||||
|
if (!PNODE || !PNODE->pParent)
|
||||||
|
return;
|
||||||
|
|
||||||
|
PNODE->pParent->splitTop = !PNODE->pParent->splitTop;
|
||||||
|
|
||||||
|
PNODE->pParent->recalcSizePosRecursive();
|
||||||
|
}
|
|
@ -50,8 +50,7 @@ public:
|
||||||
virtual void onMouseMove(const Vector2D&);
|
virtual void onMouseMove(const Vector2D&);
|
||||||
virtual void onWindowCreatedFloating(CWindow*);
|
virtual void onWindowCreatedFloating(CWindow*);
|
||||||
virtual void fullscreenRequestForWindow(CWindow*);
|
virtual void fullscreenRequestForWindow(CWindow*);
|
||||||
virtual void toggleWindowGroup(CWindow*);
|
virtual void layoutMessage(SLayoutMessageHeader, std::string);
|
||||||
virtual void switchGroupWindow(CWindow*);
|
|
||||||
virtual SWindowRenderLayoutHints requestRenderHints(CWindow*);
|
virtual SWindowRenderLayoutHints requestRenderHints(CWindow*);
|
||||||
virtual void switchWindows(CWindow*, CWindow*);
|
virtual void switchWindows(CWindow*, CWindow*);
|
||||||
virtual void alterSplitRatioBy(CWindow*, float);
|
virtual void alterSplitRatioBy(CWindow*, float);
|
||||||
|
@ -71,5 +70,9 @@ public:
|
||||||
SDwindleNodeData* getFirstNodeOnWorkspace(const int&);
|
SDwindleNodeData* getFirstNodeOnWorkspace(const int&);
|
||||||
SDwindleNodeData* getMasterNodeOnWorkspace(const int&);
|
SDwindleNodeData* getMasterNodeOnWorkspace(const int&);
|
||||||
|
|
||||||
|
void toggleWindowGroup(CWindow*);
|
||||||
|
void switchGroupWindow(CWindow*);
|
||||||
|
void toggleSplit(CWindow*);
|
||||||
|
|
||||||
friend struct SDwindleNodeData;
|
friend struct SDwindleNodeData;
|
||||||
};
|
};
|
|
@ -8,6 +8,10 @@ struct SWindowRenderLayoutHints {
|
||||||
CColor borderColor;
|
CColor borderColor;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct SLayoutMessageHeader {
|
||||||
|
CWindow* pWindow = nullptr;
|
||||||
|
};
|
||||||
|
|
||||||
interface IHyprLayout {
|
interface IHyprLayout {
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
@ -69,16 +73,10 @@ public:
|
||||||
virtual void fullscreenRequestForWindow(CWindow*) = 0;
|
virtual void fullscreenRequestForWindow(CWindow*) = 0;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Called when the user requests a window to be made into a group,
|
Called when a dispatcher requests a custom message
|
||||||
or when they want the group to be released.
|
The layout is free to ignore.
|
||||||
Everything else is free to interpret by the layout.
|
|
||||||
*/
|
*/
|
||||||
virtual void toggleWindowGroup(CWindow*) = 0;
|
virtual void layoutMessage(SLayoutMessageHeader, std::string) = 0;
|
||||||
|
|
||||||
/*
|
|
||||||
Called when the user requests a group window switch
|
|
||||||
*/
|
|
||||||
virtual void switchGroupWindow(CWindow*) = 0;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Required to be handled, but may return just SWindowRenderLayoutHints()
|
Required to be handled, but may return just SWindowRenderLayoutHints()
|
||||||
|
|
|
@ -14,6 +14,7 @@ CKeybindManager::CKeybindManager() {
|
||||||
m_mDispatchers["movewindow"] = moveActiveTo;
|
m_mDispatchers["movewindow"] = moveActiveTo;
|
||||||
m_mDispatchers["togglegroup"] = toggleGroup;
|
m_mDispatchers["togglegroup"] = toggleGroup;
|
||||||
m_mDispatchers["changegroupactive"] = changeGroupActive;
|
m_mDispatchers["changegroupactive"] = changeGroupActive;
|
||||||
|
m_mDispatchers["togglesplit"] = toggleSplit;
|
||||||
m_mDispatchers["splitratio"] = alterSplitRatio;
|
m_mDispatchers["splitratio"] = alterSplitRatio;
|
||||||
m_mDispatchers["focusmonitor"] = focusMonitor;
|
m_mDispatchers["focusmonitor"] = focusMonitor;
|
||||||
}
|
}
|
||||||
|
@ -432,11 +433,21 @@ void CKeybindManager::moveActiveTo(std::string args) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void CKeybindManager::toggleGroup(std::string args) {
|
void CKeybindManager::toggleGroup(std::string args) {
|
||||||
g_pLayoutManager->getCurrentLayout()->toggleWindowGroup(g_pCompositor->m_pLastWindow);
|
SLayoutMessageHeader header;
|
||||||
|
header.pWindow = g_pCompositor->m_pLastWindow;
|
||||||
|
g_pLayoutManager->getCurrentLayout()->layoutMessage(header, "togglegroup");
|
||||||
}
|
}
|
||||||
|
|
||||||
void CKeybindManager::changeGroupActive(std::string args) {
|
void CKeybindManager::changeGroupActive(std::string args) {
|
||||||
g_pLayoutManager->getCurrentLayout()->switchGroupWindow(g_pCompositor->m_pLastWindow);
|
SLayoutMessageHeader header;
|
||||||
|
header.pWindow = g_pCompositor->m_pLastWindow;
|
||||||
|
g_pLayoutManager->getCurrentLayout()->layoutMessage(header, "changegroupactive");
|
||||||
|
}
|
||||||
|
|
||||||
|
void CKeybindManager::toggleSplit(std::string args) {
|
||||||
|
SLayoutMessageHeader header;
|
||||||
|
header.pWindow = g_pCompositor->m_pLastWindow;
|
||||||
|
g_pLayoutManager->getCurrentLayout()->layoutMessage(header, "togglesplit");
|
||||||
}
|
}
|
||||||
|
|
||||||
void CKeybindManager::alterSplitRatio(std::string args) {
|
void CKeybindManager::alterSplitRatio(std::string args) {
|
||||||
|
|
|
@ -44,6 +44,7 @@ private:
|
||||||
static void changeGroupActive(std::string);
|
static void changeGroupActive(std::string);
|
||||||
static void alterSplitRatio(std::string);
|
static void alterSplitRatio(std::string);
|
||||||
static void focusMonitor(std::string);
|
static void focusMonitor(std::string);
|
||||||
|
static void toggleSplit(std::string);
|
||||||
};
|
};
|
||||||
|
|
||||||
inline std::unique_ptr<CKeybindManager> g_pKeybindManager;
|
inline std::unique_ptr<CKeybindManager> g_pKeybindManager;
|
Loading…
Reference in a new issue