all: update for 0.55

This commit is contained in:
Vaxry 2026-05-12 13:21:43 +01:00
parent 22de29bc1c
commit eaf18d55d5
No known key found for this signature in database
8 changed files with 100 additions and 77 deletions

View file

@ -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
}
}
}
})
```

View file

@ -1,5 +1,7 @@
#include "borderDeco.hpp"
#include <algorithm>
#include <hyprland/src/Compositor.hpp>
#include <hyprland/src/desktop/view/Window.hpp>
#include <hyprland/src/render/Renderer.hpp>
@ -9,6 +11,10 @@ using namespace Render::GL;
#include "BorderppPassElement.hpp"
#include "globals.hpp"
static size_t borderCount() {
return std::clamp<Config::INTEGER>(vars.addBorders->value(), 0, static_cast<Config::INTEGER>(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<Hyprlang::INT* const*> 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<Hyprlang::INT* const*> PCOLORS;
static std::vector<Hyprlang::INT* const*> 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<Config::INTEGER>("decoration:rounding");
static auto PBORDERSIZE = CConfigValue<Config::INTEGER>("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<int>(ORIGINALROUND) : sc<int>(rounding),
g_pHyprOpenGL->renderBorder(fullBox, CHyprColor{static_cast<uint64_t>(vars.borderColors[i]->value())},
{.round = NATURALROUND ? sc<int>(ORIGINALROUND) : sc<int>(rounding),
.roundingPower = ROUNDINGPOWER,
.borderSize = THISBORDERSIZE,
.a = a,
.outerRound = **PNATURALROUND ? sc<int>(ORIGINALROUND) : -1});
.outerRound = NATURALROUND ? sc<int>(ORIGINALROUND) : -1});
}
m_seExtents = {{fullThickness, fullThickness}, {fullThickness, fullThickness}};

View file

@ -1,5 +1,19 @@
#pragma once
#include <array>
#include <hyprland/src/config/values/types/BoolValue.hpp>
#include <hyprland/src/config/values/types/ColorValue.hpp>
#include <hyprland/src/config/values/types/IntValue.hpp>
#include <hyprland/src/plugins/PluginAPI.hpp>
inline HANDLE PHANDLE = nullptr;
struct SVars {
SP<Config::Values::CIntValue> addBorders;
SP<Config::Values::CBoolValue> naturalRounding;
std::array<SP<Config::Values::CColorValue>, 9> borderColors;
std::array<SP<Config::Values::CIntValue>, 9> borderSizes;
};
inline SVars vars = {};

View file

@ -3,6 +3,7 @@
#include <unistd.h>
#include <any>
#include <array>
#include <hyprland/src/Compositor.hpp>
#include <hyprland/src/desktop/view/Window.hpp>
#include <hyprland/src/config/ConfigManager.hpp>
@ -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<Config::Values::CIntValue>("plugin:borders-plus-plus:add_borders", "How many extra borders to draw", 1, Config::Values::SIntValueOptions{.min = 0, .max = 9});
vars.naturalRounding = makeShared<Config::Values::CBoolValue>("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<std::string, 9> borderColorNames;
static std::array<std::string, 9> 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<Config::Values::CColorValue>(borderColorNames[i].c_str(), "Color of the extra border", 0xee000000);
vars.borderSizes[i] = makeShared<Config::Values::CIntValue>(borderSizeNames[i].c_str(), "Size of the extra border", -1);
HyprlandAPI::addConfigValueV2(PHANDLE, vars.borderColors[i]);
HyprlandAPI::addConfigValueV2(PHANDLE, vars.borderSizes[i]);
}
HyprlandAPI::reloadConfig();

View file

@ -15,11 +15,11 @@ std::vector<UP<IPassElement>> CBarPassElement::draw() {
}
bool CBarPassElement::needsLiveBlur() {
static auto* const PENABLEBLURGLOBAL = (Hyprlang::INT* const*)HyprlandAPI::getConfigValue(PHANDLE, "decoration:blur:enabled")->getDataStaticPtr();
static auto PENABLEBLURGLOBAL = CConfigValue<Config::BOOL>("decoration:blur:enabled");
CHyprColor color = data.deco->m_bForcedBarColor.value_or(CHyprColor{static_cast<uint64_t>(g_pGlobalState->config.barColor->value())});
CHyprColor color = data.deco->m_bForcedBarColor.value_or(CHyprColor{static_cast<uint64_t>(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;
}

View file

@ -9,6 +9,7 @@
#include <hyprland/src/render/Renderer.hpp>
#include <hyprland/src/config/ConfigManager.hpp>
#include <hyprland/src/config/shared/animation/AnimationTree.hpp>
#include <hyprland/src/config/shared/parserUtils/ParserUtils.hpp>
#include <hyprland/src/config/supplementary/executor/Executor.hpp>
#include <hyprland/src/config/shared/actions/ConfigActions.hpp>
#include <hyprland/src/managers/animation/AnimationManager.hpp>
@ -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<Config::BOOL>("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);

View file

@ -6,6 +6,7 @@
#include <hyprland/src/Compositor.hpp>
#include <hyprland/src/desktop/view/Window.hpp>
#include <hyprland/src/config/ConfigManager.hpp>
#include <hyprland/src/config/shared/parserUtils/ParserUtils.hpp>
#include <hyprland/src/render/Renderer.hpp>
#include <hyprland/src/event/EventBus.hpp>
#include <hyprland/src/desktop/rule/windowRule/WindowRuleEffectContainer.hpp>
@ -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<Config::Values::CColorValue>("plugin:hyprbars:bar_color", "Change the bar color", *configStringToInt("rgba(33333388)"));
g_pGlobalState->config.textColor = makeShared<Config::Values::CColorValue>("plugin:hyprbars:col.text", "Change the text color", *configStringToInt("rgba(ffffffff)"));
g_pGlobalState->config.barColor = makeShared<Config::Values::CColorValue>("plugin:hyprbars:bar_color", "Change the bar color", 0x88333333);
g_pGlobalState->config.textColor = makeShared<Config::Values::CColorValue>("plugin:hyprbars:col.text", "Change the text color", 0xffffffff);
g_pGlobalState->config.inactiveButtonColor = makeShared<Config::Values::CColorValue>(
"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<Config::Values::CIntValue>("plugin:hyprbars:bar_height", "Change the bar's height", 15);
g_pGlobalState->config.barTextSize = makeShared<Config::Values::CIntValue>("plugin:hyprbars:bar_text_size", "Change the bar's text size", 10);
g_pGlobalState->config.barTitleEnabled = makeShared<Config::Values::CBoolValue>("plugin:hyprbars:bar_title_enabled", "Whether to enable titles in the bar", true);

View file

@ -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<CBaseAnimatedVariable> pav) {
window->alpha(Desktop::View::WINDOW_ALPHA_ACTIVE)->setCallbackOnEnd([w = PHLWINDOWREF{window}, POUT, ORIGINAL](WP<CBaseAnimatedVariable> 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);
}
}