summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorvaxerski <43317083+vaxerski@users.noreply.github.com>2022-04-24 12:04:16 +0200
committervaxerski <43317083+vaxerski@users.noreply.github.com>2022-04-24 12:04:16 +0200
commit3b3718df3d8e8f729980408ac86dffb041a0fcff (patch)
tree587315bb554ee28a6f7097c93f99f19c053a3f79 /src
parentf04829a4b5aeb8f88aaf25ce7f9b9539b0d91f65 (diff)
some fixes for full damage tracking
Diffstat (limited to 'src')
-rw-r--r--src/events/Layers.cpp25
-rw-r--r--src/render/Renderer.cpp23
2 files changed, 39 insertions, 9 deletions
diff --git a/src/events/Layers.cpp b/src/events/Layers.cpp
index 2b55ece2..8b4e54fb 100644
--- a/src/events/Layers.cpp
+++ b/src/events/Layers.cpp
@@ -80,6 +80,10 @@ void Events::listener_destroyLayerSurface(void* owner, void* data) {
if (PMONITOR) {
g_pHyprRenderer->arrangeLayersForMonitor(PMONITOR->ID);
g_pLayoutManager->getCurrentLayout()->recalculateMonitor(PMONITOR->ID);
+
+ // and damage
+ wlr_box geomFixed = {layersurface->geometry.x + PMONITOR->vecPosition.x, layersurface->geometry.y + PMONITOR->vecPosition.y, layersurface->geometry.width, layersurface->geometry.height};
+ g_pHyprRenderer->damageBox(&geomFixed);
}
}
@@ -95,6 +99,9 @@ void Events::listener_mapLayerSurface(void* owner, void* data) {
// fix if it changed its mon
const auto PMONITOR = g_pCompositor->getMonitorFromOutput(layersurface->layerSurface->output);
+ if (!PMONITOR)
+ return;
+
if ((uint64_t)layersurface->monitorID != PMONITOR->ID) {
const auto POLDMON = g_pCompositor->getMonitorFromID(layersurface->monitorID);
POLDMON->m_aLayerSurfaceLists[layersurface->layer].remove(layersurface);
@@ -110,6 +117,9 @@ void Events::listener_mapLayerSurface(void* owner, void* data) {
g_pCompositor->focusSurface(layersurface->layerSurface->surface);
layersurface->position = Vector2D(layersurface->geometry.x, layersurface->geometry.y);
+
+ wlr_box geomFixed = {layersurface->geometry.x + PMONITOR->vecPosition.x, layersurface->geometry.y + PMONITOR->vecPosition.y, layersurface->geometry.width, layersurface->geometry.height};
+ g_pHyprRenderer->damageBox(&geomFixed);
}
void Events::listener_unmapLayerSurface(void* owner, void* data) {
@@ -122,6 +132,14 @@ void Events::listener_unmapLayerSurface(void* owner, void* data) {
if (layersurface->layerSurface->surface == g_pCompositor->m_pLastFocus)
g_pCompositor->m_pLastFocus = nullptr;
+
+ const auto PMONITOR = g_pCompositor->getMonitorFromOutput(layersurface->layerSurface->output);
+
+ if (!PMONITOR)
+ return;
+
+ wlr_box geomFixed = {layersurface->geometry.x + PMONITOR->vecPosition.x, layersurface->geometry.y + PMONITOR->vecPosition.y, layersurface->geometry.width, layersurface->geometry.height};
+ g_pHyprRenderer->damageBox(&geomFixed);
}
void Events::listener_commitLayerSurface(void* owner, void* data) {
@@ -135,6 +153,9 @@ void Events::listener_commitLayerSurface(void* owner, void* data) {
if (!PMONITOR)
return;
+ wlr_box geomFixed = {layersurface->geometry.x + PMONITOR->vecPosition.x, layersurface->geometry.y + PMONITOR->vecPosition.y, layersurface->geometry.width, layersurface->geometry.height};
+ g_pHyprRenderer->damageBox(&geomFixed);
+
// fix if it changed its mon
if ((uint64_t)layersurface->monitorID != PMONITOR->ID) {
const auto POLDMON = g_pCompositor->getMonitorFromID(layersurface->monitorID);
@@ -159,5 +180,7 @@ void Events::listener_commitLayerSurface(void* owner, void* data) {
layersurface->position = Vector2D(layersurface->geometry.x, layersurface->geometry.y);
- g_pHyprRenderer->damageBox(&layersurface->geometry);
+ // i know i could reuse the last geomFixed box, but this way my stupid linter doesn't give me errors, and for some reason if i do = {...} it does, even though it compiles
+ wlr_box geomFixedAfter = {layersurface->geometry.x + PMONITOR->vecPosition.x, layersurface->geometry.y + PMONITOR->vecPosition.y, layersurface->geometry.width, layersurface->geometry.height};
+ g_pHyprRenderer->damageBox(&geomFixedAfter);
} \ No newline at end of file
diff --git a/src/render/Renderer.cpp b/src/render/Renderer.cpp
index 0d50dae4..2c685f98 100644
--- a/src/render/Renderer.cpp
+++ b/src/render/Renderer.cpp
@@ -444,21 +444,27 @@ void CHyprRenderer::damageSurface(wlr_surface* pSurface, double x, double y) {
}
void CHyprRenderer::damageWindow(CWindow* pWindow) {
- const auto PMONITOR = g_pCompositor->getMonitorFromID(pWindow->m_iMonitorID);
-
if (!pWindow->m_bIsFloating) {
// damage by size & pos
// TODO TEMP: revise when added shadows/etc
- wlr_box damageBox = {pWindow->m_vPosition.x - PMONITOR->vecPosition.x, pWindow->m_vPosition.y - PMONITOR->vecPosition.y, pWindow->m_vSize.x, pWindow->m_vSize.y};
- for (auto& m : g_pCompositor->m_lMonitors)
- wlr_output_damage_add_box(m.damage, &damageBox);
+ wlr_box damageBox = {pWindow->m_vRealPosition.vec().x, pWindow->m_vRealPosition.vec().y, pWindow->m_vRealSize.vec().x, pWindow->m_vRealSize.vec().y};
+ for (auto& m : g_pCompositor->m_lMonitors) {
+ wlr_box fixedDamageBox = damageBox;
+ fixedDamageBox.x -= m.vecPosition.x;
+ fixedDamageBox.y -= m.vecPosition.y;
+ wlr_output_damage_add_box(m.damage, &fixedDamageBox);
+ }
} else {
// damage by real size & pos + border size * 2 (JIC)
const auto BORDERSIZE = g_pConfigManager->getInt("general:border_size");
wlr_box damageBox = { pWindow->m_vRealPosition.vec().x - BORDERSIZE - 1, pWindow->m_vRealPosition.vec().y - BORDERSIZE - 1, pWindow->m_vRealSize.vec().x + 2 * BORDERSIZE + 2, pWindow->m_vRealSize.vec().y + 2 * BORDERSIZE + 2};
- for (auto& m : g_pCompositor->m_lMonitors)
- wlr_output_damage_add_box(m.damage, &damageBox);
+ for (auto& m : g_pCompositor->m_lMonitors) {
+ wlr_box fixedDamageBox = damageBox;
+ fixedDamageBox.x -= m.vecPosition.x;
+ fixedDamageBox.y -= m.vecPosition.y;
+ wlr_output_damage_add_box(m.damage, &fixedDamageBox);
+ }
}
}
@@ -470,7 +476,8 @@ void CHyprRenderer::damageMonitor(SMonitor* pMonitor) {
void CHyprRenderer::damageBox(wlr_box* pBox) {
for (auto& m : g_pCompositor->m_lMonitors) {
- wlr_output_damage_add_box(m.damage, pBox);
+ wlr_box damageBox = {pBox->x - m.vecPosition.x, pBox->y - m.vecPosition.y, pBox->width, pBox->height};
+ wlr_output_damage_add_box(m.damage, &damageBox);
}
}