66974389b35910de7f37e1ee597c0df743c7f462

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

Message

Fix tab bars rendering over fullscreen windows

Diff

 1diff --git a/src/Hy3Layout.cpp b/src/Hy3Layout.cpp
 2index 5f98d469eae575089832ac09ee17a1c4645288de..d4690b72a736968cb56ed082195e3d3f63c89b04 100644
 3--- a/src/Hy3Layout.cpp
 4+++ b/src/Hy3Layout.cpp
 5@@ -1617,7 +1617,7 @@ void Hy3Layout::tickHook(void*, std::any) {
 6 	auto& tab_groups = g_Hy3Layout->tab_groups;
 7 	auto entry = tab_groups.begin();
 8 	while (entry != tab_groups.end()) {
 9-		entry->damageIfRequired();
10+		entry->tick();
11 		if (entry->bar.destroy) tab_groups.erase(entry++);
12 		else entry = std::next(entry);
13 	}
14diff --git a/src/TabGroup.cpp b/src/TabGroup.cpp
15index 56e460a3d1d4cbb05eeb540399b52a2d602eeb6e..1e2d0e2904a2fc084dc33fd4106f099893a15fed 100644
16--- a/src/TabGroup.cpp
17+++ b/src/TabGroup.cpp
18@@ -133,6 +133,7 @@ Hy3TabBar::Hy3TabBar() {
19 void Hy3TabBar::beginDestroy() {
20 	this->vertical_pos = 1.0;
21 	this->fade_opacity = 0.0;
22+	this->destroying = true;
23 	this->fade_opacity.setCallbackOnEnd([this](void*) { this->destroy = true; });
24 }
25 
26@@ -280,8 +281,17 @@ void Hy3TabGroup::updateWithGroup(Hy3Node& node) {
27 	}
28 }
29 
30-void Hy3TabGroup::damageIfRequired() {
31+void Hy3TabGroup::tick() {
32 	static const auto* enter_from_top = &HyprlandAPI::getConfigValue(PHANDLE, "plugin:hy3:tabs:from_top")->intValue;
33+	auto* workspace = g_pCompositor->getWorkspaceByID(this->workspace_id);
34+
35+	if (!this->bar.destroying && workspace != nullptr) {
36+		if (workspace->m_bHasFullscreenWindow) {
37+			if (this->bar.fade_opacity.goalf() != 0.0) this->bar.fade_opacity = 0.0;
38+		} else {
39+			if (this->bar.fade_opacity.goalf() != 1.0) this->bar.fade_opacity = 1.0;
40+		}
41+	}
42 
43 	auto pos = this->pos.vec();
44 	auto size = this->size.vec();
45@@ -375,9 +385,11 @@ void Hy3TabGroup::renderTabBar() {
46 		glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);
47 	}
48 
49+	auto fade_opacity = this->bar.fade_opacity.fl() * (workspace == nullptr ? 1.0 : workspace->m_fAlpha.fl());
50+
51 	auto render_entry = [&](Hy3TabBarEntry& entry) {
52 		Vector2D entry_size = { (entry.width.fl() * size.x) - *padding, size.y };
53-		if (entry_size.x < 0 || entry_size.y < 0) return;
54+		if (entry_size.x < 0 || entry_size.y < 0 || fade_opacity == 0.0) return;
55 
56 		wlr_box box = {
57 			(pos.x + (entry.offset.fl() * size.x) + (*padding * 0.5)) * scale,
58@@ -387,7 +399,7 @@ void Hy3TabGroup::renderTabBar() {
59 		};
60 
61 		entry.prepareTexture(scale, box);
62-		g_pHyprOpenGL->renderTexture(entry.texture, &box, this->bar.fade_opacity.fl());
63+		g_pHyprOpenGL->renderTexture(entry.texture, &box, fade_opacity);
64 	};
65 
66 	for (auto& entry: this->bar.entries) {
67diff --git a/src/TabGroup.hpp b/src/TabGroup.hpp
68index 837c28b558e310e395659b185911f6f7b3db6b6c..fd8e0c918c640c3066a5d9998385f78df97956f2 100644
69--- a/src/TabGroup.hpp
70+++ b/src/TabGroup.hpp
71@@ -38,6 +38,7 @@ struct Hy3TabBarEntry {
72 class Hy3TabBar {
73 public:
74 	bool destroy = false;
75+	bool destroying = false;
76 	bool dirty = true;
77 	bool damaged = true;
78 	CAnimatedVariable vertical_pos;
79@@ -73,7 +74,7 @@ public:
80 
81 	// update tab bar with node position and data. UB if node is not a group.
82 	void updateWithGroup(Hy3Node&);
83-	void damageIfRequired();
84+	void tick();
85 	// render the scaled tab bar on the current monitor.
86 	void renderTabBar();
87