From 66974389b35910de7f37e1ee597c0df743c7f462 Mon Sep 17 00:00:00 2001 From: outfoxxed Date: Wed, 31 May 2023 23:40:54 -0700 Subject: [PATCH] Fix tab bars rendering over fullscreen windows --- src/Hy3Layout.cpp | 2 +- src/TabGroup.cpp | 18 +++++++++++++++--- src/TabGroup.hpp | 3 ++- 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/src/Hy3Layout.cpp b/src/Hy3Layout.cpp index 5f98d46..d4690b7 100644 --- a/src/Hy3Layout.cpp +++ b/src/Hy3Layout.cpp @@ -1617,7 +1617,7 @@ void Hy3Layout::tickHook(void*, std::any) { auto& tab_groups = g_Hy3Layout->tab_groups; auto entry = tab_groups.begin(); while (entry != tab_groups.end()) { - entry->damageIfRequired(); + entry->tick(); if (entry->bar.destroy) tab_groups.erase(entry++); else entry = std::next(entry); } diff --git a/src/TabGroup.cpp b/src/TabGroup.cpp index 56e460a..1e2d0e2 100644 --- a/src/TabGroup.cpp +++ b/src/TabGroup.cpp @@ -133,6 +133,7 @@ Hy3TabBar::Hy3TabBar() { void Hy3TabBar::beginDestroy() { this->vertical_pos = 1.0; this->fade_opacity = 0.0; + this->destroying = true; this->fade_opacity.setCallbackOnEnd([this](void*) { this->destroy = true; }); } @@ -280,8 +281,17 @@ void Hy3TabGroup::updateWithGroup(Hy3Node& node) { } } -void Hy3TabGroup::damageIfRequired() { +void Hy3TabGroup::tick() { static const auto* enter_from_top = &HyprlandAPI::getConfigValue(PHANDLE, "plugin:hy3:tabs:from_top")->intValue; + auto* workspace = g_pCompositor->getWorkspaceByID(this->workspace_id); + + if (!this->bar.destroying && workspace != nullptr) { + if (workspace->m_bHasFullscreenWindow) { + if (this->bar.fade_opacity.goalf() != 0.0) this->bar.fade_opacity = 0.0; + } else { + if (this->bar.fade_opacity.goalf() != 1.0) this->bar.fade_opacity = 1.0; + } + } auto pos = this->pos.vec(); auto size = this->size.vec(); @@ -375,9 +385,11 @@ void Hy3TabGroup::renderTabBar() { glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP); } + auto fade_opacity = this->bar.fade_opacity.fl() * (workspace == nullptr ? 1.0 : workspace->m_fAlpha.fl()); + auto render_entry = [&](Hy3TabBarEntry& entry) { Vector2D entry_size = { (entry.width.fl() * size.x) - *padding, size.y }; - if (entry_size.x < 0 || entry_size.y < 0) return; + if (entry_size.x < 0 || entry_size.y < 0 || fade_opacity == 0.0) return; wlr_box box = { (pos.x + (entry.offset.fl() * size.x) + (*padding * 0.5)) * scale, @@ -387,7 +399,7 @@ void Hy3TabGroup::renderTabBar() { }; entry.prepareTexture(scale, box); - g_pHyprOpenGL->renderTexture(entry.texture, &box, this->bar.fade_opacity.fl()); + g_pHyprOpenGL->renderTexture(entry.texture, &box, fade_opacity); }; for (auto& entry: this->bar.entries) { diff --git a/src/TabGroup.hpp b/src/TabGroup.hpp index 837c28b..fd8e0c9 100644 --- a/src/TabGroup.hpp +++ b/src/TabGroup.hpp @@ -38,6 +38,7 @@ struct Hy3TabBarEntry { class Hy3TabBar { public: bool destroy = false; + bool destroying = false; bool dirty = true; bool damaged = true; CAnimatedVariable vertical_pos; @@ -73,7 +74,7 @@ public: // update tab bar with node position and data. UB if node is not a group. void updateWithGroup(Hy3Node&); - void damageIfRequired(); + void tick(); // render the scaled tab bar on the current monitor. void renderTabBar();