aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/layout
diff options
context:
space:
mode:
authorVaxry <[email protected]>2024-10-27 18:45:38 +0000
committerGitHub <[email protected]>2024-10-27 18:45:38 +0000
commit5d4b54b01286c10d4b6bf402a772b5938b054ce6 (patch)
tree09c803b1cc39a67c04dd0ad09a79dc47f0f2e1f4 /src/layout
parentb6e226c3200276978e487a68a16fd696fcb7e7c8 (diff)
downloadHyprland-5d4b54b01286c10d4b6bf402a772b5938b054ce6.tar.gz
Hyprland-5d4b54b01286c10d4b6bf402a772b5938b054ce6.zip
core: move internal structures to monitor pointers (#8266)
Diffstat (limited to 'src/layout')
-rw-r--r--src/layout/DwindleLayout.cpp18
-rw-r--r--src/layout/IHyprLayout.cpp18
-rw-r--r--src/layout/MasterLayout.cpp40
3 files changed, 38 insertions, 38 deletions
diff --git a/src/layout/DwindleLayout.cpp b/src/layout/DwindleLayout.cpp
index 0fa57143..059dda99 100644
--- a/src/layout/DwindleLayout.cpp
+++ b/src/layout/DwindleLayout.cpp
@@ -111,7 +111,7 @@ void CHyprDwindleLayout::applyNodeDataToWindow(SDwindleNodeData* pNode, bool for
}
}
} else
- PMONITOR = g_pCompositor->getMonitorFromID(g_pCompositor->getWorkspaceByID(pNode->workspaceID)->m_iMonitorID);
+ PMONITOR = g_pCompositor->getWorkspaceByID(pNode->workspaceID)->m_pMonitor.lock();
if (!PMONITOR) {
Debug::log(ERR, "Orphaned Node {}!!", pNode);
@@ -234,7 +234,7 @@ void CHyprDwindleLayout::onWindowCreatedTiling(PHLWINDOW pWindow, eDirection dir
m_lDwindleNodesData.push_back(SDwindleNodeData());
const auto PNODE = &m_lDwindleNodesData.back();
- const auto PMONITOR = g_pCompositor->getMonitorFromID(pWindow->m_iMonitorID);
+ const auto PMONITOR = pWindow->m_pMonitor.lock();
static auto PUSEACTIVE = CConfigValue<Hyprlang::INT>("dwindle:use_active_for_splits");
static auto PDEFAULTSPLIT = CConfigValue<Hyprlang::FLOAT>("dwindle:default_split_ratio");
@@ -446,7 +446,7 @@ void CHyprDwindleLayout::onWindowCreatedTiling(PHLWINDOW pWindow, eDirection dir
NEWPARENT->recalcSizePosRecursive(false, horizontalOverride, verticalOverride);
- recalculateMonitor(pWindow->m_iMonitorID);
+ recalculateMonitor(pWindow->monitorID());
}
void CHyprDwindleLayout::onWindowRemovedTiling(PHLWINDOW pWindow) {
@@ -512,7 +512,7 @@ void CHyprDwindleLayout::recalculateMonitor(const MONITORID& monid) {
}
void CHyprDwindleLayout::calculateWorkspace(const PHLWORKSPACE& pWorkspace) {
- const auto PMONITOR = g_pCompositor->getMonitorFromID(pWorkspace->m_iMonitorID);
+ const auto PMONITOR = pWorkspace->m_pMonitor.lock();
if (!PMONITOR)
return;
@@ -577,7 +577,7 @@ void CHyprDwindleLayout::resizeActiveWindow(const Vector2D& pixResize, eRectCorn
static auto PSMARTRESIZING = CConfigValue<Hyprlang::INT>("dwindle:smart_resizing");
// get some data about our window
- const auto PMONITOR = g_pCompositor->getMonitorFromID(PWINDOW->m_iMonitorID);
+ const auto PMONITOR = PWINDOW->m_pMonitor.lock();
const bool DISPLAYLEFT = STICKS(PWINDOW->m_vPosition.x, PMONITOR->vecPosition.x + PMONITOR->vecReservedTopLeft.x);
const bool DISPLAYRIGHT = STICKS(PWINDOW->m_vPosition.x + PWINDOW->m_vSize.x, PMONITOR->vecPosition.x + PMONITOR->vecSize.x - PMONITOR->vecReservedBottomRight.x);
const bool DISPLAYTOP = STICKS(PWINDOW->m_vPosition.y, PMONITOR->vecPosition.y + PMONITOR->vecReservedTopLeft.y);
@@ -750,7 +750,7 @@ void CHyprDwindleLayout::resizeActiveWindow(const Vector2D& pixResize, eRectCorn
}
void CHyprDwindleLayout::fullscreenRequestForWindow(PHLWINDOW pWindow, const eFullscreenMode CURRENT_EFFECTIVE_MODE, const eFullscreenMode EFFECTIVE_MODE) {
- const auto PMONITOR = g_pCompositor->getMonitorFromID(pWindow->m_iMonitorID);
+ const auto PMONITOR = pWindow->m_pMonitor.lock();
const auto PWORKSPACE = pWindow->m_pWorkspace;
// save position and size if floating
@@ -860,9 +860,9 @@ void CHyprDwindleLayout::moveWindowTo(PHLWINDOW pWindow, const std::string& dir,
const auto PMONITORFOCAL = g_pCompositor->getMonitorFromVector(focalPoint);
- if (PMONITORFOCAL->ID != pWindow->m_iMonitorID) {
+ if (PMONITORFOCAL != pWindow->m_pMonitor) {
pWindow->moveToWorkspace(PMONITORFOCAL->activeWorkspace);
- pWindow->m_iMonitorID = PMONITORFOCAL->ID;
+ pWindow->m_pMonitor = PMONITORFOCAL;
}
onWindowCreatedTiling(pWindow);
@@ -900,7 +900,7 @@ void CHyprDwindleLayout::switchWindows(PHLWINDOW pWindow, PHLWINDOW pWindow2) {
PNODE->pWindow = pWindow2;
if (PNODE->workspaceID != PNODE2->workspaceID) {
- std::swap(pWindow2->m_iMonitorID, pWindow->m_iMonitorID);
+ std::swap(pWindow2->m_pMonitor, pWindow->m_pMonitor);
std::swap(pWindow2->m_pWorkspace, pWindow->m_pWorkspace);
}
diff --git a/src/layout/IHyprLayout.cpp b/src/layout/IHyprLayout.cpp
index 454a6132..a3c14e41 100644
--- a/src/layout/IHyprLayout.cpp
+++ b/src/layout/IHyprLayout.cpp
@@ -13,7 +13,7 @@ void IHyprLayout::onWindowCreated(PHLWINDOW pWindow, eDirection direction) {
g_pXWaylandManager->getGeometryForWindow(pWindow, &desiredGeometry);
if (desiredGeometry.width <= 5 || desiredGeometry.height <= 5) {
- const auto PMONITOR = g_pCompositor->getMonitorFromID(pWindow->m_iMonitorID);
+ const auto PMONITOR = pWindow->m_pMonitor.lock();
pWindow->m_vLastFloatingSize = PMONITOR->vecSize / 2.f;
} else
pWindow->m_vLastFloatingSize = Vector2D(desiredGeometry.width, desiredGeometry.height);
@@ -88,7 +88,7 @@ void IHyprLayout::onWindowCreatedFloating(PHLWINDOW pWindow) {
CBox desiredGeometry = {0};
g_pXWaylandManager->getGeometryForWindow(pWindow, &desiredGeometry);
- const auto PMONITOR = g_pCompositor->getMonitorFromID(pWindow->m_iMonitorID);
+ const auto PMONITOR = pWindow->m_pMonitor.lock();
if (pWindow->m_bIsX11) {
Vector2D xy = {desiredGeometry.x, desiredGeometry.y};
@@ -485,7 +485,7 @@ static void performSnap(Vector2D& pos, Vector2D& size, PHLWINDOW DRAGGINGWINDOW,
}
if (*SNAPMONITORGAP) {
- const auto MON = g_pCompositor->getMonitorFromID(DRAGGINGWINDOW->m_iMonitorID);
+ const auto MON = DRAGGINGWINDOW->m_pMonitor.lock();
const CBox mon = {MON->vecPosition.x, MON->vecPosition.y, MON->vecPosition.x + MON->vecSize.x, MON->vecPosition.y + MON->vecSize.y};
const double gap = *SNAPMONITORGAP;
@@ -677,7 +677,7 @@ void IHyprLayout::onMouseMove(const Vector2D& mousePos) {
const auto PMONITOR = g_pCompositor->getMonitorFromVector(middle);
if (PMONITOR && !SPECIAL) {
- DRAGGINGWINDOW->m_iMonitorID = PMONITOR->ID;
+ DRAGGINGWINDOW->m_pMonitor = PMONITOR;
DRAGGINGWINDOW->moveToWorkspace(PMONITOR->activeWorkspace);
DRAGGINGWINDOW->updateGroupOutputs();
@@ -705,8 +705,8 @@ void IHyprLayout::changeWindowFloatingMode(PHLWINDOW pWindow) {
EMIT_HOOK_EVENT("changeFloatingMode", pWindow);
if (!TILED) {
- const auto PNEWMON = g_pCompositor->getMonitorFromVector(pWindow->m_vRealPosition.value() + pWindow->m_vRealSize.value() / 2.f);
- pWindow->m_iMonitorID = PNEWMON->ID;
+ const auto PNEWMON = g_pCompositor->getMonitorFromVector(pWindow->m_vRealPosition.value() + pWindow->m_vRealSize.value() / 2.f);
+ pWindow->m_pMonitor = PNEWMON;
pWindow->moveToWorkspace(PNEWMON->activeSpecialWorkspace ? PNEWMON->activeSpecialWorkspace : PNEWMON->activeWorkspace);
pWindow->updateGroupOutputs();
@@ -734,7 +734,7 @@ void IHyprLayout::changeWindowFloatingMode(PHLWINDOW pWindow) {
pWindow->m_vRealSize.setValue(PSAVEDSIZE);
// fix pseudo leaving artifacts
- g_pHyprRenderer->damageMonitor(g_pCompositor->getMonitorFromID(pWindow->m_iMonitorID));
+ g_pHyprRenderer->damageMonitor(pWindow->m_pMonitor.lock());
if (pWindow == g_pCompositor->m_pLastWindow)
m_pLastTiledWindow = pWindow;
@@ -757,7 +757,7 @@ void IHyprLayout::changeWindowFloatingMode(PHLWINDOW pWindow) {
pWindow->m_vSize = wb.pos();
pWindow->m_vPosition = wb.size();
- g_pHyprRenderer->damageMonitor(g_pCompositor->getMonitorFromID(pWindow->m_iMonitorID));
+ g_pHyprRenderer->damageMonitor(pWindow->m_pMonitor.lock());
pWindow->unsetWindowData(PRIORITY_LAYOUT);
pWindow->updateWindowData();
@@ -847,7 +847,7 @@ PHLWINDOW IHyprLayout::getNextWindowCandidate(PHLWINDOW pWindow) {
pWindowCandidate = g_pCompositor->getFirstWindowOnWorkspace(pWindow->workspaceID());
if (!pWindowCandidate || pWindow == pWindowCandidate || !pWindowCandidate->m_bIsMapped || pWindowCandidate->isHidden() || pWindowCandidate->m_bX11ShouldntFocus ||
- pWindowCandidate->isX11OverrideRedirect() || pWindowCandidate->m_iMonitorID != g_pCompositor->m_pLastMonitor->ID)
+ pWindowCandidate->isX11OverrideRedirect() || pWindowCandidate->m_pMonitor != g_pCompositor->m_pLastMonitor)
return nullptr;
return pWindowCandidate;
diff --git a/src/layout/MasterLayout.cpp b/src/layout/MasterLayout.cpp
index 95b5afdf..a2321a41 100644
--- a/src/layout/MasterLayout.cpp
+++ b/src/layout/MasterLayout.cpp
@@ -80,7 +80,7 @@ void CHyprMasterLayout::onWindowCreatedTiling(PHLWINDOW pWindow, eDirection dire
static auto PNEWONTOP = CConfigValue<Hyprlang::INT>("master:new_on_top");
static auto PNEWSTATUS = CConfigValue<std::string>("master:new_status");
- const auto PMONITOR = g_pCompositor->getMonitorFromID(pWindow->m_iMonitorID);
+ const auto PMONITOR = pWindow->m_pMonitor.lock();
const bool BNEWBEFOREACTIVE = *PNEWONACTIVE == "before";
const bool BNEWISMASTER = *PNEWSTATUS == "master";
@@ -229,7 +229,7 @@ void CHyprMasterLayout::onWindowCreatedTiling(PHLWINDOW pWindow, eDirection dire
}
// recalc
- recalculateMonitor(pWindow->m_iMonitorID);
+ recalculateMonitor(pWindow->monitorID());
}
void CHyprMasterLayout::onWindowRemovedTiling(PHLWINDOW pWindow) {
@@ -279,7 +279,7 @@ void CHyprMasterLayout::onWindowRemovedTiling(PHLWINDOW pWindow) {
}
}
}
- recalculateMonitor(pWindow->m_iMonitorID);
+ recalculateMonitor(pWindow->monitorID());
}
void CHyprMasterLayout::recalculateMonitor(const MONITORID& monid) {
@@ -297,7 +297,7 @@ void CHyprMasterLayout::recalculateMonitor(const MONITORID& monid) {
}
void CHyprMasterLayout::calculateWorkspace(PHLWORKSPACE pWorkspace) {
- const auto PMONITOR = g_pCompositor->getMonitorFromID(pWorkspace->m_iMonitorID);
+ const auto PMONITOR = pWorkspace->m_pMonitor.lock();
if (!PMONITOR)
return;
@@ -604,7 +604,7 @@ void CHyprMasterLayout::applyNodeDataToWindow(SMasterNodeData* pNode) {
}
}
} else
- PMONITOR = g_pCompositor->getMonitorFromID(g_pCompositor->getWorkspaceByID(pNode->workspaceID)->m_iMonitorID);
+ PMONITOR = g_pCompositor->getWorkspaceByID(pNode->workspaceID)->m_pMonitor.lock();
if (!PMONITOR) {
Debug::log(ERR, "Orphaned Node {}!!", pNode);
@@ -711,7 +711,7 @@ void CHyprMasterLayout::resizeActiveWindow(const Vector2D& pixResize, eRectCorne
return;
}
- const auto PMONITOR = g_pCompositor->getMonitorFromID(PWINDOW->m_iMonitorID);
+ const auto PMONITOR = PWINDOW->m_pMonitor.lock();
static auto ALWAYSCENTER = CConfigValue<Hyprlang::INT>("master:always_center_master");
static auto PSMARTRESIZING = CConfigValue<Hyprlang::INT>("master:smart_resizing");
@@ -840,7 +840,7 @@ void CHyprMasterLayout::resizeActiveWindow(const Vector2D& pixResize, eRectCorne
}
void CHyprMasterLayout::fullscreenRequestForWindow(PHLWINDOW pWindow, const eFullscreenMode CURRENT_EFFECTIVE_MODE, const eFullscreenMode EFFECTIVE_MODE) {
- const auto PMONITOR = g_pCompositor->getMonitorFromID(pWindow->m_iMonitorID);
+ const auto PMONITOR = pWindow->m_pMonitor.lock();
const auto PWORKSPACE = pWindow->m_pWorkspace;
// save position and size if floating
@@ -896,7 +896,7 @@ void CHyprMasterLayout::recalculateWindow(PHLWINDOW pWindow) {
if (!PNODE)
return;
- recalculateMonitor(pWindow->m_iMonitorID);
+ recalculateMonitor(pWindow->monitorID());
}
SWindowRenderLayoutHints CHyprMasterLayout::requestRenderHints(PHLWINDOW pWindow) {
@@ -922,9 +922,9 @@ void CHyprMasterLayout::moveWindowTo(PHLWINDOW pWindow, const std::string& dir,
// if different monitors, send to monitor
onWindowRemovedTiling(pWindow);
pWindow->moveToWorkspace(PWINDOW2->m_pWorkspace);
- pWindow->m_iMonitorID = PWINDOW2->m_iMonitorID;
+ pWindow->m_pMonitor = PWINDOW2->m_pMonitor;
if (!silent) {
- const auto pMonitor = g_pCompositor->getMonitorFromID(pWindow->m_iMonitorID);
+ const auto pMonitor = pWindow->m_pMonitor.lock();
g_pCompositor->setActiveMonitor(pMonitor);
}
onWindowCreatedTiling(pWindow);
@@ -946,7 +946,7 @@ void CHyprMasterLayout::switchWindows(PHLWINDOW pWindow, PHLWINDOW pWindow2) {
return;
if (PNODE->workspaceID != PNODE2->workspaceID) {
- std::swap(pWindow2->m_iMonitorID, pWindow->m_iMonitorID);
+ std::swap(pWindow2->m_pMonitor, pWindow->m_pMonitor);
std::swap(pWindow2->m_pWorkspace, pWindow->m_pWorkspace);
}
@@ -957,9 +957,9 @@ void CHyprMasterLayout::switchWindows(PHLWINDOW pWindow, PHLWINDOW pWindow2) {
pWindow->setAnimationsToMove();
pWindow2->setAnimationsToMove();
- recalculateMonitor(pWindow->m_iMonitorID);
+ recalculateMonitor(pWindow->monitorID());
if (PNODE2->workspaceID != PNODE->workspaceID)
- recalculateMonitor(pWindow2->m_iMonitorID);
+ recalculateMonitor(pWindow2->monitorID());
g_pHyprRenderer->damageWindow(pWindow);
g_pHyprRenderer->damageWindow(pWindow2);
@@ -978,7 +978,7 @@ void CHyprMasterLayout::alterSplitRatio(PHLWINDOW pWindow, float ratio, bool exa
float newRatio = exact ? ratio : PMASTER->percMaster + ratio;
PMASTER->percMaster = std::clamp(newRatio, 0.05f, 0.95f);
- recalculateMonitor(pWindow->m_iMonitorID);
+ recalculateMonitor(pWindow->monitorID());
}
PHLWINDOW CHyprMasterLayout::getNextWindow(PHLWINDOW pWindow, bool next) {
@@ -1185,7 +1185,7 @@ std::any CHyprMasterLayout::layoutMessage(SLayoutMessageHeader header, std::stri
PNODE->isMaster = true;
}
- recalculateMonitor(header.pWindow->m_iMonitorID);
+ recalculateMonitor(header.pWindow->monitorID());
} else if (command == "removemaster") {
@@ -1217,7 +1217,7 @@ std::any CHyprMasterLayout::layoutMessage(SLayoutMessageHeader header, std::stri
PNODE->isMaster = false;
}
- recalculateMonitor(header.pWindow->m_iMonitorID);
+ recalculateMonitor(header.pWindow->monitorID());
} else if (command == "orientationleft" || command == "orientationright" || command == "orientationtop" || command == "orientationbottom" || command == "orientationcenter") {
const auto PWINDOW = header.pWindow;
@@ -1239,7 +1239,7 @@ std::any CHyprMasterLayout::layoutMessage(SLayoutMessageHeader header, std::stri
else if (command == "orientationcenter")
PWORKSPACEDATA->orientation = ORIENTATION_CENTER;
- recalculateMonitor(header.pWindow->m_iMonitorID);
+ recalculateMonitor(header.pWindow->monitorID());
} else if (command == "orientationnext") {
runOrientationCycle(header, nullptr, 1);
@@ -1274,7 +1274,7 @@ std::any CHyprMasterLayout::layoutMessage(SLayoutMessageHeader header, std::stri
}
}
- recalculateMonitor(PWINDOW->m_iMonitorID);
+ recalculateMonitor(PWINDOW->monitorID());
} else if (command == "rollprev") {
const auto PWINDOW = header.pWindow;
const auto PNODE = getNodeFromWindow(PWINDOW);
@@ -1300,7 +1300,7 @@ std::any CHyprMasterLayout::layoutMessage(SLayoutMessageHeader header, std::stri
}
}
- recalculateMonitor(PWINDOW->m_iMonitorID);
+ recalculateMonitor(PWINDOW->monitorID());
}
return 0;
@@ -1338,7 +1338,7 @@ void CHyprMasterLayout::runOrientationCycle(SLayoutMessageHeader& header, CVarLi
nextOrPrev = cycle.size() + (nextOrPrev % (int)cycle.size());
PWORKSPACEDATA->orientation = cycle.at(nextOrPrev);
- recalculateMonitor(header.pWindow->m_iMonitorID);
+ recalculateMonitor(header.pWindow->monitorID());
}
void CHyprMasterLayout::buildOrientationCycleVectorFromEOperation(std::vector<eOrientation>& cycle) {