mirror of
https://github.com/hyprwm/Hyprland.git
synced 2024-09-11 21:27:20 +03:00
master: Fix the wrong resize speed in master layout center orientation (#3289)
* rebase * change isStackVertical variable to make it more readable * fix some code getting unnecessarily repeating in a loop
This commit is contained in:
parent
4f88897fc0
commit
2ad429dfe0
@ -327,13 +327,13 @@ void CHyprMasterLayout::calculateWorkspace(const int& ws) {
|
|||||||
float nextX = 0;
|
float nextX = 0;
|
||||||
float nextY = 0;
|
float nextY = 0;
|
||||||
|
|
||||||
|
if (orientation == ORIENTATION_BOTTOM)
|
||||||
|
nextY = WSSIZE.y - HEIGHT;
|
||||||
|
|
||||||
for (auto& nd : m_lMasterNodesData) {
|
for (auto& nd : m_lMasterNodesData) {
|
||||||
if (nd.workspaceID != PWORKSPACE->m_iID || !nd.isMaster)
|
if (nd.workspaceID != PWORKSPACE->m_iID || !nd.isMaster)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (orientation == ORIENTATION_BOTTOM)
|
|
||||||
nextY = WSSIZE.y - HEIGHT;
|
|
||||||
|
|
||||||
float WIDTH = mastersLeft > 1 ? widthLeft / mastersLeft * nd.percSize : widthLeft;
|
float WIDTH = mastersLeft > 1 ? widthLeft / mastersLeft * nd.percSize : widthLeft;
|
||||||
if (WIDTH > widthLeft * 0.9f && mastersLeft > 1)
|
if (WIDTH > widthLeft * 0.9f && mastersLeft > 1)
|
||||||
WIDTH = widthLeft * 0.9f;
|
WIDTH = widthLeft * 0.9f;
|
||||||
@ -679,8 +679,13 @@ void CHyprMasterLayout::resizeActiveWindow(const Vector2D& pixResize, eRectCorne
|
|||||||
const bool DISPLAYTOP = STICKS(PWINDOW->m_vPosition.y, PMONITOR->vecPosition.y + PMONITOR->vecReservedTopLeft.y);
|
const bool DISPLAYTOP = STICKS(PWINDOW->m_vPosition.y, PMONITOR->vecPosition.y + PMONITOR->vecReservedTopLeft.y);
|
||||||
const bool DISPLAYLEFT = STICKS(PWINDOW->m_vPosition.x, PMONITOR->vecPosition.x + PMONITOR->vecReservedTopLeft.x);
|
const bool DISPLAYLEFT = STICKS(PWINDOW->m_vPosition.x, PMONITOR->vecPosition.x + PMONITOR->vecReservedTopLeft.x);
|
||||||
|
|
||||||
const bool LEFT = corner == CORNER_TOPLEFT || corner == CORNER_BOTTOMLEFT;
|
const bool LEFT = corner == CORNER_TOPLEFT || corner == CORNER_BOTTOMLEFT;
|
||||||
const bool TOP = corner == CORNER_TOPLEFT || corner == CORNER_TOPRIGHT;
|
const bool TOP = corner == CORNER_TOPLEFT || corner == CORNER_TOPRIGHT;
|
||||||
|
const bool NONE = corner == CORNER_NONE;
|
||||||
|
|
||||||
|
const auto MASTERS = getMastersOnWorkspace(PNODE->workspaceID);
|
||||||
|
const auto WINDOWS = getNodesOnWorkspace(PNODE->workspaceID);
|
||||||
|
const auto STACKWINDOWS = WINDOWS - MASTERS;
|
||||||
|
|
||||||
if (getNodesOnWorkspace(PWINDOW->m_iWorkspaceID) == 1 && !centered)
|
if (getNodesOnWorkspace(PWINDOW->m_iWorkspaceID) == 1 && !centered)
|
||||||
return;
|
return;
|
||||||
@ -692,7 +697,15 @@ void CHyprMasterLayout::resizeActiveWindow(const Vector2D& pixResize, eRectCorne
|
|||||||
case ORIENTATION_RIGHT: delta = -pixResize.x / PMONITOR->vecSize.x; break;
|
case ORIENTATION_RIGHT: delta = -pixResize.x / PMONITOR->vecSize.x; break;
|
||||||
case ORIENTATION_BOTTOM: delta = -pixResize.y / PMONITOR->vecSize.y; break;
|
case ORIENTATION_BOTTOM: delta = -pixResize.y / PMONITOR->vecSize.y; break;
|
||||||
case ORIENTATION_TOP: delta = pixResize.y / PMONITOR->vecSize.y; break;
|
case ORIENTATION_TOP: delta = pixResize.y / PMONITOR->vecSize.y; break;
|
||||||
case ORIENTATION_CENTER: delta = pixResize.x / PMONITOR->vecSize.x; break;
|
case ORIENTATION_CENTER:
|
||||||
|
delta = pixResize.x / PMONITOR->vecSize.x;
|
||||||
|
if (WINDOWS > 2) {
|
||||||
|
if (!NONE || !PNODE->isMaster)
|
||||||
|
delta *= 2;
|
||||||
|
if ((!PNODE->isMaster && DISPLAYLEFT) || (PNODE->isMaster && LEFT && *PSMARTRESIZING))
|
||||||
|
delta = -delta;
|
||||||
|
}
|
||||||
|
break;
|
||||||
default: UNREACHABLE();
|
default: UNREACHABLE();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -702,40 +715,23 @@ void CHyprMasterLayout::resizeActiveWindow(const Vector2D& pixResize, eRectCorne
|
|||||||
}
|
}
|
||||||
|
|
||||||
// check the up/down resize
|
// check the up/down resize
|
||||||
const auto RESIZEDELTA = PWORKSPACEDATA->orientation % 2 == 1 ? pixResize.x : pixResize.y;
|
const bool isStackVertical = orientation == ORIENTATION_LEFT || orientation == ORIENTATION_RIGHT || orientation == ORIENTATION_CENTER;
|
||||||
|
|
||||||
if (!*PSMARTRESIZING) {
|
const auto RESIZEDELTA = isStackVertical ? pixResize.y : pixResize.x;
|
||||||
if (RESIZEDELTA != 0) {
|
const auto WSSIZE = PMONITOR->vecSize - PMONITOR->vecReservedTopLeft - PMONITOR->vecReservedBottomRight;
|
||||||
if (PNODE->isMaster && getMastersOnWorkspace(PNODE->workspaceID) > 1) {
|
|
||||||
// check master size
|
|
||||||
const auto SIZE = PWORKSPACEDATA->orientation % 2 == 1 ?
|
|
||||||
(PMONITOR->vecSize.x - PMONITOR->vecReservedTopLeft.x - PMONITOR->vecReservedBottomRight.x) / getMastersOnWorkspace(PNODE->workspaceID) :
|
|
||||||
(PMONITOR->vecSize.y - PMONITOR->vecReservedTopLeft.y - PMONITOR->vecReservedBottomRight.y) / getMastersOnWorkspace(PNODE->workspaceID);
|
|
||||||
PNODE->percSize = std::clamp(PNODE->percSize + RESIZEDELTA / SIZE, 0.05, 1.95);
|
|
||||||
} else if (!PNODE->isMaster && (getNodesOnWorkspace(PWINDOW->m_iWorkspaceID) - getMastersOnWorkspace(PNODE->workspaceID)) > 1) {
|
|
||||||
const auto SIZE = PWORKSPACEDATA->orientation % 2 == 1 ? (PMONITOR->vecSize.x - PMONITOR->vecReservedTopLeft.x - PMONITOR->vecReservedBottomRight.x) /
|
|
||||||
(getNodesOnWorkspace(PNODE->workspaceID) - getMastersOnWorkspace(PNODE->workspaceID)) :
|
|
||||||
(PMONITOR->vecSize.y - PMONITOR->vecReservedTopLeft.y - PMONITOR->vecReservedBottomRight.y) /
|
|
||||||
(getNodesOnWorkspace(PNODE->workspaceID) - getMastersOnWorkspace(PNODE->workspaceID));
|
|
||||||
PNODE->percSize = std::clamp(PNODE->percSize + RESIZEDELTA / SIZE, 0.05, 1.95);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
const auto MASTERS = getMastersOnWorkspace(PNODE->workspaceID);
|
|
||||||
const auto WINDOWS = getNodesOnWorkspace(PNODE->workspaceID);
|
|
||||||
const auto STACKWINDOWS = WINDOWS - MASTERS;
|
|
||||||
const auto WSSIZE = PMONITOR->vecSize - PMONITOR->vecReservedTopLeft - PMONITOR->vecReservedBottomRight;
|
|
||||||
|
|
||||||
const bool isStackVertical = orientation % 2 == 0;
|
auto nodesInSameColumn = PNODE->isMaster ? MASTERS : STACKWINDOWS;
|
||||||
auto nodesInSameColumn = PNODE->isMaster ? MASTERS : STACKWINDOWS;
|
if (orientation == ORIENTATION_CENTER && !PNODE->isMaster)
|
||||||
if (orientation == ORIENTATION_CENTER && !PNODE->isMaster)
|
nodesInSameColumn = DISPLAYRIGHT ? (nodesInSameColumn + 1) / 2 : nodesInSameColumn / 2;
|
||||||
nodesInSameColumn /= 2;
|
|
||||||
|
|
||||||
if (RESIZEDELTA != 0 && nodesInSameColumn > 1) {
|
const auto SIZE = isStackVertical ? WSSIZE.y / nodesInSameColumn : WSSIZE.x / nodesInSameColumn;
|
||||||
const auto NODEIT = std::find(m_lMasterNodesData.begin(), m_lMasterNodesData.end(), *PNODE);
|
|
||||||
const auto REVNODEIT = std::find(m_lMasterNodesData.rbegin(), m_lMasterNodesData.rend(), *PNODE);
|
if (RESIZEDELTA != 0 && nodesInSameColumn > 1) {
|
||||||
const auto SIZE = isStackVertical ? (PMONITOR->vecSize.y - PMONITOR->vecReservedTopLeft.y - PMONITOR->vecReservedBottomRight.y) / nodesInSameColumn :
|
if (!*PSMARTRESIZING) {
|
||||||
(PMONITOR->vecSize.x - PMONITOR->vecReservedTopLeft.x - PMONITOR->vecReservedBottomRight.x) / nodesInSameColumn;
|
PNODE->percSize = std::clamp(PNODE->percSize + RESIZEDELTA / SIZE, 0.05, 1.95);
|
||||||
|
} else {
|
||||||
|
const auto NODEIT = std::find(m_lMasterNodesData.begin(), m_lMasterNodesData.end(), *PNODE);
|
||||||
|
const auto REVNODEIT = std::find(m_lMasterNodesData.rbegin(), m_lMasterNodesData.rend(), *PNODE);
|
||||||
|
|
||||||
const float totalSize = isStackVertical ? WSSIZE.y : WSSIZE.x;
|
const float totalSize = isStackVertical ? WSSIZE.y : WSSIZE.x;
|
||||||
const float minSize = totalSize / nodesInSameColumn * 0.2;
|
const float minSize = totalSize / nodesInSameColumn * 0.2;
|
||||||
|
Loading…
Reference in New Issue
Block a user