From eaf18d55d51cef00818c5a4fdd4170f8cc2de4dc Mon Sep 17 00:00:00 2001 From: Vaxry Date: Tue, 12 May 2026 13:21:43 +0100 Subject: [PATCH] all: update for 0.55 --- borders-plus-plus/README.md | 25 +++++++------- borders-plus-plus/borderDeco.cpp | 56 ++++++++++++++------------------ borders-plus-plus/globals.hpp | 14 ++++++++ borders-plus-plus/main.cpp | 22 ++++++++++--- hyprbars/BarPassElement.cpp | 6 ++-- hyprbars/barDeco.cpp | 25 +++++++------- hyprbars/main.cpp | 13 ++++---- hyprfocus/main.cpp | 16 ++++----- 8 files changed, 100 insertions(+), 77 deletions(-) diff --git a/borders-plus-plus/README.md b/borders-plus-plus/README.md index eb7db8d..b9ef180 100644 --- a/borders-plus-plus/README.md +++ b/borders-plus-plus/README.md @@ -5,21 +5,20 @@ Allows you to add one or two additional borders to your windows. The borders added are static. Example Config: -``` -plugin { - borders-plus-plus { - add_borders = 1 # 0 - 9 - # you can add up to 9 borders - col.border_1 = rgb(ffffff) - col.border_2 = rgb(2222ff) +```lua +hl.config({ + plugin = { + borders_plus_plus = { + add_borders = 1 + natural_rounding = true - # -1 means "default" as in the one defined in general:border_size - border_size_1 = 10 - border_size_2 = -1 + col = { + border_1 = "rgb(ffffff)" + } - # makes outer edges match rounding of the parent. Turn on / off to better understand. Default = on. - natural_rounding = yes + border_size_1 = 10 + } } -} +}) ``` \ No newline at end of file diff --git a/borders-plus-plus/borderDeco.cpp b/borders-plus-plus/borderDeco.cpp index dbb1855..6bfbdd5 100644 --- a/borders-plus-plus/borderDeco.cpp +++ b/borders-plus-plus/borderDeco.cpp @@ -1,5 +1,7 @@ #include "borderDeco.hpp" +#include + #include #include #include @@ -9,6 +11,10 @@ using namespace Render::GL; #include "BorderppPassElement.hpp" #include "globals.hpp" +static size_t borderCount() { + return std::clamp(vars.addBorders->value(), 0, static_cast(vars.borderSizes.size())); +} + CBordersPlusPlus::CBordersPlusPlus(PHLWINDOW pWindow) : IHyprWindowDecoration(pWindow), m_pWindow(pWindow) { m_lastWindowPos = pWindow->m_realPosition->value(); m_lastWindowSize = pWindow->m_realSize->value(); @@ -19,13 +25,6 @@ CBordersPlusPlus::~CBordersPlusPlus() { } SDecorationPositioningInfo CBordersPlusPlus::getPositioningInfo() { - static auto* const PBORDERS = (Hyprlang::INT* const*)HyprlandAPI::getConfigValue(PHANDLE, "plugin:borders-plus-plus:add_borders")->getDataStaticPtr(); - - static std::vector PSIZES; - for (size_t i = 0; i < 9; ++i) { - PSIZES.push_back((Hyprlang::INT* const*)HyprlandAPI::getConfigValue(PHANDLE, "plugin:borders-plus-plus:border_size_" + std::to_string(i + 1))->getDataStaticPtr()); - } - SDecorationPositioningInfo info; info.policy = DECORATION_POSITION_STICKY; info.reserved = true; @@ -35,8 +34,8 @@ SDecorationPositioningInfo CBordersPlusPlus::getPositioningInfo() { if (m_fLastThickness == 0) { double size = 0; - for (size_t i = 0; i < **PBORDERS; ++i) { - size += **PSIZES[i]; + for (size_t i = 0; i < borderCount(); ++i) { + size += vars.borderSizes[i]->value(); } info.desiredExtents = {{size, size}, {size, size}}; @@ -79,20 +78,15 @@ void CBordersPlusPlus::draw(PHLMONITOR pMonitor, const float& a) { } void CBordersPlusPlus::drawPass(PHLMONITOR pMonitor, const float& a) { - const auto PWINDOW = m_pWindow.lock(); + const auto PWINDOW = m_pWindow.lock(); - static std::vector PCOLORS; - static std::vector PSIZES; - for (size_t i = 0; i < 9; ++i) { - PCOLORS.push_back((Hyprlang::INT* const*)HyprlandAPI::getConfigValue(PHANDLE, "plugin:borders-plus-plus:col.border_" + std::to_string(i + 1))->getDataStaticPtr()); - PSIZES.push_back((Hyprlang::INT* const*)HyprlandAPI::getConfigValue(PHANDLE, "plugin:borders-plus-plus:border_size_" + std::to_string(i + 1))->getDataStaticPtr()); - } - static auto* const PBORDERS = (Hyprlang::INT* const*)HyprlandAPI::getConfigValue(PHANDLE, "plugin:borders-plus-plus:add_borders")->getDataStaticPtr(); - static auto* const PNATURALROUND = (Hyprlang::INT* const*)HyprlandAPI::getConfigValue(PHANDLE, "plugin:borders-plus-plus:natural_rounding")->getDataStaticPtr(); - static auto* const PROUNDING = (Hyprlang::INT* const*)HyprlandAPI::getConfigValue(PHANDLE, "decoration:rounding")->getDataStaticPtr(); - static auto* const PBORDERSIZE = (Hyprlang::INT* const*)HyprlandAPI::getConfigValue(PHANDLE, "general:border_size")->getDataStaticPtr(); + static auto PROUNDING = CConfigValue("decoration:rounding"); + static auto PBORDERSIZE = CConfigValue("general:border_size"); - if (**PBORDERS < 1) + const auto BORDERS = borderCount(); + const auto NATURALROUND = vars.naturalRounding->value(); + + if (BORDERS < 1) return; if (m_bAssignedGeometry.width < m_seExtents.topLeft.x + 1 || m_bAssignedGeometry.height < m_seExtents.topLeft.y + 1) @@ -101,9 +95,9 @@ void CBordersPlusPlus::drawPass(PHLMONITOR pMonitor, const float& a) { const auto PWORKSPACE = PWINDOW->m_workspace; const auto WORKSPACEOFFSET = PWORKSPACE && !PWINDOW->m_pinned ? PWORKSPACE->m_renderOffset->value() : Vector2D(); - auto rounding = PWINDOW->rounding() == 0 ? 0 : (PWINDOW->rounding() + **PBORDERSIZE) * pMonitor->m_scale; + auto rounding = PWINDOW->rounding() == 0 ? 0 : (PWINDOW->rounding() + *PBORDERSIZE) * pMonitor->m_scale; const auto ROUNDINGPOWER = PWINDOW->roundingPower(); - const auto ORIGINALROUND = rounding == 0 ? 0 : (PWINDOW->rounding() + **PBORDERSIZE) * pMonitor->m_scale; + const auto ORIGINALROUND = rounding == 0 ? 0 : (PWINDOW->rounding() + *PBORDERSIZE) * pMonitor->m_scale; CBox fullBox = m_bAssignedGeometry; fullBox.translate(g_pDecorationPositioner->getEdgeDefinedPoint(DECORATION_EDGE_BOTTOM | DECORATION_EDGE_LEFT | DECORATION_EDGE_RIGHT | DECORATION_EDGE_TOP, m_pWindow.lock())); @@ -115,16 +109,16 @@ void CBordersPlusPlus::drawPass(PHLMONITOR pMonitor, const float& a) { double fullThickness = 0; - for (size_t i = 0; i < **PBORDERS; ++i) { - const int THISBORDERSIZE = **(PSIZES[i]) == -1 ? **PBORDERSIZE : (**PSIZES[i]); + for (size_t i = 0; i < BORDERS; ++i) { + const int THISBORDERSIZE = vars.borderSizes[i]->value() == -1 ? *PBORDERSIZE : vars.borderSizes[i]->value(); fullThickness += THISBORDERSIZE; } fullBox.expand(-fullThickness).scale(pMonitor->m_scale).round(); - for (size_t i = 0; i < **PBORDERS; ++i) { - const int PREVBORDERSIZESCALED = i == 0 ? 0 : (**PSIZES[i - 1] == -1 ? **PBORDERSIZE : **(PSIZES[i - 1])) * pMonitor->m_scale; - const int THISBORDERSIZE = **(PSIZES[i]) == -1 ? **PBORDERSIZE : (**PSIZES[i]); + for (size_t i = 0; i < BORDERS; ++i) { + const int PREVBORDERSIZESCALED = i == 0 ? 0 : (vars.borderSizes[i - 1]->value() == -1 ? *PBORDERSIZE : vars.borderSizes[i - 1]->value()) * pMonitor->m_scale; + const int THISBORDERSIZE = vars.borderSizes[i]->value() == -1 ? *PBORDERSIZE : vars.borderSizes[i]->value(); if (i != 0) { rounding += rounding == 0 ? 0 : PREVBORDERSIZESCALED; @@ -139,12 +133,12 @@ void CBordersPlusPlus::drawPass(PHLMONITOR pMonitor, const float& a) { g_pHyprOpenGL->scissor(nullptr); - g_pHyprOpenGL->renderBorder(fullBox, CHyprColor{(uint64_t)**PCOLORS[i]}, - {.round = **PNATURALROUND ? sc(ORIGINALROUND) : sc(rounding), + g_pHyprOpenGL->renderBorder(fullBox, CHyprColor{static_cast(vars.borderColors[i]->value())}, + {.round = NATURALROUND ? sc(ORIGINALROUND) : sc(rounding), .roundingPower = ROUNDINGPOWER, .borderSize = THISBORDERSIZE, .a = a, - .outerRound = **PNATURALROUND ? sc(ORIGINALROUND) : -1}); + .outerRound = NATURALROUND ? sc(ORIGINALROUND) : -1}); } m_seExtents = {{fullThickness, fullThickness}, {fullThickness, fullThickness}}; diff --git a/borders-plus-plus/globals.hpp b/borders-plus-plus/globals.hpp index 66c4f04..8c2c707 100644 --- a/borders-plus-plus/globals.hpp +++ b/borders-plus-plus/globals.hpp @@ -1,5 +1,19 @@ #pragma once +#include + +#include +#include +#include #include inline HANDLE PHANDLE = nullptr; + +struct SVars { + SP addBorders; + SP naturalRounding; + std::array, 9> borderColors; + std::array, 9> borderSizes; +}; + +inline SVars vars = {}; diff --git a/borders-plus-plus/main.cpp b/borders-plus-plus/main.cpp index 5bb1389..4b1338a 100644 --- a/borders-plus-plus/main.cpp +++ b/borders-plus-plus/main.cpp @@ -3,6 +3,7 @@ #include #include +#include #include #include #include @@ -33,12 +34,25 @@ APICALL EXPORT PLUGIN_DESCRIPTION_INFO PLUGIN_INIT(HANDLE handle) { throw std::runtime_error("[bpp] Version mismatch"); } - HyprlandAPI::addConfigValue(PHANDLE, "plugin:borders-plus-plus:add_borders", Hyprlang::INT{1}); - HyprlandAPI::addConfigValue(PHANDLE, "plugin:borders-plus-plus:natural_rounding", Hyprlang::INT{1}); + vars.addBorders = + makeShared("plugin:borders-plus-plus:add_borders", "How many extra borders to draw", 1, Config::Values::SIntValueOptions{.min = 0, .max = 9}); + vars.naturalRounding = makeShared("plugin:borders-plus-plus:natural_rounding", "Use the window's original rounding", true); + + HyprlandAPI::addConfigValueV2(PHANDLE, vars.addBorders); + HyprlandAPI::addConfigValueV2(PHANDLE, vars.naturalRounding); + + static std::array borderColorNames; + static std::array borderSizeNames; for (size_t i = 0; i < 9; ++i) { - HyprlandAPI::addConfigValue(PHANDLE, "plugin:borders-plus-plus:col.border_" + std::to_string(i + 1), Hyprlang::INT{*configStringToInt("rgba(000000ee)")}); - HyprlandAPI::addConfigValue(PHANDLE, "plugin:borders-plus-plus:border_size_" + std::to_string(i + 1), Hyprlang::INT{-1}); + borderColorNames[i] = "plugin:borders-plus-plus:col.border_" + std::to_string(i + 1); + borderSizeNames[i] = "plugin:borders-plus-plus:border_size_" + std::to_string(i + 1); + + vars.borderColors[i] = makeShared(borderColorNames[i].c_str(), "Color of the extra border", 0xee000000); + vars.borderSizes[i] = makeShared(borderSizeNames[i].c_str(), "Size of the extra border", -1); + + HyprlandAPI::addConfigValueV2(PHANDLE, vars.borderColors[i]); + HyprlandAPI::addConfigValueV2(PHANDLE, vars.borderSizes[i]); } HyprlandAPI::reloadConfig(); diff --git a/hyprbars/BarPassElement.cpp b/hyprbars/BarPassElement.cpp index e714036..2f10731 100644 --- a/hyprbars/BarPassElement.cpp +++ b/hyprbars/BarPassElement.cpp @@ -15,11 +15,11 @@ std::vector> CBarPassElement::draw() { } bool CBarPassElement::needsLiveBlur() { - static auto* const PENABLEBLURGLOBAL = (Hyprlang::INT* const*)HyprlandAPI::getConfigValue(PHANDLE, "decoration:blur:enabled")->getDataStaticPtr(); + static auto PENABLEBLURGLOBAL = CConfigValue("decoration:blur:enabled"); - CHyprColor color = data.deco->m_bForcedBarColor.value_or(CHyprColor{static_cast(g_pGlobalState->config.barColor->value())}); + CHyprColor color = data.deco->m_bForcedBarColor.value_or(CHyprColor{static_cast(g_pGlobalState->config.barColor->value())}); color.a *= data.a; - const bool SHOULDBLUR = g_pGlobalState->config.barBlur->value() && **PENABLEBLURGLOBAL && color.a < 1.F; + const bool SHOULDBLUR = g_pGlobalState->config.barBlur->value() && *PENABLEBLURGLOBAL && color.a < 1.F; return SHOULDBLUR; } diff --git a/hyprbars/barDeco.cpp b/hyprbars/barDeco.cpp index f95fef1..257c4c9 100644 --- a/hyprbars/barDeco.cpp +++ b/hyprbars/barDeco.cpp @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include @@ -435,16 +436,16 @@ void CHyprBar::draw(PHLMONITOR pMonitor, const float& a) { } void CHyprBar::renderPass(PHLMONITOR pMonitor, const float& a) { - const auto PWINDOW = m_pWindow.lock(); + const auto PWINDOW = m_pWindow.lock(); - static auto* const PENABLEBLURGLOBAL = (Hyprlang::INT* const*)HyprlandAPI::getConfigValue(PHANDLE, "decoration:blur:enabled")->getDataStaticPtr(); - const auto BARCOLOR = g_pGlobalState->config.barColor->value(); - const auto HEIGHT = g_pGlobalState->config.barHeight->value(); - const auto PRECEDENCE = g_pGlobalState->config.barPrecedenceOverBorder->value(); - const auto ALIGNBUTTONS = g_pGlobalState->config.barButtonsAlignment->value(); - const auto ENABLETITLE = g_pGlobalState->config.barTitleEnabled->value(); - const auto ENABLEBLUR = g_pGlobalState->config.barBlur->value(); - const auto INACTIVECOLOR = g_pGlobalState->config.inactiveButtonColor->value(); + static auto PENABLEBLURGLOBAL = CConfigValue("decoration:blur:enabled"); + const auto BARCOLOR = g_pGlobalState->config.barColor->value(); + const auto HEIGHT = g_pGlobalState->config.barHeight->value(); + const auto PRECEDENCE = g_pGlobalState->config.barPrecedenceOverBorder->value(); + const auto ALIGNBUTTONS = g_pGlobalState->config.barButtonsAlignment->value(); + const auto ENABLETITLE = g_pGlobalState->config.barTitleEnabled->value(); + const auto ENABLEBLUR = g_pGlobalState->config.barBlur->value(); + const auto INACTIVECOLOR = g_pGlobalState->config.inactiveButtonColor->value(); if (INACTIVECOLOR > 0) { bool currentWindowFocus = PWINDOW == Desktop::focusState()->window(); @@ -462,7 +463,7 @@ void CHyprBar::renderPass(PHLMONITOR pMonitor, const float& a) { color.a *= a; const bool BUTTONSRIGHT = ALIGNBUTTONS != "left"; - const bool SHOULDBLUR = ENABLEBLUR && **PENABLEBLURGLOBAL && color.a < 1.F; + const bool SHOULDBLUR = ENABLEBLUR && *PENABLEBLURGLOBAL && color.a < 1.F; if (HEIGHT < 1) { m_iLastHeight = HEIGHT; @@ -640,9 +641,9 @@ void CHyprBar::updateRules() { if (PWINDOW->m_ruleApplicator->m_otherProps.props.contains(g_pGlobalState->nobarRuleIdx)) m_hidden = truthy(PWINDOW->m_ruleApplicator->m_otherProps.props.at(g_pGlobalState->nobarRuleIdx)->effect); if (PWINDOW->m_ruleApplicator->m_otherProps.props.contains(g_pGlobalState->barColorRuleIdx)) - m_bForcedBarColor = CHyprColor(configStringToInt(PWINDOW->m_ruleApplicator->m_otherProps.props.at(g_pGlobalState->barColorRuleIdx)->effect).value_or(0)); + m_bForcedBarColor = CHyprColor(Config::ParserUtils::parseColor(PWINDOW->m_ruleApplicator->m_otherProps.props.at(g_pGlobalState->barColorRuleIdx)->effect).value_or(0)); if (PWINDOW->m_ruleApplicator->m_otherProps.props.contains(g_pGlobalState->titleColorRuleIdx)) - m_bForcedTitleColor = CHyprColor(configStringToInt(PWINDOW->m_ruleApplicator->m_otherProps.props.at(g_pGlobalState->titleColorRuleIdx)->effect).value_or(0)); + m_bForcedTitleColor = CHyprColor(Config::ParserUtils::parseColor(PWINDOW->m_ruleApplicator->m_otherProps.props.at(g_pGlobalState->titleColorRuleIdx)->effect).value_or(0)); if (prevHidden != m_hidden) g_pDecorationPositioner->repositionDeco(this); diff --git a/hyprbars/main.cpp b/hyprbars/main.cpp index 72a4491..8465874 100644 --- a/hyprbars/main.cpp +++ b/hyprbars/main.cpp @@ -6,6 +6,7 @@ #include #include #include +#include #include #include #include @@ -86,8 +87,8 @@ Hyprlang::CParseResult onNewButton(const char* K, const char* V) { } bool userfg = false; - auto fgcolor = configStringToInt("rgb(ffffff)"); - auto bgcolor = configStringToInt(vars[0]); + auto fgcolor = Config::ParserUtils::parseColor("rgb(ffffff)"); + auto bgcolor = Config::ParserUtils::parseColor(vars[0]); if (!bgcolor) { result.setError("invalid bgcolor"); @@ -96,7 +97,7 @@ Hyprlang::CParseResult onNewButton(const char* K, const char* V) { if (vars.size() == 5) { userfg = true; - fgcolor = configStringToInt(vars[4]); + fgcolor = Config::ParserUtils::parseColor(vars[4]); } if (!fgcolor) { @@ -207,10 +208,10 @@ APICALL EXPORT PLUGIN_DESCRIPTION_INFO PLUGIN_INIT(HANDLE handle) { static auto P = Event::bus()->m_events.window.open.listen([&](PHLWINDOW w) { onNewWindow(w); }); static auto P3 = Event::bus()->m_events.window.updateRules.listen([&](PHLWINDOW w) { onUpdateWindowRules(w); }); - g_pGlobalState->config.barColor = makeShared("plugin:hyprbars:bar_color", "Change the bar color", *configStringToInt("rgba(33333388)")); - g_pGlobalState->config.textColor = makeShared("plugin:hyprbars:col.text", "Change the text color", *configStringToInt("rgba(ffffffff)")); + g_pGlobalState->config.barColor = makeShared("plugin:hyprbars:bar_color", "Change the bar color", 0x88333333); + g_pGlobalState->config.textColor = makeShared("plugin:hyprbars:col.text", "Change the text color", 0xffffffff); g_pGlobalState->config.inactiveButtonColor = makeShared( - "plugin:hyprbars:inactive_button_color", "Change the inactive button's color. 0x00000000 means unset", *configStringToInt("rgba(00000000)")); + "plugin:hyprbars:inactive_button_color", "Change the inactive button's color. 0x00000000 means unset", 0x00000000); g_pGlobalState->config.barHeight = makeShared("plugin:hyprbars:bar_height", "Change the bar's height", 15); g_pGlobalState->config.barTextSize = makeShared("plugin:hyprbars:bar_text_size", "Change the bar's text size", 10); g_pGlobalState->config.barTitleEnabled = makeShared("plugin:hyprbars:bar_title_enabled", "Whether to enable titles in the bar", true); diff --git a/hyprfocus/main.cpp b/hyprfocus/main.cpp index 3950aa9..539ae04 100644 --- a/hyprfocus/main.cpp +++ b/hyprfocus/main.cpp @@ -57,17 +57,17 @@ static void onFocusChange(PHLWINDOW window) { const auto POUT = Config::animationTree()->getAnimationPropertyConfig("hyprfocusOut"); if (configValues.mode->value() == "flash") { - const auto ORIGINAL = window->m_activeInactiveAlpha->goal(); - window->m_activeInactiveAlpha->setConfig(PIN); - *window->m_activeInactiveAlpha = configValues.fadeOpacity->value(); + const auto ORIGINAL = window->alpha(Desktop::View::WINDOW_ALPHA_ACTIVE)->goal(); + window->alpha(Desktop::View::WINDOW_ALPHA_ACTIVE)->setConfig(PIN); + *window->alpha(Desktop::View::WINDOW_ALPHA_ACTIVE) = configValues.fadeOpacity->value(); - window->m_activeInactiveAlpha->setCallbackOnEnd([w = PHLWINDOWREF{window}, POUT, ORIGINAL](WP pav) { + window->alpha(Desktop::View::WINDOW_ALPHA_ACTIVE)->setCallbackOnEnd([w = PHLWINDOWREF{window}, POUT, ORIGINAL](WP pav) { if (!w) return; - w->m_activeInactiveAlpha->setConfig(POUT); - *w->m_activeInactiveAlpha = ORIGINAL; + w->alpha(Desktop::View::WINDOW_ALPHA_ACTIVE)->setConfig(POUT); + *w->alpha(Desktop::View::WINDOW_ALPHA_ACTIVE) = ORIGINAL; - w->m_activeInactiveAlpha->setCallbackOnEnd(nullptr); + w->alpha(Desktop::View::WINDOW_ALPHA_ACTIVE)->setCallbackOnEnd(nullptr); }); } else if (configValues.mode->value() == "bounce") { const auto ORIGINAL = CBox{window->m_realPosition->goal(), window->m_realSize->goal()}; @@ -158,6 +158,6 @@ APICALL EXPORT void PLUGIN_EXIT() { w->m_realSize->setCallbackOnEnd(nullptr); w->m_realPosition->setCallbackOnEnd(nullptr); - w->m_activeInactiveAlpha->setCallbackOnEnd(nullptr); + w->alpha(Desktop::View::WINDOW_ALPHA_ACTIVE)->setCallbackOnEnd(nullptr); } }