From 342f32a3f1b245bea141690300555b3073c3561f Mon Sep 17 00:00:00 2001 From: Matthew Kosarek Date: Thu, 7 Mar 2024 09:07:55 -0500 Subject: [PATCH] (#48) Fullscreened windows are now guaranteed to be on top (#53) --- src/output_content.cpp | 12 ++++++++++-- src/tree.cpp | 14 +++++++++++++- src/tree.h | 2 ++ 3 files changed, 25 insertions(+), 3 deletions(-) diff --git a/src/output_content.cpp b/src/output_content.cpp index f404386..df7196b 100644 --- a/src/output_content.cpp +++ b/src/output_content.cpp @@ -128,7 +128,6 @@ void OutputContent::advise_focus_gained(const std::shared_ptrget_tiling_node()->get_tree()->advise_focus_gained(metadata->get_window()); - tools.send_tree_to_back(metadata->get_window()); break; } case WindowType::floating: @@ -326,6 +325,9 @@ OutputContent::confirm_placement_on_display( void OutputContent::select_window_from_point(int x, int y) { auto workspace = get_active_workspace(); + if (workspace->get_tree()->has_fullscreen_window()) + return; + auto const& floating = workspace->get_floating_windows(); int floating_index = -1; for (int i = 0; i < floating.size(); i++) @@ -526,6 +528,12 @@ void OutputContent::request_toggle_active_float() case WindowType::tiled: { auto tree = metadata->get_tiling_node()->get_tree(); + if (tree->has_fullscreen_window()) + { + mir::log_warning("request_toggle_active_float: cannot float fullscreen window"); + return; + } + tree->advise_delete_window(active_window); auto& prev_info = tools.info_for(active_window); @@ -570,4 +578,4 @@ void OutputContent::add_immediately(miral::Window &window) advise_new_window(tools.info_for(window), type); auto metadata = window_helpers::get_metadata(window, tools); handle_window_ready(tools.info_for(window), metadata); -} \ No newline at end of file +} diff --git a/src/tree.cpp b/src/tree.cpp index 996d36c..f921b17 100644 --- a/src/tree.cpp +++ b/src/tree.cpp @@ -66,6 +66,10 @@ std::shared_ptr Tree::advise_new_window(miral::WindowInfo const& window_in tools.select_active_window(window_info.window()); advise_fullscreen_window(window_info.window()); } + else + { + tools.send_tree_to_back(window_info.window()); + } return node; } @@ -344,13 +348,17 @@ void Tree::advise_focus_gained(miral::Window& window) } active_window = found_node; + if (active_window && is_active_window_fullscreen) + tools.raise_tree(window); + else + tools.send_tree_to_back(window); } void Tree::advise_focus_lost(miral::Window& window) { is_resizing = false; - if (active_window != nullptr && active_window->get_window() == window) + if (active_window != nullptr && active_window->get_window() == window && !is_active_window_fullscreen) active_window = nullptr; } @@ -628,6 +636,7 @@ bool Tree::advise_fullscreen_window(miral::Window& window) return false; tools.select_active_window(node->get_window()); + tools.raise_tree(node->get_window()); is_active_window_fullscreen = true; is_resizing = false; return true; @@ -640,7 +649,10 @@ bool Tree::advise_restored_window(miral::Window& window) return false; if (node == active_window && is_active_window_fullscreen) + { is_active_window_fullscreen = false; + constrain(active_window->get_window()); + } return true; } diff --git a/src/tree.h b/src/tree.h index b73e42d..f12b95f 100644 --- a/src/tree.h +++ b/src/tree.h @@ -54,6 +54,8 @@ class Tree /// Toggle the active window between fullscreen and not fullscreen bool try_toggle_active_fullscreen(); + bool has_fullscreen_window() { return is_active_window_fullscreen; } + // Request a change to vertical window placement void request_vertical();