From 445381f87177b90404d597e617915c8bad3c02b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=A0imon=20Brandner?= Date: Sat, 1 Jun 2024 20:02:48 +0200 Subject: [PATCH 1/5] Damage tab bar each tick to avoid defects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This solution is hacky and needs to be improved Signed-off-by: Šimon Brandner --- src/TabGroup.cpp | 8 ++++++++ src/TabGroup.hpp | 1 + 2 files changed, 9 insertions(+) diff --git a/src/TabGroup.cpp b/src/TabGroup.cpp index 86eb679..5da614f 100644 --- a/src/TabGroup.cpp +++ b/src/TabGroup.cpp @@ -271,6 +271,14 @@ void Hy3TabBar::tick() { } if (this->entries.empty()) this->destroy = true; + + damage(); +} + +void Hy3TabBar::damage() { + auto pos = this->entries.front().node.position; + auto box = CBox {pos.x, pos.y, this->size.x, this->size.y}; + g_pHyprRenderer->damageBox(&box); } void Hy3TabBar::updateNodeList(std::list& nodes) { diff --git a/src/TabGroup.hpp b/src/TabGroup.hpp index 12117f3..5640958 100644 --- a/src/TabGroup.hpp +++ b/src/TabGroup.hpp @@ -67,6 +67,7 @@ public: Hy3TabBar(); void beginDestroy(); + void damage(); void tick(); void updateNodeList(std::list& nodes); void updateAnimations(bool warp = false); From 968cadf663a6d5fb514bda8b645e1eb9fbf60e4d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=A0imon=20Brandner?= Date: Tue, 4 Jun 2024 09:24:42 +0200 Subject: [PATCH 2/5] Damage bar when animating workspace slide MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Šimon Brandner --- src/TabGroup.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/TabGroup.cpp b/src/TabGroup.cpp index 5da614f..30ce8a8 100644 --- a/src/TabGroup.cpp +++ b/src/TabGroup.cpp @@ -271,8 +271,6 @@ void Hy3TabBar::tick() { } if (this->entries.empty()) this->destroy = true; - - damage(); } void Hy3TabBar::damage() { @@ -463,6 +461,10 @@ void Hy3TabGroup::tick() { } else { if (this->bar.fade_opacity.goal() != 1.0) this->bar.fade_opacity = 1.0; } + + if (this->workspace->m_vRenderOffset.isBeingAnimated()) { + this->bar.damage(); + } } auto pos = this->pos.value(); From 11fcce578038798da2aa39ca5dfb33fca0f4a22e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=A0imon=20Brandner?= Date: Sun, 9 Jun 2024 17:01:32 +0200 Subject: [PATCH 3/5] Damage the whole node when animating slide MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Šimon Brandner --- src/TabGroup.cpp | 18 +++++++++++------- src/TabGroup.hpp | 4 +++- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/src/TabGroup.cpp b/src/TabGroup.cpp index 30ce8a8..4c4a9d5 100644 --- a/src/TabGroup.cpp +++ b/src/TabGroup.cpp @@ -273,12 +273,6 @@ void Hy3TabBar::tick() { if (this->entries.empty()) this->destroy = true; } -void Hy3TabBar::damage() { - auto pos = this->entries.front().node.position; - auto box = CBox {pos.x, pos.y, this->size.x, this->size.y}; - g_pHyprRenderer->damageBox(&box); -} - void Hy3TabBar::updateNodeList(std::list& nodes) { std::list::iterator> removed_entries; @@ -415,7 +409,17 @@ Hy3TabGroup::Hy3TabGroup(Hy3Node& node) { this->size.warp(); } +void Hy3TabGroup::damage() { + auto pos = this->node->position; + auto size = this->node->size; + auto box = CBox {pos.x, pos.y, size.x, size.y}; + + g_pHyprRenderer->damageBox(&box); +} + void Hy3TabGroup::updateWithGroup(Hy3Node& node, bool warp) { + this->node = &node; + static const auto gaps_in = ConfigValue("general:gaps_in"); static const auto gaps_out = ConfigValue("general:gaps_out"); static const auto bar_height = ConfigValue("plugin:hy3:tabs:height"); @@ -463,7 +467,7 @@ void Hy3TabGroup::tick() { } if (this->workspace->m_vRenderOffset.isBeingAnimated()) { - this->bar.damage(); + this->damage(); } } diff --git a/src/TabGroup.hpp b/src/TabGroup.hpp index 5640958..910b304 100644 --- a/src/TabGroup.hpp +++ b/src/TabGroup.hpp @@ -67,7 +67,6 @@ public: Hy3TabBar(); void beginDestroy(); - void damage(); void tick(); void updateNodeList(std::list& nodes); void updateAnimations(bool warp = false); @@ -106,6 +105,7 @@ private: std::vector stencil_windows; Vector2D last_pos; Vector2D last_size; + Hy3Node* node; Hy3TabGroup(); @@ -114,4 +114,6 @@ private: // UB if node is not a group. void updateStencilWindows(Hy3Node&); + + void damage(); }; From 3bf93f5457cbeb8a4e85d5c0c919f22c212aaeab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=A0imon=20Brandner?= Date: Mon, 10 Jun 2024 10:28:00 +0200 Subject: [PATCH 4/5] Fix visual defects when switching workspaces properly MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Šimon Brandner --- src/TabGroup.cpp | 37 +++++++++++++++++++++++-------------- src/TabGroup.hpp | 3 +-- 2 files changed, 24 insertions(+), 16 deletions(-) diff --git a/src/TabGroup.cpp b/src/TabGroup.cpp index 4c4a9d5..24b9e6a 100644 --- a/src/TabGroup.cpp +++ b/src/TabGroup.cpp @@ -409,14 +409,6 @@ Hy3TabGroup::Hy3TabGroup(Hy3Node& node) { this->size.warp(); } -void Hy3TabGroup::damage() { - auto pos = this->node->position; - auto size = this->node->size; - auto box = CBox {pos.x, pos.y, size.x, size.y}; - - g_pHyprRenderer->damageBox(&box); -} - void Hy3TabGroup::updateWithGroup(Hy3Node& node, bool warp) { this->node = &node; @@ -453,6 +445,11 @@ void Hy3TabGroup::updateWithGroup(Hy3Node& node, bool warp) { } } +void damageBox(const Vector2D* position, const Vector2D* size) { + auto box = CBox {position->x, position->y, size->x, size->y}; + g_pHyprRenderer->damageBox(&box); +} + void Hy3TabGroup::tick() { static const auto enter_from_top = ConfigValue("plugin:hy3:tabs:from_top"); static const auto padding = ConfigValue("plugin:hy3:tabs:padding"); @@ -466,8 +463,22 @@ void Hy3TabGroup::tick() { if (this->bar.fade_opacity.goal() != 1.0) this->bar.fade_opacity = 1.0; } - if (this->workspace->m_vRenderOffset.isBeingAnimated()) { - this->damage(); + auto workspaceOffset = this->workspace->m_vRenderOffset.value(); + if (this->last_workspace_offset != workspaceOffset) { + // First we damage the area where the bar was during the previous + // tick, cleaning up after ourselves + auto pos = this->last_pos + this->last_workspace_offset; + auto size = this->last_size; + damageBox(&pos, &size); + + // Then we damage the current position of the bar, to avoid seeing + // glitches with animations disabled + pos = this->pos.value() + workspaceOffset; + size = this->size.value(); + damageBox(&pos, &size); + + this->bar.damaged = true; + this->last_workspace_offset = workspaceOffset; } } @@ -475,8 +486,7 @@ void Hy3TabGroup::tick() { auto size = this->size.value(); if (this->last_pos != pos || this->last_size != size) { - CBox damage_box = {this->last_pos.x, this->last_pos.y, this->last_size.x, this->last_size.y}; - g_pHyprRenderer->damageBox(&damage_box); + damageBox(&this->last_pos, &this->last_size); this->bar.damaged = true; this->last_pos = pos; @@ -490,8 +500,7 @@ void Hy3TabGroup::tick() { pos.y -= *padding; } - CBox damage_box = {pos.x, pos.y, size.x, size.y}; - g_pHyprRenderer->damageBox(&damage_box); + damageBox(&pos, &size); this->bar.damaged = true; this->bar.dirty = false; diff --git a/src/TabGroup.hpp b/src/TabGroup.hpp index 910b304..26eda2e 100644 --- a/src/TabGroup.hpp +++ b/src/TabGroup.hpp @@ -103,6 +103,7 @@ public: private: std::vector stencil_windows; + Vector2D last_workspace_offset; Vector2D last_pos; Vector2D last_size; Hy3Node* node; @@ -114,6 +115,4 @@ private: // UB if node is not a group. void updateStencilWindows(Hy3Node&); - - void damage(); }; From 0cb9391f2ba34251c4e1012544f0a16e346ec4a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=A0imon=20Brandner?= Date: Mon, 10 Jun 2024 10:29:58 +0200 Subject: [PATCH 5/5] Remove left-over code MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Šimon Brandner --- src/TabGroup.cpp | 2 -- src/TabGroup.hpp | 1 - 2 files changed, 3 deletions(-) diff --git a/src/TabGroup.cpp b/src/TabGroup.cpp index 24b9e6a..02caeff 100644 --- a/src/TabGroup.cpp +++ b/src/TabGroup.cpp @@ -410,8 +410,6 @@ Hy3TabGroup::Hy3TabGroup(Hy3Node& node) { } void Hy3TabGroup::updateWithGroup(Hy3Node& node, bool warp) { - this->node = &node; - static const auto gaps_in = ConfigValue("general:gaps_in"); static const auto gaps_out = ConfigValue("general:gaps_out"); static const auto bar_height = ConfigValue("plugin:hy3:tabs:height"); diff --git a/src/TabGroup.hpp b/src/TabGroup.hpp index 26eda2e..149340d 100644 --- a/src/TabGroup.hpp +++ b/src/TabGroup.hpp @@ -106,7 +106,6 @@ private: Vector2D last_workspace_offset; Vector2D last_pos; Vector2D last_size; - Hy3Node* node; Hy3TabGroup();