diff --git a/src/leaf_node.cpp b/src/leaf_node.cpp index f2d5b5d..156a324 100644 --- a/src/leaf_node.cpp +++ b/src/leaf_node.cpp @@ -57,6 +57,11 @@ void LeafNode::set_parent(std::shared_ptr const& in_parent) parent = in_parent; } +void LeafNode::set_state(MirWindowState state) +{ + next_state = state; +} + geom::Rectangle LeafNode::get_visible_area() const { // TODO: Could cache these half values in the config @@ -132,7 +137,7 @@ void LeafNode::toggle_fullscreen() bool LeafNode::is_fullscreen() const { - return node_interface.get_state(window) == mir_window_state_maximized; + return node_interface.is_fullscreen(window); } void LeafNode::commit_changes() diff --git a/src/leaf_node.h b/src/leaf_node.h index 23c5d4f..019363e 100644 --- a/src/leaf_node.h +++ b/src/leaf_node.h @@ -53,6 +53,7 @@ public: [[nodiscard]] geom::Rectangle get_visible_area() const; void set_logical_area(geom::Rectangle const& target_rect) override; void set_parent(std::shared_ptr const&) override; + void set_state(MirWindowState state); void show(); void hide(); void toggle_fullscreen(); diff --git a/src/output_content.cpp b/src/output_content.cpp index 3c06af8..19caf07 100644 --- a/src/output_content.cpp +++ b/src/output_content.cpp @@ -289,20 +289,25 @@ void OutputContent::handle_modify_window(const std::shared_ptrget_tiling_node()->get_tree()) + auto& window = metadata->get_window(); + auto node = metadata->get_tiling_node(); + auto const& info = tools.info_for(window); + if (get_active_tree().get() != node->get_tree()) break; - if (modifications.state().is_set()) + if (modifications.state().is_set() && modifications.state().value() != info.state()) { auto tree = metadata->get_tiling_node()->get_tree(); + node->set_state(modifications.state().value()); + node->commit_changes(); + if (window_helpers::is_window_fullscreen(modifications.state().value())) - tree->advise_fullscreen_window(metadata->get_window()); + tree->advise_fullscreen_window(window); else if (modifications.state().value() == mir_window_state_restored) - tree->advise_restored_window(metadata->get_window()); - tree->constrain(metadata->get_window()); + tree->advise_restored_window(window); } - tools.modify_window(metadata->get_window(), modifications); + tools.modify_window(window, modifications); break; } case WindowType::floating: