From b3be42109fd358a1faf0215f44036445943d03e7 Mon Sep 17 00:00:00 2001 From: outfoxxed Date: Wed, 28 Jun 2023 16:46:05 -0700 Subject: [PATCH] Fix tab resize animation playing during non-animating node resize --- src/Hy3Layout.cpp | 6 +++--- src/Hy3Layout.hpp | 2 +- src/TabGroup.cpp | 18 ++++++++++++------ src/TabGroup.hpp | 2 +- 4 files changed, 17 insertions(+), 11 deletions(-) diff --git a/src/Hy3Layout.cpp b/src/Hy3Layout.cpp index 8d4fc86..3b60afd 100644 --- a/src/Hy3Layout.cpp +++ b/src/Hy3Layout.cpp @@ -179,7 +179,7 @@ void Hy3Node::recalcSizePosRecursive(bool no_animation) { child->setHidden(this->hidden); child->recalcSizePosRecursive(no_animation); - this->updateTabBar(); + this->updateTabBar(no_animation); return; } @@ -582,13 +582,13 @@ void findTopWindowInNode(Hy3Node& node, FindTopWindowInNodeResult& result) { } } -void Hy3Node::updateTabBar() { +void Hy3Node::updateTabBar(bool no_animation) { if (this->data.type == Hy3NodeData::Group) { auto& group = this->data.as_group; if (group.layout == Hy3GroupLayout::Tabbed) { if (group.tab_bar == nullptr) group.tab_bar = &this->layout->tab_groups.emplace_back(*this); - group.tab_bar->updateWithGroup(*this); + group.tab_bar->updateWithGroup(*this, no_animation); FindTopWindowInNodeResult result; findTopWindowInNode(*this, result); diff --git a/src/Hy3Layout.hpp b/src/Hy3Layout.hpp index ba201cf..1b466d8 100644 --- a/src/Hy3Layout.hpp +++ b/src/Hy3Layout.hpp @@ -108,7 +108,7 @@ struct Hy3Node { Hy3Node* getFocusedNode(); void updateDecos(); void setHidden(bool); - void updateTabBar(); + void updateTabBar(bool no_animation = false); void updateTabBarRecursive(); bool isUrgent(); bool isIndirectlyFocused(); diff --git a/src/TabGroup.cpp b/src/TabGroup.cpp index 17d7b21..523a39a 100644 --- a/src/TabGroup.cpp +++ b/src/TabGroup.cpp @@ -443,13 +443,12 @@ Hy3TabGroup::Hy3TabGroup(Hy3Node& node) { this->pos.registerVar(); this->size.registerVar(); - this->updateWithGroup(node); - this->bar.updateAnimations(true); + this->updateWithGroup(node, true); this->pos.warp(); this->size.warp(); } -void Hy3TabGroup::updateWithGroup(Hy3Node& node) { +void Hy3TabGroup::updateWithGroup(Hy3Node& node, bool warp) { Debug::log(LOG, "updated tab bar for %p", &node); static const auto* gaps_in = &HyprlandAPI::getConfigValue(PHANDLE, "general:gaps_in")->intValue; static const auto* gaps_out = &HyprlandAPI::getConfigValue(PHANDLE, "general:gaps_out")->intValue; @@ -461,11 +460,18 @@ void Hy3TabGroup::updateWithGroup(Hy3Node& node) { auto tsize = Vector2D(node.size.x - node.gap_size_offset.x - gaps * 2, *bar_height); this->hidden = node.hidden; - if (this->pos.goalv() != tpos) this->pos = tpos; - if (this->size.goalv() != tsize) this->size = tsize; + if (this->pos.goalv() != tpos) { + this->pos = tpos; + if (warp) this->pos.warp(); + } + + if (this->size.goalv() != tsize) { + this->size = tsize; + if (warp) this->size.warp(); + } this->bar.updateNodeList(node.data.as_group.children); - this->bar.updateAnimations(); + this->bar.updateAnimations(warp); if (node.data.as_group.focused_child != nullptr) { this->updateStencilWindows(*node.data.as_group.focused_child); diff --git a/src/TabGroup.hpp b/src/TabGroup.hpp index 90af61b..3e016fe 100644 --- a/src/TabGroup.hpp +++ b/src/TabGroup.hpp @@ -94,7 +94,7 @@ public: Hy3TabGroup(Hy3Node&); // update tab bar with node position and data. UB if node is not a group. - void updateWithGroup(Hy3Node&); + void updateWithGroup(Hy3Node&, bool warp); void tick(); // render the scaled tab bar on the current monitor. void renderTabBar();