From 3ab9173b20127fdfe387656439bb3f6ea851bfb7 Mon Sep 17 00:00:00 2001 From: Norman Feske Date: Thu, 24 Oct 2024 11:50:16 +0200 Subject: [PATCH] gui_session: window-closed state as attribute With the change of "gui_session: provide mode info as XML", the client-side window-close handling became dysfunct because the window-close state got wrongly interpreted as initial window state, to the effect that a client's initial-window size policy got applied instead of closing the window. This patch makes the inital state of running a windowed application (when no window size is defined yet) clearly distiguishable from the state after which the user closed the window. Prior this patch, both conditions were reflected by an empty node in the panorama. Now, the latter condition is reported as , which alleviates the need to track the life cycle of a window at the client size. Issue #5353 --- repos/gems/src/server/wm/gui.h | 9 +++++++++ repos/os/include/gui_session/connection.h | 8 +++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/repos/gems/src/server/wm/gui.h b/repos/gems/src/server/wm/gui.h index a289824a30..8819828f89 100644 --- a/repos/gems/src/server/wm/gui.h +++ b/repos/gems/src/server/wm/gui.h @@ -618,6 +618,7 @@ class Wm::Gui::Session_component : public Session_object, bool _resizeable = false; Area _requested_size { }; bool _resize_requested = false; + bool _close_requested = false; bool _has_alpha = false; Pointer::State _pointer_state; Point const _initial_pointer_pos { -1, -1 }; @@ -797,6 +798,11 @@ class Wm::Gui::Session_component : public Session_object, { _action.gen_screen_area_info(xml); + if (_close_requested) { + xml.node("capture", [&] { xml.attribute("closed", "yes"); }); + return; + } + auto virtual_capture_area = [&] { /* @@ -1037,6 +1043,9 @@ class Wm::Gui::Session_component : public Session_object, _requested_size = size; _resize_requested = true; + if (_requested_size.count() == 0) + _close_requested = true; + /* notify client */ if (_info_rom.constructed()) _info_rom->trigger_update(); diff --git a/repos/os/include/gui_session/connection.h b/repos/os/include/gui_session/connection.h index 427cbcee2b..91743116e6 100644 --- a/repos/os/include/gui_session/connection.h +++ b/repos/os/include/gui_session/connection.h @@ -275,20 +275,26 @@ class Gui::Connection : private Genode::Connection * to the window size as defined by the layouter. * * The returned rectangle may be undefined when a client of the window - * manager has not defined a top-level view yet. + * manager has not defined a top-level view yet. Once a window is got + * closed, the returned rectangle is zero-sized. */ Window_result window() { Rect result { }; + bool closed = false; _with_info_xml([&] (Xml_node const &info) { Rect bb { }; /* bounding box of all captured rects */ unsigned count = 0; info.for_each_sub_node("capture", [&] (Xml_node const &capture) { + closed |= (capture.attribute_value("closed", false)); bb = Rect::compound(bb, Rect::from_xml(capture)); count++; }); result = (count == 1) ? bb : Rect::from_xml(info); }); + if (closed) + return Rect { }; + return result.valid() ? Window_result { result } : Window_result { Undefined { } }; }