mirror of
https://github.com/hyprwm/hyprland-plugins.git
synced 2024-11-22 02:35:57 +01:00
hyprbars: fix for hyprland@#3755
This commit is contained in:
parent
9b1adb6043
commit
15cee0bec0
2 changed files with 14 additions and 18 deletions
|
@ -299,7 +299,7 @@ void CHyprBar::renderBarButtons(const Vector2D& bufferSize, const float scale) {
|
||||||
cairo_surface_destroy(CAIROSURFACE);
|
cairo_surface_destroy(CAIROSURFACE);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CHyprBar::renderBarButtonsText(wlr_box* barBox, const float scale, const float a) {
|
void CHyprBar::renderBarButtonsText(CBox* barBox, const float scale, const float a) {
|
||||||
const auto scaledButtonsPad = BUTTONS_PAD * scale;
|
const auto scaledButtonsPad = BUTTONS_PAD * scale;
|
||||||
int offset = scaledButtonsPad;
|
int offset = scaledButtonsPad;
|
||||||
|
|
||||||
|
@ -318,7 +318,7 @@ void CHyprBar::renderBarButtonsText(wlr_box* barBox, const float scale, const fl
|
||||||
if (button.iconTex.m_iTexID == 0)
|
if (button.iconTex.m_iTexID == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
wlr_box pos = {barBox->x + barBox->width - offset - scaledButtonSize * 1.5, barBox->y + (barBox->height - scaledButtonSize) / 2.0, scaledButtonSize, scaledButtonSize};
|
CBox pos = {barBox->x + barBox->width - offset - scaledButtonSize * 1.5, barBox->y + (barBox->height - scaledButtonSize) / 2.0, scaledButtonSize, scaledButtonSize};
|
||||||
|
|
||||||
g_pHyprOpenGL->renderTexture(button.iconTex, &pos, a);
|
g_pHyprOpenGL->renderTexture(button.iconTex, &pos, a);
|
||||||
|
|
||||||
|
@ -356,15 +356,12 @@ void CHyprBar::draw(CMonitor* pMonitor, float a, const Vector2D& offset) {
|
||||||
|
|
||||||
m_seExtents = {{0, *PHEIGHT}, {}};
|
m_seExtents = {{0, *PHEIGHT}, {}};
|
||||||
|
|
||||||
const auto BARBUF = Vector2D{(int)m_vLastWindowSize.x + 2 * BORDERSIZE, *PHEIGHT} * pMonitor->scale;
|
const auto BARBUF = Vector2D{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,
|
CBox titleBarBox = {m_vLastWindowPos.x - BORDERSIZE - pMonitor->vecPosition.x, m_vLastWindowPos.y - BORDERSIZE - *PHEIGHT - pMonitor->vecPosition.y,
|
||||||
(int)m_vLastWindowSize.x + 2 * BORDERSIZE, *PHEIGHT + ROUNDING * 3 /* to fill the bottom cuz we can't disable rounding there */};
|
m_vLastWindowSize.x + 2 * BORDERSIZE, *PHEIGHT + ROUNDING * 3 /* to fill the bottom cuz we can't disable rounding there */};
|
||||||
|
|
||||||
titleBarBox.x += offset.x;
|
titleBarBox.translate(offset).scale(pMonitor->scale).round();
|
||||||
titleBarBox.y += offset.y;
|
|
||||||
|
|
||||||
scaleBox(&titleBarBox, pMonitor->scale);
|
|
||||||
|
|
||||||
g_pHyprOpenGL->scissor(&titleBarBox);
|
g_pHyprOpenGL->scissor(&titleBarBox);
|
||||||
|
|
||||||
|
@ -379,10 +376,9 @@ void CHyprBar::draw(CMonitor* pMonitor, float a, const Vector2D& offset) {
|
||||||
|
|
||||||
glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
|
glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
|
||||||
// the +1 is a shit garbage temp fix until renderRect supports an alpha matte
|
// the +1 is a shit garbage temp fix until renderRect supports an alpha matte
|
||||||
wlr_box windowBox = {(int)m_vLastWindowPos.x + offset.x - pMonitor->vecPosition.x - BORDERSIZE + 1,
|
CBox windowBox = {m_vLastWindowPos.x + offset.x - pMonitor->vecPosition.x - BORDERSIZE + 1, m_vLastWindowPos.y + offset.y - pMonitor->vecPosition.y - BORDERSIZE + 1,
|
||||||
(int)m_vLastWindowPos.y + offset.y - pMonitor->vecPosition.y - BORDERSIZE + 1, (int)m_vLastWindowSize.x + 2 * BORDERSIZE - 2,
|
m_vLastWindowSize.x + 2 * BORDERSIZE - 2, m_vLastWindowSize.y + 2 * BORDERSIZE - 2};
|
||||||
(int)m_vLastWindowSize.y + 2 * BORDERSIZE - 2};
|
windowBox.scale(pMonitor->scale).round();
|
||||||
scaleBox(&windowBox, pMonitor->scale);
|
|
||||||
g_pHyprOpenGL->renderRect(&windowBox, CColor(0, 0, 0, 0), scaledRounding);
|
g_pHyprOpenGL->renderRect(&windowBox, CColor(0, 0, 0, 0), scaledRounding);
|
||||||
glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
|
glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
|
||||||
|
|
||||||
|
@ -407,7 +403,7 @@ void CHyprBar::draw(CMonitor* pMonitor, float a, const Vector2D& offset) {
|
||||||
glStencilFunc(GL_ALWAYS, 1, 0xFF);
|
glStencilFunc(GL_ALWAYS, 1, 0xFF);
|
||||||
}
|
}
|
||||||
|
|
||||||
wlr_box textBox = {titleBarBox.x, titleBarBox.y, (int)BARBUF.x, (int)BARBUF.y};
|
CBox textBox = {titleBarBox.x, titleBarBox.y, (int)BARBUF.x, (int)BARBUF.y};
|
||||||
g_pHyprOpenGL->renderTexture(m_tTextTex, &textBox, a);
|
g_pHyprOpenGL->renderTexture(m_tTextTex, &textBox, a);
|
||||||
|
|
||||||
if (m_bButtonsDirty || m_bWindowSizeChanged) {
|
if (m_bButtonsDirty || m_bWindowSizeChanged) {
|
||||||
|
@ -417,7 +413,7 @@ void CHyprBar::draw(CMonitor* pMonitor, float a, const Vector2D& offset) {
|
||||||
|
|
||||||
g_pHyprOpenGL->renderTexture(m_tButtonsTex, &textBox, a);
|
g_pHyprOpenGL->renderTexture(m_tButtonsTex, &textBox, a);
|
||||||
|
|
||||||
g_pHyprOpenGL->scissor((wlr_box*)nullptr);
|
g_pHyprOpenGL->scissor((CBox*)nullptr);
|
||||||
|
|
||||||
renderBarButtonsText(&textBox, pMonitor->scale, a);
|
renderBarButtonsText(&textBox, pMonitor->scale, a);
|
||||||
|
|
||||||
|
@ -449,8 +445,8 @@ void CHyprBar::updateWindow(CWindow* pWindow) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void CHyprBar::damageEntire() {
|
void CHyprBar::damageEntire() {
|
||||||
wlr_box dm = {(int)(m_vLastWindowPos.x - m_seExtents.topLeft.x - 2), (int)(m_vLastWindowPos.y - m_seExtents.topLeft.y - 2),
|
CBox dm = {(int)(m_vLastWindowPos.x - m_seExtents.topLeft.x - 2), (int)(m_vLastWindowPos.y - m_seExtents.topLeft.y - 2),
|
||||||
(int)(m_vLastWindowSize.x + m_seExtents.topLeft.x + m_seExtents.bottomRight.x + 4), (int)m_seExtents.topLeft.y + 4};
|
(int)(m_vLastWindowSize.x + m_seExtents.topLeft.x + m_seExtents.bottomRight.x + 4), (int)m_seExtents.topLeft.y + 4};
|
||||||
g_pHyprRenderer->damageBox(&dm);
|
g_pHyprRenderer->damageBox(&dm);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -47,7 +47,7 @@ class CHyprBar : public IHyprWindowDecoration {
|
||||||
void renderBarTitle(const Vector2D& bufferSize, const float scale);
|
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 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 renderBarButtons(const Vector2D& bufferSize, const float scale);
|
||||||
void renderBarButtonsText(wlr_box* barBox, const float scale, const float a);
|
void renderBarButtonsText(CBox* barBox, const float scale, const float a);
|
||||||
void onMouseDown(SCallbackInfo& info, wlr_pointer_button_event* e);
|
void onMouseDown(SCallbackInfo& info, wlr_pointer_button_event* e);
|
||||||
void onMouseMove(Vector2D coords);
|
void onMouseMove(Vector2D coords);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue