summaryrefslogtreecommitdiff
path: root/src/desktop/Workspace.cpp
diff options
context:
space:
mode:
authorVaxry <43317083+vaxerski@users.noreply.github.com>2024-04-02 20:32:39 +0100
committerGitHub <noreply@github.com>2024-04-02 20:32:39 +0100
commitef23ef60c5641c5903f9cf40571ead7ad6aba1b9 (patch)
tree2eece29849bf25d7710edd9cee5d12186a9253fc /src/desktop/Workspace.cpp
parentfc0a7af7ba5c52f7a70309020f5cb27c19d068e6 (diff)
Workspace/core: Refactor workspace storage (#5380)
* refactor workspaces to use ptrs * clang-format
Diffstat (limited to 'src/desktop/Workspace.cpp')
-rw-r--r--src/desktop/Workspace.cpp36
1 files changed, 29 insertions, 7 deletions
diff --git a/src/desktop/Workspace.cpp b/src/desktop/Workspace.cpp
index 9200b4d7..ccb0fa25 100644
--- a/src/desktop/Workspace.cpp
+++ b/src/desktop/Workspace.cpp
@@ -2,6 +2,12 @@
#include "../Compositor.hpp"
#include "../config/ConfigValue.hpp"
+PHLWORKSPACE CWorkspace::create(int id, int monitorID, std::string name, bool special) {
+ PHLWORKSPACE workspace = std::make_shared<CWorkspace>(id, monitorID, name, special);
+ workspace->init(workspace);
+ return workspace;
+}
+
CWorkspace::CWorkspace(int id, int monitorID, std::string name, bool special) {
const auto PMONITOR = g_pCompositor->getMonitorFromID(monitorID);
@@ -14,17 +20,22 @@ CWorkspace::CWorkspace(int id, int monitorID, std::string name, bool special) {
m_iID = id;
m_szName = name;
m_bIsSpecialWorkspace = special;
+}
- m_vRenderOffset.create(special ? g_pConfigManager->getAnimationPropertyConfig("specialWorkspace") : g_pConfigManager->getAnimationPropertyConfig("workspaces"), this,
- AVARDAMAGE_ENTIRE);
- m_fAlpha.create(AVARTYPE_FLOAT, special ? g_pConfigManager->getAnimationPropertyConfig("specialWorkspace") : g_pConfigManager->getAnimationPropertyConfig("workspaces"), this,
+void CWorkspace::init(PHLWORKSPACE self) {
+ m_pSelf = self;
+
+ m_vRenderOffset.create(m_bIsSpecialWorkspace ? g_pConfigManager->getAnimationPropertyConfig("specialWorkspace") : g_pConfigManager->getAnimationPropertyConfig("workspaces"),
+ self, AVARDAMAGE_ENTIRE);
+ m_fAlpha.create(AVARTYPE_FLOAT,
+ m_bIsSpecialWorkspace ? g_pConfigManager->getAnimationPropertyConfig("specialWorkspace") : g_pConfigManager->getAnimationPropertyConfig("workspaces"), self,
AVARDAMAGE_ENTIRE);
m_fAlpha.setValueAndWarp(1.f);
m_vRenderOffset.registerVar();
m_fAlpha.registerVar();
- const auto RULESFORTHIS = g_pConfigManager->getWorkspaceRulesFor(this);
+ const auto RULESFORTHIS = g_pConfigManager->getWorkspaceRulesFor(self);
for (auto& rule : RULESFORTHIS) {
if (rule.defaultName.has_value())
m_szName = rule.defaultName.value();
@@ -37,6 +48,8 @@ CWorkspace::CWorkspace(int id, int monitorID, std::string name, bool special) {
m_pLastFocusedWindow = nullptr;
});
+ m_bInert = false;
+
g_pEventManager->postEvent({"createworkspace", m_szName});
g_pEventManager->postEvent({"createworkspacev2", std::format("{},{}", m_iID, m_szName)});
EMIT_HOOK_EVENT("createWorkspace", this);
@@ -61,7 +74,7 @@ void CWorkspace::startAnim(bool in, bool left, bool instant) {
// set floating windows offset callbacks
m_vRenderOffset.setUpdateCallback([&](void*) {
for (auto& w : g_pCompositor->m_vWindows) {
- if (!g_pCompositor->windowValidMapped(w.get()) || w->m_iWorkspaceID != m_iID)
+ if (!g_pCompositor->windowValidMapped(w.get()) || w->workspaceID() != m_iID)
continue;
w->onWorkspaceAnimUpdate();
@@ -169,13 +182,13 @@ void CWorkspace::moveToMonitor(const int& id) {
}
CWindow* CWorkspace::getLastFocusedWindow() {
- if (!g_pCompositor->windowValidMapped(m_pLastFocusedWindow) || m_pLastFocusedWindow->m_iWorkspaceID != m_iID)
+ if (!g_pCompositor->windowValidMapped(m_pLastFocusedWindow) || m_pLastFocusedWindow->workspaceID() != m_iID)
return nullptr;
return m_pLastFocusedWindow;
}
-void CWorkspace::rememberPrevWorkspace(const CWorkspace* prev) {
+void CWorkspace::rememberPrevWorkspace(const PHLWORKSPACE& prev) {
if (!prev) {
m_sPrevWorkspace.iID = -1;
m_sPrevWorkspace.name = "";
@@ -405,3 +418,12 @@ bool CWorkspace::matchesStaticSelector(const std::string& selector_) {
UNREACHABLE();
return false;
}
+
+void CWorkspace::markInert() {
+ m_bInert = true;
+ m_iID = WORKSPACE_INVALID;
+}
+
+bool CWorkspace::inert() {
+ return m_bInert;
+}