Add 'exact' option for 'splitratio' (#1245)
* Simplify getPlusMinusKeywordResult() * Add an 'exact' option for 'splitratio'
This commit is contained in:
parent
0f3214714f
commit
2daabfa0e9
7 changed files with 57 additions and 78 deletions
|
|
@ -1166,7 +1166,7 @@ void CHyprDwindleLayout::switchWindows(CWindow* pWindow, CWindow* pWindow2) {
|
|||
g_pHyprRenderer->damageWindow(pWindow2);
|
||||
}
|
||||
|
||||
void CHyprDwindleLayout::alterSplitRatioBy(CWindow* pWindow, float ratio) {
|
||||
void CHyprDwindleLayout::alterSplitRatio(CWindow* pWindow, float ratio, bool exact) {
|
||||
// window should be valid, insallah
|
||||
|
||||
const auto PNODE = getNodeFromWindow(pWindow);
|
||||
|
|
@ -1174,7 +1174,8 @@ void CHyprDwindleLayout::alterSplitRatioBy(CWindow* pWindow, float ratio) {
|
|||
if (!PNODE || !PNODE->pParent || (PNODE->isGroupMember() && PNODE->getGroupMemberCount() == g_pCompositor->getWindowsOnWorkspace(PNODE->workspaceID)))
|
||||
return;
|
||||
|
||||
PNODE->pParent->splitRatio = std::clamp(PNODE->pParent->splitRatio + ratio, 0.1f, 1.9f);
|
||||
float newRatio = exact ? ratio : PNODE->pParent->splitRatio + ratio;
|
||||
PNODE->pParent->splitRatio = std::clamp(newRatio, 0.1f, 1.9f);
|
||||
|
||||
PNODE->pParent->recalcSizePosRecursive();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ class CHyprDwindleLayout : public IHyprLayout {
|
|||
virtual std::any layoutMessage(SLayoutMessageHeader, std::string);
|
||||
virtual SWindowRenderLayoutHints requestRenderHints(CWindow*);
|
||||
virtual void switchWindows(CWindow*, CWindow*);
|
||||
virtual void alterSplitRatioBy(CWindow*, float);
|
||||
virtual void alterSplitRatio(CWindow*, float, bool);
|
||||
virtual std::string getLayoutName();
|
||||
|
||||
virtual void onEnable();
|
||||
|
|
@ -81,4 +81,4 @@ class CHyprDwindleLayout : public IHyprLayout {
|
|||
std::deque<CWindow*> getGroupMembers(CWindow*);
|
||||
|
||||
friend struct SDwindleNodeData;
|
||||
};
|
||||
};
|
||||
|
|
|
|||
|
|
@ -115,10 +115,10 @@ interface IHyprLayout {
|
|||
virtual void switchWindows(CWindow*, CWindow*) = 0;
|
||||
|
||||
/*
|
||||
Called when the user requests to change the splitratio by X
|
||||
Called when the user requests to change the splitratio by or to X
|
||||
on a window
|
||||
*/
|
||||
virtual void alterSplitRatioBy(CWindow*, float) = 0;
|
||||
virtual void alterSplitRatio(CWindow*, float, bool exact = false) = 0;
|
||||
|
||||
/*
|
||||
Called when something wants the current layout's name
|
||||
|
|
|
|||
|
|
@ -604,7 +604,7 @@ void CHyprMasterLayout::switchWindows(CWindow* pWindow, CWindow* pWindow2) {
|
|||
prepareNewFocus(pWindow2, inheritFullscreen);
|
||||
}
|
||||
|
||||
void CHyprMasterLayout::alterSplitRatioBy(CWindow* pWindow, float ratio) {
|
||||
void CHyprMasterLayout::alterSplitRatio(CWindow* pWindow, float ratio, bool exact) {
|
||||
// window should be valid, insallah
|
||||
|
||||
const auto PNODE = getNodeFromWindow(pWindow);
|
||||
|
|
@ -614,7 +614,8 @@ void CHyprMasterLayout::alterSplitRatioBy(CWindow* pWindow, float ratio) {
|
|||
|
||||
const auto PMASTER = getMasterNodeOnWorkspace(pWindow->m_iWorkspaceID);
|
||||
|
||||
PMASTER->percMaster = std::clamp(PMASTER->percMaster + ratio, 0.05f, 0.95f);
|
||||
float newRatio = exact ? ratio : PMASTER->percMaster + ratio;
|
||||
PMASTER->percMaster = std::clamp(newRatio, 0.05f, 0.95f);
|
||||
|
||||
recalculateMonitor(pWindow->m_iMonitorID);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ class CHyprMasterLayout : public IHyprLayout {
|
|||
virtual std::any layoutMessage(SLayoutMessageHeader, std::string);
|
||||
virtual SWindowRenderLayoutHints requestRenderHints(CWindow*);
|
||||
virtual void switchWindows(CWindow*, CWindow*);
|
||||
virtual void alterSplitRatioBy(CWindow*, float);
|
||||
virtual void alterSplitRatio(CWindow*, float, bool);
|
||||
virtual std::string getLayoutName();
|
||||
|
||||
virtual void onEnable();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue