1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
|
#include "CHyprBorderDecoration.hpp"
#include "../../Compositor.hpp"
#include "../../config/ConfigValue.hpp"
#include "../../managers/eventLoop/EventLoopManager.hpp"
CHyprBorderDecoration::CHyprBorderDecoration(PHLWINDOW pWindow) : IHyprWindowDecoration(pWindow) {
m_pWindow = pWindow;
}
CHyprBorderDecoration::~CHyprBorderDecoration() {
;
}
SDecorationPositioningInfo CHyprBorderDecoration::getPositioningInfo() {
const auto BORDERSIZE = m_pWindow->getRealBorderSize();
m_seExtents = {{BORDERSIZE, BORDERSIZE}, {BORDERSIZE, BORDERSIZE}};
if (doesntWantBorders())
m_seExtents = {{}, {}};
SDecorationPositioningInfo info;
info.priority = 10000;
info.policy = DECORATION_POSITION_STICKY;
info.desiredExtents = m_seExtents;
info.reserved = true;
info.edges = DECORATION_EDGE_BOTTOM | DECORATION_EDGE_LEFT | DECORATION_EDGE_RIGHT | DECORATION_EDGE_TOP;
m_seReportedExtents = m_seExtents;
return info;
}
void CHyprBorderDecoration::onPositioningReply(const SDecorationPositioningReply& reply) {
m_bAssignedGeometry = reply.assignedGeometry;
}
CBox CHyprBorderDecoration::assignedBoxGlobal() {
CBox box = m_bAssignedGeometry;
box.translate(g_pDecorationPositioner->getEdgeDefinedPoint(DECORATION_EDGE_BOTTOM | DECORATION_EDGE_LEFT | DECORATION_EDGE_RIGHT | DECORATION_EDGE_TOP, m_pWindow.lock()));
const auto PWORKSPACE = m_pWindow->m_pWorkspace;
if (!PWORKSPACE)
return box;
const auto WORKSPACEOFFSET = PWORKSPACE && !m_pWindow->m_bPinned ? PWORKSPACE->m_vRenderOffset.value() : Vector2D();
return box.translate(WORKSPACEOFFSET);
}
void CHyprBorderDecoration::draw(PHLMONITOR pMonitor, float const& a) {
if (doesntWantBorders())
return;
if (m_bAssignedGeometry.width < m_seExtents.topLeft.x + 1 || m_bAssignedGeometry.height < m_seExtents.topLeft.y + 1)
return;
CBox windowBox = assignedBoxGlobal().translate(-pMonitor->vecPosition + m_pWindow->m_vFloatingOffset).expand(-m_pWindow->getRealBorderSize()).scale(pMonitor->scale).round();
if (windowBox.width < 1 || windowBox.height < 1)
return;
auto grad = m_pWindow->m_cRealBorderColor;
const bool ANIMATED = m_pWindow->m_fBorderFadeAnimationProgress.isBeingAnimated();
if (m_pWindow->m_fBorderAngleAnimationProgress.getConfig()->pValues->internalEnabled) {
grad.m_fAngle += m_pWindow->m_fBorderAngleAnimationProgress.value() * M_PI * 2;
grad.m_fAngle = normalizeAngleRad(grad.m_fAngle);
}
int borderSize = m_pWindow->getRealBorderSize();
const auto ROUNDING = m_pWindow->rounding() * pMonitor->scale;
if (ANIMATED)
g_pHyprOpenGL->renderBorder(&windowBox, m_pWindow->m_cRealBorderColorPrevious, grad, m_pWindow->m_fBorderFadeAnimationProgress.value(), ROUNDING, borderSize, a);
else
g_pHyprOpenGL->renderBorder(&windowBox, grad, ROUNDING, borderSize, a);
}
eDecorationType CHyprBorderDecoration::getDecorationType() {
return DECORATION_BORDER;
}
void CHyprBorderDecoration::updateWindow(PHLWINDOW) {
auto borderSize = m_pWindow->getRealBorderSize();
if (borderSize == m_iLastBorderSize)
return;
if (borderSize <= 0 && m_iLastBorderSize <= 0)
return;
m_iLastBorderSize = borderSize;
g_pDecorationPositioner->repositionDeco(this);
}
void CHyprBorderDecoration::damageEntire() {
if (!validMapped(m_pWindow))
return;
auto surfaceBox = m_pWindow->getWindowMainSurfaceBox();
const auto ROUNDING = m_pWindow->rounding();
const auto ROUNDINGSIZE = ROUNDING - M_SQRT1_2 * ROUNDING + 2;
const auto BORDERSIZE = m_pWindow->getRealBorderSize() + 1;
const auto PWINDOWWORKSPACE = m_pWindow->m_pWorkspace;
if (PWINDOWWORKSPACE && PWINDOWWORKSPACE->m_vRenderOffset.isBeingAnimated() && !m_pWindow->m_bPinned)
surfaceBox.translate(PWINDOWWORKSPACE->m_vRenderOffset.value());
surfaceBox.translate(m_pWindow->m_vFloatingOffset);
CBox surfaceBoxExpandedBorder = surfaceBox;
surfaceBoxExpandedBorder.expand(BORDERSIZE);
CBox surfaceBoxShrunkRounding = surfaceBox;
surfaceBoxShrunkRounding.expand(-ROUNDINGSIZE);
CRegion borderRegion(surfaceBoxExpandedBorder);
borderRegion.subtract(surfaceBoxShrunkRounding);
for (auto const& m : g_pCompositor->m_vMonitors) {
if (!g_pHyprRenderer->shouldRenderWindow(m_pWindow.lock(), m)) {
const CRegion monitorRegion({m->vecPosition, m->vecSize});
borderRegion.subtract(monitorRegion);
}
}
g_pHyprRenderer->damageRegion(borderRegion);
}
eDecorationLayer CHyprBorderDecoration::getDecorationLayer() {
return DECORATION_LAYER_OVER;
}
uint64_t CHyprBorderDecoration::getDecorationFlags() {
static auto PPARTOFWINDOW = CConfigValue<Hyprlang::INT>("general:border_part_of_window");
return *PPARTOFWINDOW && !doesntWantBorders() ? DECORATION_PART_OF_MAIN_WINDOW : 0;
}
std::string CHyprBorderDecoration::getDisplayName() {
return "Border";
}
bool CHyprBorderDecoration::doesntWantBorders() {
return m_pWindow->m_sWindowData.noBorder.valueOrDefault() || m_pWindow->m_bX11DoesntWantBorders || m_pWindow->getRealBorderSize() == 0;
}
|