b3be42109fd358a1faf0215f44036445943d03e7

Author
outfoxxed <outfoxxed@outfoxxed.me>
Committer
outfoxxed <outfoxxed@outfoxxed.me>
Date

Message

Fix tab resize animation playing during non-animating node resize

Diff

 1diff --git a/src/Hy3Layout.cpp b/src/Hy3Layout.cpp
 2index 8d4fc865583152ed3586d59228a568b7f96fbb65..3b60afdf861a475f1ab256e83b460795279650e6 100644
 3--- a/src/Hy3Layout.cpp
 4+++ b/src/Hy3Layout.cpp
 5@@ -179,7 +179,7 @@ void Hy3Node::recalcSizePosRecursive(bool no_animation) {
 6 		child->setHidden(this->hidden);
 7 
 8 		child->recalcSizePosRecursive(no_animation);
 9-		this->updateTabBar();
10+		this->updateTabBar(no_animation);
11 		return;
12 	}
13 
14@@ -582,13 +582,13 @@ void findTopWindowInNode(Hy3Node& node, FindTopWindowInNodeResult& result) {
15 	}
16 }
17 
18-void Hy3Node::updateTabBar() {
19+void Hy3Node::updateTabBar(bool no_animation) {
20 	if (this->data.type == Hy3NodeData::Group) {
21 		auto& group = this->data.as_group;
22 
23 		if (group.layout == Hy3GroupLayout::Tabbed) {
24 			if (group.tab_bar == nullptr) group.tab_bar = &this->layout->tab_groups.emplace_back(*this);
25-			group.tab_bar->updateWithGroup(*this);
26+			group.tab_bar->updateWithGroup(*this, no_animation);
27 
28 			FindTopWindowInNodeResult result;
29 			findTopWindowInNode(*this, result);
30diff --git a/src/Hy3Layout.hpp b/src/Hy3Layout.hpp
31index ba201cf1e29e316d83c2504cf47367ff4a890e59..1b466d85d3d9b9b2c22a05ea6d576174019978a3 100644
32--- a/src/Hy3Layout.hpp
33+++ b/src/Hy3Layout.hpp
34@@ -108,7 +108,7 @@ struct Hy3Node {
35 	Hy3Node* getFocusedNode();
36 	void updateDecos();
37 	void setHidden(bool);
38-	void updateTabBar();
39+	void updateTabBar(bool no_animation = false);
40 	void updateTabBarRecursive();
41 	bool isUrgent();
42 	bool isIndirectlyFocused();
43diff --git a/src/TabGroup.cpp b/src/TabGroup.cpp
44index 17d7b214d58d00e4e63a594b25258230125b9e34..523a39aa8b6dc7527d193edbbe74bf93ecd82438 100644
45--- a/src/TabGroup.cpp
46+++ b/src/TabGroup.cpp
47@@ -443,13 +443,12 @@ Hy3TabGroup::Hy3TabGroup(Hy3Node& node) {
48 	this->pos.registerVar();
49 	this->size.registerVar();
50 
51-	this->updateWithGroup(node);
52-	this->bar.updateAnimations(true);
53+	this->updateWithGroup(node, true);
54 	this->pos.warp();
55 	this->size.warp();
56 }
57 
58-void Hy3TabGroup::updateWithGroup(Hy3Node& node) {
59+void Hy3TabGroup::updateWithGroup(Hy3Node& node, bool warp) {
60 	Debug::log(LOG, "updated tab bar for %p", &node);
61 	static const auto* gaps_in = &HyprlandAPI::getConfigValue(PHANDLE, "general:gaps_in")->intValue;
62 	static const auto* gaps_out = &HyprlandAPI::getConfigValue(PHANDLE, "general:gaps_out")->intValue;
63@@ -461,11 +460,18 @@ void Hy3TabGroup::updateWithGroup(Hy3Node& node) {
64 	auto tsize = Vector2D(node.size.x - node.gap_size_offset.x - gaps * 2, *bar_height);
65 
66 	this->hidden = node.hidden;
67-	if (this->pos.goalv() != tpos) this->pos = tpos;
68-	if (this->size.goalv() != tsize) this->size = tsize;
69+	if (this->pos.goalv() != tpos) {
70+		this->pos = tpos;
71+		if (warp) this->pos.warp();
72+	}
73+
74+	if (this->size.goalv() != tsize) {
75+		this->size = tsize;
76+		if (warp) this->size.warp();
77+	}
78 
79 	this->bar.updateNodeList(node.data.as_group.children);
80-	this->bar.updateAnimations();
81+	this->bar.updateAnimations(warp);
82 
83 	if (node.data.as_group.focused_child != nullptr) {
84 		this->updateStencilWindows(*node.data.as_group.focused_child);
85diff --git a/src/TabGroup.hpp b/src/TabGroup.hpp
86index 90af61b751224e2fecd0a671c7675279c14c794c..3e016febcdfe86be435d6a2bd240b2e1f34ffa58 100644
87--- a/src/TabGroup.hpp
88+++ b/src/TabGroup.hpp
89@@ -94,7 +94,7 @@ public:
90 	Hy3TabGroup(Hy3Node&);
91 
92 	// update tab bar with node position and data. UB if node is not a group.
93-	void updateWithGroup(Hy3Node&);
94+	void updateWithGroup(Hy3Node&, bool warp);
95 	void tick();
96 	// render the scaled tab bar on the current monitor.
97 	void renderTabBar();