From a38a0e54a357d3fac123e6bcc84523db0d6e5edf Mon Sep 17 00:00:00 2001 From: Matthew Kosarek Date: Wed, 27 Nov 2024 18:31:26 -0500 Subject: [PATCH] bugfix: fullscreen windows were some times broken (#308) --- src/leaf_container.cpp | 1 - src/main.cpp | 2 +- src/policy.cpp | 2 +- src/tiling_window_tree.cpp | 65 ++++---------------------------------- src/tiling_window_tree.h | 7 ---- src/workspace.cpp | 2 +- tests/test_animator.cpp | 6 ++-- 7 files changed, 13 insertions(+), 72 deletions(-) diff --git a/src/leaf_container.cpp b/src/leaf_container.cpp index b730d67..2d43ab8 100644 --- a/src/leaf_container.cpp +++ b/src/leaf_container.cpp @@ -140,7 +140,6 @@ void LeafContainer::handle_ready() { tree->handle_container_ready(*this); get_workspace()->handle_ready_hack(*this); - auto const& info = window_controller.info_for(window_); if (window_controller.is_fullscreen(window_)) toggle_fullscreen(); } diff --git a/src/main.cpp b/src/main.cpp index 913cf5a..4de8076 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -68,7 +68,7 @@ int main(int argc, char const* argv[]) MirRunner runner { argc, argv }; miracle::CompositorState compositor_state; - std::function shutdown_hook { [] {} }; + std::function shutdown_hook { [] { } }; runner.add_stop_callback([&] { shutdown_hook(); }); diff --git a/src/policy.cpp b/src/policy.cpp index 77e2698..bb1a7bd 100644 --- a/src/policy.cpp +++ b/src/policy.cpp @@ -1384,5 +1384,5 @@ bool Policy::can_set_layout() const if (!state.active()) return false; - return true; + return !state.active()->is_fullscreen(); } diff --git a/src/tiling_window_tree.cpp b/src/tiling_window_tree.cpp index dfd3d89..37c806a 100644 --- a/src/tiling_window_tree.cpp +++ b/src/tiling_window_tree.cpp @@ -106,12 +106,6 @@ void TilingWindowTree::graft(std::shared_ptr const& leaf) bool TilingWindowTree::resize_container(miracle::Direction direction, Container& container) { - if (is_active_window_fullscreen) - { - mir::log_warning("Unable to resize the next window: fullscreened"); - return false; - } - handle_resize(container, direction, config->get_resize_jump()); return true; } @@ -119,12 +113,6 @@ bool TilingWindowTree::resize_container(miracle::Direction direction, Container& bool TilingWindowTree::select_next( miracle::Direction direction, Container& container) { - if (is_active_window_fullscreen) - { - mir::log_warning("Unable to select the next window: fullscreened"); - return false; - } - auto node = handle_select(container, direction); if (!node) { @@ -138,10 +126,10 @@ bool TilingWindowTree::select_next( bool TilingWindowTree::toggle_fullscreen(LeafContainer& container) { - if (is_active_window_fullscreen) - advise_restored_container(container); - else + if (container.is_fullscreen()) advise_fullscreen_container(container); + else + advise_restored_container(container); return true; } @@ -156,27 +144,8 @@ geom::Rectangle TilingWindowTree::get_area() const return root_lane->get_logical_area(); } -std::shared_ptr TilingWindowTree::select_window_from_point(int x, int y) -{ - if (is_active_window_fullscreen) - return active_container(); - - auto node = root_lane->find_where([&](std::shared_ptr const& node) - { - return node->is_leaf() && node->get_logical_area().contains(geom::Point(x, y)); - }); - - return Container::as_leaf(node); -} - bool TilingWindowTree::move_container(miracle::Direction direction, Container& container) { - if (is_active_window_fullscreen) - { - mir::log_warning("Unable to move active window: fullscreen"); - return false; - } - auto traversal_result = handle_move(container, direction); switch (traversal_result.traversal_type) { @@ -286,12 +255,6 @@ void TilingWindowTree::toggle_layout(Container& container, bool cycle_thru_all) void TilingWindowTree::handle_layout_scheme(LayoutScheme scheme, Container& container) { - if (is_active_window_fullscreen) - { - mir::log_warning("Unable to handle direction request: fullscreen"); - return; - } - auto parent = container.get_parent().lock(); if (!parent) { @@ -312,7 +275,7 @@ void TilingWindowTree::handle_layout_scheme(LayoutScheme scheme, Container& cont void TilingWindowTree::advise_focus_gained(LeafContainer& container) { - if (is_active_window_fullscreen) + if (container.is_fullscreen()) window_controller.raise(container.window().value()); else if (auto const& parent = container.get_parent().lock()) parent->on_focus_gained(); @@ -320,13 +283,6 @@ void TilingWindowTree::advise_focus_gained(LeafContainer& container) void TilingWindowTree::advise_delete_window(std::shared_ptr const& container) { - auto active = active_container(); - if (active == container) - { - if (is_active_window_fullscreen) - is_active_window_fullscreen = false; - } - auto parent = handle_remove(container); parent->commit_changes(); } @@ -650,16 +606,14 @@ bool TilingWindowTree::advise_fullscreen_container(LeafContainer& container) auto window = container.window().value(); window_controller.select_active_window(window); window_controller.raise(window); - is_active_window_fullscreen = true; return true; } bool TilingWindowTree::advise_restored_container(LeafContainer& container) { - auto active = active_container(); - if (active && active->window() == container.window().value() && is_active_window_fullscreen) + auto active = state.active(); + if (active && active->window() == container.window().value()) { - is_active_window_fullscreen = false; container.set_logical_area(container.get_logical_area()); container.commit_changes(); } @@ -670,7 +624,7 @@ bool TilingWindowTree::advise_restored_container(LeafContainer& container) bool TilingWindowTree::handle_container_ready(LeafContainer& container) { constrain(container); - if (is_active_window_fullscreen) + if (state.active() && state.active()->is_fullscreen()) return true; auto window = container.window().value(); @@ -796,8 +750,3 @@ Workspace* TilingWindowTree::get_workspace() const { return tree_interface->get_workspace(); } - -std::shared_ptr TilingWindowTree::active_container() const -{ - return Container::as_leaf(state.active()); -} diff --git a/src/tiling_window_tree.h b/src/tiling_window_tree.h index 65c5e27..7b7b687 100644 --- a/src/tiling_window_tree.h +++ b/src/tiling_window_tree.h @@ -83,8 +83,6 @@ public: /// Toggle the active window between fullscreen and not fullscreen bool toggle_fullscreen(LeafContainer&); - bool has_fullscreen_window() const { return is_active_window_fullscreen; } - void request_layout(Container&, LayoutScheme); /// Request a change to vertical window placement @@ -113,8 +111,6 @@ public: geom::Rectangle get_area() const; - std::shared_ptr select_window_from_point(int x, int y); - bool advise_fullscreen_container(LeafContainer&); bool advise_restored_container(LeafContainer&); bool handle_container_ready(LeafContainer&); @@ -159,7 +155,6 @@ private: std::shared_ptr root_lane; std::unique_ptr tree_interface; - bool is_active_window_fullscreen = false; bool is_hidden = false; int config_handle = 0; @@ -187,8 +182,6 @@ private: /// Selects the next node in the provided direction /// @returns The next selectable window or nullptr if none is found static std::shared_ptr handle_select(Container& from, Direction direction); - - std::shared_ptr active_container() const; }; } diff --git a/src/workspace.cpp b/src/workspace.cpp index af587b2..70fa148 100644 --- a/src/workspace.cpp +++ b/src/workspace.cpp @@ -177,7 +177,7 @@ void Workspace::handle_ready_hack(LeafContainer& container) for (auto const& window : floating_windows) window_controller.raise(window->window().value()); - if (tree->has_fullscreen_window()) + if (state.active() && state.active()->is_fullscreen()) window_controller.raise(state.active()->window().value()); } diff --git a/tests/test_animator.cpp b/tests/test_animator.cpp index ea396e2..f59b4c1 100644 --- a/tests/test_animator.cpp +++ b/tests/test_animator.cpp @@ -45,8 +45,8 @@ class ImmediateServerActionQueue : public mir::ServerActionQueue action(); } - void pause_processing_for(void const* owner) override {}; - void resume_processing_for(void const* owner) override {}; + void pause_processing_for(void const* owner) override { }; + void resume_processing_for(void const* owner) override { }; }; class AnimatorTest : public testing::Test @@ -154,6 +154,6 @@ TEST_F(AnimationTest, InterruptingSlideResultsInModifiedAnimationDuration) mir::geometry::Rectangle( mir::geometry::Point(200, 200), mir::geometry::Size(0, 0)), - [](auto const& asr) {}); + [](auto const& asr) { }); ASSERT_NEAR(animation.get_runtime_seconds(), 2, 0.05); } \ No newline at end of file