From d284aaa2caaf6d25793fe27740b724a7b99a5be7 Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Wed, 27 Apr 2022 17:46:07 +0200 Subject: [PATCH] Added custom reserved area per mon --- src/config/ConfigManager.cpp | 30 ++++++++++++++++++++++++++++-- src/config/ConfigManager.hpp | 9 +++++++++ src/render/Renderer.cpp | 4 ++++ 3 files changed, 41 insertions(+), 2 deletions(-) diff --git a/src/config/ConfigManager.cpp b/src/config/ConfigManager.cpp index e6d0ccd1..64a3f01e 100644 --- a/src/config/ConfigManager.cpp +++ b/src/config/ConfigManager.cpp @@ -160,8 +160,33 @@ void CConfigManager::handleMonitor(const std::string& command, const std::string nextItem(); - if (curitem == "disable" || curitem == "disabled") { - newrule.disabled = true; + if (curitem == "disable" || curitem == "disabled" || curitem == "addreserved") { + if (curitem == "disable" || curitem == "disabled") + newrule.disabled = true; + else if (curitem == "addreserved") { + nextItem(); + + int top = std::stoi(curitem); + + nextItem(); + + int bottom = std::stoi(curitem); + + nextItem(); + + int left = std::stoi(curitem); + + nextItem(); + + int right = std::stoi(curitem); + + m_mAdditionalReservedAreas[newrule.name] = {top, bottom, left, right}; + + return; // this is not a rule, ignore + } else { + Debug::log(ERR, "ConfigManager parseMonitor, curitem bogus???"); + return; + } // overwrite if exists for (auto& r : m_dMonitorRules) { @@ -422,6 +447,7 @@ void CConfigManager::loadConfigLoadVars() { m_dWindowRules.clear(); g_pKeybindManager->clearKeybinds(); g_pAnimationManager->removeAllBeziers(); + m_mAdditionalReservedAreas.clear(); const char* const ENVHOME = getenv("HOME"); const std::string CONFIGPATH = ENVHOME + (ISDEBUG ? (std::string) "/.config/hypr/hyprlandd.conf" : (std::string) "/.config/hypr/hyprland.conf"); diff --git a/src/config/ConfigManager.hpp b/src/config/ConfigManager.hpp index 5c1e125c..b8136016 100644 --- a/src/config/ConfigManager.hpp +++ b/src/config/ConfigManager.hpp @@ -30,6 +30,13 @@ struct SMonitorRule { bool disabled = false; }; +struct SMonitorAdditionalReservedArea { + int top = 0; + int bottom = 0; + int left = 0; + int right = 0; +}; + struct SWindowRule { std::string szRule; std::string szValue; @@ -55,6 +62,8 @@ public: std::vector getMatchingRules(CWindow*); + std::unordered_map m_mAdditionalReservedAreas; + // no-op when done. void dispatchExecOnce(); diff --git a/src/render/Renderer.cpp b/src/render/Renderer.cpp index bf4aa6d6..f86def13 100644 --- a/src/render/Renderer.cpp +++ b/src/render/Renderer.cpp @@ -408,6 +408,10 @@ void CHyprRenderer::arrangeLayersForMonitor(const int& monitor) { PMONITOR->vecReservedTopLeft = Vector2D(usableArea.x, usableArea.y) - PMONITOR->vecPosition; PMONITOR->vecReservedBottomRight = PMONITOR->vecSize - Vector2D(usableArea.width, usableArea.height) - PMONITOR->vecReservedTopLeft; + const auto ENTRY = g_pConfigManager->m_mAdditionalReservedAreas[PMONITOR->szName]; + PMONITOR->vecReservedTopLeft = PMONITOR->vecReservedTopLeft + Vector2D(ENTRY.left, ENTRY.top); + PMONITOR->vecReservedBottomRight = PMONITOR->vecReservedBottomRight + Vector2D(ENTRY.right, ENTRY.bottom); + Debug::log(LOG, "Monitor %s layers arranged: reserved: %f %f %f %f", PMONITOR->szName.c_str(), PMONITOR->vecReservedTopLeft.x, PMONITOR->vecReservedTopLeft.y, PMONITOR->vecReservedBottomRight.x, PMONITOR->vecReservedBottomRight.y); }