diff --git a/repos/gems/src/app/sculpt_manager/gui.cc b/repos/gems/src/app/sculpt_manager/gui.cc index ec7253aa5e..759e5f4a07 100644 --- a/repos/gems/src/app/sculpt_manager/gui.cc +++ b/repos/gems/src/app/sculpt_manager/gui.cc @@ -150,7 +150,7 @@ struct Gui::Session_component : Rpc_object * Do not call 'Connection::buffer' to avoid paying session quota * from our own budget. */ - _connection.Client::buffer(mode, use_alpha); + _connection.Session_client::buffer(mode, use_alpha); } void focus(Capability session) override { diff --git a/repos/gems/src/lib/dialog/sandboxed_runtime.cc b/repos/gems/src/lib/dialog/sandboxed_runtime.cc index 072da517ca..cf62dba3a0 100644 --- a/repos/gems/src/lib/dialog/sandboxed_runtime.cc +++ b/repos/gems/src/lib/dialog/sandboxed_runtime.cc @@ -154,7 +154,7 @@ struct Sandboxed_runtime::Gui_session : Session_object * Do not call 'Connection::buffer' to avoid paying session quota * from our own budget. */ - _connection.Client::buffer(mode, use_alpha); + _connection.Session_client::buffer(mode, use_alpha); } void focus(Capability session) override { diff --git a/repos/gems/src/server/wm/gui.h b/repos/gems/src/server/wm/gui.h index 69f02ac38e..a08f9a2d82 100644 --- a/repos/gems/src/server/wm/gui.h +++ b/repos/gems/src/server/wm/gui.h @@ -1061,7 +1061,7 @@ class Wm::Gui::Session_component : public Rpc_object, }; -class Wm::Gui::Root : public Genode::Rpc_object >, +class Wm::Gui::Root : public Genode::Rpc_object >, public Decorator_content_callback { private: @@ -1247,7 +1247,7 @@ class Wm::Gui::Root : public Genode::Rpc_object >, } } - return Session_capability(); + return { }; } void upgrade(Genode::Session_capability session_cap, Upgrade_args const &args) override @@ -1395,13 +1395,13 @@ class Wm::Gui::Root : public Genode::Rpc_object >, s->content_geometry(id, rect); } - Capability lookup_gui_session(unsigned win_id) + Capability lookup_gui_session(unsigned win_id) { for (Session_component *s = _sessions.first(); s; s = s->next()) if (s->has_win_id(win_id)) return s->session(); - return Capability(); + return { }; } void request_resize(unsigned win_id, Area size) diff --git a/repos/libports/src/app/pdf_view/main.cc b/repos/libports/src/app/pdf_view/main.cc index ab0f27550b..12cc868a7e 100644 --- a/repos/libports/src/app/pdf_view/main.cc +++ b/repos/libports/src/app/pdf_view/main.cc @@ -143,7 +143,7 @@ class Pdf_view _nit_mode.area.h/4); typedef Gui::Session::Command Command; - _gui.enqueue(_view, Rect(Point(), _nit_mode.area)); + _gui.enqueue(_view, Gui::Rect(Gui::Point(), _nit_mode.area)); _gui.enqueue(_view, Gui::Session::View_handle()); _gui.execute(); } diff --git a/repos/os/include/gui_session/client.h b/repos/os/include/gui_session/client.h index 3c32151671..a2b9f3da49 100644 --- a/repos/os/include/gui_session/client.h +++ b/repos/os/include/gui_session/client.h @@ -21,11 +21,11 @@ namespace Gui { struct Session_client; } -class Gui::Session_client : public Genode::Rpc_client +class Gui::Session_client : public Rpc_client { private: - Genode::Attached_dataspace _command_ds; + Attached_dataspace _command_ds; Command_buffer &_command_buffer; @@ -34,7 +34,7 @@ class Gui::Session_client : public Genode::Rpc_client /** * Constructor */ - Session_client(Genode::Region_map &rm, Session_capability session) + Session_client(Region_map &rm, Session_capability session) : Rpc_client(session), _command_ds(rm, command_dataspace()), @@ -65,7 +65,7 @@ class Gui::Session_client : public Genode::Rpc_client void release_view_handle(View_handle handle) override { call(handle); } - Genode::Dataspace_capability command_dataspace() override { + Dataspace_capability command_dataspace() override { return call(); } void execute() override @@ -77,7 +77,7 @@ class Gui::Session_client : public Genode::Rpc_client Framebuffer::Mode mode() override { return call(); } - void mode_sigh(Genode::Signal_context_capability sigh) override { + void mode_sigh(Signal_context_capability sigh) override { call(sigh); } void buffer(Framebuffer::Mode mode, bool alpha) override { diff --git a/repos/os/include/gui_session/connection.h b/repos/os/include/gui_session/connection.h index 289a9e38b3..7e641dd53b 100644 --- a/repos/os/include/gui_session/connection.h +++ b/repos/os/include/gui_session/connection.h @@ -29,14 +29,14 @@ class Gui::Connection : public Genode::Connection, Framebuffer::Session_client _framebuffer; Input::Session_client _input; - Genode::size_t _session_quota = 0; + size_t _session_quota = 0; public: /** * Constructor */ - Connection(Genode::Env &env, Label const &label = Label()) + Connection(Env &env, Label const &label = Label()) : /* establish nitpicker session */ Genode::Connection(env, label, Ram_quota { 36*1024 }, Args()), @@ -49,8 +49,8 @@ class Gui::Connection : public Genode::Connection, void buffer(Framebuffer::Mode mode, bool use_alpha) override { - Genode::size_t const needed = ram_quota(mode, use_alpha); - Genode::size_t const upgrade = needed > _session_quota + size_t const needed = ram_quota(mode, use_alpha); + size_t const upgrade = needed > _session_quota ? needed - _session_quota : 0; if (upgrade > 0) { diff --git a/repos/os/include/gui_session/gui_session.h b/repos/os/include/gui_session/gui_session.h index 6a7f5809bd..9a4e544b7f 100644 --- a/repos/os/include/gui_session/gui_session.h +++ b/repos/os/include/gui_session/gui_session.h @@ -22,20 +22,17 @@ namespace Gui { - using Genode::size_t; + using namespace Genode; struct Session_client; struct View; struct Session; - typedef Genode::Capability View_capability; + using View_capability = Capability; - typedef Genode::Surface_base::Rect Rect; - typedef Genode::Surface_base::Point Point; - typedef Genode::Surface_base::Area Area; - - typedef Genode::Out_of_ram Out_of_ram; - typedef Genode::Out_of_caps Out_of_caps; + using Rect = Surface_base::Rect; + using Point = Surface_base::Point; + using Area = Surface_base::Area; } @@ -55,15 +52,13 @@ struct Gui::Session : Genode::Session static constexpr unsigned CAP_QUOTA = Framebuffer::Session::CAP_QUOTA + Input::Session::CAP_QUOTA + 3; - typedef Session_client Client; - /** * Session-local view handle * * When issuing commands to nitpicker via the 'execute' method, views * are referenced by session-local handles. */ - typedef Genode::Handle View_handle; + using View_handle = Handle; struct Command @@ -72,10 +67,6 @@ struct Gui::Session : Genode::Session OP_TO_FRONT, OP_TO_BACK, OP_BACKGROUND, OP_TITLE, OP_NOP }; - /* - * Argument structures for nitpicker's command interface - */ - struct Nop { static Opcode opcode() { return OP_NOP; } }; struct Geometry @@ -116,7 +107,7 @@ struct Gui::Session : Genode::Session { static Opcode opcode() { return OP_TITLE; } View_handle view; - Genode::String<64> title; + String<64> title; }; Opcode opcode; @@ -183,17 +174,14 @@ struct Gui::Session : Genode::Session Command get(unsigned i) { - if (i >= MAX_COMMANDS) return Command(Command::Nop()); - - return _commands[i]; + return (i < MAX_COMMANDS) ? _commands[i] : Command(Command::Nop()); } - }; /** * Exception types */ - struct Invalid_handle : Genode::Exception { }; + struct Invalid_handle : Exception { }; virtual ~Session() { } @@ -258,7 +246,7 @@ struct Gui::Session : Genode::Session /** * Request dataspace used for issuing view commands to nitpicker */ - virtual Genode::Dataspace_capability command_dataspace() = 0; + virtual Dataspace_capability command_dataspace() = 0; /** * Execution batch of commands contained in the command dataspace @@ -273,7 +261,7 @@ struct Gui::Session : Genode::Session /** * Register signal handler to be notified about mode changes */ - virtual void mode_sigh(Genode::Signal_context_capability) = 0; + virtual void mode_sigh(Signal_context_capability) = 0; /** * Define dimensions of virtual framebuffer @@ -297,9 +285,7 @@ struct Gui::Session : Genode::Session * referred to by its session capability, a common parent can manage the * focus among its children. But unrelated sessions cannot interfere. */ - virtual void focus(Genode::Capability focused) = 0; - - typedef Genode::String<160> Label; + virtual void focus(Capability focused) = 0; /** * Return number of bytes needed for virtual framebuffer of specified size @@ -327,12 +313,12 @@ struct Gui::Session : Genode::Session GENODE_TYPE_LIST(Out_of_ram, Out_of_caps), View_capability, View_handle); GENODE_RPC(Rpc_view_capability, View_capability, view_capability, View_handle); GENODE_RPC(Rpc_release_view_handle, void, release_view_handle, View_handle); - GENODE_RPC(Rpc_command_dataspace, Genode::Dataspace_capability, command_dataspace); + GENODE_RPC(Rpc_command_dataspace, Dataspace_capability, command_dataspace); GENODE_RPC(Rpc_execute, void, execute); GENODE_RPC(Rpc_background, int, background, View_capability); GENODE_RPC(Rpc_mode, Framebuffer::Mode, mode); - GENODE_RPC(Rpc_mode_sigh, void, mode_sigh, Genode::Signal_context_capability); - GENODE_RPC(Rpc_focus, void, focus, Genode::Capability); + GENODE_RPC(Rpc_mode_sigh, void, mode_sigh, Signal_context_capability); + GENODE_RPC(Rpc_focus, void, focus, Capability); GENODE_RPC_THROW(Rpc_buffer, void, buffer, GENODE_TYPE_LIST(Out_of_ram, Out_of_caps), Framebuffer::Mode, bool); diff --git a/repos/os/src/server/nitpicker/background.h b/repos/os/src/server/nitpicker/background.h index 1c7e5c317b..bb38e779c6 100644 --- a/repos/os/src/server/nitpicker/background.h +++ b/repos/os/src/server/nitpicker/background.h @@ -16,8 +16,8 @@ #include -#include "gui_session.h" -#include "clip_guard.h" +#include +#include namespace Nitpicker { struct Background; } @@ -37,7 +37,7 @@ struct Nitpicker::Background : private Texture_base, View Background(View_owner &owner, Area size) : Texture_base(Area(0, 0)), - View(owner, _texture, View::NOT_TRANSPARENT, View::BACKGROUND, 0) + View(owner, _texture, { .transparent = false, .background = true }, 0) { View::geometry(Rect(Point(0, 0), size)); } diff --git a/repos/os/src/server/nitpicker/buffer.h b/repos/os/src/server/nitpicker/buffer.h index 71ff17b896..e6c0d4bf33 100644 --- a/repos/os/src/server/nitpicker/buffer.h +++ b/repos/os/src/server/nitpicker/buffer.h @@ -19,7 +19,7 @@ #include /* local includes */ -#include "types.h" +#include namespace Nitpicker { class Buffer; } diff --git a/repos/os/src/server/nitpicker/canvas.h b/repos/os/src/server/nitpicker/canvas.h index 7da3294da6..78adbb34c0 100644 --- a/repos/os/src/server/nitpicker/canvas.h +++ b/repos/os/src/server/nitpicker/canvas.h @@ -19,13 +19,13 @@ #include /* local includes */ -#include "types.h" +#include namespace Nitpicker { struct Canvas_base; template class Canvas; - typedef Text_painter::Font Font; + using Font = Text_painter::Font; } diff --git a/repos/os/src/server/nitpicker/chunky_texture.h b/repos/os/src/server/nitpicker/chunky_texture.h index 9e637fdc58..6b39d4c274 100644 --- a/repos/os/src/server/nitpicker/chunky_texture.h +++ b/repos/os/src/server/nitpicker/chunky_texture.h @@ -15,7 +15,7 @@ #define _CHUNKY_TEXTURE_H_ /* local includes */ -#include "buffer.h" +#include namespace Nitpicker { template class Chunky_texture; } diff --git a/repos/os/src/server/nitpicker/clip_guard.h b/repos/os/src/server/nitpicker/clip_guard.h index 27c4b541f6..2e3f0b1e2a 100644 --- a/repos/os/src/server/nitpicker/clip_guard.h +++ b/repos/os/src/server/nitpicker/clip_guard.h @@ -28,7 +28,7 @@ #ifndef _CLIP_GUARD_H_ #define _CLIP_GUARD_H_ -#include "canvas.h" +#include namespace Nitpicker { class Clip_guard; } diff --git a/repos/os/src/server/nitpicker/domain_registry.h b/repos/os/src/server/nitpicker/domain_registry.h index d1af325b9f..3d20ce40cf 100644 --- a/repos/os/src/server/nitpicker/domain_registry.h +++ b/repos/os/src/server/nitpicker/domain_registry.h @@ -14,7 +14,7 @@ #ifndef _DOMAIN_REGISTRY_ #define _DOMAIN_REGISTRY_ -#include "types.h" +#include namespace Nitpicker { class Domain_registry; } @@ -27,22 +27,18 @@ class Nitpicker::Domain_registry { public: - typedef String<64> Name; + using Name = String<64>; - enum Label { LABEL_NO, LABEL_YES }; - enum Content { CONTENT_CLIENT, CONTENT_TINTED }; - enum Hover { HOVER_FOCUSED, HOVER_ALWAYS }; - enum Focus { FOCUS_NONE, FOCUS_CLICK, FOCUS_TRANSIENT }; + enum class Label { NO, YES }; + enum class Content { CLIENT, TINTED }; + enum class Hover { FOCUSED, ALWAYS }; + enum class Focus { NONE, CLICK, TRANSIENT }; /** * Origin of the domain's coordiate system */ - enum Origin { - ORIGIN_POINTER, - ORIGIN_TOP_LEFT, - ORIGIN_TOP_RIGHT, - ORIGIN_BOTTOM_LEFT, - ORIGIN_BOTTOM_RIGHT }; + enum class Origin { POINTER, TOP_LEFT, TOP_RIGHT, + BOTTOM_LEFT, BOTTOM_RIGHT }; private: @@ -71,12 +67,12 @@ class Nitpicker::Domain_registry Point _corner(Area const screen_area) const { switch (_origin) { - case ORIGIN_POINTER: return Point(0, 0); - case ORIGIN_TOP_LEFT: return Point(0, 0); - case ORIGIN_TOP_RIGHT: return Point(screen_area.w, 0); - case ORIGIN_BOTTOM_LEFT: return Point(0, screen_area.h); - case ORIGIN_BOTTOM_RIGHT: return Point(screen_area.w, - screen_area.h); + case Origin::POINTER: return Point(0, 0); + case Origin::TOP_LEFT: return Point(0, 0); + case Origin::TOP_RIGHT: return Point(screen_area.w, 0); + case Origin::BOTTOM_LEFT: return Point(0, screen_area.h); + case Origin::BOTTOM_RIGHT: return Point(screen_area.w, + screen_area.h); } return Point(0, 0); } @@ -91,13 +87,13 @@ class Nitpicker::Domain_registry Content content() const { return _content; } Hover hover() const { return _hover; } - bool label_visible() const { return _label == LABEL_YES; } - bool content_client() const { return _content == CONTENT_CLIENT; } - bool hover_focused() const { return _hover == HOVER_FOCUSED; } - bool hover_always() const { return _hover == HOVER_ALWAYS; } - bool focus_click() const { return _focus == FOCUS_CLICK; } - bool focus_transient() const { return _focus == FOCUS_TRANSIENT; } - bool origin_pointer() const { return _origin == ORIGIN_POINTER; } + bool label_visible() const { return _label == Label::YES; } + bool content_client() const { return _content == Content::CLIENT; } + bool hover_focused() const { return _hover == Hover::FOCUSED; } + bool hover_always() const { return _hover == Hover::ALWAYS; } + bool focus_click() const { return _focus == Focus::CLICK; } + bool focus_transient() const { return _focus == Focus::TRANSIENT; } + bool origin_pointer() const { return _origin == Origin::POINTER; } Point phys_pos(Point pos, Area screen_area) const { @@ -120,65 +116,65 @@ class Nitpicker::Domain_registry static Entry::Label _label(Xml_node domain) { - typedef String<32> Value; + using Value = String<32>; Value const value = domain.attribute_value("label", Value("yes")); - if (value == "no") return Entry::LABEL_NO; - if (value == "yes") return Entry::LABEL_YES; + if (value == "no") return Entry::Label::NO; + if (value == "yes") return Entry::Label::YES; warning("invalid value of label attribute in "); - return Entry::LABEL_YES; + return Entry::Label::YES; } static Entry::Content _content(Xml_node domain) { - typedef String<32> Value; + using Value = String<32>; Value const value = domain.attribute_value("content", Value("tinted")); - if (value == "client") return Entry::CONTENT_CLIENT; - if (value == "tinted") return Entry::CONTENT_TINTED; + if (value == "client") return Entry::Content::CLIENT; + if (value == "tinted") return Entry::Content::TINTED; - return Entry::CONTENT_TINTED; + return Entry::Content::TINTED; } static Entry::Hover _hover(Xml_node domain) { - typedef String<32> Value; + using Value = String<32>; Value const value = domain.attribute_value("hover", Value("focused")); - if (value == "focused") return Entry::HOVER_FOCUSED; - if (value == "always") return Entry::HOVER_ALWAYS; + if (value == "focused") return Entry::Hover::FOCUSED; + if (value == "always") return Entry::Hover::ALWAYS; warning("invalid value of hover attribute in "); - return Entry::HOVER_FOCUSED; + return Entry::Hover::FOCUSED; } static Entry::Focus _focus(Xml_node domain) { - typedef String<32> Value; + using Value = String<32>; Value const value = domain.attribute_value("focus", Value("none")); - if (value == "none") return Entry::FOCUS_NONE; - if (value == "click") return Entry::FOCUS_CLICK; - if (value == "transient") return Entry::FOCUS_TRANSIENT; + if (value == "none") return Entry::Focus::NONE; + if (value == "click") return Entry::Focus::CLICK; + if (value == "transient") return Entry::Focus::TRANSIENT; warning("invalid value of focus attribute in "); - return Entry::FOCUS_NONE; + return Entry::Focus::NONE; } static Entry::Origin _origin(Xml_node domain) { - typedef String<32> Value; + using Value = String<32>; Value const value = domain.attribute_value("origin", Value("top_left")); - if (value == "top_left") return Entry::ORIGIN_TOP_LEFT; - if (value == "top_right") return Entry::ORIGIN_TOP_RIGHT; - if (value == "bottom_left") return Entry::ORIGIN_BOTTOM_LEFT; - if (value == "bottom_right") return Entry::ORIGIN_BOTTOM_RIGHT; - if (value == "pointer") return Entry::ORIGIN_POINTER; + if (value == "top_left") return Entry::Origin::TOP_LEFT; + if (value == "top_right") return Entry::Origin::TOP_RIGHT; + if (value == "bottom_left") return Entry::Origin::BOTTOM_LEFT; + if (value == "bottom_right") return Entry::Origin::BOTTOM_RIGHT; + if (value == "pointer") return Entry::Origin::POINTER; warning("invalid value of origin attribute in "); - return Entry::ORIGIN_BOTTOM_LEFT; + return Entry::Origin::BOTTOM_LEFT; } void _insert(Xml_node domain) @@ -200,13 +196,13 @@ class Nitpicker::Domain_registry return; } - unsigned const layer = (unsigned)domain.attribute_value("layer", ~0UL); + unsigned const layer = domain.attribute_value("layer", ~0U); - Point const offset((int)domain.attribute_value("xpos", 0L), - (int)domain.attribute_value("ypos", 0L)); + Point const offset(domain.attribute_value("xpos", 0), + domain.attribute_value("ypos", 0)); - Point const area((int)domain.attribute_value("width", 0L), - (int)domain.attribute_value("height", 0L)); + Point const area(domain.attribute_value("width", 0), + domain.attribute_value("height", 0)); Color const color = domain.attribute_value("color", white()); diff --git a/repos/os/src/server/nitpicker/draw_label.h b/repos/os/src/server/nitpicker/draw_label.h index bbe0bc952e..6c9e6c05ae 100644 --- a/repos/os/src/server/nitpicker/draw_label.h +++ b/repos/os/src/server/nitpicker/draw_label.h @@ -14,8 +14,8 @@ #ifndef _DRAW_LABEL_H_ #define _DRAW_LABEL_H_ -#include "canvas.h" -#include "types.h" +#include +#include namespace Nitpicker { diff --git a/repos/os/src/server/nitpicker/event_session.h b/repos/os/src/server/nitpicker/event_session.h index 62bf303d9b..7fe50a2f45 100644 --- a/repos/os/src/server/nitpicker/event_session.h +++ b/repos/os/src/server/nitpicker/event_session.h @@ -19,7 +19,7 @@ #include /* local includes */ -#include "user_state.h" +#include namespace Nitpicker { class Event_session; } diff --git a/repos/os/src/server/nitpicker/focus.h b/repos/os/src/server/nitpicker/focus.h index 6aad016bb9..fa6f731b62 100644 --- a/repos/os/src/server/nitpicker/focus.h +++ b/repos/os/src/server/nitpicker/focus.h @@ -14,8 +14,8 @@ #ifndef _FOCUS_H_ #define _FOCUS_H_ -#include "types.h" -#include "view.h" +#include +#include namespace Nitpicker { struct Focus; diff --git a/repos/os/src/server/nitpicker/framebuffer_session.h b/repos/os/src/server/nitpicker/framebuffer_session.h index a1d03fa1cf..bc6a0e6ec8 100644 --- a/repos/os/src/server/nitpicker/framebuffer_session.h +++ b/repos/os/src/server/nitpicker/framebuffer_session.h @@ -15,7 +15,7 @@ #define _FRAMEBUFFER_SESSION_COMPONENT_H_ /* local includes */ -#include "buffer.h" +#include namespace Framebuffer { diff --git a/repos/os/src/server/nitpicker/global_keys.cc b/repos/os/src/server/nitpicker/global_keys.cc index 4ecb7c6a8f..e318cfec5b 100644 --- a/repos/os/src/server/nitpicker/global_keys.cc +++ b/repos/os/src/server/nitpicker/global_keys.cc @@ -12,7 +12,7 @@ */ /* local includes */ -#include "global_keys.h" +#include using namespace Nitpicker; @@ -44,7 +44,7 @@ void Global_keys::apply_config(Xml_node config, Session_list &session_list) continue; } - typedef String<32> Name; + using Name = String<32>; Name name = node.attribute_value("name", Name()); Policy * policy = _lookup_policy(name.string()); if (!policy) { diff --git a/repos/os/src/server/nitpicker/global_keys.h b/repos/os/src/server/nitpicker/global_keys.h index eb45dc6911..b6910e7926 100644 --- a/repos/os/src/server/nitpicker/global_keys.h +++ b/repos/os/src/server/nitpicker/global_keys.h @@ -18,7 +18,7 @@ #include /* local includes */ -#include "gui_session.h" +#include namespace Nitpicker { class Global_keys; } diff --git a/repos/os/src/server/nitpicker/gui_session.cc b/repos/os/src/server/nitpicker/gui_session.cc index 9b78fefbc4..b7453249d0 100644 --- a/repos/os/src/server/nitpicker/gui_session.cc +++ b/repos/os/src/server/nitpicker/gui_session.cc @@ -11,7 +11,7 @@ * under the terms of the GNU Affero General Public License version 3. */ -#include "view_stack.h" +#include using namespace Nitpicker; @@ -246,7 +246,7 @@ Gui_session::View_handle Gui_session::create_view(View_handle parent_handle) return View_handle(); view = new (_view_alloc) - View(*this, _texture, View::NOT_TRANSPARENT, View::NOT_BACKGROUND, &(*parent)); + View(*this, _texture, { .transparent = false, .background = false }, &(*parent)); parent->add_child(*view); } @@ -260,7 +260,7 @@ Gui_session::View_handle Gui_session::create_view(View_handle parent_handle) else { try { view = new (_view_alloc) - View(*this, _texture, View::NOT_TRANSPARENT, View::NOT_BACKGROUND, nullptr); + View(*this, _texture, { .transparent = false, .background = false }, nullptr); } catch (Allocator::Out_of_memory) { throw Out_of_ram(); } } @@ -292,7 +292,7 @@ void Gui_session::apply_session_policy(Xml_node config, return; } - typedef Domain_registry::Entry::Name Name; + using Name = Domain_registry::Entry::Name; Name const name = policy.attribute_value("domain", Name()); diff --git a/repos/os/src/server/nitpicker/gui_session.h b/repos/os/src/server/nitpicker/gui_session.h index 1492f8a9e7..49b53032c2 100644 --- a/repos/os/src/server/nitpicker/gui_session.h +++ b/repos/os/src/server/nitpicker/gui_session.h @@ -25,19 +25,19 @@ #include /* local includes */ -#include "canvas.h" -#include "domain_registry.h" -#include "framebuffer_session.h" -#include "input_session.h" -#include "focus.h" -#include "view.h" +#include +#include +#include +#include +#include +#include namespace Nitpicker { class Gui_session; class View; - typedef List Session_list; + using Session_list = List; } @@ -122,7 +122,7 @@ class Nitpicker::Gui_session : public Session_object, Command_buffer &_command_buffer = *_command_ds.local_addr(); - typedef Handle_registry View_handle_registry; + using View_handle_registry = Handle_registry; View_handle_registry _view_handle_registry; diff --git a/repos/os/src/server/nitpicker/input_session.h b/repos/os/src/server/nitpicker/input_session.h index 8c550e1ebf..02712db8d0 100644 --- a/repos/os/src/server/nitpicker/input_session.h +++ b/repos/os/src/server/nitpicker/input_session.h @@ -20,7 +20,7 @@ #include /* local incudes */ -#include "types.h" +#include namespace Input { using namespace Nitpicker; diff --git a/repos/os/src/server/nitpicker/main.cc b/repos/os/src/server/nitpicker/main.cc index 449dc9c40f..36f099d7b7 100644 --- a/repos/os/src/server/nitpicker/main.cc +++ b/repos/os/src/server/nitpicker/main.cc @@ -26,14 +26,14 @@ #include /* local includes */ -#include "types.h" -#include "user_state.h" -#include "background.h" -#include "clip_guard.h" -#include "pointer_origin.h" -#include "domain_registry.h" -#include "capture_session.h" -#include "event_session.h" +#include +#include +#include +#include +#include +#include +#include +#include namespace Nitpicker { class Gui_root; @@ -359,7 +359,7 @@ struct Nitpicker::Main : Focus_updater, Hover_updater, Constructible _input { }; - typedef Pixel_rgb888 PT; /* physical pixel type */ + using PT = Pixel_rgb888; /* physical pixel type */ /* * Initialize framebuffer @@ -379,7 +379,7 @@ struct Nitpicker::Main : Focus_updater, Hover_updater, Area size = screen.size(); - typedef Genode::Dirty_rect Dirty_rect; + using Dirty_rect = Genode::Dirty_rect; Dirty_rect dirty_rect { }; @@ -791,7 +791,7 @@ void Nitpicker::Main::_handle_focus() _focus_rom->update(); - typedef Gui::Session::Label Label; + using Label = String<160>; Label const label = _focus_rom->xml().attribute_value("label", Label()); /* diff --git a/repos/os/src/server/nitpicker/pointer_origin.h b/repos/os/src/server/nitpicker/pointer_origin.h index 409cdea300..140b3792c8 100644 --- a/repos/os/src/server/nitpicker/pointer_origin.h +++ b/repos/os/src/server/nitpicker/pointer_origin.h @@ -14,8 +14,8 @@ #ifndef _POINTER_ORIGIN_H_ #define _POINTER_ORIGIN_H_ -#include "view.h" -#include "gui_session.h" +#include +#include namespace Nitpicker { struct Pointer_origin; } @@ -26,7 +26,7 @@ struct Nitpicker::Pointer_origin : View Pointer_origin(View_owner &owner) : - View(owner, _texture, View::TRANSPARENT, View::NOT_BACKGROUND, 0) + View(owner, _texture, { .transparent = true, .background = false }, 0) { } diff --git a/repos/os/src/server/nitpicker/resizeable_texture.h b/repos/os/src/server/nitpicker/resizeable_texture.h index 942d22a841..f5b7436cbf 100644 --- a/repos/os/src/server/nitpicker/resizeable_texture.h +++ b/repos/os/src/server/nitpicker/resizeable_texture.h @@ -19,7 +19,7 @@ #include /* local includes */ -#include "chunky_texture.h" +#include namespace Nitpicker { template class Resizeable_texture; } @@ -85,7 +85,7 @@ class Nitpicker::Resizeable_texture /* copy alpha channel */ if (_textures[_current]->alpha() && _textures[next]->alpha()) { - typedef Pixel_alpha8 AT; + using AT = Pixel_alpha8; Surface surface((AT *)_textures[next]->alpha(), _textures[next]->Texture_base::size()); diff --git a/repos/os/src/server/nitpicker/target.mk b/repos/os/src/server/nitpicker/target.mk index 0cb3be8128..32ce26f960 100644 --- a/repos/os/src/server/nitpicker/target.mk +++ b/repos/os/src/server/nitpicker/target.mk @@ -2,3 +2,4 @@ TARGET = nitpicker LIBS = base blit SRC_CC = $(notdir $(wildcard $(PRG_DIR)/*.cc)) SRC_BIN = default.tff +INC_DIR += $(PRG_DIR) diff --git a/repos/os/src/server/nitpicker/types.h b/repos/os/src/server/nitpicker/types.h index defd1890b0..c23723a6fd 100644 --- a/repos/os/src/server/nitpicker/types.h +++ b/repos/os/src/server/nitpicker/types.h @@ -18,21 +18,18 @@ #include #include #include -#include -#include #include - -namespace Gui { } +#include namespace Nitpicker { - using namespace Genode; using namespace Gui; + using Pixel = Pixel_rgb888; - typedef Surface_base::Point Point; - typedef Surface_base::Area Area; - typedef Surface_base::Rect Rect; + using Point = Gui::Point; + using Area = Gui::Area; + using Rect = Gui::Rect; static constexpr Color white() { return Color::rgb(255, 255, 255); } diff --git a/repos/os/src/server/nitpicker/user_state.cc b/repos/os/src/server/nitpicker/user_state.cc index fad6d14083..e36e0c01d2 100644 --- a/repos/os/src/server/nitpicker/user_state.cc +++ b/repos/os/src/server/nitpicker/user_state.cc @@ -14,7 +14,7 @@ #include #include -#include "user_state.h" +#include using namespace Input; diff --git a/repos/os/src/server/nitpicker/user_state.h b/repos/os/src/server/nitpicker/user_state.h index ed23ae2582..821017f027 100644 --- a/repos/os/src/server/nitpicker/user_state.h +++ b/repos/os/src/server/nitpicker/user_state.h @@ -20,9 +20,9 @@ #include -#include "focus.h" -#include "view_stack.h" -#include "global_keys.h" +#include +#include +#include namespace Nitpicker { class User_state; } @@ -150,7 +150,7 @@ class Nitpicker::User_state return (key <= Input::KEY_MAX) && _states[key].pressed; } - void report_state(Genode::Xml_generator &xml) const + void report_state(Xml_generator &xml) const { for (unsigned i = 0; i <= Input::KEY_MAX; i++) if (_states[i].pressed) diff --git a/repos/os/src/server/nitpicker/view.cc b/repos/os/src/server/nitpicker/view.cc index 4d6e989a13..1a580886cd 100644 --- a/repos/os/src/server/nitpicker/view.cc +++ b/repos/os/src/server/nitpicker/view.cc @@ -16,10 +16,10 @@ #include #include -#include "view.h" -#include "clip_guard.h" -#include "gui_session.h" -#include "draw_label.h" +#include +#include +#include +#include /*************** diff --git a/repos/os/src/server/nitpicker/view.h b/repos/os/src/server/nitpicker/view.h index 2d19074f8a..03b2c09550 100644 --- a/repos/os/src/server/nitpicker/view.h +++ b/repos/os/src/server/nitpicker/view.h @@ -21,9 +21,9 @@ #include /* local includes */ -#include "canvas.h" -#include "view_owner.h" -#include "resizeable_texture.h" +#include +#include +#include namespace Nitpicker { @@ -60,7 +60,7 @@ namespace Gui { * We use view capabilities as mere tokens to pass views between sessions. * There is no RPC interface associated with a view. */ - struct View : Genode::Interface { GENODE_RPC_INTERFACE(); }; + struct View : Interface { GENODE_RPC_INTERFACE(); }; } @@ -73,10 +73,7 @@ class Nitpicker::View : private Same_buffer_list_elem, { public: - typedef String<32> Title; - - enum Transparent { NOT_TRANSPARENT = 0, TRANSPARENT = 1 }; - enum Background { NOT_BACKGROUND = 0, BACKGROUND = 1 }; + using Title = String<32>; using Weak_object::weak_ptr; using Weak_object::weak_ptr_const; @@ -93,8 +90,8 @@ class Nitpicker::View : private Same_buffer_list_elem, View(View const &); View &operator = (View const &); - Transparent const _transparent; /* background is partly visible */ - Background _background; /* view is a background view */ + bool const _transparent; /* background is partly visible */ + bool _background; /* view is a background view */ View *_parent; /* parent view */ Rect _geometry { }; /* position and size relative to parent */ @@ -130,11 +127,13 @@ class Nitpicker::View : private Same_buffer_list_elem, public: + struct Attr { bool transparent, background; }; + View(View_owner &owner, Resizeable_texture const &texture, - Transparent transparent, Background bg, View *parent) + Attr attr, View *parent) : - _transparent(transparent), _background(bg), _parent(parent), - _owner(owner), _texture(texture) + _transparent(attr.transparent), _background(attr.background), + _parent(parent), _owner(owner), _texture(texture) { } virtual ~View() @@ -239,8 +238,7 @@ class Nitpicker::View : private Same_buffer_list_elem, * * \param bg true if view is background */ - void background(bool bg) { - _background = bg ? BACKGROUND : NOT_BACKGROUND; } + void background(bool bg) { _background = bg; } /** * Accessors diff --git a/repos/os/src/server/nitpicker/view_owner.h b/repos/os/src/server/nitpicker/view_owner.h index fa30d4a198..81b57609bc 100644 --- a/repos/os/src/server/nitpicker/view_owner.h +++ b/repos/os/src/server/nitpicker/view_owner.h @@ -26,7 +26,7 @@ #include /* local includes */ -#include "types.h" +#include namespace Nitpicker { class View_owner; } diff --git a/repos/os/src/server/nitpicker/view_stack.cc b/repos/os/src/server/nitpicker/view_stack.cc index b8f439ca87..3a2521013a 100644 --- a/repos/os/src/server/nitpicker/view_stack.cc +++ b/repos/os/src/server/nitpicker/view_stack.cc @@ -11,8 +11,8 @@ * under the terms of the GNU Affero General Public License version 3. */ -#include "view_stack.h" -#include "clip_guard.h" +#include +#include using namespace Nitpicker; @@ -314,7 +314,7 @@ void View_stack::remove_view(View const &view, bool /* redraw */) void View_stack::sort_views_by_layer() { - Genode::List sorted; + List sorted; /* last element of the sorted list */ View_stack_elem *at = nullptr; diff --git a/repos/os/src/server/nitpicker/view_stack.h b/repos/os/src/server/nitpicker/view_stack.h index 5b3543a4c1..c110c22f41 100644 --- a/repos/os/src/server/nitpicker/view_stack.h +++ b/repos/os/src/server/nitpicker/view_stack.h @@ -14,9 +14,9 @@ #ifndef _VIEW_STACK_H_ #define _VIEW_STACK_H_ -#include "view.h" -#include "gui_session.h" -#include "canvas.h" +#include +#include +#include namespace Nitpicker { class View_stack; } diff --git a/repos/os/src/test/nitpicker/main.cc b/repos/os/src/test/nitpicker/main.cc new file mode 100644 index 0000000000..11f828f7c5 --- /dev/null +++ b/repos/os/src/test/nitpicker/main.cc @@ -0,0 +1,323 @@ +/* + * \brief Nitpicker test program + * \author Norman Feske + * \date 2006-08-23 + */ + +/* + * Copyright (C) 2006-2017 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU Affero General Public License version 3. + */ + +#include +#include +#include +#include +#include +#include + +namespace Test { + + using namespace Genode; + + class View; + struct Top_level_view; + struct Child_view; + class View_stack; + struct Main; +} + + +class Test::View : private List::Element, Interface +{ + public: + + using Title = String<32>; + + struct Attr + { + Gui::Point pos; + Gui::Area size; + Title title; + }; + + private: + + friend class View_stack; + friend class List; + + using View_handle = Gui::Session::View_handle; + using Command = Gui::Session::Command; + + Gui::Connection &_gui; + View_handle const _handle; + Attr const _attr; + Gui::Point _pos = _attr.pos; + + public: + + View(Gui::Connection &gui, Attr const attr, auto const &create_fn) + : + _gui(gui), _handle(create_fn()), _attr(attr) + { + using namespace Gui; + + _gui.enqueue(_handle, Gui::Rect { _pos, _attr.size }); + _gui.enqueue(_handle, View_handle()); + _gui.enqueue(_handle, _attr.title); + _gui.execute(); + } + + Gui::View_capability view_cap() + { + return _gui.view_capability(_handle); + } + + void top() + { + _gui.enqueue(_handle, View_handle()); + _gui.execute(); + } + + virtual void move(Gui::Point const pos) + { + _pos = pos; + _gui.enqueue(_handle, Gui::Rect { _pos, _attr.size }); + _gui.execute(); + } + + virtual Gui::Point pos() const { return _pos; } + + Gui::Rect rect() const { return { pos(), _attr.size }; } + + bool contains(Gui::Point pos) { return rect().contains(pos); } +}; + + +struct Test::Top_level_view : View +{ + Top_level_view(Gui::Connection &gui, Attr const &attr) + : + View(gui, attr, [&] { return gui.create_view(); }) + { } +}; + + +struct Test::Child_view : View +{ + View &_parent; + + Child_view(Gui::Connection &gui, View &parent, Attr const &attr) + : + View(gui, attr, + [&] /* create_fn */ { + using View_handle = Gui::Session::View_handle; + View_handle const parent_handle = gui.view_handle(parent.view_cap()); + View_handle const handle = gui.create_view(parent_handle); + gui.release_view_handle(parent_handle); + return handle; + } + ), _parent(parent) + { } + + void move(Gui::Point const pos) override + { + View::move(pos - _parent.pos()); + } + + Gui::Point pos() const override + { + return _parent.pos() + View::pos(); + } +}; + + +class Test::View_stack : Noncopyable +{ + public: + + struct Input_mask_ptr + { + Gui::Area size; + + uint8_t *ptr; + + /** + * Return true if input at given position is enabled + */ + bool hit(Gui::Point const at) const + { + return ptr + && Rect(Point(0, 0), size).contains(at) + && ptr[size.w*at.y + at.x]; + } + }; + + private: + + Input_mask_ptr const _input_mask_ptr; + + List _views { }; + + struct { View const *_dragged = nullptr; }; + + public: + + View_stack(Input_mask_ptr input_mask) : _input_mask_ptr(input_mask) { } + + void with_view_at(Gui::Point const pos, auto const &fn) + { + View *tv = _views.first(); + for ( ; tv; tv = tv->next()) { + + if (!tv->contains(pos)) + continue; + + Point const rel = pos - tv->pos(); + + if (_input_mask_ptr.hit(rel)) + break; + } + if (tv) + fn(*tv); + } + + void with_dragged_view(auto const &fn) + { + for (View *tv = _views.first(); tv; tv = tv->next()) + if (_dragged == tv) + fn(*tv); + } + + void insert(View &tv) { _views.insert(&tv); } + + void top(View &tv) + { + _views.remove(&tv); + tv.top(); + _views.insert(&tv); + } + + void drag(View const &tv) { _dragged = &tv; }; + + void release_dragged_view() { _dragged = nullptr; } +}; + + +struct Test::Main +{ + Env &_env; + + struct Config { bool alpha; } _config { .alpha = false }; + + Gui::Connection _gui { _env, "testnit" }; + + Constructible _fb_ds { }; + + Constructible _view_stack { }; + + /* + * View '_v1' is used as coordinate origin of '_v2' and '_v3'. + */ + Top_level_view _v1 { _gui, { .pos = { 150, 100 }, + .size = { 230, 200 }, + .title = "Eins" } }; + + Child_view _v2 { _gui, _v1, { .pos = { 20, 20 }, + .size = { 230, 210 }, + .title = "Zwei" } }; + + Child_view _v3 { _gui, _v1, { .pos = { 40, 40 }, + .size = { 230, 220 }, + .title = "Drei" } }; + + Signal_handler
_input_handler { _env.ep(), *this, &Main::_handle_input }; + + int _mx = 0, _my = 0, _key_cnt = 0; + + void _handle_input(); + + Main(Env &env); +}; + + +Test::Main::Main(Genode::Env &env) : _env(env) +{ + _gui.input()->sigh(_input_handler); + + Gui::Area const size { 256, 256 }; + + Framebuffer::Mode const mode { .area = size }; + + log("screen is ", mode); + + _gui.buffer(mode, _config.alpha); + + _fb_ds.construct(_env.rm(), _gui.framebuffer()->dataspace()); + + /* + * Paint into pixel buffer, fill alpha channel and input-mask buffer + * + * Input should refer to the view if the alpha value is more than 50%. + */ + + using PT = Pixel_rgb888; + PT * const pixels = _fb_ds->local_addr(); + + uint8_t * const alpha = (uint8_t *)&pixels[size.count()]; + uint8_t * const input_mask = _config.alpha ? alpha + size.count() : 0; + + for (unsigned i = 0; i < size.h; i++) + for (unsigned j = 0; j < size.w; j++) { + pixels[i*size.w + j] = PT((3*i)/8, j, i*j/32); + if (_config.alpha) { + alpha[i*size.w + j] = (uint8_t)((i*2) ^ (j*2)); + input_mask[i*size.w + j] = alpha[i*size.w + j] > 127; + } + } + + _view_stack.construct(View_stack::Input_mask_ptr { .size = size, + .ptr = input_mask }); + + _view_stack->insert(_v1); + _view_stack->insert(_v2); + _view_stack->insert(_v3); +} + + +void Test::Main::_handle_input() +{ + while (_gui.input()->pending()) { + + _gui.input()->for_each_event([&] (Input::Event const &ev) { + + if (ev.press()) _key_cnt++; + if (ev.release()) _key_cnt--; + + ev.handle_absolute_motion([&] (int x, int y) { + + /* move selected view */ + _view_stack->with_dragged_view([&] (View &tv) { + tv.move(tv.pos() + Point(x, y) - Point(_mx, _my)); }); + + _mx = x; _my = y; + }); + + /* find selected view and bring it to front */ + if (ev.press() && _key_cnt == 1) { + _view_stack->with_view_at(Point(_mx, _my), [&] (View &tv) { + _view_stack->top(tv); + _view_stack->drag(tv); + }); + } + + if (ev.release() && _key_cnt == 0) + _view_stack->release_dragged_view(); + }); + } +} + + +void Component::construct(Genode::Env &env) { static Test::Main main { env }; } diff --git a/repos/os/src/test/nitpicker/target.mk b/repos/os/src/test/nitpicker/target.mk index d63a5dc5e1..cd9424aa29 100644 --- a/repos/os/src/test/nitpicker/target.mk +++ b/repos/os/src/test/nitpicker/target.mk @@ -1,3 +1,3 @@ TARGET = testnit -SRC_CC = test.cc +SRC_CC = main.cc LIBS = base diff --git a/repos/os/src/test/nitpicker/test.cc b/repos/os/src/test/nitpicker/test.cc deleted file mode 100644 index e24d32db85..0000000000 --- a/repos/os/src/test/nitpicker/test.cc +++ /dev/null @@ -1,246 +0,0 @@ -/* - * \brief Nitpicker test program - * \author Norman Feske - * \date 2006-08-23 - */ - -/* - * Copyright (C) 2006-2017 Genode Labs GmbH - * - * This file is part of the Genode OS framework, which is distributed - * under the terms of the GNU Affero General Public License version 3. - */ - -#include -#include -#include -#include -#include -#include -#include -#include - -using namespace Genode; - -class Test_view : public List::Element -{ - private: - - using View_handle = Gui::Session::View_handle; - using Command = Gui::Session::Command; - - Gui::Session_client &_gui; - View_handle _handle { }; - int _x, _y, _w, _h; - const char *_title; - Test_view *_parent_view; - - public: - - Test_view(Gui::Session_client *gui, - int x, int y, int w, int h, - const char *title, - Test_view *parent_view = 0) - : - _gui(*gui), - _x(x), _y(y), _w(w), _h(h), _title(title), _parent_view(parent_view) - { - using namespace Gui; - - View_handle parent_handle; - - if (_parent_view) - parent_handle = _gui.view_handle(_parent_view->view_cap()); - - _handle = _gui.create_view(parent_handle); - - if (parent_handle.valid()) - _gui.release_view_handle(parent_handle); - - Gui::Rect rect(Gui::Point(_x, _y), Gui::Area(_w, _h)); - _gui.enqueue(_handle, rect); - _gui.enqueue(_handle, View_handle()); - _gui.enqueue(_handle, _title); - _gui.execute(); - } - - Gui::View_capability view_cap() - { - return _gui.view_capability(_handle); - } - - void top() - { - _gui.enqueue(_handle, View_handle()); - _gui.execute(); - } - - /** - * Move view to absolute position - */ - void move(int x, int y) - { - /* - * If the view uses a parent view as corrdinate origin, we need to - * transform the absolute coordinates to parent-relative - * coordinates. - */ - _x = _parent_view ? x - _parent_view->x() : x; - _y = _parent_view ? y - _parent_view->y() : y; - - Gui::Rect rect(Gui::Point(_x, _y), Gui::Area(_w, _h)); - _gui.enqueue(_handle, rect); - _gui.execute(); - } - - /** - * Accessors - */ - const char *title() const { return _title; } - int x() const { return _parent_view ? _parent_view->x() + _x : _x; } - int y() const { return _parent_view ? _parent_view->y() + _y : _y; } - int w() const { return _w; } - int h() const { return _h; } -}; - - -class Test_view_stack : public List -{ - private: - - unsigned char *_input_mask; - unsigned _input_mask_w; - public: - - Test_view_stack(unsigned char *input_mask, unsigned input_mask_w) - : _input_mask(input_mask), _input_mask_w(input_mask_w) { } - - Test_view *find(int x, int y) - { - for (Test_view *tv = first(); tv; tv = tv->next()) { - - if (x < tv->x() || x >= tv->x() + tv->w() - || y < tv->y() || y >= tv->y() + tv->h()) - continue; - - if (!_input_mask) - return tv; - - if (_input_mask[(y - tv->y())*_input_mask_w + (x - tv->x())]) - return tv; - } - - return 0; - } - - void top(Test_view *tv) - { - remove(tv); - tv->top(); - insert(tv); - } -}; - - -void Component::construct(Genode::Env &env) -{ - /* - * Init sessions to the required external services - */ - enum { CONFIG_ALPHA = false }; - static Gui::Connection gui { env, "testnit" }; - static Timer::Connection timer { env }; - - Framebuffer::Mode const mode { .area = { 256, 256 } }; - gui.buffer(mode, false); - - int const scr_w = mode.area.w, scr_h = mode.area.h; - - log("screen is ", mode); - if (!scr_w || !scr_h) { - error("got invalid screen - sleeping forever"); - return; - } - - /* bad-case test */ - { - /* issue #3232 */ - Gui::Session::View_handle handle { gui.create_view() }; - gui.destroy_view(handle); - gui.destroy_view(handle); - } - - Genode::Attached_dataspace fb_ds( - env.rm(), gui.framebuffer()->dataspace()); - - typedef Genode::Pixel_rgb888 PT; - PT *pixels = fb_ds.local_addr(); - unsigned char *alpha = (unsigned char *)&pixels[scr_w*scr_h]; - unsigned char *input_mask = CONFIG_ALPHA ? alpha + scr_w*scr_h : 0; - - /* - * Paint into pixel buffer, fill alpha channel and input-mask buffer - * - * Input should refer to the view if the alpha value is more than 50%. - */ - for (int i = 0; i < scr_h; i++) - for (int j = 0; j < scr_w; j++) { - pixels[i*scr_w + j] = PT((3*i)/8, j, i*j/32); - if (CONFIG_ALPHA) { - alpha[i*scr_w + j] = (unsigned char)((i*2) ^ (j*2)); - input_mask[i*scr_w + j] = alpha[i*scr_w + j] > 127; - } - } - - /* - * Create views to display the buffer - */ - Test_view_stack tvs(input_mask, scr_w); - - { - /* - * View 'v1' is used as coordinate origin of 'v2' and 'v3'. - */ - static Test_view v1(&gui, 150, 100, 230, 200, "Eins"); - static Test_view v2(&gui, 20, 20, 230, 210, "Zwei", &v1); - static Test_view v3(&gui, 40, 40, 230, 220, "Drei", &v1); - - tvs.insert(&v1); - tvs.insert(&v2); - tvs.insert(&v3); - } - - /* - * Handle input events - */ - int mx = 0, my = 0, key_cnt = 0; - Test_view *tv = nullptr; - while (1) { - - while (!gui.input()->pending()) timer.msleep(20); - - gui.input()->for_each_event([&] (Input::Event const &ev) { - - if (ev.press()) key_cnt++; - if (ev.release()) key_cnt--; - - ev.handle_absolute_motion([&] (int x, int y) { - - /* move selected view */ - if (key_cnt > 0 && tv) - tv->move(tv->x() + x - mx, tv->y() + y - my); - - mx = x; my = y; - }); - - /* find selected view and bring it to front */ - if (ev.press() && key_cnt == 1) { - tv = tvs.find(mx, my); - if (tv) - tvs.top(tv); - } - }); - } - - env.parent().exit(0); -}