From 805e3552fd4156a57113a0d6b837e41b6a34826d Mon Sep 17 00:00:00 2001 From: Norman Feske Date: Fri, 9 Aug 2024 10:59:49 +0200 Subject: [PATCH] gui_session: definition of Gui::Title This commit allows all GUI clients and servers to talk about the same type. Issue #5242 --- .../src/server/liquid_framebuffer/main.cc | 3 +-- repos/gems/src/app/decorator/window.h | 2 +- repos/gems/src/app/themed_decorator/window.h | 3 +-- repos/gems/src/server/wm/gui.h | 20 +++++++++---------- repos/gems/src/server/wm/window_registry.h | 6 +++--- repos/libports/src/app/pdf_view/main.cc | 4 ++-- repos/os/include/gui_session/gui_session.h | 3 ++- repos/os/src/server/nitpicker/gui_session.cc | 2 +- repos/os/src/server/nitpicker/view.h | 2 -- repos/os/src/server/nitpicker/view_stack.cc | 2 +- repos/os/src/server/nitpicker/view_stack.h | 2 +- repos/os/src/test/nitpicker/main.cc | 4 +--- 12 files changed, 24 insertions(+), 29 deletions(-) diff --git a/repos/demo/src/server/liquid_framebuffer/main.cc b/repos/demo/src/server/liquid_framebuffer/main.cc index ec6c36d211..f3ef47dd00 100644 --- a/repos/demo/src/server/liquid_framebuffer/main.cc +++ b/repos/demo/src/server/liquid_framebuffer/main.cc @@ -79,8 +79,7 @@ static long config_fb_y = 260; /** * Window title */ -using Title = Genode::String<128>; -static Title config_title { "Liquid Framebuffer" }; +static Gui::Title config_title { "Liquid Framebuffer" }; /** * Resize handle diff --git a/repos/gems/src/app/decorator/window.h b/repos/gems/src/app/decorator/window.h index 0d07a60322..705dda85ff 100644 --- a/repos/gems/src/app/decorator/window.h +++ b/repos/gems/src/app/decorator/window.h @@ -54,7 +54,7 @@ class Decorator::Window : public Window_base * We supply the window ID as label for the anchor view. */ if (id) - _gui.enqueue(_id, Genode::String<128>(id).string()); + _gui.enqueue(_id, Gui::Title { id }); } ~Gui_view() diff --git a/repos/gems/src/app/themed_decorator/window.h b/repos/gems/src/app/themed_decorator/window.h index 148bc47820..b69d4d06e6 100644 --- a/repos/gems/src/app/themed_decorator/window.h +++ b/repos/gems/src/app/themed_decorator/window.h @@ -161,8 +161,7 @@ class Decorator::Window : public Window_base, public Animator::Item * We supply the window ID as label for the anchor view. */ if (win_id) - _gui.enqueue(_id, - Genode::String<128>(win_id).string()); + _gui.enqueue(_id, Gui::Title { win_id }); } Gui::View_id _create_remote_view(Gui::Connection &remote_gui) diff --git a/repos/gems/src/server/wm/gui.h b/repos/gems/src/server/wm/gui.h index 0323f24a1f..806a5a9da0 100644 --- a/repos/gems/src/server/wm/gui.h +++ b/repos/gems/src/server/wm/gui.h @@ -107,9 +107,9 @@ class Wm::Gui::View : private Genode::Weak_object, protected: - using Title = Genode::String<100>; - using Command = Gui::Session::Command; - using View_id = Gui::View_id; + using Title = Gui::Title; + using Command = Gui::Session::Command; + using View_id = Gui::View_id; Session_label _session_label; Real_gui &_real_gui; @@ -144,7 +144,7 @@ class Wm::Gui::View : private Genode::Weak_object, _propagate_view_geometry(); _real_gui.enqueue(*_real_view, _buffer_offset); - _real_gui.enqueue (*_real_view, _title.string()); + _real_gui.enqueue (*_real_view, _title); Constructible real_neighbor_id { }; @@ -206,9 +206,9 @@ class Wm::Gui::View : private Genode::Weak_object, } } - virtual void title(char const *title) + virtual void title(Title const &title) { - _title = Title(title); + _title = title; if (_real_view.constructed()) { _real_gui.enqueue(*_real_view, title); @@ -326,7 +326,7 @@ class Wm::Gui::Top_level_view : public View, private List::Eleme */ if (!_win_id.valid()) { _win_id = _window_registry.create(); - _window_registry.title(_win_id, _window_title.string()); + _window_registry.title(_win_id, _window_title); _window_registry.label(_win_id, _session_label); _window_registry.has_alpha(_win_id, View::has_alpha()); _window_registry.resizeable(_win_id, _resizeable); @@ -339,14 +339,14 @@ class Wm::Gui::Top_level_view : public View, private List::Eleme Area size() const { return _geometry.area; } - void title(char const *title) override + void title(Title const &title) override { View::title(title); - _window_title = Title(title); + _window_title = title; if (_win_id.valid()) - _window_registry.title(_win_id, _window_title.string()); + _window_registry.title(_win_id, _window_title); } bool has_win_id(Window_registry::Id id) const { return id == _win_id; } diff --git a/repos/gems/src/server/wm/window_registry.h b/repos/gems/src/server/wm/window_registry.h index 4736c40578..3f62bd27c0 100644 --- a/repos/gems/src/server/wm/window_registry.h +++ b/repos/gems/src/server/wm/window_registry.h @@ -61,7 +61,7 @@ class Wm::Window_registry { public: - using Title = Genode::String<200>; + using Title = Gui::Title; using Session_label = Genode::Session_label; enum Has_alpha { HAS_ALPHA, HAS_NO_ALPHA }; @@ -261,9 +261,9 @@ class Wm::Window_registry void size(Id id, Area size) { _set_attr(id, size); } - void title(Id id, Window::Title title) { _set_attr(id, title); } + void title(Id id, Window::Title const &title) { _set_attr(id, title); } - void label(Id id, Window::Session_label label) { _set_attr(id, label); } + void label(Id id, Window::Session_label const &label) { _set_attr(id, label); } void has_alpha(Id id, bool has_alpha) { diff --git a/repos/libports/src/app/pdf_view/main.cc b/repos/libports/src/app/pdf_view/main.cc index 5974435c3b..af7c092125 100644 --- a/repos/libports/src/app/pdf_view/main.cc +++ b/repos/libports/src/app/pdf_view/main.cc @@ -269,7 +269,7 @@ class Pdf_view Genode::log(Genode::Cstring(pdfapp_version(&_pdfapp))); } - void title(char const *msg) + void title(Gui::Title const &msg) { using Command = Gui::Session::Command; _gui.enqueue(_view, msg); @@ -405,7 +405,7 @@ void winreloadfile(pdfapp_t *) void wintitle(pdfapp_t *pdfapp, char *s) { Pdf_view *pdf_view = (Pdf_view *)pdfapp->userdata; - pdf_view->title(s); + pdf_view->title((char const *)s); } diff --git a/repos/os/include/gui_session/gui_session.h b/repos/os/include/gui_session/gui_session.h index 6fe1ace2ea..c17a6150c4 100644 --- a/repos/os/include/gui_session/gui_session.h +++ b/repos/os/include/gui_session/gui_session.h @@ -39,6 +39,7 @@ namespace Gui { using View_capability = Capability; using View_id = Id_space::Id; + using Title = String<64>; using Rect = Surface_base::Rect; using Point = Surface_base::Point; using Area = Surface_base::Area; @@ -85,7 +86,7 @@ struct Gui::Session : Genode::Session struct Front_of : View_op { View_id neighbor; }; struct Behind_of : View_op { View_id neighbor; }; struct Background : View_op { }; - struct Title : View_op { String<64> title; }; + struct Title : View_op<TITLE> { Gui::Title title; }; Opcode opcode; union diff --git a/repos/os/src/server/nitpicker/gui_session.cc b/repos/os/src/server/nitpicker/gui_session.cc index 472129aeac..eae16c0e33 100644 --- a/repos/os/src/server/nitpicker/gui_session.cc +++ b/repos/os/src/server/nitpicker/gui_session.cc @@ -136,7 +136,7 @@ void Gui_session::_execute_command(Command const &command) case Command::TITLE: with_this(command.title, [&] (View &view, Command::Title const &args) { - _view_stack.title(view, args.title.string()); }); + _view_stack.title(view, args.title); }); return; case Command::NOP: diff --git a/repos/os/src/server/nitpicker/view.h b/repos/os/src/server/nitpicker/view.h index e7c7d9cecc..f1d69a7a12 100644 --- a/repos/os/src/server/nitpicker/view.h +++ b/repos/os/src/server/nitpicker/view.h @@ -65,8 +65,6 @@ class Nitpicker::View : private Same_buffer_list_elem, { public: - using Title = String<32>; - using Weak_object<View>::weak_ptr; private: diff --git a/repos/os/src/server/nitpicker/view_stack.cc b/repos/os/src/server/nitpicker/view_stack.cc index 3a2521013a..d76235655c 100644 --- a/repos/os/src/server/nitpicker/view_stack.cc +++ b/repos/os/src/server/nitpicker/view_stack.cc @@ -277,7 +277,7 @@ void View_stack::stack(View &view, View const *neighbor, bool behind) } -void View_stack::title(View &view, const char *title) +void View_stack::title(View &view, Title const &title) { view.title(_font, title); _place_labels(view.abs_geometry()); diff --git a/repos/os/src/server/nitpicker/view_stack.h b/repos/os/src/server/nitpicker/view_stack.h index c110c22f41..bc3567ca68 100644 --- a/repos/os/src/server/nitpicker/view_stack.h +++ b/repos/os/src/server/nitpicker/view_stack.h @@ -208,7 +208,7 @@ class Nitpicker::View_stack /** * Set view title */ - void title(View &view, char const *title); + void title(View &view, Title const &title); /** * Find view at specified position diff --git a/repos/os/src/test/nitpicker/main.cc b/repos/os/src/test/nitpicker/main.cc index 439c650446..b4212a2025 100644 --- a/repos/os/src/test/nitpicker/main.cc +++ b/repos/os/src/test/nitpicker/main.cc @@ -34,13 +34,11 @@ class Test::View : private List<View>::Element, Interface { public: - using Title = String<32>; - struct Attr { Gui::Point pos; Gui::Area size; - Title title; + Gui::Title title; }; private: