mirror of
https://github.com/hyprwm/hyprland-plugins.git
synced 2024-11-25 03:35:59 +01:00
hyprbars: update for hyprland@#3739
This commit is contained in:
parent
874deb2980
commit
69287a4dec
2 changed files with 23 additions and 21 deletions
|
@ -31,10 +31,6 @@ CHyprBar::~CHyprBar() {
|
|||
std::erase(g_pGlobalState->bars, this);
|
||||
}
|
||||
|
||||
bool CHyprBar::allowsInput() {
|
||||
return true;
|
||||
}
|
||||
|
||||
SWindowDecorationExtents CHyprBar::getWindowDecorationExtents() {
|
||||
return m_seExtents;
|
||||
}
|
||||
|
@ -303,7 +299,7 @@ void CHyprBar::renderBarButtons(const Vector2D& bufferSize, const float scale) {
|
|||
cairo_surface_destroy(CAIROSURFACE);
|
||||
}
|
||||
|
||||
void CHyprBar::renderBarButtonsText(wlr_box* barBox, const float scale) {
|
||||
void CHyprBar::renderBarButtonsText(wlr_box* barBox, const float scale, const float a) {
|
||||
const auto scaledButtonsPad = BUTTONS_PAD * scale;
|
||||
int offset = scaledButtonsPad;
|
||||
|
||||
|
@ -324,7 +320,7 @@ void CHyprBar::renderBarButtonsText(wlr_box* barBox, const float scale) {
|
|||
|
||||
wlr_box pos = {barBox->x + barBox->width - offset - scaledButtonSize * 1.5, barBox->y + (barBox->height - scaledButtonSize) / 2.0, scaledButtonSize, scaledButtonSize};
|
||||
|
||||
g_pHyprOpenGL->renderTexture(button.iconTex, &pos, 1);
|
||||
g_pHyprOpenGL->renderTexture(button.iconTex, &pos, a);
|
||||
|
||||
offset += scaledButtonsPad + scaledButtonSize;
|
||||
};
|
||||
|
@ -341,7 +337,6 @@ void CHyprBar::draw(CMonitor* pMonitor, float a, const Vector2D& offset) {
|
|||
if (!m_pWindow->m_sSpecialRenderData.decorate)
|
||||
return;
|
||||
|
||||
static auto* const PROUNDING = &HyprlandAPI::getConfigValue(PHANDLE, "decoration:rounding")->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;
|
||||
|
||||
|
@ -351,23 +346,20 @@ void CHyprBar::draw(CMonitor* pMonitor, float a, const Vector2D& offset) {
|
|||
}
|
||||
|
||||
const auto BORDERSIZE = m_pWindow->getRealBorderSize();
|
||||
const auto ROUNDING = m_pWindow->rounding() + m_pWindow->getRealBorderSize();
|
||||
|
||||
const auto scaledRounding = *PROUNDING * pMonitor->scale;
|
||||
const auto scaledRounding = ROUNDING * pMonitor->scale;
|
||||
const auto scaledBorderSize = BORDERSIZE * pMonitor->scale;
|
||||
|
||||
CColor color = *PCOLOR;
|
||||
color.a *= a;
|
||||
|
||||
const auto ROUNDING = !m_pWindow->m_sSpecialRenderData.rounding ?
|
||||
0 :
|
||||
(m_pWindow->m_sAdditionalConfigData.rounding.toUnderlying() == -1 ? *PROUNDING : m_pWindow->m_sAdditionalConfigData.rounding.toUnderlying());
|
||||
|
||||
m_seExtents = {{0, *PHEIGHT + 1}, {}};
|
||||
m_seExtents = {{0, *PHEIGHT}, {}};
|
||||
|
||||
const auto BARBUF = Vector2D{(int)m_vLastWindowSize.x + 2 * BORDERSIZE, *PHEIGHT} * pMonitor->scale;
|
||||
|
||||
wlr_box titleBarBox = {(int)m_vLastWindowPos.x - BORDERSIZE - pMonitor->vecPosition.x, (int)m_vLastWindowPos.y - BORDERSIZE - *PHEIGHT - pMonitor->vecPosition.y,
|
||||
(int)m_vLastWindowSize.x + 2 * BORDERSIZE, *PHEIGHT + *PROUNDING * 3 /* to fill the bottom cuz we can't disable rounding there */};
|
||||
(int)m_vLastWindowSize.x + 2 * BORDERSIZE, *PHEIGHT + ROUNDING * 3 /* to fill the bottom cuz we can't disable rounding there */};
|
||||
|
||||
titleBarBox.x += offset.x;
|
||||
titleBarBox.y += offset.y;
|
||||
|
@ -376,7 +368,7 @@ void CHyprBar::draw(CMonitor* pMonitor, float a, const Vector2D& offset) {
|
|||
|
||||
g_pHyprOpenGL->scissor(&titleBarBox);
|
||||
|
||||
if (*PROUNDING) {
|
||||
if (ROUNDING) {
|
||||
glClearStencil(0);
|
||||
glClear(GL_STENCIL_BUFFER_BIT);
|
||||
|
||||
|
@ -404,7 +396,7 @@ void CHyprBar::draw(CMonitor* pMonitor, float a, const Vector2D& offset) {
|
|||
renderBarTitle(BARBUF, pMonitor->scale);
|
||||
}
|
||||
|
||||
if (*PROUNDING) {
|
||||
if (ROUNDING) {
|
||||
// cleanup stencil
|
||||
glClearStencil(0);
|
||||
glClear(GL_STENCIL_BUFFER_BIT);
|
||||
|
@ -425,7 +417,7 @@ void CHyprBar::draw(CMonitor* pMonitor, float a, const Vector2D& offset) {
|
|||
|
||||
g_pHyprOpenGL->scissor((wlr_box*)nullptr);
|
||||
|
||||
renderBarButtonsText(&textBox, pMonitor->scale);
|
||||
renderBarButtonsText(&textBox, pMonitor->scale, a);
|
||||
|
||||
m_bWindowSizeChanged = false;
|
||||
|
||||
|
@ -470,3 +462,11 @@ Vector2D CHyprBar::cursorRelativeToBar() {
|
|||
static auto* const PBORDER = &HyprlandAPI::getConfigValue(PHANDLE, "general:border_size")->intValue;
|
||||
return g_pInputManager->getMouseCoordsInternal() - m_pWindow->m_vRealPosition.vec() + Vector2D{*PBORDER, *PHEIGHT + *PBORDER};
|
||||
}
|
||||
|
||||
eDecorationLayer CHyprBar::getDecorationLayer() {
|
||||
return DECORATION_LAYER_UNDER;
|
||||
}
|
||||
|
||||
uint64_t CHyprBar::getDecorationFlags() {
|
||||
return DECORATION_ALLOWS_MOUSE_INPUT | DECORATION_PART_OF_MAIN_WINDOW;
|
||||
}
|
|
@ -23,7 +23,9 @@ class CHyprBar : public IHyprWindowDecoration {
|
|||
|
||||
virtual SWindowDecorationExtents getWindowDecorationReservedArea();
|
||||
|
||||
virtual bool allowsInput();
|
||||
virtual eDecorationLayer getDecorationLayer();
|
||||
|
||||
virtual uint64_t getDecorationFlags();
|
||||
|
||||
bool m_bButtonsDirty = true;
|
||||
|
||||
|
@ -45,7 +47,7 @@ class CHyprBar : public IHyprWindowDecoration {
|
|||
void renderBarTitle(const Vector2D& bufferSize, const float scale);
|
||||
void renderText(CTexture& out, const std::string& text, const CColor& color, const Vector2D& bufferSize, const float scale, const int fontSize);
|
||||
void renderBarButtons(const Vector2D& bufferSize, const float scale);
|
||||
void renderBarButtonsText(wlr_box* barBox, const float scale);
|
||||
void renderBarButtonsText(wlr_box* barBox, const float scale, const float a);
|
||||
void onMouseDown(SCallbackInfo& info, wlr_pointer_button_event* e);
|
||||
void onMouseMove(Vector2D coords);
|
||||
|
||||
|
|
Loading…
Reference in a new issue