Fix tab bars rendering over fullscreen windows

This commit is contained in:
outfoxxed 2023-05-31 23:40:54 -07:00
parent 3a2ec87255
commit 66974389b3
No known key found for this signature in database
GPG key ID: 4C88A185FB89301E
3 changed files with 18 additions and 5 deletions

View file

@ -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);
}

View file

@ -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) {

View file

@ -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();