Added togglesplit dispatcher

This commit is contained in:
vaxerski 2022-05-16 17:37:46 +02:00
parent e90c1f7022
commit 50f978e518
5 changed files with 46 additions and 13 deletions

View file

@ -832,5 +832,25 @@ void CHyprDwindleLayout::alterSplitRatioBy(CWindow* pWindow, float ratio) {
PNODE->pParent->splitRatio = std::clamp(PNODE->pParent->splitRatio + ratio, 0.1f, 1.9f);
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();
}

View file

@ -50,8 +50,7 @@ public:
virtual void onMouseMove(const Vector2D&);
virtual void onWindowCreatedFloating(CWindow*);
virtual void fullscreenRequestForWindow(CWindow*);
virtual void toggleWindowGroup(CWindow*);
virtual void switchGroupWindow(CWindow*);
virtual void layoutMessage(SLayoutMessageHeader, std::string);
virtual SWindowRenderLayoutHints requestRenderHints(CWindow*);
virtual void switchWindows(CWindow*, CWindow*);
virtual void alterSplitRatioBy(CWindow*, float);
@ -71,5 +70,9 @@ public:
SDwindleNodeData* getFirstNodeOnWorkspace(const int&);
SDwindleNodeData* getMasterNodeOnWorkspace(const int&);
void toggleWindowGroup(CWindow*);
void switchGroupWindow(CWindow*);
void toggleSplit(CWindow*);
friend struct SDwindleNodeData;
};

View file

@ -8,6 +8,10 @@ struct SWindowRenderLayoutHints {
CColor borderColor;
};
struct SLayoutMessageHeader {
CWindow* pWindow = nullptr;
};
interface IHyprLayout {
public:
@ -69,16 +73,10 @@ public:
virtual void fullscreenRequestForWindow(CWindow*) = 0;
/*
Called when the user requests a window to be made into a group,
or when they want the group to be released.
Everything else is free to interpret by the layout.
Called when a dispatcher requests a custom message
The layout is free to ignore.
*/
virtual void toggleWindowGroup(CWindow*) = 0;
/*
Called when the user requests a group window switch
*/
virtual void switchGroupWindow(CWindow*) = 0;
virtual void layoutMessage(SLayoutMessageHeader, std::string) = 0;
/*
Required to be handled, but may return just SWindowRenderLayoutHints()