summaryrefslogtreecommitdiff
path: root/src/desktop/Workspace.cpp
diff options
context:
space:
mode:
authorVaxry <43317083+vaxerski@users.noreply.github.com>2026-02-21 21:30:39 +0000
committerGitHub <noreply@github.com>2026-02-21 21:30:39 +0000
commit723870337f299d4c80aa0048144f3a1ca1c885bd (patch)
treeca3279ae5dbc841f676c64d2f58f895de13cd3bf /src/desktop/Workspace.cpp
parent51f8849e541f0a8150ac3a43fa928c1e299daf18 (diff)
layout: rethonk layouts from the ground up (#12890)
Rewrites layouts to be much smaller, and deal with much less annoying BS. Improves the overall architecture, unifies handling of pseudotiling, and various other improvements.
Diffstat (limited to 'src/desktop/Workspace.cpp')
-rw-r--r--src/desktop/Workspace.cpp45
1 files changed, 27 insertions, 18 deletions
diff --git a/src/desktop/Workspace.cpp b/src/desktop/Workspace.cpp
index 2895137d..f6e5288e 100644
--- a/src/desktop/Workspace.cpp
+++ b/src/desktop/Workspace.cpp
@@ -1,10 +1,13 @@
#include "Workspace.hpp"
+#include "view/Group.hpp"
#include "../Compositor.hpp"
#include "../config/ConfigValue.hpp"
#include "config/ConfigManager.hpp"
#include "managers/animation/AnimationManager.hpp"
#include "../managers/EventManager.hpp"
#include "../managers/HookSystemManager.hpp"
+#include "../layout/space/Space.hpp"
+#include "../layout/supplementary/WorkspaceAlgoMatcher.hpp"
#include <hyprutils/animation/AnimatedVariable.hpp>
#include <hyprutils/string/String.hpp>
@@ -41,6 +44,9 @@ void CWorkspace::init(PHLWORKSPACE self) {
m_lastFocusedWindow.reset();
});
+ m_space = Layout::CSpace::create(m_self.lock());
+ m_space->setAlgorithmProvider(Layout::Supplementary::algoMatcher()->createAlgorithmForWorkspace(m_self.lock()));
+
m_inert = false;
const auto WORKSPACERULE = g_pConfigManager->getWorkspaceRuleFor(self);
@@ -406,14 +412,19 @@ bool CWorkspace::isVisibleNotCovered() {
int CWorkspace::getWindows(std::optional<bool> onlyTiled, std::optional<bool> onlyPinned, std::optional<bool> onlyVisible) {
int no = 0;
- for (auto const& w : g_pCompositor->m_windows) {
- if (w->workspaceID() != m_id || !w->m_isMapped)
+
+ if (!m_space)
+ return 0;
+
+ for (auto const& t : m_space->targets()) {
+ if (!t)
continue;
- if (onlyTiled.has_value() && w->m_isFloating == onlyTiled.value())
+
+ if (onlyTiled.has_value() && t->floating() == onlyTiled.value())
continue;
- if (onlyPinned.has_value() && w->m_pinned != onlyPinned.value())
+ if (onlyPinned.has_value() && (!t->window() || t->window()->m_pinned != onlyPinned.value()))
continue;
- if (onlyVisible.has_value() && w->isHidden() == onlyVisible.value())
+ if (onlyVisible.has_value() && (!t->window() || t->window()->isHidden() == onlyVisible.value()))
continue;
no++;
}
@@ -423,16 +434,16 @@ int CWorkspace::getWindows(std::optional<bool> onlyTiled, std::optional<bool> on
int CWorkspace::getGroups(std::optional<bool> onlyTiled, std::optional<bool> onlyPinned, std::optional<bool> onlyVisible) {
int no = 0;
- for (auto const& w : g_pCompositor->m_windows) {
- if (w->workspaceID() != m_id || !w->m_isMapped)
- continue;
- if (!w->m_groupData.head)
+ for (auto const& g : Desktop::View::groups()) {
+ const auto HEAD = g->head();
+
+ if (HEAD->workspaceID() != m_id || !HEAD->m_isMapped)
continue;
- if (onlyTiled.has_value() && w->m_isFloating == onlyTiled.value())
+ if (onlyTiled.has_value() && HEAD->m_isFloating == onlyTiled.value())
continue;
- if (onlyPinned.has_value() && w->m_pinned != onlyPinned.value())
+ if (onlyPinned.has_value() && HEAD->m_pinned != onlyPinned.value())
continue;
- if (onlyVisible.has_value() && w->isHidden() == onlyVisible.value())
+ if (onlyVisible.has_value() && g->current()->isHidden() == onlyVisible.value())
continue;
no++;
}
@@ -514,13 +525,11 @@ void CWorkspace::rename(const std::string& name) {
}
void CWorkspace::updateWindows() {
- m_hasFullscreenWindow = std::ranges::any_of(g_pCompositor->m_windows, [this](const auto& w) { return w->m_isMapped && w->m_workspace == m_self && w->isFullscreen(); });
-
- for (auto const& w : g_pCompositor->m_windows) {
- if (!w->m_isMapped || w->m_workspace != m_self)
- continue;
+ m_hasFullscreenWindow = std::ranges::any_of(m_space->targets(), [](const auto& t) { return t->fullscreenMode() != FSMODE_NONE; });
- w->m_ruleApplicator->propertiesChanged(Desktop::Rule::RULE_PROP_ON_WORKSPACE);
+ for (auto const& t : m_space->targets()) {
+ if (t->window())
+ t->window()->m_ruleApplicator->propertiesChanged(Desktop::Rule::RULE_PROP_ON_WORKSPACE);
}
}