summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/desktop/LayerRule.cpp2
-rw-r--r--src/desktop/LayerSurface.cpp4
-rw-r--r--src/desktop/Popup.cpp1
-rw-r--r--src/desktop/Window.cpp83
-rw-r--r--src/desktop/Window.hpp8
-rw-r--r--src/desktop/WindowRule.cpp13
-rw-r--r--src/desktop/Workspace.cpp19
-rw-r--r--src/desktop/Workspace.hpp1
8 files changed, 57 insertions, 74 deletions
diff --git a/src/desktop/LayerRule.cpp b/src/desktop/LayerRule.cpp
index 9b5f9da2..dfcd289a 100644
--- a/src/desktop/LayerRule.cpp
+++ b/src/desktop/LayerRule.cpp
@@ -8,7 +8,7 @@ static const auto RULES = std::unordered_set<std::string>{"noanim", "blur
static const auto RULES_PREFIX = std::unordered_set<std::string>{"ignorealpha", "ignorezero", "xray", "animation", "order", "abovelock"};
CLayerRule::CLayerRule(const std::string& rule_, const std::string& ns_) : m_targetNamespace(ns_), m_rule(rule_) {
- const bool VALID = RULES.contains(m_rule) || std::any_of(RULES_PREFIX.begin(), RULES_PREFIX.end(), [&rule_](const auto& prefix) { return rule_.starts_with(prefix); });
+ const bool VALID = RULES.contains(m_rule) || std::ranges::any_of(RULES_PREFIX, [&rule_](const auto& prefix) { return rule_.starts_with(prefix); });
if (!VALID)
return;
diff --git a/src/desktop/LayerSurface.cpp b/src/desktop/LayerSurface.cpp
index a5d9067a..f913b658 100644
--- a/src/desktop/LayerSurface.cpp
+++ b/src/desktop/LayerSurface.cpp
@@ -186,7 +186,7 @@ void CLayerSurface::onMap() {
m_readyToDelete = false;
m_fadingOut = false;
- g_pEventManager->postEvent(SHyprIPCEvent{"openlayer", m_namespace});
+ g_pEventManager->postEvent(SHyprIPCEvent{.event = "openlayer", .data = m_namespace});
EMIT_HOOK_EVENT("openLayer", m_self.lock());
g_pCompositor->setPreferredScaleForSurface(m_surface->resource(), PMONITOR->m_scale);
@@ -196,7 +196,7 @@ void CLayerSurface::onMap() {
void CLayerSurface::onUnmap() {
Debug::log(LOG, "LayerSurface {:x} unmapped", (uintptr_t)m_layerSurface.get());
- g_pEventManager->postEvent(SHyprIPCEvent{"closelayer", m_layerSurface->m_layerNamespace});
+ g_pEventManager->postEvent(SHyprIPCEvent{.event = "closelayer", .data = m_layerSurface->m_layerNamespace});
EMIT_HOOK_EVENT("closeLayer", m_self.lock());
std::erase_if(g_pInputManager->m_exclusiveLSes, [this](const auto& other) { return !other || other == m_self; });
diff --git a/src/desktop/Popup.cpp b/src/desktop/Popup.cpp
index ed882c3a..b647bed5 100644
--- a/src/desktop/Popup.cpp
+++ b/src/desktop/Popup.cpp
@@ -5,7 +5,6 @@
#include "../protocols/XDGShell.hpp"
#include "../protocols/core/Compositor.hpp"
#include "../managers/SeatManager.hpp"
-#include "../managers/eventLoop/EventLoopManager.hpp"
#include "../desktop/LayerSurface.hpp"
#include "../managers/input/InputManager.hpp"
#include "../render/Renderer.hpp"
diff --git a/src/desktop/Window.cpp b/src/desktop/Window.cpp
index c2b92094..f90702dc 100644
--- a/src/desktop/Window.cpp
+++ b/src/desktop/Window.cpp
@@ -1,10 +1,10 @@
+#include <algorithm>
#include <hyprutils/animation/AnimatedVariable.hpp>
#include <re2/re2.h>
#include <any>
#include <bit>
#include <string_view>
-#include <algorithm>
#include "Window.hpp"
#include "../Compositor.hpp"
#include "../render/decorations/CHyprDropShadowDecoration.hpp"
@@ -137,25 +137,22 @@ SBoxExtents CWindow::getFullWindowExtents() {
if (m_windowData.dimAround.valueOrDefault()) {
if (const auto PMONITOR = m_monitor.lock(); PMONITOR)
- return {{m_realPosition->value().x - PMONITOR->m_position.x, m_realPosition->value().y - PMONITOR->m_position.y},
- {PMONITOR->m_size.x - (m_realPosition->value().x - PMONITOR->m_position.x), PMONITOR->m_size.y - (m_realPosition->value().y - PMONITOR->m_position.y)}};
+ return {.topLeft = {m_realPosition->value().x - PMONITOR->m_position.x, m_realPosition->value().y - PMONITOR->m_position.y},
+ .bottomRight = {PMONITOR->m_size.x - (m_realPosition->value().x - PMONITOR->m_position.x),
+ PMONITOR->m_size.y - (m_realPosition->value().y - PMONITOR->m_position.y)}};
}
- SBoxExtents maxExtents = {{BORDERSIZE + 2, BORDERSIZE + 2}, {BORDERSIZE + 2, BORDERSIZE + 2}};
+ SBoxExtents maxExtents = {.topLeft = {BORDERSIZE + 2, BORDERSIZE + 2}, .bottomRight = {BORDERSIZE + 2, BORDERSIZE + 2}};
const auto EXTENTS = g_pDecorationPositioner->getWindowDecorationExtents(m_self.lock());
- if (EXTENTS.topLeft.x > maxExtents.topLeft.x)
- maxExtents.topLeft.x = EXTENTS.topLeft.x;
+ maxExtents.topLeft.x = std::max(EXTENTS.topLeft.x, maxExtents.topLeft.x);
- if (EXTENTS.topLeft.y > maxExtents.topLeft.y)
- maxExtents.topLeft.y = EXTENTS.topLeft.y;
+ maxExtents.topLeft.y = std::max(EXTENTS.topLeft.y, maxExtents.topLeft.y);
- if (EXTENTS.bottomRight.x > maxExtents.bottomRight.x)
- maxExtents.bottomRight.x = EXTENTS.bottomRight.x;
+ maxExtents.bottomRight.x = std::max(EXTENTS.bottomRight.x, maxExtents.bottomRight.x);
- if (EXTENTS.bottomRight.y > maxExtents.bottomRight.y)
- maxExtents.bottomRight.y = EXTENTS.bottomRight.y;
+ maxExtents.bottomRight.y = std::max(EXTENTS.bottomRight.y, maxExtents.bottomRight.y);
if (m_wlSurface->exists() && !m_isX11 && m_popupHead) {
CBox surfaceExtents = {0, 0, 0, 0};
@@ -167,10 +164,8 @@ SBoxExtents CWindow::getFullWindowExtents() {
CBox* pSurfaceExtents = (CBox*)data;
CBox surf = CBox{popup->coordsRelativeToParent(), popup->size()};
- if (surf.x < pSurfaceExtents->x)
- pSurfaceExtents->x = surf.x;
- if (surf.y < pSurfaceExtents->y)
- pSurfaceExtents->y = surf.y;
+ pSurfaceExtents->x = std::min(surf.x, pSurfaceExtents->x);
+ pSurfaceExtents->y = std::min(surf.y, pSurfaceExtents->y);
if (surf.x + surf.w > pSurfaceExtents->width)
pSurfaceExtents->width = surf.x + surf.w - pSurfaceExtents->x;
if (surf.y + surf.h > pSurfaceExtents->height)
@@ -178,11 +173,9 @@ SBoxExtents CWindow::getFullWindowExtents() {
},
&surfaceExtents);
- if (-surfaceExtents.x > maxExtents.topLeft.x)
- maxExtents.topLeft.x = -surfaceExtents.x;
+ maxExtents.topLeft.x = std::max(-surfaceExtents.x, maxExtents.topLeft.x);
- if (-surfaceExtents.y > maxExtents.topLeft.y)
- maxExtents.topLeft.y = -surfaceExtents.y;
+ maxExtents.topLeft.y = std::max(-surfaceExtents.y, maxExtents.topLeft.y);
if (surfaceExtents.x + surfaceExtents.width > m_wlSurface->resource()->m_current.size.x + maxExtents.bottomRight.x)
maxExtents.bottomRight.x = surfaceExtents.x + surfaceExtents.width - m_wlSurface->resource()->m_current.size.x;
@@ -249,7 +242,7 @@ CBox CWindow::getWindowBoxUnified(uint64_t properties) {
return {PMONITOR->m_position.x, PMONITOR->m_position.y, PMONITOR->m_size.x, PMONITOR->m_size.y};
}
- SBoxExtents EXTENTS = {{0, 0}, {0, 0}};
+ SBoxExtents EXTENTS = {.topLeft = {0, 0}, .bottomRight = {0, 0}};
if (properties & RESERVED_EXTENTS)
EXTENTS.addExtents(g_pDecorationPositioner->getWindowDecorationReserved(m_self.lock()));
if (properties & INPUT_EXTENTS)
@@ -297,7 +290,7 @@ void CWindow::updateWindowDecos() {
}
for (auto const& wd : decos) {
- if (std::find_if(m_windowDecorations.begin(), m_windowDecorations.end(), [wd](const auto& other) { return other.get() == wd; }) == m_windowDecorations.end())
+ if (std::ranges::find_if(m_windowDecorations, [wd](const auto& other) { return other.get() == wd; }) == m_windowDecorations.end())
continue;
wd->updateWindow(m_self.lock());
}
@@ -452,8 +445,8 @@ void CWindow::moveToWorkspace(PHLWORKSPACE pWorkspace) {
g_pCompositor->updateAllWindowsAnimatedDecorationValues();
if (valid(pWorkspace)) {
- g_pEventManager->postEvent(SHyprIPCEvent{"movewindow", std::format("{:x},{}", (uintptr_t)this, pWorkspace->m_name)});
- g_pEventManager->postEvent(SHyprIPCEvent{"movewindowv2", std::format("{:x},{},{}", (uintptr_t)this, pWorkspace->m_id, pWorkspace->m_name)});
+ g_pEventManager->postEvent(SHyprIPCEvent{.event = "movewindow", .data = std::format("{:x},{}", (uintptr_t)this, pWorkspace->m_name)});
+ g_pEventManager->postEvent(SHyprIPCEvent{.event = "movewindowv2", .data = std::format("{:x},{},{}", (uintptr_t)this, pWorkspace->m_id, pWorkspace->m_name)});
EMIT_HOOK_EVENT("moveWindow", (std::vector<std::any>{m_self.lock(), pWorkspace}));
}
@@ -479,7 +472,7 @@ PHLWINDOW CWindow::x11TransientFor() {
while (s) {
// break loops. Some X apps make them, and it seems like it's valid behavior?!?!?!
// TODO: we should reject loops being created in the first place.
- if (std::find(visited.begin(), visited.end(), s) != visited.end())
+ if (std::ranges::find(visited.begin(), visited.end(), s) != visited.end())
break;
visited.emplace_back(s.lock());
@@ -647,18 +640,18 @@ void CWindow::applyDynamicRule(const SP<CWindowRule>& r) {
if (r == "override") {
if (opacityIDX == 1)
- m_windowData.alpha = CWindowOverridableVar(SAlphaValue{m_windowData.alpha.value().alpha, true}, priority);
+ m_windowData.alpha = CWindowOverridableVar(SAlphaValue{.alpha = m_windowData.alpha.value().alpha, .overridden = true}, priority);
else if (opacityIDX == 2)
- m_windowData.alphaInactive = CWindowOverridableVar(SAlphaValue{m_windowData.alphaInactive.value().alpha, true}, priority);
+ m_windowData.alphaInactive = CWindowOverridableVar(SAlphaValue{.alpha = m_windowData.alphaInactive.value().alpha, .overridden = true}, priority);
else if (opacityIDX == 3)
- m_windowData.alphaFullscreen = CWindowOverridableVar(SAlphaValue{m_windowData.alphaFullscreen.value().alpha, true}, priority);
+ m_windowData.alphaFullscreen = CWindowOverridableVar(SAlphaValue{.alpha = m_windowData.alphaFullscreen.value().alpha, .overridden = true}, priority);
} else {
if (opacityIDX == 0) {
- m_windowData.alpha = CWindowOverridableVar(SAlphaValue{std::stof(r), false}, priority);
+ m_windowData.alpha = CWindowOverridableVar(SAlphaValue{.alpha = std::stof(r), .overridden = false}, priority);
} else if (opacityIDX == 1) {
- m_windowData.alphaInactive = CWindowOverridableVar(SAlphaValue{std::stof(r), false}, priority);
+ m_windowData.alphaInactive = CWindowOverridableVar(SAlphaValue{.alpha = std::stof(r), .overridden = false}, priority);
} else if (opacityIDX == 2) {
- m_windowData.alphaFullscreen = CWindowOverridableVar(SAlphaValue{std::stof(r), false}, priority);
+ m_windowData.alphaFullscreen = CWindowOverridableVar(SAlphaValue{.alpha = std::stof(r), .overridden = false}, priority);
} else {
throw std::runtime_error("more than 3 alpha values");
}
@@ -702,9 +695,9 @@ void CWindow::applyDynamicRule(const SP<CWindowRule>& r) {
} else if (token.contains("deg"))
inactiveBorderGradient.m_angle = std::stoi(token.substr(0, token.size() - 3)) * (PI / 180.0);
else if (active)
- activeBorderGradient.m_colors.push_back(configStringToInt(token).value_or(0));
+ activeBorderGradient.m_colors.emplace_back(configStringToInt(token).value_or(0));
else
- inactiveBorderGradient.m_colors.push_back(configStringToInt(token).value_or(0));
+ inactiveBorderGradient.m_colors.emplace_back(configStringToInt(token).value_or(0));
}
activeBorderGradient.updateColorsOk();
@@ -902,7 +895,7 @@ void CWindow::createGroup() {
g_pLayoutManager->getCurrentLayout()->recalculateMonitor(monitorID());
g_pCompositor->updateAllWindowsAnimatedDecorationValues();
- g_pEventManager->postEvent(SHyprIPCEvent{"togglegroup", std::format("1,{:x}", (uintptr_t)this)});
+ g_pEventManager->postEvent(SHyprIPCEvent{.event = "togglegroup", .data = std::format("1,{:x}", (uintptr_t)this)});
}
}
@@ -922,7 +915,7 @@ void CWindow::destroyGroup() {
g_pLayoutManager->getCurrentLayout()->recalculateMonitor(monitorID());
g_pCompositor->updateAllWindowsAnimatedDecorationValues();
- g_pEventManager->postEvent(SHyprIPCEvent{"togglegroup", std::format("0,{:x}", (uintptr_t)this)});
+ g_pEventManager->postEvent(SHyprIPCEvent{.event = "togglegroup", .data = std::format("0,{:x}", (uintptr_t)this)});
return;
}
@@ -962,7 +955,7 @@ void CWindow::destroyGroup() {
if (!addresses.empty())
addresses.pop_back();
- g_pEventManager->postEvent(SHyprIPCEvent{"togglegroup", std::format("0,{}", addresses)});
+ g_pEventManager->postEvent(SHyprIPCEvent{.event = "togglegroup", .data = std::format("0,{}", addresses)});
}
PHLWINDOW CWindow::getGroupHead() {
@@ -1399,7 +1392,7 @@ void CWindow::activate(bool force) {
m_isUrgent = true;
- g_pEventManager->postEvent(SHyprIPCEvent{"urgent", std::format("{:x}", (uintptr_t)this)});
+ g_pEventManager->postEvent(SHyprIPCEvent{.event = "urgent", .data = std::format("{:x}", (uintptr_t)this)});
EMIT_HOOK_EVENT("urgent", m_self.lock());
if (!force && (!m_windowData.focusOnActivate.valueOr(*PFOCUSONACTIVATE) || (m_suppressedEvents & SUPPRESS_ACTIVATE_FOCUSONLY) || (m_suppressedEvents & SUPPRESS_ACTIVATE)))
@@ -1454,13 +1447,13 @@ void CWindow::onUpdateMeta() {
if (m_title != NEWTITLE) {
m_title = NEWTITLE;
- g_pEventManager->postEvent(SHyprIPCEvent{"windowtitle", std::format("{:x}", (uintptr_t)this)});
- g_pEventManager->postEvent(SHyprIPCEvent{"windowtitlev2", std::format("{:x},{}", (uintptr_t)this, m_title)});
+ g_pEventManager->postEvent(SHyprIPCEvent{.event = "windowtitle", .data = std::format("{:x}", (uintptr_t)this)});
+ g_pEventManager->postEvent(SHyprIPCEvent{.event = "windowtitlev2", .data = std::format("{:x},{}", (uintptr_t)this, m_title)});
EMIT_HOOK_EVENT("windowTitle", m_self.lock());
if (m_self == g_pCompositor->m_lastWindow) { // if it's the active, let's post an event to update others
- g_pEventManager->postEvent(SHyprIPCEvent{"activewindow", m_class + "," + m_title});
- g_pEventManager->postEvent(SHyprIPCEvent{"activewindowv2", std::format("{:x}", (uintptr_t)this)});
+ g_pEventManager->postEvent(SHyprIPCEvent{.event = "activewindow", .data = m_class + "," + m_title});
+ g_pEventManager->postEvent(SHyprIPCEvent{.event = "activewindowv2", .data = std::format("{:x}", (uintptr_t)this)});
EMIT_HOOK_EVENT("activeWindow", m_self.lock());
}
@@ -1473,8 +1466,8 @@ void CWindow::onUpdateMeta() {
m_class = NEWCLASS;
if (m_self == g_pCompositor->m_lastWindow) { // if it's the active, let's post an event to update others
- g_pEventManager->postEvent(SHyprIPCEvent{"activewindow", m_class + "," + m_title});
- g_pEventManager->postEvent(SHyprIPCEvent{"activewindowv2", std::format("{:x}", (uintptr_t)this)});
+ g_pEventManager->postEvent(SHyprIPCEvent{.event = "activewindow", .data = m_class + "," + m_title});
+ g_pEventManager->postEvent(SHyprIPCEvent{.event = "activewindowv2", .data = std::format("{:x}", (uintptr_t)this)});
EMIT_HOOK_EVENT("activeWindow", m_self.lock());
}
@@ -1514,7 +1507,7 @@ std::string CWindow::fetchClass() {
}
void CWindow::onAck(uint32_t serial) {
- const auto SERIAL = std::find_if(m_pendingSizeAcks.rbegin(), m_pendingSizeAcks.rend(), [serial](const auto& e) { return e.first == serial; });
+ const auto SERIAL = std::ranges::find_if(m_pendingSizeAcks.rbegin(), m_pendingSizeAcks.rend(), [serial](const auto& e) { return e.first == serial; });
if (SERIAL == m_pendingSizeAcks.rend())
return;
@@ -1647,7 +1640,7 @@ PHLWINDOW CWindow::getSwallower() {
if (!w)
continue;
- if (std::find(candidates.begin(), candidates.end(), w.lock()) != candidates.end())
+ if (std::ranges::find(candidates.begin(), candidates.end(), w.lock()) != candidates.end())
return w.lock();
}
diff --git a/src/desktop/Window.hpp b/src/desktop/Window.hpp
index abc2747f..47d28db2 100644
--- a/src/desktop/Window.hpp
+++ b/src/desktop/Window.hpp
@@ -6,8 +6,6 @@
#include "../config/ConfigDataValues.hpp"
#include "../helpers/AnimatedVariable.hpp"
-#include "../helpers/math/Math.hpp"
-#include "../helpers/signal/Signal.hpp"
#include "../helpers/TagKeeper.hpp"
#include "../macros.hpp"
#include "../managers/XWaylandManager.hpp"
@@ -79,9 +77,9 @@ struct SAlphaValue {
};
struct SWindowData {
- CWindowOverridableVar<SAlphaValue> alpha = SAlphaValue{1.f, false};
- CWindowOverridableVar<SAlphaValue> alphaInactive = SAlphaValue{1.f, false};
- CWindowOverridableVar<SAlphaValue> alphaFullscreen = SAlphaValue{1.f, false};
+ CWindowOverridableVar<SAlphaValue> alpha = SAlphaValue{.alpha = 1.f, .overridden = false};
+ CWindowOverridableVar<SAlphaValue> alphaInactive = SAlphaValue{.alpha = 1.f, .overridden = false};
+ CWindowOverridableVar<SAlphaValue> alphaFullscreen = SAlphaValue{.alpha = 1.f, .overridden = false};
CWindowOverridableVar<bool> allowsInput = false;
CWindowOverridableVar<bool> dimAround = false;
diff --git a/src/desktop/WindowRule.cpp b/src/desktop/WindowRule.cpp
index db1b0dde..48bf2ff0 100644
--- a/src/desktop/WindowRule.cpp
+++ b/src/desktop/WindowRule.cpp
@@ -15,10 +15,9 @@ static const auto RULES_PREFIX = std::unordered_set<std::string>{
CWindowRule::CWindowRule(const std::string& rule, const std::string& value, bool isV2, bool isExecRule) : m_value(value), m_rule(rule), m_v2(isV2), m_execRule(isExecRule) {
const auto VALS = CVarList(rule, 2, ' ');
- const bool VALID = RULES.contains(rule) || std::any_of(RULES_PREFIX.begin(), RULES_PREFIX.end(), [&rule](auto prefix) { return rule.starts_with(prefix); }) ||
- (NWindowProperties::boolWindowProperties.find(VALS[0]) != NWindowProperties::boolWindowProperties.end()) ||
- (NWindowProperties::intWindowProperties.find(VALS[0]) != NWindowProperties::intWindowProperties.end()) ||
- (NWindowProperties::floatWindowProperties.find(VALS[0]) != NWindowProperties::floatWindowProperties.end());
+ const bool VALID = RULES.contains(rule) || std::ranges::any_of(RULES_PREFIX, [&rule](auto prefix) { return rule.starts_with(prefix); }) ||
+ (NWindowProperties::boolWindowProperties.contains(VALS[0])) || (NWindowProperties::intWindowProperties.contains(VALS[0])) ||
+ (NWindowProperties::floatWindowProperties.contains(VALS[0]));
if (!VALID)
return;
@@ -84,9 +83,9 @@ CWindowRule::CWindowRule(const std::string& rule, const std::string& value, bool
else {
// check if this is a prop.
const CVarList VARS(rule, 0, 's', true);
- if (NWindowProperties::intWindowProperties.find(VARS[0]) != NWindowProperties::intWindowProperties.end() ||
- NWindowProperties::boolWindowProperties.find(VARS[0]) != NWindowProperties::boolWindowProperties.end() ||
- NWindowProperties::floatWindowProperties.find(VARS[0]) != NWindowProperties::floatWindowProperties.end()) {
+ const bool ISPROP = NWindowProperties::intWindowProperties.contains(VARS[0]) || NWindowProperties::boolWindowProperties.contains(VARS[0]) ||
+ NWindowProperties::floatWindowProperties.contains(VARS[0]);
+ if (ISPROP) {
*const_cast<std::string*>(&m_rule) = "prop " + rule;
m_ruleType = RULE_PROP;
Debug::log(LOG, "CWindowRule: direct prop rule found, rewritten {} -> {}", rule, m_rule);
diff --git a/src/desktop/Workspace.cpp b/src/desktop/Workspace.cpp
index fbbad118..886c52fb 100644
--- a/src/desktop/Workspace.cpp
+++ b/src/desktop/Workspace.cpp
@@ -47,10 +47,10 @@ void CWorkspace::init(PHLWORKSPACE self) {
if (self->m_wasCreatedEmpty)
if (auto cmd = WORKSPACERULE.onCreatedEmptyRunCmd)
- g_pKeybindManager->spawnWithRules(*cmd, self);
+ CKeybindManager::spawnWithRules(*cmd, self);
- g_pEventManager->postEvent({"createworkspace", m_name});
- g_pEventManager->postEvent({"createworkspacev2", std::format("{},{}", m_id, m_name)});
+ g_pEventManager->postEvent({.event = "createworkspace", .data = m_name});
+ g_pEventManager->postEvent({.event = "createworkspacev2", .data = std::format("{},{}", m_id, m_name)});
EMIT_HOOK_EVENT("createWorkspace", this);
}
@@ -66,8 +66,8 @@ CWorkspace::~CWorkspace() {
g_pHookSystem->unhook(m_focusedWindowHook);
if (g_pEventManager) {
- g_pEventManager->postEvent({"destroyworkspace", m_name});
- g_pEventManager->postEvent({"destroyworkspacev2", std::format("{},{}", m_id, m_name)});
+ g_pEventManager->postEvent({.event = "destroyworkspace", .data = m_name});
+ g_pEventManager->postEvent({.event = "destroyworkspacev2", .data = std::format("{},{}", m_id, m_name)});
EMIT_HOOK_EVENT("destroyWorkspace", this);
}
}
@@ -604,12 +604,7 @@ PHLWINDOW CWorkspace::getTopLeftWindow() {
}
bool CWorkspace::hasUrgentWindow() {
- for (auto const& w : g_pCompositor->m_windows) {
- if (w->m_workspace == m_self && w->m_isMapped && w->m_isUrgent)
- return true;
- }
-
- return false;
+ return std::ranges::any_of(g_pCompositor->m_windows, [this](const auto& w) { return w->m_workspace == m_self && w->m_isMapped && w->m_isUrgent; });
}
void CWorkspace::updateWindowDecos() {
@@ -654,7 +649,7 @@ void CWorkspace::rename(const std::string& name) {
if (WORKSPACERULE.isPersistent)
g_pCompositor->ensurePersistentWorkspacesPresent(std::vector<SWorkspaceRule>{WORKSPACERULE}, m_self.lock());
- g_pEventManager->postEvent({"renameworkspace", std::to_string(m_id) + "," + m_name});
+ g_pEventManager->postEvent({.event = "renameworkspace", .data = std::to_string(m_id) + "," + m_name});
}
void CWorkspace::updateWindows() {
diff --git a/src/desktop/Workspace.hpp b/src/desktop/Workspace.hpp
index a3fe21e8..4f109257 100644
--- a/src/desktop/Workspace.hpp
+++ b/src/desktop/Workspace.hpp
@@ -2,7 +2,6 @@
#include "../helpers/AnimatedVariable.hpp"
#include <string>
-#include "../defines.hpp"
#include "DesktopTypes.hpp"
#include "../helpers/MiscFunctions.hpp"