gui_session: definition of Gui::Title

This commit allows all GUI clients and servers to talk about the same
type.

Issue #5242
This commit is contained in:
Norman Feske 2024-08-09 10:59:49 +02:00 committed by Christian Helmuth
parent 24378ac873
commit 805e3552fd
12 changed files with 24 additions and 29 deletions

View File

@ -79,8 +79,7 @@ static long config_fb_y = 260;
/** /**
* Window title * Window title
*/ */
using Title = Genode::String<128>; static Gui::Title config_title { "Liquid Framebuffer" };
static Title config_title { "Liquid Framebuffer" };
/** /**
* Resize handle * Resize handle

View File

@ -54,7 +54,7 @@ class Decorator::Window : public Window_base
* We supply the window ID as label for the anchor view. * We supply the window ID as label for the anchor view.
*/ */
if (id) if (id)
_gui.enqueue<Command::Title>(_id, Genode::String<128>(id).string()); _gui.enqueue<Command::Title>(_id, Gui::Title { id });
} }
~Gui_view() ~Gui_view()

View File

@ -161,8 +161,7 @@ class Decorator::Window : public Window_base, public Animator::Item
* We supply the window ID as label for the anchor view. * We supply the window ID as label for the anchor view.
*/ */
if (win_id) if (win_id)
_gui.enqueue<Command::Title>(_id, _gui.enqueue<Command::Title>(_id, Gui::Title { win_id });
Genode::String<128>(win_id).string());
} }
Gui::View_id _create_remote_view(Gui::Connection &remote_gui) Gui::View_id _create_remote_view(Gui::Connection &remote_gui)

View File

