mirror of
https://github.com/hyprwm/Hyprland
synced 2024-11-22 17:45:59 +01:00
fix dwindle with workspaces
This commit is contained in:
parent
2e18fa268a
commit
5644e668ef
2 changed files with 21 additions and 21 deletions
|
@ -31,18 +31,18 @@ void SDwindleNodeData::recalcSizePosRecursive() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int CHyprDwindleLayout::getNodesOnMonitor(const int& id) {
|
int CHyprDwindleLayout::getNodesOnWorkspace(const int& id) {
|
||||||
int no = 0;
|
int no = 0;
|
||||||
for (auto& n : m_lDwindleNodesData) {
|
for (auto& n : m_lDwindleNodesData) {
|
||||||
if (n.monitorID == id)
|
if (n.workspaceID == id)
|
||||||
++no;
|
++no;
|
||||||
}
|
}
|
||||||
return no;
|
return no;
|
||||||
}
|
}
|
||||||
|
|
||||||
SDwindleNodeData* CHyprDwindleLayout::getFirstNodeOnMonitor(const int& id) {
|
SDwindleNodeData* CHyprDwindleLayout::getFirstNodeOnWorkspace(const int& id) {
|
||||||
for (auto& n : m_lDwindleNodesData) {
|
for (auto& n : m_lDwindleNodesData) {
|
||||||
if (n.monitorID == id)
|
if (n.workspaceID == id)
|
||||||
return &n;
|
return &n;
|
||||||
}
|
}
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
@ -57,19 +57,19 @@ SDwindleNodeData* CHyprDwindleLayout::getNodeFromWindow(CWindow* pWindow) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
SDwindleNodeData* CHyprDwindleLayout::getMasterNodeOnMonitor(const int& id) {
|
SDwindleNodeData* CHyprDwindleLayout::getMasterNodeOnWorkspace(const int& id) {
|
||||||
for (auto& n : m_lDwindleNodesData) {
|
for (auto& n : m_lDwindleNodesData) {
|
||||||
if (!n.pParent && n.monitorID == id)
|
if (!n.pParent && n.workspaceID == id)
|
||||||
return &n;
|
return &n;
|
||||||
}
|
}
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CHyprDwindleLayout::applyNodeDataToWindow(SDwindleNodeData* pNode) {
|
void CHyprDwindleLayout::applyNodeDataToWindow(SDwindleNodeData* pNode) {
|
||||||
const auto PMONITOR = g_pCompositor->getMonitorFromID(pNode->monitorID);
|
const auto PMONITOR = g_pCompositor->getMonitorFromID(g_pCompositor->getWorkspaceByID(pNode->workspaceID)->monitorID);
|
||||||
|
|
||||||
if (!PMONITOR){
|
if (!PMONITOR){
|
||||||
Debug::log(ERR, "Orphaned Node %x (monitor ID: %i)!!", pNode, pNode->monitorID);
|
Debug::log(ERR, "Orphaned Node %x (workspace ID: %i)!!", pNode, pNode->workspaceID);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -124,16 +124,16 @@ void CHyprDwindleLayout::onWindowCreated(CWindow* pWindow) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const auto PMONITOR = g_pCompositor->getMonitorFromID(pWindow->m_iMonitorID);
|
||||||
|
|
||||||
// Populate the node with our window's data
|
// Populate the node with our window's data
|
||||||
PNODE->monitorID = pWindow->m_iMonitorID;
|
PNODE->workspaceID = PMONITOR->activeWorkspace;
|
||||||
PNODE->pWindow = pWindow;
|
PNODE->pWindow = pWindow;
|
||||||
PNODE->isNode = false;
|
PNODE->isNode = false;
|
||||||
PNODE->layout = this;
|
PNODE->layout = this;
|
||||||
|
|
||||||
const auto PMONITOR = g_pCompositor->getMonitorFromID(PNODE->monitorID);
|
|
||||||
|
|
||||||
// if it's the first, it's easy. Make it fullscreen.
|
// if it's the first, it's easy. Make it fullscreen.
|
||||||
if (getNodesOnMonitor(pWindow->m_iMonitorID) == 1) {
|
if (getNodesOnWorkspace(PNODE->workspaceID) == 1) {
|
||||||
PNODE->position = PMONITOR->vecPosition + PMONITOR->vecReservedTopLeft;
|
PNODE->position = PMONITOR->vecPosition + PMONITOR->vecReservedTopLeft;
|
||||||
PNODE->size = PMONITOR->vecSize - PMONITOR->vecReservedTopLeft - PMONITOR->vecReservedBottomRight;
|
PNODE->size = PMONITOR->vecSize - PMONITOR->vecReservedTopLeft - PMONITOR->vecReservedBottomRight;
|
||||||
|
|
||||||
|
@ -146,7 +146,7 @@ void CHyprDwindleLayout::onWindowCreated(CWindow* pWindow) {
|
||||||
const auto PLASTFOCUS = getNodeFromWindow(g_pCompositor->getWindowFromSurface(g_pCompositor->m_pLastFocus));
|
const auto PLASTFOCUS = getNodeFromWindow(g_pCompositor->getWindowFromSurface(g_pCompositor->m_pLastFocus));
|
||||||
SDwindleNodeData* OPENINGON = PLASTFOCUS;
|
SDwindleNodeData* OPENINGON = PLASTFOCUS;
|
||||||
if (PLASTFOCUS) {
|
if (PLASTFOCUS) {
|
||||||
if (PLASTFOCUS->monitorID != PNODE->monitorID) {
|
if (PLASTFOCUS->workspaceID != PNODE->workspaceID) {
|
||||||
OPENINGON = getNodeFromWindow(g_pCompositor->vectorToWindow(g_pInputManager->getMouseCoordsInternal()));
|
OPENINGON = getNodeFromWindow(g_pCompositor->vectorToWindow(g_pInputManager->getMouseCoordsInternal()));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -154,7 +154,7 @@ void CHyprDwindleLayout::onWindowCreated(CWindow* pWindow) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!OPENINGON) {
|
if (!OPENINGON) {
|
||||||
OPENINGON = getFirstNodeOnMonitor(PNODE->monitorID);
|
OPENINGON = getFirstNodeOnWorkspace(PNODE->workspaceID);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!OPENINGON) {
|
if (!OPENINGON) {
|
||||||
|
@ -170,7 +170,7 @@ void CHyprDwindleLayout::onWindowCreated(CWindow* pWindow) {
|
||||||
NEWPARENT->children[1] = PNODE;
|
NEWPARENT->children[1] = PNODE;
|
||||||
NEWPARENT->position = OPENINGON->position;
|
NEWPARENT->position = OPENINGON->position;
|
||||||
NEWPARENT->size = OPENINGON->size;
|
NEWPARENT->size = OPENINGON->size;
|
||||||
NEWPARENT->monitorID = OPENINGON->monitorID;
|
NEWPARENT->workspaceID = OPENINGON->workspaceID;
|
||||||
NEWPARENT->pParent = OPENINGON->pParent;
|
NEWPARENT->pParent = OPENINGON->pParent;
|
||||||
NEWPARENT->isNode = true; // it is a node
|
NEWPARENT->isNode = true; // it is a node
|
||||||
|
|
||||||
|
@ -244,8 +244,8 @@ void CHyprDwindleLayout::onWindowRemoved(CWindow* pWindow) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void CHyprDwindleLayout::recalculateMonitor(const int& monid) {
|
void CHyprDwindleLayout::recalculateMonitor(const int& monid) {
|
||||||
const auto TOPNODE = getMasterNodeOnMonitor(monid);
|
|
||||||
const auto PMONITOR = g_pCompositor->getMonitorFromID(monid);
|
const auto PMONITOR = g_pCompositor->getMonitorFromID(monid);
|
||||||
|
const auto TOPNODE = getMasterNodeOnWorkspace(PMONITOR->activeWorkspace);
|
||||||
|
|
||||||
if (TOPNODE && PMONITOR) {
|
if (TOPNODE && PMONITOR) {
|
||||||
TOPNODE->position = PMONITOR->vecPosition + PMONITOR->vecReservedTopLeft;
|
TOPNODE->position = PMONITOR->vecPosition + PMONITOR->vecReservedTopLeft;
|
||||||
|
|
|
@ -16,11 +16,11 @@ struct SDwindleNodeData {
|
||||||
Vector2D position;
|
Vector2D position;
|
||||||
Vector2D size;
|
Vector2D size;
|
||||||
|
|
||||||
int monitorID = -1;
|
int workspaceID = -1;
|
||||||
|
|
||||||
// For list lookup
|
// For list lookup
|
||||||
bool operator==(const SDwindleNodeData& rhs) {
|
bool operator==(const SDwindleNodeData& rhs) {
|
||||||
return pWindow == rhs.pWindow && monitorID == rhs.monitorID && position == rhs.position && size == rhs.size && pParent == rhs.pParent && children[0] == rhs.children[0] && children[1] == rhs.children[1];
|
return pWindow == rhs.pWindow && workspaceID == rhs.workspaceID && position == rhs.position && size == rhs.size && pParent == rhs.pParent && children[0] == rhs.children[0] && children[1] == rhs.children[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
void recalcSizePosRecursive();
|
void recalcSizePosRecursive();
|
||||||
|
@ -45,11 +45,11 @@ public:
|
||||||
Vector2D m_vBeginDragPositionXY;
|
Vector2D m_vBeginDragPositionXY;
|
||||||
Vector2D m_vBeginDragSizeXY;
|
Vector2D m_vBeginDragSizeXY;
|
||||||
|
|
||||||
int getNodesOnMonitor(const int&);
|
int getNodesOnWorkspace(const int&);
|
||||||
void applyNodeDataToWindow(SDwindleNodeData*);
|
void applyNodeDataToWindow(SDwindleNodeData*);
|
||||||
SDwindleNodeData* getNodeFromWindow(CWindow*);
|
SDwindleNodeData* getNodeFromWindow(CWindow*);
|
||||||
SDwindleNodeData* getFirstNodeOnMonitor(const int&);
|
SDwindleNodeData* getFirstNodeOnWorkspace(const int&);
|
||||||
SDwindleNodeData* getMasterNodeOnMonitor(const int&);
|
SDwindleNodeData* getMasterNodeOnWorkspace(const int&);
|
||||||
|
|
||||||
friend struct SDwindleNodeData;
|
friend struct SDwindleNodeData;
|
||||||
};
|
};
|
Loading…
Reference in a new issue