mirror of
https://github.com/Trensa-Organization/hy3.git
synced 2025-03-16 03:03:40 +01:00
Render tab bars based on the topmost window
This commit is contained in:
parent
5a76590882
commit
00262d89dd
2 changed files with 41 additions and 3 deletions
|
@ -298,7 +298,6 @@ void Hy3Node::markFocused() {
|
||||||
// update focus
|
// update focus
|
||||||
if (this->data.type == Hy3NodeData::Group) {
|
if (this->data.type == Hy3NodeData::Group) {
|
||||||
this->data.as_group.group_focused = true;
|
this->data.as_group.group_focused = true;
|
||||||
this->data.as_group.focused_child = nullptr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
auto* node2 = node;
|
auto* node2 = node;
|
||||||
|
@ -507,6 +506,39 @@ void Hy3Node::swapData(Hy3Node& a, Hy3Node& b) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct FindTopWindowInNodeResult {
|
||||||
|
CWindow* window = nullptr;
|
||||||
|
size_t index = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
void findTopWindowInNode(Hy3Node& node, FindTopWindowInNodeResult& result) {
|
||||||
|
switch(node.data.type) {
|
||||||
|
case Hy3NodeData::Window: {
|
||||||
|
auto* window = node.data.as_window;
|
||||||
|
auto& windows = g_pCompositor->m_vWindows;
|
||||||
|
|
||||||
|
for (; result.index < windows.size(); result.index++) {
|
||||||
|
if (&*windows[result.index] == window) {
|
||||||
|
result.window = window;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} break;
|
||||||
|
case Hy3NodeData::Group: {
|
||||||
|
auto& group = node.data.as_group;
|
||||||
|
|
||||||
|
if (group.layout == Hy3GroupLayout::Tabbed) {
|
||||||
|
if (group.focused_child != nullptr) findTopWindowInNode(*group.focused_child, result);
|
||||||
|
} else {
|
||||||
|
for (auto* child: group.children) {
|
||||||
|
findTopWindowInNode(*child, result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Hy3Node::updateTabBar() {
|
void Hy3Node::updateTabBar() {
|
||||||
if (this->data.type == Hy3NodeData::Group) {
|
if (this->data.type == Hy3NodeData::Group) {
|
||||||
auto& group = this->data.as_group;
|
auto& group = this->data.as_group;
|
||||||
|
@ -514,6 +546,10 @@ void Hy3Node::updateTabBar() {
|
||||||
if (group.layout == Hy3GroupLayout::Tabbed) {
|
if (group.layout == Hy3GroupLayout::Tabbed) {
|
||||||
if (group.tab_bar == nullptr) group.tab_bar = &this->layout->tab_groups.emplace_back(*this);
|
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);
|
||||||
|
|
||||||
|
FindTopWindowInNodeResult result;
|
||||||
|
findTopWindowInNode(*this, result);
|
||||||
|
group.tab_bar->target_window = result.window;
|
||||||
} else if (group.tab_bar != nullptr) {
|
} else if (group.tab_bar != nullptr) {
|
||||||
group.tab_bar->bar.beginDestroy();
|
group.tab_bar->bar.beginDestroy();
|
||||||
group.tab_bar = nullptr;
|
group.tab_bar = nullptr;
|
||||||
|
@ -1553,12 +1589,13 @@ void renderTabs(Hy3Node& node);
|
||||||
|
|
||||||
void Hy3Layout::renderHook(void*, std::any data) {
|
void Hy3Layout::renderHook(void*, std::any data) {
|
||||||
auto render_stage = std::any_cast<eRenderStage>(data);
|
auto render_stage = std::any_cast<eRenderStage>(data);
|
||||||
if (render_stage == RENDER_POST_WINDOWS) {
|
if (render_stage == RENDER_POST_WINDOW) {
|
||||||
auto& tab_groups = g_Hy3Layout->tab_groups;
|
auto& tab_groups = g_Hy3Layout->tab_groups;
|
||||||
auto entry = tab_groups.begin();
|
auto entry = tab_groups.begin();
|
||||||
while (entry != tab_groups.end()) {
|
while (entry != tab_groups.end()) {
|
||||||
if (entry->bar.destroy) tab_groups.erase(entry++);
|
if (entry->bar.destroy) tab_groups.erase(entry++);
|
||||||
else entry++->renderTabBar();
|
else if (entry->target_window == g_pHyprOpenGL->m_pCurrentWindow) entry++->renderTabBar();
|
||||||
|
else entry++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,6 +63,7 @@ private:
|
||||||
|
|
||||||
class Hy3TabGroup {
|
class Hy3TabGroup {
|
||||||
public:
|
public:
|
||||||
|
CWindow* target_window = nullptr;
|
||||||
Hy3TabBar bar;
|
Hy3TabBar bar;
|
||||||
CAnimatedVariable pos;
|
CAnimatedVariable pos;
|
||||||
CAnimatedVariable size;
|
CAnimatedVariable size;
|
||||||
|
|
Loading…
Add table
Reference in a new issue