mirror of
https://github.com/hyprwm/Hypr.git
synced 2024-11-21 21:15:59 +01:00
fixed the entire master layout + added splitratio (only master-children)
This commit is contained in:
parent
b0dedddce9
commit
82eeba5c94
2 changed files with 20 additions and 8 deletions
|
@ -555,7 +555,7 @@ CWindow* Events::remapWindow(int windowID, bool wasfloating, int forcemonitor) {
|
||||||
// For master layout, add the index
|
// For master layout, add the index
|
||||||
PWINDOWINARR->setMasterChildIndex(g_pWindowManager->getWindowsOnWorkspace(g_pWindowManager->activeWorkspaces[CURRENTSCREEN]) - 1);
|
PWINDOWINARR->setMasterChildIndex(g_pWindowManager->getWindowsOnWorkspace(g_pWindowManager->activeWorkspaces[CURRENTSCREEN]) - 1);
|
||||||
// and set master if needed
|
// and set master if needed
|
||||||
if (g_pWindowManager->getWindowsOnWorkspace(g_pWindowManager->activeWorkspaces[CURRENTSCREEN]) == 0)
|
if (g_pWindowManager->getWindowsOnWorkspace(g_pWindowManager->activeWorkspaces[CURRENTSCREEN]) == 1) // 1 because the current window is already in the arr
|
||||||
PWINDOWINARR->setMaster(true);
|
PWINDOWINARR->setMaster(true);
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1062,25 +1062,37 @@ void CWindowManager::recalcEntireWorkspace(const int& workspace) {
|
||||||
// first, calc the size
|
// first, calc the size
|
||||||
CWindow* pMaster = nullptr;
|
CWindow* pMaster = nullptr;
|
||||||
for (auto& w : windows) {
|
for (auto& w : windows) {
|
||||||
if (w.getWorkspaceID() == workspace && w.getMaster() && !w.getDead()) {
|
if (w.getWorkspaceID() == workspace && w.getMaster() && !w.getDead() && !w.getIsFloating() && !w.getDock()) {
|
||||||
pMaster = &w;
|
pMaster = &w;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CWindow* pMasterContainer = nullptr;
|
||||||
|
for (auto& w : windows) {
|
||||||
|
if (w.getWorkspaceID() == workspace && w.getParentNodeID() == 0 && !w.getIsFloating() && !w.getDock()) {
|
||||||
|
pMasterContainer = &w;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!pMaster) {
|
if (!pMaster) {
|
||||||
Debug::log(ERR, "No master found on workspace???");
|
Debug::log(ERR, "No master found on workspace???");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// set the xy for master
|
// set the xy for master
|
||||||
|
float splitRatio = 1;
|
||||||
|
if (pMasterContainer)
|
||||||
|
splitRatio = pMasterContainer->getSplitRatio();
|
||||||
|
|
||||||
pMaster->setPosition(Vector2D(0, 0) + PMONITOR->vecPosition);
|
pMaster->setPosition(Vector2D(0, 0) + PMONITOR->vecPosition);
|
||||||
pMaster->setSize(Vector2D(PMONITOR->vecSize.x / 2, PMONITOR->vecSize.y));
|
pMaster->setSize(Vector2D(PMONITOR->vecSize.x / 2 * splitRatio, PMONITOR->vecSize.y));
|
||||||
|
|
||||||
// get children sorted
|
// get children sorted
|
||||||
std::vector<CWindow*> children;
|
std::vector<CWindow*> children;
|
||||||
for (auto& w : windows) {
|
for (auto& w : windows) {
|
||||||
if (w.getWorkspaceID() == workspace && !w.getMaster() && w.getDrawable() > 0 && !w.getDead())
|
if (w.getWorkspaceID() == workspace && !w.getMaster() && w.getDrawable() > 0 && !w.getDead() && !w.getDock())
|
||||||
children.push_back(&w);
|
children.push_back(&w);
|
||||||
}
|
}
|
||||||
std::sort(children.begin(), children.end(), [](CWindow*& a, CWindow*& b) {
|
std::sort(children.begin(), children.end(), [](CWindow*& a, CWindow*& b) {
|
||||||
|
@ -1096,8 +1108,8 @@ void CWindowManager::recalcEntireWorkspace(const int& workspace) {
|
||||||
// Children sorted, set xy
|
// Children sorted, set xy
|
||||||
int yoff = 0;
|
int yoff = 0;
|
||||||
for (const auto& child : children) {
|
for (const auto& child : children) {
|
||||||
child->setPosition(Vector2D(PMONITOR->vecSize.x / 2, yoff) + PMONITOR->vecPosition);
|
child->setPosition(Vector2D(PMONITOR->vecSize.x / 2 * splitRatio, yoff) + PMONITOR->vecPosition);
|
||||||
child->setSize(Vector2D(PMONITOR->vecSize.x / 2, PMONITOR->vecSize.y / children.size()));
|
child->setSize(Vector2D(PMONITOR->vecSize.x / 2 * (2 - splitRatio), PMONITOR->vecSize.y / children.size()));
|
||||||
|
|
||||||
yoff += PMONITOR->vecSize.y / children.size();
|
yoff += PMONITOR->vecSize.y / children.size();
|
||||||
}
|
}
|
||||||
|
@ -1296,7 +1308,7 @@ CWindow* CWindowManager::getMasterForWorkspace(const int& work) {
|
||||||
if (!pMaster) {
|
if (!pMaster) {
|
||||||
Debug::log(ERR, "No master found on workspace? Setting automatically");
|
Debug::log(ERR, "No master found on workspace? Setting automatically");
|
||||||
for (auto& w : windows) {
|
for (auto& w : windows) {
|
||||||
if (w.getWorkspaceID() == work) {
|
if (w.getWorkspaceID() == work && !w.getDock() && !w.getIsFloating()) {
|
||||||
pMaster = &w;
|
pMaster = &w;
|
||||||
w.setMaster(true);
|
w.setMaster(true);
|
||||||
break;
|
break;
|
||||||
|
@ -1314,7 +1326,7 @@ void CWindowManager::fixMasterWorkspaceOnClosed(CWindow* pWindow) {
|
||||||
// get children sorted
|
// get children sorted
|
||||||
std::vector<CWindow*> children;
|
std::vector<CWindow*> children;
|
||||||
for (auto& w : windows) {
|
for (auto& w : windows) {
|
||||||
if (w.getWorkspaceID() == pWindow->getWorkspaceID() && !w.getMaster() && w.getDrawable() > 0 && w.getDrawable() != pWindow->getDrawable())
|
if (w.getWorkspaceID() == pWindow->getWorkspaceID() && !w.getMaster() && w.getDrawable() > 0 && w.getDrawable() != pWindow->getDrawable() && !w.getDock())
|
||||||
children.push_back(&w);
|
children.push_back(&w);
|
||||||
}
|
}
|
||||||
std::sort(children.begin(), children.end(), [](CWindow*& a, CWindow*& b) {
|
std::sort(children.begin(), children.end(), [](CWindow*& a, CWindow*& b) {
|
||||||
|
|
Loading…
Reference in a new issue