mirror of
https://github.com/hyprwm/Hyprland
synced 2024-12-23 09:29:49 +01:00
add config option to enable/disable new intuitive resizing (#2774)
dwindle:smart_resizing = 1 by default == 1 then use new resizing else use old resizing
This commit is contained in:
parent
d3bba2489d
commit
9845f99b60
2 changed files with 110 additions and 50 deletions
|
@ -160,6 +160,7 @@ void CConfigManager::setDefaultVars() {
|
||||||
configValues["dwindle:use_active_for_splits"].intValue = 1;
|
configValues["dwindle:use_active_for_splits"].intValue = 1;
|
||||||
configValues["dwindle:default_split_ratio"].floatValue = 1.f;
|
configValues["dwindle:default_split_ratio"].floatValue = 1.f;
|
||||||
configValues["dwindle:smart_split"].intValue = 0;
|
configValues["dwindle:smart_split"].intValue = 0;
|
||||||
|
configValues["dwindle:smart_resizing"].intValue = 1;
|
||||||
|
|
||||||
configValues["master:special_scale_factor"].floatValue = 0.8f;
|
configValues["master:special_scale_factor"].floatValue = 0.8f;
|
||||||
configValues["master:mfact"].floatValue = 0.55f;
|
configValues["master:mfact"].floatValue = 0.55f;
|
||||||
|
|
|
@ -607,6 +607,7 @@ void CHyprDwindleLayout::resizeActiveWindow(const Vector2D& pixResize, eRectCorn
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto PANIMATE = &g_pConfigManager->getConfigValuePtr("misc:animate_manual_resizes")->intValue;
|
const auto PANIMATE = &g_pConfigManager->getConfigValuePtr("misc:animate_manual_resizes")->intValue;
|
||||||
|
const auto PSMARTRESIZING = &g_pConfigManager->getConfigValuePtr("dwindle:smart_resizing")->intValue;
|
||||||
|
|
||||||
// get some data about our window
|
// get some data about our window
|
||||||
const auto PMONITOR = g_pCompositor->getMonitorFromID(PWINDOW->m_iMonitorID);
|
const auto PMONITOR = g_pCompositor->getMonitorFromID(PWINDOW->m_iMonitorID);
|
||||||
|
@ -661,8 +662,8 @@ void CHyprDwindleLayout::resizeActiveWindow(const Vector2D& pixResize, eRectCorn
|
||||||
if (DISPLAYBOTTOM && DISPLAYTOP)
|
if (DISPLAYBOTTOM && DISPLAYTOP)
|
||||||
allowedMovement.y = 0;
|
allowedMovement.y = 0;
|
||||||
|
|
||||||
// Identify inner and outer nodes for both directions.
|
if (*PSMARTRESIZING == 1) {
|
||||||
|
// Identify inner and outer nodes for both directions
|
||||||
SDwindleNodeData* PVOUTER = nullptr;
|
SDwindleNodeData* PVOUTER = nullptr;
|
||||||
SDwindleNodeData* PVINNER = nullptr;
|
SDwindleNodeData* PVINNER = nullptr;
|
||||||
SDwindleNodeData* PHOUTER = nullptr;
|
SDwindleNodeData* PHOUTER = nullptr;
|
||||||
|
@ -719,6 +720,64 @@ void CHyprDwindleLayout::resizeActiveWindow(const Vector2D& pixResize, eRectCorn
|
||||||
} else
|
} else
|
||||||
PVOUTER->pParent->recalcSizePosRecursive(*PANIMATE == 0);
|
PVOUTER->pParent->recalcSizePosRecursive(*PANIMATE == 0);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
// get the correct containers to apply splitratio to
|
||||||
|
const auto PPARENT = PNODE->pParent;
|
||||||
|
|
||||||
|
if (!PPARENT)
|
||||||
|
return; // the only window on a workspace, ignore
|
||||||
|
|
||||||
|
const bool PARENTSIDEBYSIDE = !PPARENT->splitTop;
|
||||||
|
|
||||||
|
// Get the parent's parent
|
||||||
|
auto PPARENT2 = PPARENT->pParent;
|
||||||
|
|
||||||
|
// No parent means we have only 2 windows, and thus one axis of freedom
|
||||||
|
if (!PPARENT2) {
|
||||||
|
if (PARENTSIDEBYSIDE) {
|
||||||
|
allowedMovement.x *= 2.f / PPARENT->size.x;
|
||||||
|
PPARENT->splitRatio = std::clamp(PPARENT->splitRatio + allowedMovement.x, 0.1, 1.9);
|
||||||
|
PPARENT->recalcSizePosRecursive(*PANIMATE == 0);
|
||||||
|
} else {
|
||||||
|
allowedMovement.y *= 2.f / PPARENT->size.y;
|
||||||
|
PPARENT->splitRatio = std::clamp(PPARENT->splitRatio + allowedMovement.y, 0.1, 1.9);
|
||||||
|
PPARENT->recalcSizePosRecursive(*PANIMATE == 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get first parent with other split
|
||||||
|
while (PPARENT2 && PPARENT2->splitTop == !PARENTSIDEBYSIDE)
|
||||||
|
PPARENT2 = PPARENT2->pParent;
|
||||||
|
|
||||||
|
// no parent, one axis of freedom
|
||||||
|
if (!PPARENT2) {
|
||||||
|
if (PARENTSIDEBYSIDE) {
|
||||||
|
allowedMovement.x *= 2.f / PPARENT->size.x;
|
||||||
|
PPARENT->splitRatio = std::clamp(PPARENT->splitRatio + allowedMovement.x, 0.1, 1.9);
|
||||||
|
PPARENT->recalcSizePosRecursive(*PANIMATE == 0);
|
||||||
|
} else {
|
||||||
|
allowedMovement.y *= 2.f / PPARENT->size.y;
|
||||||
|
PPARENT->splitRatio = std::clamp(PPARENT->splitRatio + allowedMovement.y, 0.1, 1.9);
|
||||||
|
PPARENT->recalcSizePosRecursive(*PANIMATE == 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 2 axes of freedom
|
||||||
|
const auto SIDECONTAINER = PARENTSIDEBYSIDE ? PPARENT : PPARENT2;
|
||||||
|
const auto TOPCONTAINER = PARENTSIDEBYSIDE ? PPARENT2 : PPARENT;
|
||||||
|
|
||||||
|
allowedMovement.x *= 2.f / SIDECONTAINER->size.x;
|
||||||
|
allowedMovement.y *= 2.f / TOPCONTAINER->size.y;
|
||||||
|
|
||||||
|
SIDECONTAINER->splitRatio = std::clamp(SIDECONTAINER->splitRatio + allowedMovement.x, 0.1, 1.9);
|
||||||
|
TOPCONTAINER->splitRatio = std::clamp(TOPCONTAINER->splitRatio + allowedMovement.y, 0.1, 1.9);
|
||||||
|
SIDECONTAINER->recalcSizePosRecursive(*PANIMATE == 0);
|
||||||
|
TOPCONTAINER->recalcSizePosRecursive(*PANIMATE == 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CHyprDwindleLayout::fullscreenRequestForWindow(CWindow* pWindow, eFullscreenMode fullscreenMode, bool on) {
|
void CHyprDwindleLayout::fullscreenRequestForWindow(CWindow* pWindow, eFullscreenMode fullscreenMode, bool on) {
|
||||||
|
|
Loading…
Reference in a new issue