mirror of
https://github.com/hyprwm/hyprland-plugins.git
synced 2024-11-22 10:35:58 +01:00
add offset to bordersplusplus
This commit is contained in:
parent
b053a9e627
commit
11a7ad55b7
1 changed files with 28 additions and 35 deletions
|
@ -1,28 +1,24 @@
|
||||||
#include "borderDeco.hpp"
|
#include "borderDeco.hpp"
|
||||||
#include "globals.hpp"
|
|
||||||
#include <src/Compositor.hpp>
|
#include <src/Compositor.hpp>
|
||||||
#include <src/Window.hpp>
|
#include <src/Window.hpp>
|
||||||
|
|
||||||
|
#include "globals.hpp"
|
||||||
|
|
||||||
CBordersPlusPlus::CBordersPlusPlus(CWindow* pWindow) {
|
CBordersPlusPlus::CBordersPlusPlus(CWindow* pWindow) {
|
||||||
m_pWindow = pWindow;
|
m_pWindow = pWindow;
|
||||||
m_vLastWindowPos = pWindow->m_vRealPosition.vec();
|
m_vLastWindowPos = pWindow->m_vRealPosition.vec();
|
||||||
m_vLastWindowSize = pWindow->m_vRealSize.vec();
|
m_vLastWindowSize = pWindow->m_vRealSize.vec();
|
||||||
}
|
}
|
||||||
|
|
||||||
CBordersPlusPlus::~CBordersPlusPlus() {
|
CBordersPlusPlus::~CBordersPlusPlus() { damageEntire(); }
|
||||||
damageEntire();
|
|
||||||
}
|
|
||||||
|
|
||||||
SWindowDecorationExtents CBordersPlusPlus::getWindowDecorationExtents() {
|
SWindowDecorationExtents CBordersPlusPlus::getWindowDecorationExtents() { return m_seExtents; }
|
||||||
return m_seExtents;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CBordersPlusPlus::draw(CMonitor* pMonitor, float a, const Vector2D& offset) {
|
void CBordersPlusPlus::draw(CMonitor* pMonitor, float a, const Vector2D& offset) {
|
||||||
if (!g_pCompositor->windowValidMapped(m_pWindow))
|
if (!g_pCompositor->windowValidMapped(m_pWindow)) return;
|
||||||
return;
|
|
||||||
|
|
||||||
if (!m_pWindow->m_sSpecialRenderData.decorate)
|
if (!m_pWindow->m_sSpecialRenderData.decorate) return;
|
||||||
return;
|
|
||||||
|
|
||||||
static auto* const PCOLOR1 = &HyprlandAPI::getConfigValue(PHANDLE, "plugin:borders-plus-plus:col.border_1")->intValue;
|
static auto* const PCOLOR1 = &HyprlandAPI::getConfigValue(PHANDLE, "plugin:borders-plus-plus:col.border_1")->intValue;
|
||||||
static auto* const PCOLOR2 = &HyprlandAPI::getConfigValue(PHANDLE, "plugin:borders-plus-plus:col.border_2")->intValue;
|
static auto* const PCOLOR2 = &HyprlandAPI::getConfigValue(PHANDLE, "plugin:borders-plus-plus:col.border_2")->intValue;
|
||||||
|
@ -30,15 +26,16 @@ void CBordersPlusPlus::draw(CMonitor* pMonitor, float a, const Vector2D& offset)
|
||||||
static auto* const PROUNDING = &HyprlandAPI::getConfigValue(PHANDLE, "decoration:rounding")->intValue;
|
static auto* const PROUNDING = &HyprlandAPI::getConfigValue(PHANDLE, "decoration:rounding")->intValue;
|
||||||
static auto* const PBORDERSIZE = &HyprlandAPI::getConfigValue(PHANDLE, "general:border_size")->intValue;
|
static auto* const PBORDERSIZE = &HyprlandAPI::getConfigValue(PHANDLE, "general:border_size")->intValue;
|
||||||
|
|
||||||
if (*PBORDERS < 1)
|
if (*PBORDERS < 1) return;
|
||||||
return;
|
|
||||||
|
|
||||||
const auto ROUNDING = !m_pWindow->m_sSpecialRenderData.rounding ?
|
const auto ROUNDING = !m_pWindow->m_sSpecialRenderData.rounding ? 0
|
||||||
0 :
|
: (m_pWindow->m_sAdditionalConfigData.rounding.toUnderlying() == -1
|
||||||
(m_pWindow->m_sAdditionalConfigData.rounding.toUnderlying() == -1 ? *PROUNDING : m_pWindow->m_sAdditionalConfigData.rounding.toUnderlying());
|
? *PROUNDING
|
||||||
|
: m_pWindow->m_sAdditionalConfigData.rounding.toUnderlying());
|
||||||
|
|
||||||
// draw the border
|
// draw the border
|
||||||
wlr_box fullBox = { (int)(m_vLastWindowPos.x - *PBORDERSIZE), (int)(m_vLastWindowPos.y - *PBORDERSIZE), (int)(m_vLastWindowSize.x + 2.0 * *PBORDERSIZE), (int)(m_vLastWindowSize.y + 2.0 * *PBORDERSIZE) };
|
wlr_box fullBox = {(int)(m_vLastWindowPos.x - *PBORDERSIZE + offset.x), (int)(m_vLastWindowPos.y - *PBORDERSIZE + offset.y),
|
||||||
|
(int)(m_vLastWindowSize.x + 2.0 * *PBORDERSIZE), (int)(m_vLastWindowSize.y + 2.0 * *PBORDERSIZE)};
|
||||||
|
|
||||||
fullBox.x -= pMonitor->vecPosition.x;
|
fullBox.x -= pMonitor->vecPosition.x;
|
||||||
fullBox.y -= pMonitor->vecPosition.y;
|
fullBox.y -= pMonitor->vecPosition.y;
|
||||||
|
@ -50,8 +47,7 @@ void CBordersPlusPlus::draw(CMonitor* pMonitor, float a, const Vector2D& offset)
|
||||||
fullBox.x += offset.x;
|
fullBox.x += offset.x;
|
||||||
fullBox.y += offset.y;
|
fullBox.y += offset.y;
|
||||||
|
|
||||||
if (fullBox.width < 1 || fullBox.height < 1)
|
if (fullBox.width < 1 || fullBox.height < 1) return; // don't draw invisible shadows
|
||||||
return; // don't draw invisible shadows
|
|
||||||
|
|
||||||
g_pHyprOpenGL->scissor((wlr_box*)nullptr);
|
g_pHyprOpenGL->scissor((wlr_box*)nullptr);
|
||||||
|
|
||||||
|
@ -60,10 +56,10 @@ void CBordersPlusPlus::draw(CMonitor* pMonitor, float a, const Vector2D& offset)
|
||||||
|
|
||||||
// pass 2
|
// pass 2
|
||||||
|
|
||||||
if (*PBORDERS < 2)
|
if (*PBORDERS < 2) return;
|
||||||
return;
|
|
||||||
|
|
||||||
fullBox = { (int)(m_vLastWindowPos.x - *PBORDERSIZE * 2), (int)(m_vLastWindowPos.y - *PBORDERSIZE * 2), (int)(m_vLastWindowSize.x + 2.0 * *PBORDERSIZE * 2), (int)(m_vLastWindowSize.y + 2.0 * *PBORDERSIZE * 2) };
|
fullBox = {(int)(m_vLastWindowPos.x - *PBORDERSIZE * 2 + offset.x), (int)(m_vLastWindowPos.y - *PBORDERSIZE * 2 + offset.y),
|
||||||
|
(int)(m_vLastWindowSize.x + 2.0 * *PBORDERSIZE * 2), (int)(m_vLastWindowSize.y + 2.0 * *PBORDERSIZE * 2)};
|
||||||
|
|
||||||
scaleBox(&fullBox, pMonitor->scale);
|
scaleBox(&fullBox, pMonitor->scale);
|
||||||
g_pHyprOpenGL->renderBorder(&fullBox, CColor(*PCOLOR1), *PROUNDING * pMonitor->scale + *PBORDERSIZE * 2, a);
|
g_pHyprOpenGL->renderBorder(&fullBox, CColor(*PCOLOR1), *PROUNDING * pMonitor->scale + *PBORDERSIZE * 2, a);
|
||||||
|
@ -78,8 +74,7 @@ void CBordersPlusPlus::draw(CMonitor* pMonitor, float a, const Vector2D& offset)
|
||||||
fullBox.x += offset.x;
|
fullBox.x += offset.x;
|
||||||
fullBox.y += offset.y;
|
fullBox.y += offset.y;
|
||||||
|
|
||||||
if (fullBox.width < 1 || fullBox.height < 1)
|
if (fullBox.width < 1 || fullBox.height < 1) return; // don't draw invisible shadows
|
||||||
return; // don't draw invisible shadows
|
|
||||||
|
|
||||||
g_pHyprOpenGL->scissor((wlr_box*)nullptr);
|
g_pHyprOpenGL->scissor((wlr_box*)nullptr);
|
||||||
|
|
||||||
|
@ -87,12 +82,9 @@ void CBordersPlusPlus::draw(CMonitor* pMonitor, float a, const Vector2D& offset)
|
||||||
g_pHyprOpenGL->renderBorder(&fullBox, CColor(*PCOLOR2), *PROUNDING * pMonitor->scale + *PBORDERSIZE * 2, a);
|
g_pHyprOpenGL->renderBorder(&fullBox, CColor(*PCOLOR2), *PROUNDING * pMonitor->scale + *PBORDERSIZE * 2, a);
|
||||||
}
|
}
|
||||||
|
|
||||||
eDecorationType CBordersPlusPlus::getDecorationType() {
|
eDecorationType CBordersPlusPlus::getDecorationType() { return DECORATION_CUSTOM; }
|
||||||
return DECORATION_CUSTOM;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CBordersPlusPlus::updateWindow(CWindow* pWindow) {
|
void CBordersPlusPlus::updateWindow(CWindow* pWindow) {
|
||||||
|
|
||||||
m_vLastWindowPos = pWindow->m_vRealPosition.vec();
|
m_vLastWindowPos = pWindow->m_vRealPosition.vec();
|
||||||
m_vLastWindowSize = pWindow->m_vRealSize.vec();
|
m_vLastWindowSize = pWindow->m_vRealSize.vec();
|
||||||
|
|
||||||
|
@ -100,6 +92,7 @@ void CBordersPlusPlus::updateWindow(CWindow* pWindow) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void CBordersPlusPlus::damageEntire() {
|
void CBordersPlusPlus::damageEntire() {
|
||||||
wlr_box dm = { (int)(m_vLastWindowPos.x - m_seExtents.topLeft.x), (int)(m_vLastWindowPos.y - m_seExtents.topLeft.y), (int)(m_vLastWindowSize.x + m_seExtents.topLeft.x + m_seExtents.bottomRight.x), (int)m_seExtents.topLeft.y };
|
wlr_box dm = {(int)(m_vLastWindowPos.x - m_seExtents.topLeft.x), (int)(m_vLastWindowPos.y - m_seExtents.topLeft.y),
|
||||||
|
(int)(m_vLastWindowSize.x + m_seExtents.topLeft.x + m_seExtents.bottomRight.x), (int)m_seExtents.topLeft.y};
|
||||||
g_pHyprRenderer->damageBox(&dm);
|
g_pHyprRenderer->damageBox(&dm);
|
||||||
}
|
}
|
Loading…
Reference in a new issue