@ -107,9 +107,9 @@ class Wm::Gui::View : private Genode::Weak_object<View>,
protected: protected:
using Title = Genode::String<100>; using Title = Gui::Title;
using Command = Gui::Session::Command; using Command = Gui::Session::Command;
using View_id = Gui::View_id; using View_id = Gui::View_id;
Session_label _session_label; Session_label _session_label;
Real_gui &_real_gui; Real_gui &_real_gui;
@ -144,7 +144,7 @@ class Wm::Gui::View : private Genode::Weak_object<View>,
_propagate_view_geometry(); _propagate_view_geometry();
_real_gui.enqueue<Command::Offset>(*_real_view, _buffer_offset); _real_gui.enqueue<Command::Offset>(*_real_view, _buffer_offset);
_real_gui.enqueue<Command::Title> (*_real_view, _title.string()); _real_gui.enqueue<Command::Title> (*_real_view, _title);
Constructible<View_id> real_neighbor_id { }; Constructible<View_id> real_neighbor_id { };
@ -206,9 +206,9 @@ class Wm::Gui::View : private Genode::Weak_object<View>,
} }
} }
virtual void title(char const *title) virtual void title(Title const &title)
{ {
_title = Title(title); _title = title;
if (_real_view.constructed()) { if (_real_view.constructed()) {
_real_gui.enqueue<Command::Title>(*_real_view, title); _real_gui.enqueue<Command::Title>(*_real_view, title);
@ -326,7 +326,7 @@ class Wm::Gui::Top_level_view : public View, private List<Top_level_view>::Eleme
*/ */
if (!_win_id.valid()) { if (!_win_id.valid()) {
_win_id = _window_registry.create(); _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.label(_win_id, _session_label);
_window_registry.has_alpha(_win_id, View::has_alpha()); _window_registry.has_alpha(_win_id, View::has_alpha());
_window_registry.resizeable(_win_id, _resizeable); _window_registry.resizeable(_win_id, _resizeable);
@ -339,14 +339,14 @@ class Wm::Gui::Top_level_view : public View, private List<Top_level_view>::Eleme
Area size() const { return _geometry.area; } Area size() const { return _geometry.area; }
void title(char const *title) override void title(Title const &title) override
{ {
View::title(title); View::title(title);
_window_title = Title(title); _window_title = title;
if (_win_id.valid()) 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; } bool has_win_id(Window_registry::Id id) const { return id == _win_id; }

View File

@ -61,7 +61,7 @@ class Wm::Window_registry
{ {
public: public:
using Title = Genode::String<200>; using Title = Gui::Title;
using Session_label = Genode::Session_label; using Session_label = Genode::Session_label;
enum Has_alpha { HAS_ALPHA, HAS_NO_ALPHA }; 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 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) void has_alpha(Id id, bool has_alpha)
{ {

View File

@ -269,7 +269,7 @@ class Pdf_view
Genode::log(Genode::Cstring(pdfapp_version(&_pdfapp))); Genode::log(Genode::Cstring(pdfapp_version(&_pdfapp)));
} }
void title(char const *msg) void title(Gui::Title const &msg)
{ {
using Command = Gui::Session::Command; using Command = Gui::Session::Command;
_gui.enqueue<Command::Title>(_view, msg); _gui.enqueue<Command::Title>(_view, msg);
@ -405,7 +405,7 @@ void winreloadfile(pdfapp_t *)
void wintitle(pdfapp_t *pdfapp, char *s) void wintitle(pdfapp_t *pdfapp, char *s)
{ {
Pdf_view *pdf_view = (Pdf_view *)pdfapp->userdata; Pdf_view *pdf_view = (Pdf_view *)pdfapp->userdata;
pdf_view->title(s); pdf_view->title((char const *)s);
} }

View File

@ -39,6 +39,7 @@ namespace Gui {
using View_capability = Capability<View>; using View_capability = Capability<View>;
using View_id = Id_space<View_ref>::Id; using View_id = Id_space<View_ref>::Id;
using Title = String<64>;
using Rect = Surface_base::Rect; using Rect = Surface_base::Rect;
using Point = Surface_base::Point; using Point = Surface_base::Point;
using Area = Surface_base::Area; using Area = Surface_base::Area;
@ -85,7 +86,7 @@ struct Gui::Session : Genode::Session
struct Front_of : View_op<FRONT_OF> { View_id neighbor; }; struct Front_of : View_op<FRONT_OF> { View_id neighbor; };
struct Behind_of : View_op<BEHIND_OF> { View_id neighbor; }; struct Behind_of : View_op<BEHIND_OF> { View_id neighbor; };
struct Background : View_op<BACKGROUND> { }; struct Background : View_op<BACKGROUND> { };
struct Title : View_op<TITLE> { String<64> title; }; struct Title : View_op<TITLE> { Gui::Title title; };
Opcode opcode; Opcode opcode;
union union

View File

@ -136,7 +136,7 @@ void Gui_session::_execute_command(Command const &command)
case Command::TITLE: case Command::TITLE:
with_this(command.title, [&] (View &view, Command::Title const &args) { with_this(command.title, [&] (View &view, Command::Title const &args) {
_view_stack.title(view, args.title.string()); }); _view_stack.title(view, args.title); });
return; return;
case Command::NOP: case Command::NOP:

View File

@ -65,8 +65,6 @@ class Nitpicker::View : private Same_buffer_list_elem,
{ {
public: public:
using Title = String<32>;
using Weak_object<View>::weak_ptr; using Weak_object<View>::weak_ptr;
private: private:

View File

@ -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); view.title(_font, title);
_place_labels(view.abs_geometry()); _place_labels(view.abs_geometry());

View File

@ -208,7 +208,7 @@ class Nitpicker::View_stack
/** /**
* Set view title * Set view title
*/ */
void title(View &view, char const *title); void title(View &view, Title const &title);
/** /**
* Find view at specified position * Find view at specified position

View File

@ -34,13 +34,11 @@ class Test::View : private List<View>::Element, Interface
{ {
public: public:
using Title = String<32>;
struct Attr struct Attr
{ {
Gui::Point pos; Gui::Point pos;
Gui::Area size; Gui::Area size;
Title title; Gui::Title title;
}; };
private: private: