From 57cb8730e49bf762d68d721702fbeea9b67fdee4 Mon Sep 17 00:00:00 2001 From: MightyPlaza <123664421+MightyPlaza@users.noreply.github.com> Date: Thu, 4 Jul 2024 22:06:15 +0100 Subject: [PATCH] clean up modified: src/Compositor.cpp modified: src/Compositor.hpp modified: src/config/ConfigManager.cpp modified: src/config/ConfigManager.hpp modified: src/debug/HyprCtl.cpp modified: src/desktop/Window.cpp modified: src/desktop/Window.hpp modified: src/events/Windows.cpp modified: src/layout/DwindleLayout.cpp modified: src/layout/IHyprLayout.cpp modified: src/layout/IHyprLayout.hpp modified: src/layout/MasterLayout.cpp modified: src/managers/KeybindManager.cpp --- src/Compositor.cpp | 4 +- src/Compositor.hpp | 2 +- src/config/ConfigManager.cpp | 20 +++++----- src/config/ConfigManager.hpp | 66 +++++++++++++++++++++----------- src/debug/HyprCtl.cpp | 22 +++++------ src/desktop/Window.cpp | 68 +++++++++++---------------------- src/desktop/Window.hpp | 17 +++++---- src/events/Windows.cpp | 4 +- src/layout/DwindleLayout.cpp | 6 +-- src/layout/IHyprLayout.cpp | 10 ++++- src/layout/IHyprLayout.hpp | 2 + src/layout/MasterLayout.cpp | 6 +-- src/managers/KeybindManager.cpp | 4 +- 13 files changed, 120 insertions(+), 111 deletions(-) diff --git a/src/Compositor.cpp b/src/Compositor.cpp index 651df27e..b79921ed 100644 --- a/src/Compositor.cpp +++ b/src/Compositor.cpp @@ -2259,7 +2259,7 @@ void CCompositor::updateWorkspaceWindowDecos(const int& id) { } } -void CCompositor::updateWorkspaceSpecialRenderData(const int& id) { +void CCompositor::updateWorkspaceWindowData(const int& id) { const auto PWORKSPACE = getWorkspaceByID(id); const auto WORKSPACERULE = PWORKSPACE ? g_pConfigManager->getWorkspaceRuleFor(PWORKSPACE) : SWorkspaceRule{}; @@ -2267,7 +2267,7 @@ void CCompositor::updateWorkspaceSpecialRenderData(const int& id) { if (w->workspaceID() != id) continue; - w->updateSpecialRenderData(WORKSPACERULE); + w->updateWindowData(WORKSPACERULE); } } diff --git a/src/Compositor.hpp b/src/Compositor.hpp index 5a1d8a64..17db2c8b 100644 --- a/src/Compositor.hpp +++ b/src/Compositor.hpp @@ -127,7 +127,7 @@ class CCompositor { PHLWORKSPACE getWorkspaceByString(const std::string&); void sanityCheckWorkspaces(); void updateWorkspaceWindowDecos(const int&); - void updateWorkspaceSpecialRenderData(const int&); + void updateWorkspaceWindowData(const int&); int getWindowsOnWorkspace(const int& id, std::optional onlyTiled = {}, std::optional onlyVisible = {}); int getGroupsOnWorkspace(const int& id, std::optional onlyTiled = {}, std::optional onlyVisible = {}); PHLWINDOW getUrgentWindow(); diff --git a/src/config/ConfigManager.cpp b/src/config/ConfigManager.cpp index ff9d3a6d..eb35f42c 100644 --- a/src/config/ConfigManager.cpp +++ b/src/config/ConfigManager.cpp @@ -839,7 +839,7 @@ void CConfigManager::postConfigReload(const Hyprlang::CParseResult& result) { if (w->inert()) continue; g_pCompositor->updateWorkspaceWindows(w->m_iID); - g_pCompositor->updateWorkspaceSpecialRenderData(w->m_iID); + g_pCompositor->updateWorkspaceWindowData(w->m_iID); } // Update window border colors @@ -1053,14 +1053,14 @@ SWorkspaceRule CConfigManager::mergeWorkspaceRules(const SWorkspaceRule& rule1, mergedRule.gapsOut = rule2.gapsOut; if (rule2.borderSize.has_value()) mergedRule.borderSize = rule2.borderSize; - if (rule2.border.has_value()) - mergedRule.border = rule2.border; - if (rule2.rounding.has_value()) - mergedRule.rounding = rule2.rounding; + if (rule2.noBorder.has_value()) + mergedRule.noBorder = rule2.noBorder; + if (rule2.noRounding.has_value()) + mergedRule.noRounding = rule2.noRounding; if (rule2.decorate.has_value()) mergedRule.decorate = rule2.decorate; - if (rule2.shadow.has_value()) - mergedRule.shadow = rule2.shadow; + if (rule2.noShadow.has_value()) + mergedRule.noShadow = rule2.noShadow; if (rule2.onCreatedEmptyRunCmd.has_value()) mergedRule.onCreatedEmptyRunCmd = rule2.onCreatedEmptyRunCmd; if (rule2.defaultName.has_value()) @@ -2416,11 +2416,11 @@ std::optional CConfigManager::handleWorkspaceRules(const std::strin wsRule.borderSize = std::stoi(rule.substr(delim + 11)); } catch (...) { return "Error parsing workspace rule bordersize: {}", rule.substr(delim + 11); } else if ((delim = rule.find("border:")) != std::string::npos) - wsRule.border = configStringToInt(rule.substr(delim + 7)); + wsRule.noBorder = !configStringToInt(rule.substr(delim + 7)); else if ((delim = rule.find("shadow:")) != std::string::npos) - wsRule.shadow = configStringToInt(rule.substr(delim + 7)); + wsRule.noShadow = !configStringToInt(rule.substr(delim + 7)); else if ((delim = rule.find("rounding:")) != std::string::npos) - wsRule.rounding = configStringToInt(rule.substr(delim + 9)); + wsRule.noRounding = !configStringToInt(rule.substr(delim + 9)); else if ((delim = rule.find("decorate:")) != std::string::npos) wsRule.decorate = configStringToInt(rule.substr(delim + 9)); else if ((delim = rule.find("monitor:")) != std::string::npos) diff --git a/src/config/ConfigManager.hpp b/src/config/ConfigManager.hpp index c43cb020..ebeb40fa 100644 --- a/src/config/ConfigManager.hpp +++ b/src/config/ConfigManager.hpp @@ -39,10 +39,10 @@ struct SWorkspaceRule { std::optional gapsIn; std::optional gapsOut; std::optional borderSize; - std::optional border; - std::optional rounding; - std::optional decorate; - std::optional shadow; + std::optional decorate; + std::optional noRounding; + std::optional noBorder; + std::optional noShadow; std::optional onCreatedEmptyRunCmd; std::optional defaultName; std::map layoutopts; @@ -148,25 +148,47 @@ class CConfigManager { std::string getErrors(); // keywords - std::optional handleRawExec(const std::string&, const std::string&); - std::optional handleExecOnce(const std::string&, const std::string&); - std::optional handleMonitor(const std::string&, const std::string&); - std::optional handleBind(const std::string&, const std::string&); - std::optional handleUnbind(const std::string&, const std::string&); - std::optional handleWindowRule(const std::string&, const std::string&); - std::optional handleLayerRule(const std::string&, const std::string&); - std::optional handleWindowRuleV2(const std::string&, const std::string&); - std::optional handleWorkspaceRules(const std::string&, const std::string&); - std::optional handleBezier(const std::string&, const std::string&); - std::optional handleAnimation(const std::string&, const std::string&); - std::optional handleSource(const std::string&, const std::string&); - std::optional handleSubmap(const std::string&, const std::string&); - std::optional handleBlurLS(const std::string&, const std::string&); - std::optional handleBindWS(const std::string&, const std::string&); - std::optional handleEnv(const std::string&, const std::string&); - std::optional handlePlugin(const std::string&, const std::string&); + std::optional handleRawExec(const std::string&, const std::string&); + std::optional handleExecOnce(const std::string&, const std::string&); + std::optional handleMonitor(const std::string&, const std::string&); + std::optional handleBind(const std::string&, const std::string&); + std::optional handleUnbind(const std::string&, const std::string&); + std::optional handleWindowRule(const std::string&, const std::string&); + std::optional handleLayerRule(const std::string&, const std::string&); + std::optional handleWindowRuleV2(const std::string&, const std::string&); + std::optional handleWorkspaceRules(const std::string&, const std::string&); + std::optional handleBezier(const std::string&, const std::string&); + std::optional handleAnimation(const std::string&, const std::string&); + std::optional handleSource(const std::string&, const std::string&); + std::optional handleSubmap(const std::string&, const std::string&); + std::optional handleBlurLS(const std::string&, const std::string&); + std::optional handleBindWS(const std::string&, const std::string&); + std::optional handleEnv(const std::string&, const std::string&); + std::optional handlePlugin(const std::string&, const std::string&); - std::string configCurrentPath; + std::string configCurrentPath; + + std::unordered_map*(PHLWINDOW)>> mbWindowProperties = { + {"dimaround", [](const PHLWINDOW& pWindow) { return &pWindow->m_sWindowData.dimAround; }}, + {"focusonactivate", [](PHLWINDOW pWindow) { return &pWindow->m_sWindowData.focusOnActivate; }}, + {"forceinput", [](PHLWINDOW pWindow) { return &pWindow->m_sWindowData.allowsInput; }}, + {"forceopaque", [](PHLWINDOW pWindow) { return &pWindow->m_sWindowData.opaque; }}, + {"forcergbx", [](PHLWINDOW pWindow) { return &pWindow->m_sWindowData.RGBX; }}, + {"immediate", [](PHLWINDOW pWindow) { return &pWindow->m_sWindowData.tearing; }}, + {"keepaspectratio", [](PHLWINDOW pWindow) { return &pWindow->m_sWindowData.keepAspectRatio; }}, + {"nearestneighbor", [](PHLWINDOW pWindow) { return &pWindow->m_sWindowData.nearestNeighbor; }}, + {"noanim", [](PHLWINDOW pWindow) { return &pWindow->m_sWindowData.noAnim; }}, + {"noblur", [](PHLWINDOW pWindow) { return &pWindow->m_sWindowData.noBlur; }}, + {"noborder", [](PHLWINDOW pWindow) { return &pWindow->m_sWindowData.noBorder; }}, + {"nodim", [](PHLWINDOW pWindow) { return &pWindow->m_sWindowData.noDim; }}, + {"nofocus", [](PHLWINDOW pWindow) { return &pWindow->m_sWindowData.noFocus; }}, + {"nomaxsize", [](PHLWINDOW pWindow) { return &pWindow->m_sWindowData.noMaxSize; }}, + {"noshadow", [](PHLWINDOW pWindow) { return &pWindow->m_sWindowData.noShadow; }}, + {"windowdance", [](PHLWINDOW pWindow) { return &pWindow->m_sWindowData.windowDanceCompat; }}, + }; + + std::unordered_map*(PHLWINDOW)>> miWindowProperties = { + {"rounding", [](PHLWINDOW pWindow) { return &pWindow->m_sWindowData.rounding; }}, {"bordersize", [](PHLWINDOW pWindow) { return &pWindow->m_sWindowData.borderSize; }}}; private: std::unique_ptr m_pConfig; diff --git a/src/debug/HyprCtl.cpp b/src/debug/HyprCtl.cpp index ca820c65..5e3e8d87 100644 --- a/src/debug/HyprCtl.cpp +++ b/src/debug/HyprCtl.cpp @@ -311,10 +311,10 @@ static std::string getWorkspaceRuleData(const SWorkspaceRule& r, eHyprCtlOutputF std::format(",\n \"gapsOut\": [{}, {}, {}, {}]", r.gapsOut.value().top, r.gapsOut.value().right, r.gapsOut.value().bottom, r.gapsOut.value().left) : ""; const std::string borderSize = (bool)(r.borderSize) ? std::format(",\n \"borderSize\": {}", r.borderSize.value()) : ""; - const std::string border = (bool)(r.border) ? std::format(",\n \"border\": {}", boolToString(r.border.value())) : ""; - const std::string rounding = (bool)(r.rounding) ? std::format(",\n \"rounding\": {}", boolToString(r.rounding.value())) : ""; - const std::string decorate = (bool)(r.decorate) ? std::format(",\n \"decorate\": {}", boolToString(r.decorate.value())) : ""; - const std::string shadow = (bool)(r.shadow) ? std::format(",\n \"shadow\": {}", boolToString(r.shadow.value())) : ""; + const std::string border = (bool)(r.noBorder) ? std::format(",\n \"border\": {}", boolToString(!r.noBorder.value())) : ""; + const std::string rounding = (bool)(r.noRounding) ? std::format(",\n \"rounding\": {}", boolToString(r.noRounding.value())) : ""; + const std::string decorate = (bool)(r.decorate) ? std::format(",\n \"decorate\": {}", boolToString(!r.decorate.value())) : ""; + const std::string shadow = (bool)(r.noShadow) ? std::format(",\n \"shadow\": {}", boolToString(!r.noShadow.value())) : ""; std::string result = std::format(R"#({{ "workspaceString": "{}"{}{}{}{}{}{}{}{} @@ -333,10 +333,10 @@ static std::string getWorkspaceRuleData(const SWorkspaceRule& r, eHyprCtlOutputF std::to_string(r.gapsOut.value().bottom), std::to_string(r.gapsOut.value().left)) : std::format("\tgapsOut: \n"); const std::string borderSize = std::format("\tborderSize: {}\n", (bool)(r.borderSize) ? std::to_string(r.borderSize.value()) : ""); - const std::string border = std::format("\tborder: {}\n", (bool)(r.border) ? boolToString(r.border.value()) : ""); - const std::string rounding = std::format("\trounding: {}\n", (bool)(r.rounding) ? boolToString(r.rounding.value()) : ""); + const std::string border = std::format("\tborder: {}\n", (bool)(r.noBorder) ? boolToString(!r.noBorder.value()) : ""); + const std::string rounding = std::format("\trounding: {}\n", (bool)(r.noRounding) ? boolToString(!r.noRounding.value()) : ""); const std::string decorate = std::format("\tdecorate: {}\n", (bool)(r.decorate) ? boolToString(r.decorate.value()) : ""); - const std::string shadow = std::format("\tshadow: {}\n", (bool)(r.shadow) ? boolToString(r.shadow.value()) : ""); + const std::string shadow = std::format("\tshadow: {}\n", (bool)(r.noShadow) ? boolToString(!r.noShadow.value()) : ""); std::string result = std::format("Workspace rule {}:\n{}{}{}{}{}{}{}{}{}{}\n", escapeJSONStrings(r.workspaceString), monitor, default_, persistent, gapsIn, gapsOut, borderSize, border, rounding, decorate, shadow); @@ -1248,10 +1248,10 @@ std::string dispatchSetProp(eHyprCtlOutputFormat format, std::string request) { PWINDOW->m_sWindowData.activeBorderColor = CWindowOverridableVar(colorData, PRIORITY_SET_PROP); else PWINDOW->m_sWindowData.inactiveBorderColor = CWindowOverridableVar(colorData, PRIORITY_SET_PROP); - } else if (auto search = PWINDOW->mbWindowProperties.find(PROP); search != PWINDOW->mbWindowProperties.end()) { - *(search->second) = CWindowOverridableVar((bool)configStringToInt(VAL), PRIORITY_SET_PROP); - } else if (auto search = PWINDOW->miWindowProperties.find(PROP); search != PWINDOW->miWindowProperties.end()) { - *(search->second) = CWindowOverridableVar((int)configStringToInt(VAL), PRIORITY_SET_PROP); + } else if (auto search = g_pConfigManager->mbWindowProperties.find(PROP); search != g_pConfigManager->mbWindowProperties.end()) { + *(search->second(PWINDOW)) = CWindowOverridableVar((bool)configStringToInt(VAL), PRIORITY_SET_PROP); + } else if (auto search = g_pConfigManager->miWindowProperties.find(PROP); search != g_pConfigManager->miWindowProperties.end()) { + *(search->second(PWINDOW)) = CWindowOverridableVar((int)configStringToInt(VAL), PRIORITY_SET_PROP); } else { return "prop not found"; } diff --git a/src/desktop/Window.cpp b/src/desktop/Window.cpp index f77bc0e1..6d1c1b57 100644 --- a/src/desktop/Window.cpp +++ b/src/desktop/Window.cpp @@ -280,28 +280,6 @@ void CWindow::updateWindowDecos() { } } -void CWindow::createWindowProperties() { - mbWindowProperties["dimaround"] = &m_sWindowData.dimAround; - mbWindowProperties["focusonactivate"] = &m_sWindowData.focusOnActivate; - mbWindowProperties["forceinput"] = &m_sWindowData.allowsInput; - mbWindowProperties["forceopaque"] = &m_sWindowData.opaque; - mbWindowProperties["forcergbx"] = &m_sWindowData.RGBX; - mbWindowProperties["immediate"] = &m_sWindowData.tearing; - mbWindowProperties["keepaspectratio"] = &m_sWindowData.keepAspectRatio; - mbWindowProperties["nearestneighbor"] = &m_sWindowData.nearestNeighbor; - mbWindowProperties["noanim"] = &m_sWindowData.noAnim; - mbWindowProperties["noblur"] = &m_sWindowData.noBlur; - mbWindowProperties["noborder"] = &m_sWindowData.noBorder; - mbWindowProperties["nodim"] = &m_sWindowData.noDim; - mbWindowProperties["nofocus"] = &m_sWindowData.noFocus; - mbWindowProperties["nomaxsize"] = &m_sWindowData.noMaxSize; - mbWindowProperties["noshadow"] = &m_sWindowData.noShadow; - mbWindowProperties["windowdance"] = &m_sWindowData.windowDanceCompat; - - miWindowProperties["rounding"] = &m_sWindowData.rounding; - miWindowProperties["bordersize"] = &m_sWindowData.borderSize; -} - void CWindow::addWindowDeco(std::unique_ptr deco) { m_dWindowDecorations.emplace_back(std::move(deco)); g_pDecorationPositioner->forceRecalcFor(m_pSelf.lock()); @@ -433,11 +411,11 @@ void CWindow::moveToWorkspace(PHLWORKSPACE pWorkspace) { setAnimationsToMove(); g_pCompositor->updateWorkspaceWindows(OLDWORKSPACE->m_iID); - g_pCompositor->updateWorkspaceSpecialRenderData(OLDWORKSPACE->m_iID); + g_pCompositor->updateWorkspaceWindowData(OLDWORKSPACE->m_iID); g_pLayoutManager->getCurrentLayout()->recalculateMonitor(OLDWORKSPACE->m_iMonitorID); g_pCompositor->updateWorkspaceWindows(workspaceID()); - g_pCompositor->updateWorkspaceSpecialRenderData(workspaceID()); + g_pCompositor->updateWorkspaceWindowData(workspaceID()); g_pLayoutManager->getCurrentLayout()->recalculateMonitor(m_iMonitorID); g_pCompositor->updateAllWindowsAnimatedDecorationValues(); @@ -546,7 +524,7 @@ void CWindow::onUnmap() { PMONITOR->solitaryClient.reset(); g_pCompositor->updateWorkspaceWindows(workspaceID()); - g_pCompositor->updateWorkspaceSpecialRenderData(workspaceID()); + g_pCompositor->updateWorkspaceWindowData(workspaceID()); g_pLayoutManager->getCurrentLayout()->recalculateMonitor(m_iMonitorID); g_pCompositor->updateAllWindowsAnimatedDecorationValues(); @@ -724,11 +702,11 @@ void CWindow::applyDynamicRule(const SWindowRule& r) { try { m_sWindowData.xray = CWindowOverridableVar((bool)configStringToInt(vars[1]), PRIORITY_WINDOW_RULE); } catch (...) {} - } else if (auto search = mbWindowProperties.find(r.szRule); search != mbWindowProperties.end()) { - *(search->second) = CWindowOverridableVar(true, PRIORITY_WINDOW_RULE); - } else if (auto search = miWindowProperties.find(r.szRule.substr(0, r.szRule.find_first_of(' '))); search != miWindowProperties.end()) { + } else if (auto search = g_pConfigManager->mbWindowProperties.find(r.szRule); search != g_pConfigManager->mbWindowProperties.end()) { + *(search->second(m_pSelf.lock())) = CWindowOverridableVar(true, PRIORITY_WINDOW_RULE); + } else if (auto search = g_pConfigManager->miWindowProperties.find(r.szRule.substr(0, r.szRule.find_first_of(' '))); search != g_pConfigManager->miWindowProperties.end()) { try { - *(search->second) = CWindowOverridableVar(std::stoi(r.szRule.substr(r.szRule.find_first_of(' ') + 1)), PRIORITY_WINDOW_RULE); + *(search->second(m_pSelf.lock())) = CWindowOverridableVar(std::stoi(r.szRule.substr(r.szRule.find_first_of(' ') + 1)), PRIORITY_WINDOW_RULE); } catch (std::exception& e) { Debug::log(ERR, "Rule \"{}\" failed with: {}", r.szRule, e.what()); } } else if (r.szRule.starts_with("idleinhibit")) { auto IDLERULE = r.szRule.substr(r.szRule.find_first_of(' ') + 1); @@ -884,7 +862,7 @@ void CWindow::createGroup() { addWindowDeco(std::make_unique(m_pSelf.lock())); g_pCompositor->updateWorkspaceWindows(workspaceID()); - g_pCompositor->updateWorkspaceSpecialRenderData(workspaceID()); + g_pCompositor->updateWorkspaceWindowData(workspaceID()); g_pLayoutManager->getCurrentLayout()->recalculateMonitor(m_iMonitorID); g_pCompositor->updateAllWindowsAnimatedDecorationValues(); @@ -902,7 +880,7 @@ void CWindow::destroyGroup() { m_sGroupData.head = false; updateWindowDecos(); g_pCompositor->updateWorkspaceWindows(workspaceID()); - g_pCompositor->updateWorkspaceSpecialRenderData(workspaceID()); + g_pCompositor->updateWorkspaceWindowData(workspaceID()); g_pLayoutManager->getCurrentLayout()->recalculateMonitor(m_iMonitorID); g_pCompositor->updateAllWindowsAnimatedDecorationValues(); @@ -938,7 +916,7 @@ void CWindow::destroyGroup() { g_pKeybindManager->m_bGroupsLocked = GROUPSLOCKEDPREV; g_pCompositor->updateWorkspaceWindows(workspaceID()); - g_pCompositor->updateWorkspaceSpecialRenderData(workspaceID()); + g_pCompositor->updateWorkspaceWindowData(workspaceID()); g_pLayoutManager->getCurrentLayout()->recalculateMonitor(m_iMonitorID); g_pCompositor->updateAllWindowsAnimatedDecorationValues(); @@ -1161,27 +1139,25 @@ float CWindow::rounding() { return m_sWindowData.noRounding.value_or(false) ? 0 : rounding; } -void CWindow::updateSpecialRenderData() { +void CWindow::updateWindowData() { const auto PWORKSPACE = m_pWorkspace; const auto WORKSPACERULE = PWORKSPACE ? g_pConfigManager->getWorkspaceRuleFor(PWORKSPACE) : SWorkspaceRule{}; - updateSpecialRenderData(WORKSPACERULE); + updateWindowData(WORKSPACERULE); } -void CWindow::updateSpecialRenderData(const SWorkspaceRule& workspaceRule) { +void CWindow::updateWindowData(const SWorkspaceRule& workspaceRule) { static auto PNOBORDERONFLOATING = CConfigValue("general:no_border_on_floating"); - m_sWindowData.noBorder = CWindowOverridableVar(*PNOBORDERONFLOATING && m_bIsFloating, PRIORITY_LAYOUT); + if (*PNOBORDERONFLOATING) + m_sWindowData.noBorder = CWindowOverridableVar(m_bIsFloating, PRIORITY_LAYOUT); + else + m_sWindowData.noBorder.unset(PRIORITY_LAYOUT); - if (workspaceRule.borderSize.has_value()) - m_sWindowData.borderSize = CWindowOverridableVar((int)workspaceRule.borderSize.value(), PRIORITY_WORKSPACE_RULE); - if (workspaceRule.decorate.has_value()) - m_sWindowData.decorate = CWindowOverridableVar((bool)workspaceRule.decorate.value(), PRIORITY_WORKSPACE_RULE); - if (workspaceRule.border.has_value()) - m_sWindowData.noBorder = CWindowOverridableVar(!workspaceRule.border.value(), PRIORITY_WORKSPACE_RULE); - if (workspaceRule.rounding.has_value()) - m_sWindowData.noRounding = CWindowOverridableVar(!workspaceRule.rounding.value(), PRIORITY_WORKSPACE_RULE); - if (workspaceRule.shadow.has_value()) - m_sWindowData.noShadow = CWindowOverridableVar(!workspaceRule.shadow.value(), PRIORITY_WORKSPACE_RULE); + m_sWindowData.borderSize.matchOptional(workspaceRule.borderSize, PRIORITY_WORKSPACE_RULE); + m_sWindowData.decorate.matchOptional(workspaceRule.decorate, PRIORITY_WORKSPACE_RULE); + m_sWindowData.noBorder.matchOptional(workspaceRule.noBorder, PRIORITY_WORKSPACE_RULE); + m_sWindowData.noRounding.matchOptional(workspaceRule.noRounding, PRIORITY_WORKSPACE_RULE); + m_sWindowData.noShadow.matchOptional(workspaceRule.noShadow, PRIORITY_WORKSPACE_RULE); } int CWindow::getRealBorderSize() { diff --git a/src/desktop/Window.hpp b/src/desktop/Window.hpp index 4a070284..87c5f43d 100644 --- a/src/desktop/Window.hpp +++ b/src/desktop/Window.hpp @@ -129,6 +129,13 @@ class CWindowOverridableVar { throw std::bad_optional_access(); } + void matchOptional(std::optional const& optValue, eOverridePriority priority) { + if (optValue.has_value()) + values[priority] = optValue.value(); + else + unset(priority); + } + private: std::map values; }; @@ -319,10 +326,7 @@ class CWindow { std::vector m_vDecosToRemove; // Special render data, rules, etc - SWindowData m_sWindowData; - - std::unordered_map*> mbWindowProperties; - std::unordered_map*> miWindowProperties; + SWindowData m_sWindowData; // Transformers std::vector> m_vTransformers; @@ -397,7 +401,6 @@ class CWindow { void onMap(); void setHidden(bool hidden); bool isHidden(); - void createWindowProperties(); void applyDynamicRule(const SWindowRule& r); void updateDynamicRules(); SBoxExtents getFullWindowReservedArea(); @@ -414,8 +417,8 @@ class CWindow { int surfacesCount(); int getRealBorderSize(); - void updateSpecialRenderData(); - void updateSpecialRenderData(const struct SWorkspaceRule&); + void updateWindowData(); + void updateWindowData(const struct SWorkspaceRule&); void onBorderAngleAnimEnd(void* ptr); bool isInCurvedCorner(double x, double y); diff --git a/src/events/Windows.cpp b/src/events/Windows.cpp index 46e15b55..c0081fbd 100644 --- a/src/events/Windows.cpp +++ b/src/events/Windows.cpp @@ -139,8 +139,6 @@ void Events::listener_mapWindow(void* owner, void* data) { bool overridingNoFullscreen = false; bool overridingNoMaximize = false; - PWINDOW->createWindowProperties(); - for (auto& r : PWINDOW->m_vMatchedRules) { if (r.szRule.starts_with("monitor")) { try { @@ -316,7 +314,7 @@ void Events::listener_mapWindow(void* owner, void* data) { workspaceSilent = false; } - PWINDOW->updateSpecialRenderData(); + g_pLayoutManager->getCurrentLayout()->unsetLayoutWindowData(PWINDOW); if (PWINDOW->m_bIsFloating) { g_pLayoutManager->getCurrentLayout()->onWindowCreatedFloating(PWINDOW); diff --git a/src/layout/DwindleLayout.cpp b/src/layout/DwindleLayout.cpp index 5c98c1ab..03cc56f1 100644 --- a/src/layout/DwindleLayout.cpp +++ b/src/layout/DwindleLayout.cpp @@ -139,7 +139,7 @@ void CHyprDwindleLayout::applyNodeDataToWindow(SDwindleNodeData* pNode, bool for if (PWINDOW->m_bIsFullscreen && !pNode->ignoreFullscreenChecks) return; - PWINDOW->updateSpecialRenderData(); + unsetLayoutWindowData(PWINDOW); static auto PNOGAPSWHENONLY = CConfigValue("dwindle:no_gaps_when_only"); static auto PGAPSINDATA = CConfigValue("general:gaps_in"); @@ -496,7 +496,7 @@ void CHyprDwindleLayout::onWindowRemovedTiling(PHLWINDOW pWindow) { return; } - pWindow->updateSpecialRenderData(); + unsetLayoutWindowData(pWindow); if (pWindow->m_bIsFullscreen) g_pCompositor->setWindowFullscreen(pWindow, false, FULLSCREEN_FULL); @@ -830,7 +830,7 @@ void CHyprDwindleLayout::fullscreenRequestForWindow(PHLWINDOW pWindow, eFullscre pWindow->m_vRealPosition = pWindow->m_vLastFloatingPosition; pWindow->m_vRealSize = pWindow->m_vLastFloatingSize; - pWindow->updateSpecialRenderData(); + unsetLayoutWindowData(pWindow); } } else { // if it now got fullscreen, make it fullscreen diff --git a/src/layout/IHyprLayout.cpp b/src/layout/IHyprLayout.cpp index 858100ce..4ac55829 100644 --- a/src/layout/IHyprLayout.cpp +++ b/src/layout/IHyprLayout.cpp @@ -542,7 +542,7 @@ void IHyprLayout::changeWindowFloatingMode(PHLWINDOW pWindow) { g_pHyprRenderer->damageMonitor(g_pCompositor->getMonitorFromID(pWindow->m_iMonitorID)); - pWindow->updateSpecialRenderData(); + g_pLayoutManager->getCurrentLayout()->unsetLayoutWindowData(pWindow); if (pWindow == m_pLastTiledWindow) m_pLastTiledWindow.reset(); @@ -712,4 +712,12 @@ Vector2D IHyprLayout::predictSizeForNewWindow(PHLWINDOW pWindow) { return sizePredicted; } +void IHyprLayout::unsetLayoutWindowData(PHLWINDOW pWindow) { + // not finished + pWindow->m_sWindowData.decorate.unset(PRIORITY_LAYOUT); + pWindow->m_sWindowData.noBorder.unset(PRIORITY_LAYOUT); + pWindow->m_sWindowData.noRounding.unset(PRIORITY_LAYOUT); + pWindow->m_sWindowData.noShadow.unset(PRIORITY_LAYOUT); +} + IHyprLayout::~IHyprLayout() {} diff --git a/src/layout/IHyprLayout.hpp b/src/layout/IHyprLayout.hpp index 74a00d19..bdfd4306 100644 --- a/src/layout/IHyprLayout.hpp +++ b/src/layout/IHyprLayout.hpp @@ -195,6 +195,8 @@ class IHyprLayout { virtual Vector2D predictSizeForNewWindow(PHLWINDOW pWindow); virtual Vector2D predictSizeForNewWindowFloating(PHLWINDOW pWindow); + virtual void unsetLayoutWindowData(PHLWINDOW); + private: int m_iMouseMoveEventCount; Vector2D m_vBeginDragXY; diff --git a/src/layout/MasterLayout.cpp b/src/layout/MasterLayout.cpp index 2b7b0aeb..bfb77918 100644 --- a/src/layout/MasterLayout.cpp +++ b/src/layout/MasterLayout.cpp @@ -264,7 +264,7 @@ void CHyprMasterLayout::onWindowRemovedTiling(PHLWINDOW pWindow) { const auto MASTERSLEFT = getMastersOnWorkspace(WORKSPACEID); static auto SMALLSPLIT = CConfigValue("master:allow_small_split"); - pWindow->updateSpecialRenderData(); + unsetLayoutWindowData(pWindow); g_pCompositor->setWindowFullscreen(pWindow, false, FULLSCREEN_FULL); @@ -646,7 +646,7 @@ void CHyprMasterLayout::applyNodeDataToWindow(SMasterNodeData* pNode) { if (PWINDOW->m_bIsFullscreen && !pNode->ignoreFullscreenChecks) return; - PWINDOW->updateSpecialRenderData(); + unsetLayoutWindowData(PWINDOW); static auto PNOGAPSWHENONLY = CConfigValue("master:no_gaps_when_only"); static auto PANIMATE = CConfigValue("misc:animate_manual_resizes"); @@ -922,7 +922,7 @@ void CHyprMasterLayout::fullscreenRequestForWindow(PHLWINDOW pWindow, eFullscree pWindow->m_vRealPosition = pWindow->m_vLastFloatingPosition; pWindow->m_vRealSize = pWindow->m_vLastFloatingSize; - pWindow->updateSpecialRenderData(); + unsetLayoutWindowData(pWindow); } } else { // if it now got fullscreen, make it fullscreen diff --git a/src/managers/KeybindManager.cpp b/src/managers/KeybindManager.cpp index 7610f5cc..38c9d5f1 100644 --- a/src/managers/KeybindManager.cpp +++ b/src/managers/KeybindManager.cpp @@ -252,7 +252,7 @@ bool CKeybindManager::ensureMouseBindState() { g_pInputManager->dragMode = MBIND_INVALID; g_pCompositor->updateWorkspaceWindows(lastDraggedWindow->workspaceID()); - g_pCompositor->updateWorkspaceSpecialRenderData(lastDraggedWindow->workspaceID()); + g_pCompositor->updateWorkspaceWindowData(lastDraggedWindow->workspaceID()); g_pLayoutManager->getCurrentLayout()->recalculateMonitor(lastDraggedWindow->m_iMonitorID); g_pCompositor->updateAllWindowsAnimatedDecorationValues(); @@ -974,7 +974,7 @@ static void toggleActiveFloatingCore(std::string args, std::optional float g_pLayoutManager->getCurrentLayout()->changeWindowFloatingMode(PWINDOW); } g_pCompositor->updateWorkspaceWindows(PWINDOW->workspaceID()); - g_pCompositor->updateWorkspaceSpecialRenderData(PWINDOW->workspaceID()); + g_pCompositor->updateWorkspaceWindowData(PWINDOW->workspaceID()); g_pLayoutManager->getCurrentLayout()->recalculateMonitor(PWINDOW->m_iMonitorID); g_pCompositor->updateAllWindowsAnimatedDecorationValues(); }