(#166) XWayland windows now have a proper Z-order so that they don't step on each other's toes (#170)

This commit is contained in:
Matthew Kosarek 2024-06-18 16:45:16 -04:00 committed by GitHub
parent 79a912698c
commit caab71d750
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 34 additions and 19 deletions

View File

@ -153,7 +153,16 @@ void OutputContent::handle_window_ready(miral::WindowInfo& window_info, std::sha
{
case WindowType::tiled:
{
metadata->get_tiling_node()->get_tree()->handle_window_ready(window_info);
auto tree = metadata->get_tiling_node()->get_tree();
tree->handle_window_ready(window_info);
// Note: By default, new windows are raised. To properly maintain the ordering, we must
// raise floating windows and then raise fullscreen windows.
for (auto const& window : get_active_workspace()->get_floating_windows())
node_interface.raise(window);
if (tree->has_fullscreen_window())
node_interface.raise(active_window);
break;
}
case WindowType::floating:

View File

@ -87,10 +87,6 @@ std::shared_ptr<LeafNode> TilingWindowTree::advise_new_window(miral::WindowInfo
tiling_interface.select_active_window(window_info.window());
advise_fullscreen_window(window_info.window());
}
else
{
tiling_interface.send_to_back(window_info.window());
}
return node;
}
@ -302,8 +298,6 @@ void TilingWindowTree::advise_focus_gained(miral::Window& window)
active_window = metadata->get_tiling_node();
if (active_window && is_active_window_fullscreen)
tiling_interface.raise(window);
else
tiling_interface.send_to_back(window);
}
void TilingWindowTree::advise_focus_lost(miral::Window& window)
@ -808,12 +802,12 @@ void TilingWindowTree::hide()
});
}
void TilingWindowTree::show()
std::shared_ptr<LeafNode> TilingWindowTree::show()
{
if (!is_hidden)
{
mir::log_warning("Tree is already shown");
return;
return nullptr;
}
is_hidden = false;
@ -828,14 +822,12 @@ void TilingWindowTree::show()
if (leaf_node->is_fullscreen())
fullscreen_node = leaf_node;
else
tiling_interface.raise(leaf_node->get_window());
}
});
if (fullscreen_node)
{
tiling_interface.select_active_window(fullscreen_node->get_window());
tiling_interface.raise(fullscreen_node->get_window());
}
return fullscreen_node;
}
bool TilingWindowTree::is_empty()

View File

@ -37,6 +37,7 @@ namespace miracle
class OutputContent;
class MiracleConfig;
class TilingInterface;
class LeafNode;
class TilingWindowTree
{
@ -110,8 +111,8 @@ public:
/// Hides the entire tree
void hide();
/// Shows the entire tree
void show();
/// Shows the tree and returns a fullscreen node
std::shared_ptr<LeafNode> show();
void recalculate_root_node_area();
bool is_empty();

View File

@ -36,7 +36,8 @@ WorkspaceContent::WorkspaceContent(
output { screen },
tools { tools },
tree(std::make_shared<TilingWindowTree>(screen, node_interface, config)),
workspace { workspace }
workspace { workspace },
node_interface{ node_interface}
{
}
@ -52,8 +53,7 @@ std::shared_ptr<TilingWindowTree> const& WorkspaceContent::get_tree() const
void WorkspaceContent::show()
{
tree->show();
auto fullscreen_node = tree->show();
for (auto const& window : floating_windows)
{
auto metadata = window_helpers::get_metadata(window, tools);
@ -65,15 +65,26 @@ void WorkspaceContent::show()
// Pinned windows don't require restoration
if (metadata->get_is_pinned())
{
tools.raise_tree(window);
continue;
}
if (auto state = metadata->consume_restore_state())
{
miral::WindowSpecification spec;
spec.state() = state.value();
tools.modify_window(window, spec);
tools.raise_tree(window);
}
}
// TODO: ugh that's ugly. Fullscreen nodes should show above floating nodes
if (fullscreen_node)
{
node_interface.select_active_window(fullscreen_node->get_window());
node_interface.raise(fullscreen_node->get_window());
}
}
void WorkspaceContent::for_each_window(std::function<void(std::shared_ptr<WindowMetadata>)> const& f)
@ -113,6 +124,7 @@ void WorkspaceContent::hide()
miral::WindowSpecification spec;
spec.state() = mir_window_state_hidden;
tools.modify_window(window, spec);
node_interface.send_to_back(window);
}
}

View File

@ -64,6 +64,7 @@ private:
std::shared_ptr<TilingWindowTree> tree;
int workspace;
std::vector<miral::Window> floating_windows;
TilingInterface& node_interface;
};
} // miracle