diff --git a/repos/gems/src/app/themed_decorator/main.cc b/repos/gems/src/app/themed_decorator/main.cc index 65cf621920..b720909c06 100644 --- a/repos/gems/src/app/themed_decorator/main.cc +++ b/repos/gems/src/app/themed_decorator/main.cc @@ -13,10 +13,10 @@ /* Genode includes */ #include -#include -#include +#include +#include +#include #include -#include /* decorator includes */ #include @@ -34,46 +34,48 @@ namespace Decorator { struct Decorator::Main : Window_factory_base { - Server::Entrypoint &ep; + Env &_env; - Window_stack window_stack = { *this }; + Window_stack _window_stack = { *this }; /** - * Install handler for responding to window-layout changes + * Handler for responding to window-layout changes */ - void handle_window_layout_update(unsigned); + void _handle_window_layout_update(); - Signal_rpc_member
window_layout_dispatcher = { - ep, *this, &Main::handle_window_layout_update }; + Signal_handler
_window_layout_handler = { + _env.ep(), *this, &Main::_handle_window_layout_update }; - Attached_rom_dataspace window_layout { "window_layout" }; + Attached_rom_dataspace _window_layout { _env, "window_layout" }; /** - * Install handler for responding to pointer-position updates + * Handler for responding to pointer-position updates */ - void handle_pointer_update(unsigned); + void _handle_pointer_update(); - Signal_rpc_member
pointer_dispatcher = { - ep, *this, &Main::handle_pointer_update }; + Signal_handler
_pointer_handler = { + _env.ep(), *this, &Main::_handle_pointer_update }; - Lazy_volatile_object pointer; + Lazy_volatile_object _pointer; - Window_base::Hover hover; + Window_base::Hover _hover; - Reporter hover_reporter = { "hover" }; + Reporter _hover_reporter = { "hover" }; /** * Nitpicker connection used to sync animations */ - Nitpicker::Connection nitpicker; + Nitpicker::Connection _nitpicker { _env }; - bool window_layout_update_needed = false; + bool _window_layout_update_needed = false; - Animator animator; + Animator _animator; - Theme theme { *Genode::env()->heap() }; + Heap _heap { _env.ram(), _env.rm() }; - Reporter decorator_margins_reporter = { "decorator_margins" }; + Theme _theme { _heap }; + + Reporter _decorator_margins_reporter = { "decorator_margins" }; /** * Process the update every 'frame_period' nitpicker sync signals. The @@ -86,28 +88,30 @@ struct Decorator::Main : Window_factory_base * 'frame_period' of 2 results in an update rate of 1000/20 = 50 frames per * second. */ - unsigned frame_cnt = 0; - unsigned frame_period = 2; + unsigned _frame_cnt = 0; + unsigned _frame_period = 2; /** * Install handler for responding to nitpicker sync events */ - void handle_nitpicker_sync(unsigned); + void _handle_nitpicker_sync(); - Signal_rpc_member
nitpicker_sync_dispatcher = { - ep, *this, &Main::handle_nitpicker_sync }; + Signal_handler
_nitpicker_sync_handler = { + _env.ep(), *this, &Main::_handle_nitpicker_sync }; - Config config; + Attached_rom_dataspace _config { _env, "config" }; - void handle_config(unsigned); + Config _decorator_config; - Signal_rpc_member
config_dispatcher = { - ep, *this, &Main::handle_config}; + void _handle_config(); + + Signal_handler
_config_handler = { + _env.ep(), *this, &Main::_handle_config}; /** * Constructor */ - Main(Server::Entrypoint &ep) : ep(ep) + Main(Env &env) : _env(env) { /* * Eagerly upgrade the session quota in order to be able to create a @@ -118,31 +122,31 @@ struct Decorator::Main : Window_factory_base * and view_handle operations. Currently, these exceptions will * abort the decorator. */ - nitpicker.upgrade_ram(256*1024); + _nitpicker.upgrade_ram(256*1024); - Genode::config()->sigh(config_dispatcher); - handle_config(0); + _config.sigh(_config_handler); + _handle_config(); - window_layout.sigh(window_layout_dispatcher); + _window_layout.sigh(_window_layout_handler); try { - pointer.construct("pointer"); - pointer->sigh(pointer_dispatcher); + _pointer.construct(_env, "pointer"); + _pointer->sigh(_pointer_handler); } catch (Genode::Rom_connection::Rom_connection_failed) { Genode::log("pointer information unavailable"); } - nitpicker.framebuffer()->sync_sigh(nitpicker_sync_dispatcher); + _nitpicker.framebuffer()->sync_sigh(_nitpicker_sync_handler); - hover_reporter.enabled(true); + _hover_reporter.enabled(true); - decorator_margins_reporter.enabled(true); + _decorator_margins_reporter.enabled(true); - Genode::Reporter::Xml_generator xml(decorator_margins_reporter, [&] () + Genode::Reporter::Xml_generator xml(_decorator_margins_reporter, [&] () { xml.node("floating", [&] () { - Theme::Margins const margins = theme.decor_margins(); + Theme::Margins const margins = _theme.decor_margins(); xml.attribute("top", margins.top); xml.attribute("bottom", margins.bottom); @@ -152,8 +156,8 @@ struct Decorator::Main : Window_factory_base }); /* import initial state */ - handle_pointer_update(0); - handle_window_layout_update(0); + _handle_pointer_update(); + _handle_window_layout_update(); } /** @@ -161,9 +165,9 @@ struct Decorator::Main : Window_factory_base */ Window_base *create(Xml_node window_node) override { - return new (env()->heap()) - Window(attribute(window_node, "id", 0UL), nitpicker, animator, - *env()->ram_session(), theme, config); + return new (_heap) + Window(attribute(window_node, "id", 0UL), _nitpicker, _animator, + _env.ram(), _theme, _decorator_config); } /** @@ -171,21 +175,21 @@ struct Decorator::Main : Window_factory_base */ void destroy(Window_base *window) override { - Genode::destroy(env()->heap(), static_cast(window)); + Genode::destroy(_heap, static_cast(window)); } }; -void Decorator::Main::handle_config(unsigned) +void Decorator::Main::_handle_config() { - Genode::config()->reload(); + _config.update(); /* notify all windows to consider the updated policy */ - window_stack.for_each_window([&] (Window_base &window) { + _window_stack.for_each_window([&] (Window_base &window) { static_cast(window).adapt_to_changed_config(); }); /* trigger redraw of the window stack */ - handle_window_layout_update(0); + _handle_window_layout_update(); } @@ -237,29 +241,29 @@ static void update_hover_report(Genode::Xml_node pointer_node, } -void Decorator::Main::handle_window_layout_update(unsigned) +void Decorator::Main::_handle_window_layout_update() { - window_layout.update(); + _window_layout.update(); - window_layout_update_needed = true; + _window_layout_update_needed = true; } -void Decorator::Main::handle_nitpicker_sync(unsigned) +void Decorator::Main::_handle_nitpicker_sync() { - if (frame_cnt++ < frame_period) + if (_frame_cnt++ < _frame_period) return; - frame_cnt = 0; + _frame_cnt = 0; bool model_updated = false; - if (window_layout_update_needed && window_layout.valid()) { + if (_window_layout_update_needed && _window_layout.valid()) { try { - Xml_node xml(window_layout.local_addr(), - window_layout.size()); - window_stack.update_model(xml); + Xml_node xml(_window_layout.local_addr(), + _window_layout.size()); + _window_stack.update_model(xml); model_updated = true; @@ -267,9 +271,9 @@ void Decorator::Main::handle_nitpicker_sync(unsigned) * A decorator element might have appeared or disappeared under * the pointer. */ - if (pointer.constructed() && pointer->valid()) - update_hover_report(Xml_node(pointer->local_addr()), - window_stack, hover, hover_reporter); + if (_pointer.constructed() && _pointer->valid()) + update_hover_report(Xml_node(_pointer->local_addr()), + _window_stack, _hover, _hover_reporter); } catch (Xml_node::Invalid_syntax) { @@ -277,54 +281,40 @@ void Decorator::Main::handle_nitpicker_sync(unsigned) * An error occured with processing the XML model. Flush the * internal representation. */ - window_stack.flush(); + _window_stack.flush(); } - window_layout_update_needed = false; + _window_layout_update_needed = false; } - bool const windows_animated = window_stack.schedule_animated_windows(); + bool const windows_animated = _window_stack.schedule_animated_windows(); /* * To make the perceived animation speed independent from the setting of * 'frame_period', we update the animation as often as the nitpicker * sync signal occurs. */ - for (unsigned i = 0; i < frame_period; i++) - animator.animate(); + for (unsigned i = 0; i < _frame_period; i++) + _animator.animate(); if (!model_updated && !windows_animated) return; - window_stack.update_nitpicker_views(); + _window_stack.update_nitpicker_views(); } -void Decorator::Main::handle_pointer_update(unsigned) +void Decorator::Main::_handle_pointer_update() { - if (!pointer.constructed()) + if (!_pointer.constructed()) return; - pointer->update(); + _pointer->update(); - if (pointer->valid()) - update_hover_report(Xml_node(pointer->local_addr()), - window_stack, hover, hover_reporter); + if (_pointer->valid()) + update_hover_report(Xml_node(_pointer->local_addr()), + _window_stack, _hover, _hover_reporter); } -/************ - ** Server ** - ************/ - -namespace Server { - - char const *name() { return "decorator_ep"; } - - size_t stack_size() { return 8*1024*sizeof(long); } - - void construct(Entrypoint &ep) - { - static Decorator::Main main(ep); - } -} +void Component::construct(Genode::Env &env) { static Decorator::Main main(env); } diff --git a/repos/gems/src/app/themed_decorator/target.mk b/repos/gems/src/app/themed_decorator/target.mk index 25dd827677..e5a0470828 100644 --- a/repos/gems/src/app/themed_decorator/target.mk +++ b/repos/gems/src/app/themed_decorator/target.mk @@ -1,6 +1,6 @@ TARGET = themed_decorator SRC_CC = main.cc theme.cc window.cc -LIBS = base config server libc libpng zlib blit file +LIBS = base libc libpng zlib blit file INC_DIR += $(PRG_DIR) .PHONY: plain_decorator_theme.tar