From 8018a2f817f39f876152f1fa26aa9bb4b89d5251 Mon Sep 17 00:00:00 2001 From: Vaxry Date: Wed, 13 Dec 2023 00:51:21 +0000 Subject: [PATCH] hyprbars: add precedence_over_border fixes #39 --- hyprbars/README.md | 2 ++ hyprbars/barDeco.cpp | 12 +++++++----- hyprbars/main.cpp | 1 + 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/hyprbars/README.md b/hyprbars/README.md index 547eae0..652813f 100644 --- a/hyprbars/README.md +++ b/hyprbars/README.md @@ -36,6 +36,8 @@ plugin { `bar_part_of_window` -> (bool) whether the bar is a part of the main window (if it is, stuff like shadows render around it) +`bar_precedence_over_border` -> (bool) whether the bar should have a higher priority than the border (border will be around the bar) + ## Buttons Config Use the `hyprbars-button` keyword. diff --git a/hyprbars/barDeco.cpp b/hyprbars/barDeco.cpp index f7634e4..9aa00b9 100644 --- a/hyprbars/barDeco.cpp +++ b/hyprbars/barDeco.cpp @@ -30,12 +30,13 @@ CHyprBar::~CHyprBar() { } SDecorationPositioningInfo CHyprBar::getPositioningInfo() { - static auto* const PHEIGHT = &HyprlandAPI::getConfigValue(PHANDLE, "plugin:hyprbars:bar_height")->intValue; + static auto* const PHEIGHT = &HyprlandAPI::getConfigValue(PHANDLE, "plugin:hyprbars:bar_height")->intValue; + static auto* const PPRECEDENCE = &HyprlandAPI::getConfigValue(PHANDLE, "plugin:hyprbars:bar_precedence_over_border")->intValue; SDecorationPositioningInfo info; info.policy = DECORATION_POSITION_STICKY; info.edges = DECORATION_EDGE_TOP; - info.priority = 1000; + info.priority = *PPRECEDENCE ? 10005 : 5000; info.reserved = true; info.desiredExtents = {{0, *PHEIGHT}, {0, 0}}; return info; @@ -351,8 +352,9 @@ void CHyprBar::draw(CMonitor* pMonitor, float a, const Vector2D& offset) { if (!m_pWindow->m_sSpecialRenderData.decorate) return; - static auto* const PCOLOR = &HyprlandAPI::getConfigValue(PHANDLE, "plugin:hyprbars:bar_color")->intValue; - static auto* const PHEIGHT = &HyprlandAPI::getConfigValue(PHANDLE, "plugin:hyprbars:bar_height")->intValue; + static auto* const PCOLOR = &HyprlandAPI::getConfigValue(PHANDLE, "plugin:hyprbars:bar_color")->intValue; + static auto* const PHEIGHT = &HyprlandAPI::getConfigValue(PHANDLE, "plugin:hyprbars:bar_height")->intValue; + static auto* const PPRECEDENCE = &HyprlandAPI::getConfigValue(PHANDLE, "plugin:hyprbars:bar_precedence_over_border")->intValue; if (*PHEIGHT < 1) { m_iLastHeight = *PHEIGHT; @@ -362,7 +364,7 @@ void CHyprBar::draw(CMonitor* pMonitor, float a, const Vector2D& offset) { const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(m_pWindow->m_iWorkspaceID); const auto WORKSPACEOFFSET = PWORKSPACE && !m_pWindow->m_bPinned ? PWORKSPACE->m_vRenderOffset.vec() : Vector2D(); - const auto ROUNDING = m_pWindow->rounding() + m_pWindow->getRealBorderSize(); + const auto ROUNDING = m_pWindow->rounding() + (*PPRECEDENCE ? 0 : m_pWindow->getRealBorderSize()); const auto scaledRounding = ROUNDING > 0 ? ROUNDING * pMonitor->scale - 2 /* idk why but otherwise it looks bad due to the gaps */ : 0; diff --git a/hyprbars/main.cpp b/hyprbars/main.cpp index 81c1b9c..2163f6b 100644 --- a/hyprbars/main.cpp +++ b/hyprbars/main.cpp @@ -72,6 +72,7 @@ APICALL EXPORT PLUGIN_DESCRIPTION_INFO PLUGIN_INIT(HANDLE handle) { HyprlandAPI::addConfigValue(PHANDLE, "plugin:hyprbars:bar_text_font", SConfigValue{.strValue = "Sans"}); HyprlandAPI::addConfigValue(PHANDLE, "plugin:hyprbars:bar_text_align", SConfigValue{.strValue = "center"}); HyprlandAPI::addConfigValue(PHANDLE, "plugin:hyprbars:bar_part_of_window", SConfigValue{.intValue = 1}); + HyprlandAPI::addConfigValue(PHANDLE, "plugin:hyprbars:bar_precedence_over_border", SConfigValue{.intValue = 0}); HyprlandAPI::addConfigKeyword(PHANDLE, "hyprbars-button", [&](const std::string& k, const std::string& v) { onNewButton(k, v); }); HyprlandAPI::registerCallbackDynamic(PHANDLE, "preConfigReload", [&](void* self, SCallbackInfo& info, std::any data) { onPreConfigReload(); });