desktop: cleanup code and use std::ranges (#10289)
Some checks are pending
Build Hyprland / Build Hyprland (Arch) (push) Waiting to run
Build Hyprland / Build Hyprland with Meson (Arch) (push) Waiting to run
Build Hyprland / Build Hyprland without precompiled headers (Arch) (push) Waiting to run
Build Hyprland / Build Hyprland in pure Wayland (Arch) (push) Waiting to run
Build Hyprland / Code Style (Arch) (push) Waiting to run
Nix (CI) / update-inputs (push) Waiting to run
Nix (CI) / build (push) Waiting to run
Security Checks / Flawfinder Checks (push) Waiting to run

This commit is contained in:
s1dd 2025-05-09 00:31:49 +05:30 committed by GitHub
parent 04c98abd1f
commit f01e3043b8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 57 additions and 74 deletions

View file

@ -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"}; 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_) { 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) if (!VALID)
return; return;

View file

@ -186,7 +186,7 @@ void CLayerSurface::onMap() {
m_readyToDelete = false; m_readyToDelete = false;
m_fadingOut = 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()); EMIT_HOOK_EVENT("openLayer", m_self.lock());
g_pCompositor->setPreferredScaleForSurface(m_surface->resource(), PMONITOR->m_scale); g_pCompositor->setPreferredScaleForSurface(m_surface->resource(), PMONITOR->m_scale);
@ -196,7 +196,7 @@ void CLayerSurface::onMap() {
void CLayerSurface::onUnmap() { void CLayerSurface::onUnmap() {
Debug::log(LOG, "LayerSurface {:x} unmapped", (uintptr_t)m_layerSurface.get()); 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()); EMIT_HOOK_EVENT("closeLayer", m_self.lock());
std::erase_if(g_pInputManager->m_exclusiveLSes, [this](const auto& other) { return !other || other == m_self; }); std::erase_if(g_pInputManager->m_exclusiveLSes, [this](const auto& other) { return !other || other == m_self; });

View file

@ -5,7 +5,6 @@
#include "../protocols/XDGShell.hpp" #include "../protocols/XDGShell.hpp"
#include "../protocols/core/Compositor.hpp" #include "../protocols/core/Compositor.hpp"
#include "../managers/SeatManager.hpp" #include "../managers/SeatManager.hpp"
#include "../managers/eventLoop/EventLoopManager.hpp"
#include "../desktop/LayerSurface.hpp" #include "../desktop/LayerSurface.hpp"
#include "../managers/input/InputManager.hpp" #include "../managers/input/InputManager.hpp"
#include "../render/Renderer.hpp" #include "../render/Renderer.hpp"

View file

@ -1,10 +1,10 @@
#include <algorithm>
#include <hyprutils/animation/AnimatedVariable.hpp> #include <hyprutils/animation/AnimatedVariable.hpp>
#include <re2/re2.h> #include <re2/re2.h>
#include <any> #include <any>
#include <bit> #include <bit>
#include <string_view> #include <string_view>
#include <algorithm>
#include "Window.hpp" #include "Window.hpp"
#include "../Compositor.hpp" #include "../Compositor.hpp"
#include "../render/decorations/CHyprDropShadowDecoration.hpp" #include "../render/decorations/CHyprDropShadowDecoration.hpp"
@ -137,25 +137,22 @@ SBoxExtents CWindow::getFullWindowExtents() {
if (m_windowData.dimAround.valueOrDefault()) { if (m_windowData.dimAround.valueOrDefault()) {
if (const auto PMONITOR = m_monitor.lock(); PMONITOR) 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}, return {.topLeft = {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)}}; .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()); const auto EXTENTS = g_pDecorationPositioner->getWindowDecorationExtents(m_self.lock());
if (EXTENTS.topLeft.x > maxExtents.topLeft.x) maxExtents.topLeft.x = std::max(EXTENTS.topLeft.x, maxExtents.topLeft.x);
maxExtents.topLeft.x = EXTENTS.topLeft.x;
if (EXTENTS.topLeft.y > maxExtents.topLeft.y) maxExtents.topLeft.y = std::max(EXTENTS.topLeft.y, maxExtents.topLeft.y);
maxExtents.topLeft.y = EXTENTS.topLeft.y;
if (EXTENTS.bottomRight.x > maxExtents.bottomRight.x) maxExtents.bottomRight.x = std::max(EXTENTS.bottomRight.x, maxExtents.bottomRight.x);
maxExtents.bottomRight.x = EXTENTS.bottomRight.x;
if (EXTENTS.bottomRight.y > maxExtents.bottomRight.y) maxExtents.bottomRight.y = std::max(EXTENTS.bottomRight.y, maxExtents.bottomRight.y);
maxExtents.bottomRight.y = EXTENTS.bottomRight.y;
if (m_wlSurface->exists() && !m_isX11 && m_popupHead) { if (m_wlSurface->exists() && !m_isX11 && m_popupHead) {
CBox surfaceExtents = {0, 0, 0, 0}; CBox surfaceExtents = {0, 0, 0, 0};
@ -167,10 +164,8 @@ SBoxExtents CWindow::getFullWindowExtents() {
CBox* pSurfaceExtents = (CBox*)data; CBox* pSurfaceExtents = (CBox*)data;
CBox surf = CBox{popup->coordsRelativeToParent(), popup->size()}; CBox surf = CBox{popup->coordsRelativeToParent(), popup->size()};
if (surf.x < pSurfaceExtents->x) pSurfaceExtents->x = std::min(surf.x, pSurfaceExtents->x);
pSurfaceExtents->x = surf.x; pSurfaceExtents->y = std::min(surf.y, pSurfaceExtents->y);
if (surf.y < pSurfaceExtents->y)
pSurfaceExtents->y = surf.y;
if (surf.x + surf.w > pSurfaceExtents->width) if (surf.x + surf.w > pSurfaceExtents->width)
pSurfaceExtents->width = surf.x + surf.w - pSurfaceExtents->x; pSurfaceExtents->width = surf.x + surf.w - pSurfaceExtents->x;
if (surf.y + surf.h > pSurfaceExtents->height) if (surf.y + surf.h > pSurfaceExtents->height)
@ -178,11 +173,9 @@ SBoxExtents CWindow::getFullWindowExtents() {
}, },
&surfaceExtents); &surfaceExtents);
if (-surfaceExtents.x > maxExtents.topLeft.x) maxExtents.topLeft.x = std::max(-surfaceExtents.x, maxExtents.topLeft.x);
maxExtents.topLeft.x = -surfaceExtents.x;
if (-surfaceExtents.y > maxExtents.topLeft.y) maxExtents.topLeft.y = std::max(-surfaceExtents.y, maxExtents.topLeft.y);
maxExtents.topLeft.y = -surfaceExtents.y;
if (surfaceExtents.x + surfaceExtents.width > m_wlSurface->resource()->m_current.size.x + maxExtents.bottomRight.x) 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; 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}; 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) if (properties & RESERVED_EXTENTS)
EXTENTS.addExtents(g_pDecorationPositioner->getWindowDecorationReserved(m_self.lock())); EXTENTS.addExtents(g_pDecorationPositioner->getWindowDecorationReserved(m_self.lock()));
if (properties & INPUT_EXTENTS) if (properties & INPUT_EXTENTS)
@ -297,7 +290,7 @@ void CWindow::updateWindowDecos() {
} }
for (auto const& wd : decos) { 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; continue;
wd->updateWindow(m_self.lock()); wd->updateWindow(m_self.lock());
} }
@ -452,8 +445,8 @@ void CWindow::moveToWorkspace(PHLWORKSPACE pWorkspace) {
g_pCompositor->updateAllWindowsAnimatedDecorationValues(); g_pCompositor->updateAllWindowsAnimatedDecorationValues();
if (valid(pWorkspace)) { if (valid(pWorkspace)) {
g_pEventManager->postEvent(SHyprIPCEvent{"movewindow", std::format("{:x},{}", (uintptr_t)this, pWorkspace->m_name)}); g_pEventManager->postEvent(SHyprIPCEvent{.event = "movewindow", .data = 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 = "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})); EMIT_HOOK_EVENT("moveWindow", (std::vector<std::any>{m_self.lock(), pWorkspace}));
} }
@ -479,7 +472,7 @@ PHLWINDOW CWindow::x11TransientFor() {
while (s) { while (s) {
// break loops. Some X apps make them, and it seems like it's valid behavior?!?!?! // 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. // 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; break;
visited.emplace_back(s.lock()); visited.emplace_back(s.lock());
@ -647,18 +640,18 @@ void CWindow::applyDynamicRule(const SP<CWindowRule>& r) {
if (r == "override") { if (r == "override") {
if (opacityIDX == 1) 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) 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) 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 { } else {
if (opacityIDX == 0) { 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) { } 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) { } 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 { } else {
throw std::runtime_error("more than 3 alpha values"); 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")) } else if (token.contains("deg"))
inactiveBorderGradient.m_angle = std::stoi(token.substr(0, token.size() - 3)) * (PI / 180.0); inactiveBorderGradient.m_angle = std::stoi(token.substr(0, token.size() - 3)) * (PI / 180.0);
else if (active) else if (active)
activeBorderGradient.m_colors.push_back(configStringToInt(token).value_or(0)); activeBorderGradient.m_colors.emplace_back(configStringToInt(token).value_or(0));
else else
inactiveBorderGradient.m_colors.push_back(configStringToInt(token).value_or(0)); inactiveBorderGradient.m_colors.emplace_back(configStringToInt(token).value_or(0));
} }
activeBorderGradient.updateColorsOk(); activeBorderGradient.updateColorsOk();
@ -902,7 +895,7 @@ void CWindow::createGroup() {
g_pLayoutManager->getCurrentLayout()->recalculateMonitor(monitorID()); g_pLayoutManager->getCurrentLayout()->recalculateMonitor(monitorID());
g_pCompositor->updateAllWindowsAnimatedDecorationValues(); 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_pLayoutManager->getCurrentLayout()->recalculateMonitor(monitorID());
g_pCompositor->updateAllWindowsAnimatedDecorationValues(); 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; return;
} }
@ -962,7 +955,7 @@ void CWindow::destroyGroup() {
if (!addresses.empty()) if (!addresses.empty())
addresses.pop_back(); 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() { PHLWINDOW CWindow::getGroupHead() {
@ -1399,7 +1392,7 @@ void CWindow::activate(bool force) {
m_isUrgent = true; 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()); EMIT_HOOK_EVENT("urgent", m_self.lock());
if (!force && (!m_windowData.focusOnActivate.valueOr(*PFOCUSONACTIVATE) || (m_suppressedEvents & SUPPRESS_ACTIVATE_FOCUSONLY) || (m_suppressedEvents & SUPPRESS_ACTIVATE))) 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) { if (m_title != NEWTITLE) {
m_title = NEWTITLE; m_title = NEWTITLE;
g_pEventManager->postEvent(SHyprIPCEvent{"windowtitle", std::format("{:x}", (uintptr_t)this)}); g_pEventManager->postEvent(SHyprIPCEvent{.event = "windowtitle", .data = std::format("{:x}", (uintptr_t)this)});
g_pEventManager->postEvent(SHyprIPCEvent{"windowtitlev2", std::format("{:x},{}", (uintptr_t)this, m_title)}); g_pEventManager->postEvent(SHyprIPCEvent{.event = "windowtitlev2", .data = std::format("{:x},{}", (uintptr_t)this, m_title)});
EMIT_HOOK_EVENT("windowTitle", m_self.lock()); 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 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{.event = "activewindow", .data = m_class + "," + m_title});
g_pEventManager->postEvent(SHyprIPCEvent{"activewindowv2", std::format("{:x}", (uintptr_t)this)}); g_pEventManager->postEvent(SHyprIPCEvent{.event = "activewindowv2", .data = std::format("{:x}", (uintptr_t)this)});
EMIT_HOOK_EVENT("activeWindow", m_self.lock()); EMIT_HOOK_EVENT("activeWindow", m_self.lock());
} }
@ -1473,8 +1466,8 @@ void CWindow::onUpdateMeta() {
m_class = NEWCLASS; m_class = NEWCLASS;
if (m_self == g_pCompositor->m_lastWindow) { // if it's the active, let's post an event to update others 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{.event = "activewindow", .data = m_class + "," + m_title});
g_pEventManager->postEvent(SHyprIPCEvent{"activewindowv2", std::format("{:x}", (uintptr_t)this)}); g_pEventManager->postEvent(SHyprIPCEvent{.event = "activewindowv2", .data = std::format("{:x}", (uintptr_t)this)});
EMIT_HOOK_EVENT("activeWindow", m_self.lock()); EMIT_HOOK_EVENT("activeWindow", m_self.lock());
} }
@ -1514,7 +1507,7 @@ std::string CWindow::fetchClass() {
} }
void CWindow::onAck(uint32_t serial) { 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()) if (SERIAL == m_pendingSizeAcks.rend())
return; return;
@ -1647,7 +1640,7 @@ PHLWINDOW CWindow::getSwallower() {
if (!w) if (!w)
continue; 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(); return w.lock();
} }

View file

@ -6,8 +6,6 @@
#include "../config/ConfigDataValues.hpp" #include "../config/ConfigDataValues.hpp"
#include "../helpers/AnimatedVariable.hpp" #include "../helpers/AnimatedVariable.hpp"
#include "../helpers/math/Math.hpp"
#include "../helpers/signal/Signal.hpp"
#include "../helpers/TagKeeper.hpp" #include "../helpers/TagKeeper.hpp"
#include "../macros.hpp" #include "../macros.hpp"
#include "../managers/XWaylandManager.hpp" #include "../managers/XWaylandManager.hpp"
@ -79,9 +77,9 @@ struct SAlphaValue {
}; };
struct SWindowData { struct SWindowData {
CWindowOverridableVar<SAlphaValue> alpha = SAlphaValue{1.f, false}; CWindowOverridableVar<SAlphaValue> alpha = SAlphaValue{.alpha = 1.f, .overridden = false};
CWindowOverridableVar<SAlphaValue> alphaInactive = SAlphaValue{1.f, false}; CWindowOverridableVar<SAlphaValue> alphaInactive = SAlphaValue{.alpha = 1.f, .overridden = false};
CWindowOverridableVar<SAlphaValue> alphaFullscreen = SAlphaValue{1.f, false}; CWindowOverridableVar<SAlphaValue> alphaFullscreen = SAlphaValue{.alpha = 1.f, .overridden = false};
CWindowOverridableVar<bool> allowsInput = false; CWindowOverridableVar<bool> allowsInput = false;
CWindowOverridableVar<bool> dimAround = false; CWindowOverridableVar<bool> dimAround = false;

View file

@ -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) { 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 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); }) || const bool VALID = RULES.contains(rule) || std::ranges::any_of(RULES_PREFIX, [&rule](auto prefix) { return rule.starts_with(prefix); }) ||
(NWindowProperties::boolWindowProperties.find(VALS[0]) != NWindowProperties::boolWindowProperties.end()) || (NWindowProperties::boolWindowProperties.contains(VALS[0])) || (NWindowProperties::intWindowProperties.contains(VALS[0])) ||
(NWindowProperties::intWindowProperties.find(VALS[0]) != NWindowProperties::intWindowProperties.end()) || (NWindowProperties::floatWindowProperties.contains(VALS[0]));
(NWindowProperties::floatWindowProperties.find(VALS[0]) != NWindowProperties::floatWindowProperties.end());
if (!VALID) if (!VALID)
return; return;
@ -84,9 +83,9 @@ CWindowRule::CWindowRule(const std::string& rule, const std::string& value, bool
else { else {
// check if this is a prop. // check if this is a prop.
const CVarList VARS(rule, 0, 's', true); const CVarList VARS(rule, 0, 's', true);
if (NWindowProperties::intWindowProperties.find(VARS[0]) != NWindowProperties::intWindowProperties.end() || const bool ISPROP = NWindowProperties::intWindowProperties.contains(VARS[0]) || NWindowProperties::boolWindowProperties.contains(VARS[0]) ||
NWindowProperties::boolWindowProperties.find(VARS[0]) != NWindowProperties::boolWindowProperties.end() || NWindowProperties::floatWindowProperties.contains(VARS[0]);
NWindowProperties::floatWindowProperties.find(VARS[0]) != NWindowProperties::floatWindowProperties.end()) { if (ISPROP) {
*const_cast<std::string*>(&m_rule) = "prop " + rule; *const_cast<std::string*>(&m_rule) = "prop " + rule;
m_ruleType = RULE_PROP; m_ruleType = RULE_PROP;
Debug::log(LOG, "CWindowRule: direct prop rule found, rewritten {} -> {}", rule, m_rule); Debug::log(LOG, "CWindowRule: direct prop rule found, rewritten {} -> {}", rule, m_rule);

View file

@ -47,10 +47,10 @@ void CWorkspace::init(PHLWORKSPACE self) {
if (self->m_wasCreatedEmpty) if (self->m_wasCreatedEmpty)
if (auto cmd = WORKSPACERULE.onCreatedEmptyRunCmd) if (auto cmd = WORKSPACERULE.onCreatedEmptyRunCmd)
g_pKeybindManager->spawnWithRules(*cmd, self); CKeybindManager::spawnWithRules(*cmd, self);
g_pEventManager->postEvent({"createworkspace", m_name}); g_pEventManager->postEvent({.event = "createworkspace", .data = m_name});
g_pEventManager->postEvent({"createworkspacev2", std::format("{},{}", m_id, m_name)}); g_pEventManager->postEvent({.event = "createworkspacev2", .data = std::format("{},{}", m_id, m_name)});
EMIT_HOOK_EVENT("createWorkspace", this); EMIT_HOOK_EVENT("createWorkspace", this);
} }
@ -66,8 +66,8 @@ CWorkspace::~CWorkspace() {
g_pHookSystem->unhook(m_focusedWindowHook); g_pHookSystem->unhook(m_focusedWindowHook);
if (g_pEventManager) { if (g_pEventManager) {
g_pEventManager->postEvent({"destroyworkspace", m_name}); g_pEventManager->postEvent({.event = "destroyworkspace", .data = m_name});
g_pEventManager->postEvent({"destroyworkspacev2", std::format("{},{}", m_id, m_name)}); g_pEventManager->postEvent({.event = "destroyworkspacev2", .data = std::format("{},{}", m_id, m_name)});
EMIT_HOOK_EVENT("destroyWorkspace", this); EMIT_HOOK_EVENT("destroyWorkspace", this);
} }
} }
@ -604,12 +604,7 @@ PHLWINDOW CWorkspace::getTopLeftWindow() {
} }
bool CWorkspace::hasUrgentWindow() { bool CWorkspace::hasUrgentWindow() {
for (auto const& w : g_pCompositor->m_windows) { 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; });
if (w->m_workspace == m_self && w->m_isMapped && w->m_isUrgent)
return true;
}
return false;
} }
void CWorkspace::updateWindowDecos() { void CWorkspace::updateWindowDecos() {
@ -654,7 +649,7 @@ void CWorkspace::rename(const std::string& name) {
if (WORKSPACERULE.isPersistent) if (WORKSPACERULE.isPersistent)
g_pCompositor->ensurePersistentWorkspacesPresent(std::vector<SWorkspaceRule>{WORKSPACERULE}, m_self.lock()); 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() { void CWorkspace::updateWindows() {

View file

@ -2,7 +2,6 @@
#include "../helpers/AnimatedVariable.hpp" #include "../helpers/AnimatedVariable.hpp"
#include <string> #include <string>
#include "../defines.hpp"
#include "DesktopTypes.hpp" #include "DesktopTypes.hpp"
#include "../helpers/MiscFunctions.hpp" #include "../helpers/MiscFunctions.hpp"