summaryrefslogtreecommitdiff
path: root/src/desktop
diff options
context:
space:
mode:
authorVaxry <43317083+vaxerski@users.noreply.github.com>2024-10-27 18:45:38 +0000
committerGitHub <noreply@github.com>2024-10-27 18:45:38 +0000
commit5d4b54b01286c10d4b6bf402a772b5938b054ce6 (patch)
tree09c803b1cc39a67c04dd0ad09a79dc47f0f2e1f4 /src/desktop
parentb6e226c3200276978e487a68a16fd696fcb7e7c8 (diff)
core: move internal structures to monitor pointers (#8266)
Diffstat (limited to 'src/desktop')
-rw-r--r--src/desktop/LayerSurface.cpp24
-rw-r--r--src/desktop/LayerSurface.hpp5
-rw-r--r--src/desktop/Window.cpp54
-rw-r--r--src/desktop/Window.hpp5
-rw-r--r--src/desktop/Workspace.cpp30
-rw-r--r--src/desktop/Workspace.hpp11
6 files changed, 72 insertions, 57 deletions
diff --git a/src/desktop/LayerSurface.cpp b/src/desktop/LayerSurface.cpp
index 6c024ee0..f073da82 100644
--- a/src/desktop/LayerSurface.cpp
+++ b/src/desktop/LayerSurface.cpp
@@ -26,7 +26,7 @@ PHLLS CLayerSurface::create(SP<CLayerShellResource> resource) {
pLS->layer = resource->current.layer;
pLS->popupHead = std::make_unique<CPopup>(pLS);
- pLS->monitorID = pMonitor->ID;
+ pLS->monitor = pMonitor;
pMonitor->m_aLayerSurfaceLayers[resource->current.layer].emplace_back(pLS);
pLS->forceBlur = g_pConfigManager->shouldBlurLS(pLS->szNamespace);
@@ -50,7 +50,7 @@ PHLLS CLayerSurface::create(SP<CLayerShellResource> resource) {
void CLayerSurface::registerCallbacks() {
alpha.setUpdateCallback([this](void*) {
if (dimAround)
- g_pHyprRenderer->damageMonitor(g_pCompositor->getMonitorFromID(monitorID));
+ g_pHyprRenderer->damageMonitor(monitor.lock());
});
}
@@ -82,9 +82,9 @@ CLayerSurface::~CLayerSurface() {
void CLayerSurface::onDestroy() {
Debug::log(LOG, "LayerSurface {:x} destroyed", (uintptr_t)layerSurface.get());
- const auto PMONITOR = g_pCompositor->getMonitorFromID(monitorID);
+ const auto PMONITOR = monitor.lock();
- if (!g_pCompositor->getMonitorFromID(monitorID))
+ if (!PMONITOR)
Debug::log(WARN, "Layersurface destroyed on an invalid monitor (removed?)");
if (!fadingOut) {
@@ -137,7 +137,7 @@ void CLayerSurface::onMap() {
g_pCompositor->removeFromFadingOutSafe(self.lock());
// fix if it changed its mon
- const auto PMONITOR = g_pCompositor->getMonitorFromID(monitorID);
+ const auto PMONITOR = monitor.lock();
if (!PMONITOR)
return;
@@ -197,7 +197,7 @@ void CLayerSurface::onUnmap() {
std::erase_if(g_pInputManager->m_dExclusiveLSes, [this](const auto& other) { return !other.lock() || other.lock() == self.lock(); });
- if (!g_pCompositor->getMonitorFromID(monitorID) || g_pCompositor->m_bUnsafeState) {
+ if (!monitor || g_pCompositor->m_bUnsafeState) {
Debug::log(WARN, "Layersurface unmapping on invalid monitor (removed?) ignoring.");
g_pCompositor->addToFadingOutSafe(self.lock());
@@ -221,7 +221,7 @@ void CLayerSurface::onUnmap() {
g_pCompositor->addToFadingOutSafe(self.lock());
- const auto PMONITOR = g_pCompositor->getMonitorFromID(monitorID);
+ const auto PMONITOR = monitor.lock();
const bool WASLASTFOCUS = g_pCompositor->m_pLastFocus == surface->resource();
@@ -256,13 +256,13 @@ void CLayerSurface::onCommit() {
if (layerSurface->surface && !layerSurface->surface->current.texture) {
fadingOut = false;
geometry = {};
- g_pHyprRenderer->arrangeLayersForMonitor(monitorID);
+ g_pHyprRenderer->arrangeLayersForMonitor(monitorID());
}
return;
}
- const auto PMONITOR = g_pCompositor->getMonitorFromID(monitorID);
+ const auto PMONITOR = monitor.lock();
if (!PMONITOR)
return;
@@ -336,7 +336,7 @@ void CLayerSurface::onCommit() {
// moveMouseUnified won't focus non interactive layers but it won't unfocus them either,
// so unfocus the surface here.
g_pCompositor->focusSurface(nullptr);
- g_pInputManager->refocusLastWindow(g_pCompositor->getMonitorFromID(monitorID));
+ g_pInputManager->refocusLastWindow(monitor.lock());
} else if (!WASEXCLUSIVE && ISEXCLUSIVE) {
// if now exclusive and not previously
g_pSeatManager->setGrab(nullptr);
@@ -545,3 +545,7 @@ int CLayerSurface::popupsCount() {
popupHead->breadthfirst([](CPopup* p, void* data) { *(int*)data += 1; }, &no);
return no;
}
+
+MONITORID CLayerSurface::monitorID() {
+ return monitor ? monitor->ID : MONITOR_INVALID;
+}
diff --git a/src/desktop/LayerSurface.hpp b/src/desktop/LayerSurface.hpp
index e0f17039..6aa8eb81 100644
--- a/src/desktop/LayerSurface.hpp
+++ b/src/desktop/LayerSurface.hpp
@@ -42,7 +42,7 @@ class CLayerSurface {
bool mapped = false;
uint32_t layer = 0;
- MONITORID monitorID = -1;
+ PHLMONITORREF monitor;
bool fadingOut = false;
bool readyToDelete = false;
@@ -70,6 +70,7 @@ class CLayerSurface {
void onMap();
void onUnmap();
void onCommit();
+ MONITORID monitorID();
private:
struct {
@@ -83,6 +84,6 @@ class CLayerSurface {
// For the list lookup
bool operator==(const CLayerSurface& rhs) const {
- return layerSurface == rhs.layerSurface && monitorID == rhs.monitorID;
+ return layerSurface == rhs.layerSurface && monitor == rhs.monitor;
}
};
diff --git a/src/desktop/Window.cpp b/src/desktop/Window.cpp
index 0772b676..e4f987eb 100644
--- a/src/desktop/Window.cpp
+++ b/src/desktop/Window.cpp
@@ -113,7 +113,7 @@ SBoxExtents CWindow::getFullWindowExtents() {
const int BORDERSIZE = getRealBorderSize();
if (m_sWindowData.dimAround.valueOrDefault()) {
- if (const auto PMONITOR = g_pCompositor->getMonitorFromID(m_iMonitorID); PMONITOR)
+ if (const auto PMONITOR = m_pMonitor.lock(); PMONITOR)
return {{m_vRealPosition.value().x - PMONITOR->vecPosition.x, m_vRealPosition.value().y - PMONITOR->vecPosition.y},
{PMONITOR->vecSize.x - (m_vRealPosition.value().x - PMONITOR->vecPosition.x), PMONITOR->vecSize.y - (m_vRealPosition.value().y - PMONITOR->vecPosition.y)}};
}
@@ -173,7 +173,7 @@ SBoxExtents CWindow::getFullWindowExtents() {
CBox CWindow::getFullWindowBoundingBox() {
if (m_sWindowData.dimAround.valueOrDefault()) {
- if (const auto PMONITOR = g_pCompositor->getMonitorFromID(m_iMonitorID); PMONITOR)
+ if (const auto PMONITOR = m_pMonitor.lock(); PMONITOR)
return {PMONITOR->vecPosition.x, PMONITOR->vecPosition.y, PMONITOR->vecSize.x, PMONITOR->vecSize.y};
}
@@ -186,7 +186,7 @@ CBox CWindow::getFullWindowBoundingBox() {
}
CBox CWindow::getWindowIdealBoundingBoxIgnoreReserved() {
- const auto PMONITOR = g_pCompositor->getMonitorFromID(m_iMonitorID);
+ const auto PMONITOR = m_pMonitor.lock();
if (!PMONITOR)
return {m_vPosition, m_vSize};
@@ -221,7 +221,7 @@ CBox CWindow::getWindowIdealBoundingBoxIgnoreReserved() {
CBox CWindow::getWindowBoxUnified(uint64_t properties) {
if (m_sWindowData.dimAround.valueOrDefault()) {
- const auto PMONITOR = g_pCompositor->getMonitorFromID(m_iMonitorID);
+ const auto PMONITOR = m_pMonitor.lock();
if (PMONITOR)
return {PMONITOR->vecPosition.x, PMONITOR->vecPosition.y, PMONITOR->vecSize.x, PMONITOR->vecSize.y};
}
@@ -352,9 +352,9 @@ void CWindow::updateSurfaceScaleTransformDetails(bool force) {
const auto PLASTMONITOR = g_pCompositor->getMonitorFromID(m_iLastSurfaceMonitorID);
- m_iLastSurfaceMonitorID = m_iMonitorID;
+ m_iLastSurfaceMonitorID = monitorID();
- const auto PNEWMONITOR = g_pCompositor->getMonitorFromID(m_iMonitorID);
+ const auto PNEWMONITOR = m_pMonitor.lock();
if (!PNEWMONITOR)
return;
@@ -366,10 +366,10 @@ void CWindow::updateSurfaceScaleTransformDetails(bool force) {
m_pWLSurface->resource()->breadthfirst([PNEWMONITOR](SP<CWLSurfaceResource> s, const Vector2D& offset, void* d) { s->enter(PNEWMONITOR->self.lock()); }, nullptr);
}
- m_pWLSurface->resource()->breadthfirst(
- [this](SP<CWLSurfaceResource> s, const Vector2D& offset, void* d) {
- const auto PMONITOR = g_pCompositor->getMonitorFromID(m_iMonitorID);
+ const auto PMONITOR = m_pMonitor.lock();
+ m_pWLSurface->resource()->breadthfirst(
+ [PMONITOR](SP<CWLSurfaceResource> s, const Vector2D& offset, void* d) {
const auto PSURFACE = CWLSurface::fromResource(s);
if (PSURFACE && PSURFACE->m_fLastScale == PMONITOR->scale)
return;
@@ -404,7 +404,7 @@ void CWindow::moveToWorkspace(PHLWORKSPACE pWorkspace) {
const auto OLDWORKSPACE = m_pWorkspace;
- m_iMonitorMovedFrom = OLDWORKSPACE ? OLDWORKSPACE->m_iMonitorID : -1;
+ m_iMonitorMovedFrom = OLDWORKSPACE ? OLDWORKSPACE->monitorID() : -1;
m_fMovingToWorkspaceAlpha.setValueAndWarp(1.F);
m_fMovingToWorkspaceAlpha = 0.F;
m_fMovingToWorkspaceAlpha.setCallbackOnEnd([this](void* thisptr) { m_iMonitorMovedFrom = -1; });
@@ -415,11 +415,11 @@ void CWindow::moveToWorkspace(PHLWORKSPACE pWorkspace) {
g_pCompositor->updateWorkspaceWindows(OLDWORKSPACE->m_iID);
g_pCompositor->updateWorkspaceWindowData(OLDWORKSPACE->m_iID);
- g_pLayoutManager->getCurrentLayout()->recalculateMonitor(OLDWORKSPACE->m_iMonitorID);
+ g_pLayoutManager->getCurrentLayout()->recalculateMonitor(OLDWORKSPACE->monitorID());
g_pCompositor->updateWorkspaceWindows(workspaceID());
g_pCompositor->updateWorkspaceWindowData(workspaceID());
- g_pLayoutManager->getCurrentLayout()->recalculateMonitor(m_iMonitorID);
+ g_pLayoutManager->getCurrentLayout()->recalculateMonitor(monitorID());
g_pCompositor->updateAllWindowsAnimatedDecorationValues();
@@ -431,14 +431,14 @@ void CWindow::moveToWorkspace(PHLWORKSPACE pWorkspace) {
if (const auto SWALLOWED = m_pSwallowed.lock()) {
SWALLOWED->moveToWorkspace(pWorkspace);
- SWALLOWED->m_iMonitorID = m_iMonitorID;
+ SWALLOWED->m_pMonitor = m_pMonitor;
}
// update xwayland coords
g_pXWaylandManager->setWindowSize(m_pSelf.lock(), m_vRealSize.value());
if (OLDWORKSPACE && g_pCompositor->isWorkspaceSpecial(OLDWORKSPACE->m_iID) && g_pCompositor->getWindowsOnWorkspace(OLDWORKSPACE->m_iID) == 0 && *PCLOSEONLASTSPECIAL) {
- if (const auto PMONITOR = g_pCompositor->getMonitorFromID(OLDWORKSPACE->m_iMonitorID); PMONITOR)
+ if (const auto PMONITOR = OLDWORKSPACE->m_pMonitor.lock(); PMONITOR)
PMONITOR->setSpecialWorkspace(nullptr);
}
}
@@ -517,19 +517,19 @@ void CWindow::onUnmap() {
std::erase_if(g_pCompositor->m_vWindowFocusHistory, [&](const auto& other) { return other.expired() || other.lock().get() == this; });
if (*PCLOSEONLASTSPECIAL && g_pCompositor->getWindowsOnWorkspace(workspaceID()) == 0 && onSpecialWorkspace()) {
- const auto PMONITOR = g_pCompositor->getMonitorFromID(m_iMonitorID);
+ const auto PMONITOR = m_pMonitor.lock();
if (PMONITOR && PMONITOR->activeSpecialWorkspace && PMONITOR->activeSpecialWorkspace == m_pWorkspace)
PMONITOR->setSpecialWorkspace(nullptr);
}
- const auto PMONITOR = g_pCompositor->getMonitorFromID(m_iMonitorID);
+ const auto PMONITOR = m_pMonitor.lock();
if (PMONITOR && PMONITOR->solitaryClient.lock().get() == this)
PMONITOR->solitaryClient.reset();
g_pCompositor->updateWorkspaceWindows(workspaceID());
g_pCompositor->updateWorkspaceWindowData(workspaceID());
- g_pLayoutManager->getCurrentLayout()->recalculateMonitor(m_iMonitorID);
+ g_pLayoutManager->getCurrentLayout()->recalculateMonitor(monitorID());
g_pCompositor->updateAllWindowsAnimatedDecorationValues();
m_pWorkspace.reset();
@@ -790,7 +790,7 @@ void CWindow::updateDynamicRules() {
EMIT_HOOK_EVENT("windowUpdateRules", m_pSelf.lock());
- g_pLayoutManager->getCurrentLayout()->recalculateMonitor(m_iMonitorID);
+ g_pLayoutManager->getCurrentLayout()->recalculateMonitor(monitorID());
}
// check if the point is "hidden" under a rounded corner of the window
@@ -857,7 +857,7 @@ void CWindow::createGroup() {
g_pCompositor->updateWorkspaceWindows(workspaceID());
g_pCompositor->updateWorkspaceWindowData(workspaceID());
- g_pLayoutManager->getCurrentLayout()->recalculateMonitor(m_iMonitorID);
+ g_pLayoutManager->getCurrentLayout()->recalculateMonitor(monitorID());
g_pCompositor->updateAllWindowsAnimatedDecorationValues();
g_pEventManager->postEvent(SHyprIPCEvent{"togglegroup", std::format("1,{:x}", (uintptr_t)this)});
@@ -875,7 +875,7 @@ void CWindow::destroyGroup() {
updateWindowDecos();
g_pCompositor->updateWorkspaceWindows(workspaceID());
g_pCompositor->updateWorkspaceWindowData(workspaceID());
- g_pLayoutManager->getCurrentLayout()->recalculateMonitor(m_iMonitorID);
+ g_pLayoutManager->getCurrentLayout()->recalculateMonitor(monitorID());
g_pCompositor->updateAllWindowsAnimatedDecorationValues();
g_pEventManager->postEvent(SHyprIPCEvent{"togglegroup", std::format("0,{:x}", (uintptr_t)this)});
@@ -911,7 +911,7 @@ void CWindow::destroyGroup() {
g_pCompositor->updateWorkspaceWindows(workspaceID());
g_pCompositor->updateWorkspaceWindowData(workspaceID());
- g_pLayoutManager->getCurrentLayout()->recalculateMonitor(m_iMonitorID);
+ g_pLayoutManager->getCurrentLayout()->recalculateMonitor(monitorID());
g_pCompositor->updateAllWindowsAnimatedDecorationValues();
if (!addresses.empty())
@@ -1087,7 +1087,7 @@ void CWindow::updateGroupOutputs() {
const auto WS = m_pWorkspace;
while (curr.get() != this) {
- curr->m_iMonitorID = m_iMonitorID;
+ curr->m_pMonitor = m_pMonitor;
curr->moveToWorkspace(WS);
curr->m_vRealPosition = m_vRealPosition.goal();
@@ -1209,7 +1209,7 @@ void CWindow::onWorkspaceAnimUpdate() {
if (!PWORKSPACE)
return;
- const auto PWSMON = g_pCompositor->getMonitorFromID(PWORKSPACE->m_iMonitorID);
+ const auto PWSMON = m_pMonitor.lock();
if (!PWSMON)
return;
@@ -1275,6 +1275,10 @@ WORKSPACEID CWindow::workspaceID() {
return m_pWorkspace ? m_pWorkspace->m_iID : m_iLastWorkspace;
}
+MONITORID CWindow::monitorID() {
+ return m_pMonitor ? m_pMonitor->ID : MONITOR_INVALID;
+}
+
bool CWindow::onSpecialWorkspace() {
return m_pWorkspace ? m_pWorkspace->m_bIsSpecialWorkspace : g_pCompositor->isWorkspaceSpecial(m_iLastWorkspace);
}
@@ -1461,7 +1465,7 @@ void CWindow::onX11Configure(CBox box) {
m_pXWaylandSurface->configure(box);
m_vPendingReportedSize = box.size();
m_vReportedSize = box.size();
- if (const auto PMONITOR = g_pCompositor->getMonitorFromID(m_iMonitorID); PMONITOR)
+ if (const auto PMONITOR = m_pMonitor.lock(); PMONITOR)
m_fX11SurfaceScaledBy = PMONITOR->scale;
return;
}
@@ -1487,7 +1491,7 @@ void CWindow::onX11Configure(CBox box) {
static auto PXWLFORCESCALEZERO = CConfigValue<Hyprlang::INT>("xwayland:force_zero_scaling");
if (*PXWLFORCESCALEZERO) {
- if (const auto PMONITOR = g_pCompositor->getMonitorFromID(m_iMonitorID); PMONITOR) {
+ if (const auto PMONITOR = m_pMonitor.lock(); PMONITOR) {
m_vRealSize.setValueAndWarp(m_vRealSize.goal() / PMONITOR->scale);
m_fX11SurfaceScaledBy = PMONITOR->scale;
}
diff --git a/src/desktop/Window.hpp b/src/desktop/Window.hpp
index 64f39558..825e8ca2 100644
--- a/src/desktop/Window.hpp
+++ b/src/desktop/Window.hpp
@@ -272,12 +272,12 @@ class CWindow {
bool m_bDraggingTiled = false; // for dragging around tiled windows
bool m_bWasMaximized = false;
sFullscreenState m_sFullscreenState = {.internal = FSMODE_NONE, .client = FSMODE_NONE};
- MONITORID m_iMonitorID = -1;
std::string m_szTitle = "";
std::string m_szClass = "";
std::string m_szInitialTitle = "";
std::string m_szInitialClass = "";
PHLWORKSPACE m_pWorkspace;
+ PHLMONITORREF m_pMonitor;
bool m_bIsMapped = false;
@@ -429,6 +429,7 @@ class CWindow {
void setSuspended(bool suspend);
bool visibleOnMonitor(PHLMONITOR pMonitor);
WORKSPACEID workspaceID();
+ MONITORID monitorID();
bool onSpecialWorkspace();
void activate(bool force = false);
int surfacesCount();
@@ -559,7 +560,7 @@ struct std::formatter<PHLWINDOW, CharT> : std::formatter<CharT> {
if (formatWorkspace)
std::format_to(out, ", workspace: {}", w->m_pWorkspace ? w->workspaceID() : WORKSPACE_INVALID);
if (formatMonitor)
- std::format_to(out, ", monitor: {}", w->m_iMonitorID);
+ std::format_to(out, ", monitor: {}", w->monitorID());
if (formatClass)
std::format_to(out, ", class: {}", w->m_szClass);
return std::format_to(out, "]");
diff --git a/src/desktop/Workspace.cpp b/src/desktop/Workspace.cpp
index 2d92659c..2e1e91f2 100644
--- a/src/desktop/Workspace.cpp
+++ b/src/desktop/Workspace.cpp
@@ -5,14 +5,14 @@
#include <hyprutils/string/String.hpp>
using namespace Hyprutils::String;
-PHLWORKSPACE CWorkspace::create(WORKSPACEID id, MONITORID monitorID, std::string name, bool special, bool isEmpty) {
- PHLWORKSPACE workspace = makeShared<CWorkspace>(id, monitorID, name, special, isEmpty);
+PHLWORKSPACE CWorkspace::create(WORKSPACEID id, PHLMONITOR monitor, std::string name, bool special, bool isEmpty) {
+ PHLWORKSPACE workspace = makeShared<CWorkspace>(id, monitor, name, special, isEmpty);
workspace->init(workspace);
return workspace;
}
-CWorkspace::CWorkspace(WORKSPACEID id, MONITORID monitorID, std::string name, bool special, bool isEmpty) {
- m_iMonitorID = monitorID;
+CWorkspace::CWorkspace(WORKSPACEID id, PHLMONITOR monitor, std::string name, bool special, bool isEmpty) {
+ m_pMonitor = monitor;
m_iID = id;
m_szName = name;
m_bIsSpecialWorkspace = special;
@@ -103,7 +103,7 @@ void CWorkspace::startAnim(bool in, bool left, bool instant) {
});
if (ANIMSTYLE.starts_with("slidefade")) {
- const auto PMONITOR = g_pCompositor->getMonitorFromID(m_iMonitorID);
+ const auto PMONITOR = m_pMonitor.lock();
float movePerc = 100.f;
if (ANIMSTYLE.find("%") != std::string::npos) {
@@ -151,7 +151,7 @@ void CWorkspace::startAnim(bool in, bool left, bool instant) {
}
} else if (ANIMSTYLE == "slidevert") {
// fallback is slide
- const auto PMONITOR = g_pCompositor->getMonitorFromID(m_iMonitorID);
+ const auto PMONITOR = m_pMonitor.lock();
const auto YDISTANCE = PMONITOR->vecSize.y + *PWORKSPACEGAP;
m_fAlpha.setValueAndWarp(1.f); // fix a bug, if switching from fade -> slide.
@@ -164,7 +164,7 @@ void CWorkspace::startAnim(bool in, bool left, bool instant) {
}
} else {
// fallback is slide
- const auto PMONITOR = g_pCompositor->getMonitorFromID(m_iMonitorID);
+ const auto PMONITOR = m_pMonitor.lock();
const auto XDISTANCE = PMONITOR->vecSize.x + *PWORKSPACEGAP;
m_fAlpha.setValueAndWarp(1.f); // fix a bug, if switching from fade -> slide.
@@ -224,7 +224,7 @@ void CWorkspace::rememberPrevWorkspace(const PHLWORKSPACE& prev) {
m_sPrevWorkspace.id = prev->m_iID;
m_sPrevWorkspace.name = prev->m_szName;
- if (prev->m_iMonitorID == m_iMonitorID) {
+ if (prev->m_pMonitor == m_pMonitor) {
m_sPrevWorkspacePerMonitor.id = prev->m_iID;
m_sPrevWorkspacePerMonitor.name = prev->m_szName;
}
@@ -347,7 +347,7 @@ bool CWorkspace::matchesStaticSelector(const std::string& selector_) {
const auto PMONITOR = g_pCompositor->getMonitorFromString(prop);
- if (!(PMONITOR ? PMONITOR->ID == m_iMonitorID : false))
+ if (!(PMONITOR ? PMONITOR == m_pMonitor : false))
return false;
continue;
}
@@ -512,12 +512,16 @@ bool CWorkspace::matchesStaticSelector(const std::string& selector_) {
}
void CWorkspace::markInert() {
- m_bInert = true;
- m_iID = WORKSPACE_INVALID;
- m_iMonitorID = MONITOR_INVALID;
- m_bVisible = false;
+ m_bInert = true;
+ m_iID = WORKSPACE_INVALID;
+ m_bVisible = false;
+ m_pMonitor.reset();
}
bool CWorkspace::inert() {
return m_bInert;
}
+
+MONITORID CWorkspace::monitorID() {
+ return m_pMonitor ? m_pMonitor->ID : MONITOR_INVALID;
+}
diff --git a/src/desktop/Workspace.hpp b/src/desktop/Workspace.hpp
index 7a32459c..3ed9f50c 100644
--- a/src/desktop/Workspace.hpp
+++ b/src/desktop/Workspace.hpp
@@ -17,16 +17,16 @@ class CWindow;
class CWorkspace {
public:
- static PHLWORKSPACE create(WORKSPACEID id, MONITORID monitorID, std::string name, bool special = false, bool isEmpty = true);
+ static PHLWORKSPACE create(WORKSPACEID id, PHLMONITOR monitor, std::string name, bool special = false, bool isEmpty = true);
// use create() don't use this
- CWorkspace(WORKSPACEID id, MONITORID monitorID, std::string name, bool special = false, bool isEmpty = true);
+ CWorkspace(WORKSPACEID id, PHLMONITOR monitor, std::string name, bool special = false, bool isEmpty = true);
~CWorkspace();
// Workspaces ID-based have IDs > 0
// and workspaces name-based have IDs starting with -1337
- WORKSPACEID m_iID = WORKSPACE_INVALID;
- std::string m_szName = "";
- MONITORID m_iMonitorID = MONITOR_INVALID;
+ WORKSPACEID m_iID = WORKSPACE_INVALID;
+ std::string m_szName = "";
+ PHLMONITORREF m_pMonitor;
// Previous workspace ID and name is stored during a workspace change, allowing travel
// to the previous workspace.
SWorkspaceIDName m_sPrevWorkspace, m_sPrevWorkspacePerMonitor;
@@ -68,6 +68,7 @@ class CWorkspace {
void setActive(bool on);
void moveToMonitor(const MONITORID&);
+ MONITORID monitorID();
PHLWINDOW getLastFocusedWindow();
void rememberPrevWorkspace(const PHLWORKSPACE& prevWorkspace);