mirror of
https://github.com/hyprwm/Hyprland
synced 2024-11-26 22:45:59 +01:00
Added resizing individual master windows
This commit is contained in:
parent
f41fe59cb6
commit
34b145ee65
2 changed files with 42 additions and 16 deletions
|
@ -198,32 +198,44 @@ void CHyprMasterLayout::calculateWorkspace(const int& ws) {
|
||||||
applyNodeDataToWindow(PMASTERNODE);
|
applyNodeDataToWindow(PMASTERNODE);
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
int masterno = 0;
|
float heightLeft = PMONITOR->vecSize.y - PMONITOR->vecReservedBottomRight.y - PMONITOR->vecReservedTopLeft.y;
|
||||||
const float HEIGHTOFMASTER = PMONITOR->vecSize.y - PMONITOR->vecReservedBottomRight.y - PMONITOR->vecReservedTopLeft.y;
|
int nodesLeft = MASTERS;
|
||||||
|
float nextY = 0;
|
||||||
|
|
||||||
for (auto& n : m_lMasterNodesData) {
|
for (auto& n : m_lMasterNodesData) {
|
||||||
if (n.workspaceID == PWORKSPACE->m_iID && n.isMaster) {
|
if (n.workspaceID == PWORKSPACE->m_iID && n.isMaster) {
|
||||||
n.position = PMONITOR->vecReservedTopLeft + PMONITOR->vecPosition + Vector2D(0, masterno * (HEIGHTOFMASTER / MASTERS));
|
n.position = PMONITOR->vecReservedTopLeft + PMONITOR->vecPosition + Vector2D(0, nextY);
|
||||||
n.size = Vector2D((PMONITOR->vecSize.x - PMONITOR->vecReservedTopLeft.x - PMONITOR->vecReservedBottomRight.x) * PMASTERNODE->percMaster, HEIGHTOFMASTER / MASTERS);
|
float HEIGHT = nodesLeft > 1 ? heightLeft / nodesLeft * n.percSize : heightLeft;
|
||||||
|
if (HEIGHT > heightLeft * 0.9f && nodesLeft > 1)
|
||||||
|
HEIGHT = heightLeft * 0.9f;
|
||||||
|
n.size = Vector2D((PMONITOR->vecSize.x - PMONITOR->vecReservedTopLeft.x - PMONITOR->vecReservedBottomRight.x) * PMASTERNODE->percMaster, HEIGHT);
|
||||||
|
|
||||||
masterno++;
|
nodesLeft--;
|
||||||
|
heightLeft -= HEIGHT;
|
||||||
|
nextY += HEIGHT;
|
||||||
|
|
||||||
applyNodeDataToWindow(&n);
|
applyNodeDataToWindow(&n);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto SLAVESIZE = 1.f / (getNodesOnWorkspace(PWORKSPACE->m_iID) - MASTERS) * (PMONITOR->vecSize.y - PMONITOR->vecReservedBottomRight.y - PMONITOR->vecReservedTopLeft.y);
|
float heightLeft = PMONITOR->vecSize.y - PMONITOR->vecReservedBottomRight.y - PMONITOR->vecReservedTopLeft.y;
|
||||||
int slavesDone = 0;
|
int slavesLeft = getNodesOnWorkspace(PWORKSPACE->m_iID) - MASTERS;
|
||||||
|
float nextY = 0;
|
||||||
|
|
||||||
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;
|
||||||
|
|
||||||
nd.position = Vector2D(PMASTERNODE->size.x + PMASTERNODE->position.x, slavesDone * SLAVESIZE + PMASTERNODE->position.y);
|
nd.position = Vector2D(PMASTERNODE->size.x + PMASTERNODE->position.x, nextY);
|
||||||
nd.size = Vector2D(PMONITOR->vecSize.x - PMONITOR->vecReservedBottomRight.x - PMONITOR->vecReservedTopLeft.x - PMASTERNODE->size.x, SLAVESIZE);
|
float HEIGHT = slavesLeft > 1 ? heightLeft / slavesLeft * nd.percSize : heightLeft;
|
||||||
|
if (HEIGHT > heightLeft * 0.9f && slavesLeft > 1)
|
||||||
|
HEIGHT = heightLeft * 0.9f;
|
||||||
|
nd.size = Vector2D(PMONITOR->vecSize.x - PMONITOR->vecReservedBottomRight.x - PMONITOR->vecReservedTopLeft.x - PMASTERNODE->size.x, HEIGHT);
|
||||||
|
|
||||||
slavesDone++;
|
slavesLeft--;
|
||||||
|
heightLeft -= HEIGHT;
|
||||||
|
nextY += HEIGHT;
|
||||||
|
|
||||||
applyNodeDataToWindow(&nd);
|
applyNodeDataToWindow(&nd);
|
||||||
}
|
}
|
||||||
|
@ -343,8 +355,7 @@ void CHyprMasterLayout::resizeActiveWindow(const Vector2D& pixResize, CWindow* p
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// get master
|
// get monitor
|
||||||
const auto PMASTER = getMasterNodeOnWorkspace(PWINDOW->m_iWorkspaceID);
|
|
||||||
const auto PMONITOR = g_pCompositor->getMonitorFromID(PWINDOW->m_iMonitorID);
|
const auto PMONITOR = g_pCompositor->getMonitorFromID(PWINDOW->m_iMonitorID);
|
||||||
|
|
||||||
if (getNodesOnWorkspace(PWINDOW->m_iWorkspaceID) < 2)
|
if (getNodesOnWorkspace(PWINDOW->m_iWorkspaceID) < 2)
|
||||||
|
@ -352,11 +363,24 @@ void CHyprMasterLayout::resizeActiveWindow(const Vector2D& pixResize, CWindow* p
|
||||||
|
|
||||||
m_bForceWarps = true;
|
m_bForceWarps = true;
|
||||||
|
|
||||||
float delta = pixResize.x / PMONITOR->vecSize.x;
|
double delta = pixResize.x / PMONITOR->vecSize.x;
|
||||||
|
|
||||||
PMASTER->percMaster += delta;
|
for (auto& n : m_lMasterNodesData) {
|
||||||
|
if (n.isMaster)
|
||||||
|
n.percMaster = std::clamp(n.percMaster + delta, 0.05, 0.95);
|
||||||
|
}
|
||||||
|
|
||||||
std::clamp(PMASTER->percMaster, 0.05f, 0.95f);
|
// check the up/down resize
|
||||||
|
if (pixResize.y != 0) {
|
||||||
|
if (PNODE->isMaster && getMastersOnWorkspace(PNODE->workspaceID) > 1) {
|
||||||
|
// check master size
|
||||||
|
const auto SIZEY = (PMONITOR->vecSize.y - PMONITOR->vecReservedTopLeft.y - PMONITOR->vecReservedBottomRight.y) / getMastersOnWorkspace(PNODE->workspaceID);
|
||||||
|
PNODE->percSize = std::clamp(PNODE->percSize + pixResize.y / SIZEY, 0.05, 1.95);
|
||||||
|
} else if (!PNODE->isMaster && (getNodesOnWorkspace(PWINDOW->m_iWorkspaceID) - getMastersOnWorkspace(PNODE->workspaceID)) > 1) {
|
||||||
|
const auto SIZEY = (PMONITOR->vecSize.y - PMONITOR->vecReservedTopLeft.y - PMONITOR->vecReservedBottomRight.y) / getNodesOnWorkspace(PNODE->workspaceID);
|
||||||
|
PNODE->percSize = std::clamp(PNODE->percSize + pixResize.y / SIZEY, 0.05, 1.95);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
recalculateMonitor(PMONITOR->ID);
|
recalculateMonitor(PMONITOR->ID);
|
||||||
|
|
||||||
|
|
|
@ -15,6 +15,8 @@ struct SMasterNodeData {
|
||||||
Vector2D position;
|
Vector2D position;
|
||||||
Vector2D size;
|
Vector2D size;
|
||||||
|
|
||||||
|
float percSize = 1.f; // size multiplier for resizing children
|
||||||
|
|
||||||
int workspaceID = -1;
|
int workspaceID = -1;
|
||||||
|
|
||||||
bool operator==(const SMasterNodeData& rhs) {
|
bool operator==(const SMasterNodeData& rhs) {
|
||||||
|
|
Loading…
Reference in a new issue