nitpicker: change to component API

Issue #1987
This commit is contained in:
Norman Feske
2016-07-13 16:30:38 +02:00
parent b85fdd828a
commit 11c5bf28c9
7 changed files with 138 additions and 139 deletions

View File

@ -125,7 +125,7 @@ class Domain_registry
if (value == "no") return Entry::LABEL_NO; if (value == "no") return Entry::LABEL_NO;
if (value == "yes") return Entry::LABEL_YES; if (value == "yes") return Entry::LABEL_YES;
PWRN("invalid value of label attribute in <domain>"); Genode::warning("invalid value of label attribute in <domain>");
return Entry::LABEL_YES; return Entry::LABEL_YES;
} }
@ -148,7 +148,7 @@ class Domain_registry
if (value == "focused") return Entry::HOVER_FOCUSED; if (value == "focused") return Entry::HOVER_FOCUSED;
if (value == "always") return Entry::HOVER_ALWAYS; if (value == "always") return Entry::HOVER_ALWAYS;
PWRN("invalid value of hover attribute in <domain>"); Genode::warning("invalid value of hover attribute in <domain>");
return Entry::HOVER_FOCUSED; return Entry::HOVER_FOCUSED;
} }
@ -161,7 +161,7 @@ class Domain_registry
if (value == "click") return Entry::FOCUS_CLICK; if (value == "click") return Entry::FOCUS_CLICK;
if (value == "transient") return Entry::FOCUS_TRANSIENT; if (value == "transient") return Entry::FOCUS_TRANSIENT;
PWRN("invalid value of focus attribute in <domain>"); Genode::warning("invalid value of focus attribute in <domain>");
return Entry::FOCUS_NONE; return Entry::FOCUS_NONE;
} }
@ -176,7 +176,7 @@ class Domain_registry
if (value == "bottom_right") return Entry::ORIGIN_BOTTOM_RIGHT; if (value == "bottom_right") return Entry::ORIGIN_BOTTOM_RIGHT;
if (value == "pointer") return Entry::ORIGIN_POINTER; if (value == "pointer") return Entry::ORIGIN_POINTER;
PWRN("invalid value of origin attribute in <domain>"); Genode::warning("invalid value of origin attribute in <domain>");
return Entry::ORIGIN_BOTTOM_LEFT; return Entry::ORIGIN_BOTTOM_LEFT;
} }
@ -191,19 +191,19 @@ class Domain_registry
} catch (...) { } } catch (...) { }
if (!name_defined) { if (!name_defined) {
PERR("no valid domain name specified"); Genode::error("no valid domain name specified");
return; return;
} }
Entry::Name const name(buf); Entry::Name const name(buf);
if (lookup(name)) { if (lookup(name)) {
PERR("domain name \"%s\" is not unique", name.string()); Genode::error("domain name \"", name, "\" is not unique");
return; return;
} }
if (!domain.has_attribute("layer")) { if (!domain.has_attribute("layer")) {
PERR("no layer specified for domain \"%s\"", name.string()); Genode::error("no layer specified for domain \"", name, "\"");
return; return;
} }

View File

@ -11,9 +11,6 @@
* under the terms of the GNU General Public License version 2. * under the terms of the GNU General Public License version 2.
*/ */
/* Genode includes */
#include <os/config.h>
/* local includes */ /* local includes */
#include "global_keys.h" #include "global_keys.h"
@ -28,30 +25,28 @@ Global_keys::Policy *Global_keys::_lookup_policy(char const *key_name)
} }
void Global_keys::apply_config(Session_list &session_list) void Global_keys::apply_config(Xml_node config, Session_list &session_list)
{ {
for (unsigned i = 0; i < NUM_POLICIES; i++) for (unsigned i = 0; i < NUM_POLICIES; i++)
_policies[i] = Policy(); _policies[i] = Policy();
char const *node_type = "global-key"; char const *node_type = "global-key";
using Genode::Xml_node;
try { try {
Xml_node node = Genode::config()->xml_node().sub_node(node_type); Xml_node node = config.sub_node(node_type);
for (; ; node = node.next(node_type)) { for (; ; node = node.next(node_type)) {
if (!node.has_attribute("name")) { if (!node.has_attribute("name")) {
PWRN("attribute 'name' missing in <global-key> config node"); Genode::warning("attribute 'name' missing in <global-key> config node");
continue; continue;
} }
char name[32]; name[0] = 0; typedef Genode::String<32> Name;
node.attribute("name").value(name, sizeof(name)); Name name = node.attribute_value("name", Name());
Policy * policy = _lookup_policy(name.string());
Policy * policy = _lookup_policy(name);
if (!policy) { if (!policy) {
PWRN("invalid key name \"%s\"", name); Genode::warning("invalid key name \"", name, "\"");
continue; continue;
} }
@ -60,7 +55,7 @@ void Global_keys::apply_config(Session_list &session_list)
continue; continue;
if (!node.has_attribute("label")) { if (!node.has_attribute("label")) {
PWRN("missing 'label' attribute for key %s", name); Genode::warning("missing 'label' attribute for key ", name);
continue; continue;
} }

View File

@ -16,6 +16,7 @@
/* Genode includes */ /* Genode includes */
#include <input/keycodes.h> #include <input/keycodes.h>
#include <util/xml_node.h>
/* local includes */ /* local includes */
#include "session.h" #include "session.h"
@ -24,6 +25,8 @@ class Global_keys
{ {
private: private:
typedef Genode::Xml_node Xml_node;
struct Policy struct Policy
{ {
Session *_session = nullptr; Session *_session = nullptr;
@ -50,7 +53,7 @@ class Global_keys
Session *global_receiver(Input::Keycode key) { Session *global_receiver(Input::Keycode key) {
return _valid(key) ? _policies[key]._session : 0; } return _valid(key) ? _policies[key]._session : 0; }
void apply_config(Session_list &session_list); void apply_config(Xml_node config, Session_list &session_list);
}; };
#endif /* _GLOBAL_KEYS_H_ */ #endif /* _GLOBAL_KEYS_H_ */

View File

@ -12,11 +12,12 @@
*/ */
/* Genode includes */ /* Genode includes */
#include <base/env.h>
#include <base/sleep.h> #include <base/sleep.h>
#include <base/printf.h> #include <base/log.h>
#include <base/component.h>
#include <base/allocator_guard.h> #include <base/allocator_guard.h>
#include <os/attached_ram_dataspace.h> #include <base/attached_ram_dataspace.h>
#include <base/attached_rom_dataspace.h>
#include <input/event.h> #include <input/event.h>
#include <input/keycodes.h> #include <input/keycodes.h>
#include <root/component.h> #include <root/component.h>
@ -29,7 +30,6 @@
#include <util/color.h> #include <util/color.h>
#include <os/pixel_rgb565.h> #include <os/pixel_rgb565.h>
#include <os/session_policy.h> #include <os/session_policy.h>
#include <os/server.h>
#include <os/reporter.h> #include <os/reporter.h>
/* local includes */ /* local includes */
@ -50,20 +50,20 @@ namespace Nitpicker {
using Genode::size_t; using Genode::size_t;
using Genode::Allocator; using Genode::Allocator;
using Genode::Rpc_entrypoint; using Genode::Entrypoint;
using Genode::List; using Genode::List;
using Genode::Pixel_rgb565; using Genode::Pixel_rgb565;
using Genode::strcmp; using Genode::strcmp;
using Genode::config; using Genode::Env;
using Genode::env;
using Genode::Arg_string; using Genode::Arg_string;
using Genode::Object_pool; using Genode::Object_pool;
using Genode::Dataspace_capability; using Genode::Dataspace_capability;
using Genode::Session_label; using Genode::Session_label;
using Genode::Signal_transmitter; using Genode::Signal_transmitter;
using Genode::Signal_context_capability; using Genode::Signal_context_capability;
using Genode::Signal_rpc_member; using Genode::Signal_handler;
using Genode::Attached_ram_dataspace; using Genode::Attached_ram_dataspace;
using Genode::Attached_rom_dataspace;
using Genode::Attached_dataspace; using Genode::Attached_dataspace;
using Genode::Weak_ptr; using Genode::Weak_ptr;
using Genode::Locked_ptr; using Genode::Locked_ptr;
@ -131,10 +131,10 @@ class Buffer
* \throw Ram_session::Alloc_failed * \throw Ram_session::Alloc_failed
* \throw Rm_session::Attach_failed * \throw Rm_session::Attach_failed
*/ */
Buffer(Area size, Framebuffer::Mode::Format format, Genode::size_t bytes) Buffer(Genode::Ram_session &ram, Genode::Region_map &rm,
Area size, Framebuffer::Mode::Format format, Genode::size_t bytes)
: :
_size(size), _format(format), _size(size), _format(format), _ram_ds(ram, rm, bytes)
_ram_ds(env()->ram_session(), bytes)
{ } { }
/** /**
@ -184,9 +184,10 @@ class Chunky_dataspace_texture : public Buffer,
/** /**
* Constructor * Constructor
*/ */
Chunky_dataspace_texture(Area size, bool use_alpha) Chunky_dataspace_texture(Genode::Ram_session &ram, Genode::Region_map &rm,
Area size, bool use_alpha)
: :
Buffer(size, _format(), calc_num_bytes(size, use_alpha)), Buffer(ram, rm, size, _format(), calc_num_bytes(size, use_alpha)),
Texture<PT>((PT *)local_addr(), Texture<PT>((PT *)local_addr(),
_alpha_base(size, use_alpha), size) { } _alpha_base(size, use_alpha), size) { }
@ -233,7 +234,7 @@ class Input::Session_component : public Genode::Rpc_object<Session>
/* /*
* Exported event buffer dataspace * Exported event buffer dataspace
*/ */
Attached_ram_dataspace _ev_ram_ds = { env()->ram_session(), ev_ds_size() }; Attached_ram_dataspace _ev_ram_ds;
/* /*
* Local event buffer that is copied * Local event buffer that is copied
@ -247,6 +248,11 @@ class Input::Session_component : public Genode::Rpc_object<Session>
public: public:
Session_component(Genode::Env &env)
:
_ev_ram_ds(env.ram(), env.rm(), ev_ds_size())
{ }
/** /**
* Wake up client * Wake up client
*/ */
@ -402,6 +408,8 @@ class Nitpicker::Session_component : public Genode::Rpc_object<Session>,
typedef ::View View; typedef ::View View;
Env &_env;
Genode::Allocator_guard _session_alloc; Genode::Allocator_guard _session_alloc;
Framebuffer::Session &_framebuffer; Framebuffer::Session &_framebuffer;
@ -410,13 +418,7 @@ class Nitpicker::Session_component : public Genode::Rpc_object<Session>,
Framebuffer::Session_component _framebuffer_session_component; Framebuffer::Session_component _framebuffer_session_component;
/* Input_session_component */ /* Input_session_component */
Input::Session_component _input_session_component; Input::Session_component _input_session_component { _env };
/*
* Entrypoint that is used for the views, input session,
* and framebuffer session.
*/
Rpc_entrypoint &_ep;
View_stack &_view_stack; View_stack &_view_stack;
@ -439,7 +441,7 @@ class Nitpicker::Session_component : public Genode::Rpc_object<Session>,
/* size of currently allocated virtual framebuffer, in bytes */ /* size of currently allocated virtual framebuffer, in bytes */
size_t _buffer_size = 0; size_t _buffer_size = 0;
Attached_ram_dataspace _command_ds { env()->ram_session(), Attached_ram_dataspace _command_ds { _env.ram(), _env.rm(),
sizeof(Command_buffer) }; sizeof(Command_buffer) };
Command_buffer &_command_buffer = *_command_ds.local_addr<Command_buffer>(); Command_buffer &_command_buffer = *_command_ds.local_addr<Command_buffer>();
@ -646,7 +648,7 @@ class Nitpicker::Session_component : public Genode::Rpc_object<Session>,
void _destroy_view(View &view) void _destroy_view(View &view)
{ {
_view_stack.remove_view(view); _view_stack.remove_view(view);
_ep.dissolve(&view); _env.ep().dissolve(view);
_view_list.remove(&view); _view_list.remove(&view);
destroy(_view_alloc, &view); destroy(_view_alloc, &view);
} }
@ -656,11 +658,11 @@ class Nitpicker::Session_component : public Genode::Rpc_object<Session>,
/** /**
* Constructor * Constructor
*/ */
Session_component(Session_label const &label, Session_component(Env &env,
Session_label const &label,
View_stack &view_stack, View_stack &view_stack,
Mode &mode, Mode &mode,
View &pointer_origin, View &pointer_origin,
Rpc_entrypoint &ep,
Framebuffer::Session &framebuffer, Framebuffer::Session &framebuffer,
bool provides_default_bg, bool provides_default_bg,
Allocator &session_alloc, Allocator &session_alloc,
@ -668,13 +670,14 @@ class Nitpicker::Session_component : public Genode::Rpc_object<Session>,
Genode::Reporter &focus_reporter) Genode::Reporter &focus_reporter)
: :
::Session(label), ::Session(label),
_env(env),
_session_alloc(&session_alloc, ram_quota), _session_alloc(&session_alloc, ram_quota),
_framebuffer(framebuffer), _framebuffer(framebuffer),
_framebuffer_session_component(view_stack, *this, framebuffer, *this), _framebuffer_session_component(view_stack, *this, framebuffer, *this),
_ep(ep), _view_stack(view_stack), _mode(mode), _view_stack(view_stack), _mode(mode),
_pointer_origin(pointer_origin), _pointer_origin(pointer_origin),
_framebuffer_session_cap(_ep.manage(&_framebuffer_session_component)), _framebuffer_session_cap(_env.ep().manage(_framebuffer_session_component)),
_input_session_cap(_ep.manage(&_input_session_component)), _input_session_cap(_env.ep().manage(_input_session_component)),
_provides_default_bg(provides_default_bg), _provides_default_bg(provides_default_bg),
_view_handle_registry(_session_alloc), _view_handle_registry(_session_alloc),
_focus_reporter(focus_reporter) _focus_reporter(focus_reporter)
@ -687,8 +690,8 @@ class Nitpicker::Session_component : public Genode::Rpc_object<Session>,
*/ */
~Session_component() ~Session_component()
{ {
_ep.dissolve(&_framebuffer_session_component); _env.ep().dissolve(_framebuffer_session_component);
_ep.dissolve(&_input_session_component); _env.ep().dissolve(_input_session_component);
destroy_all_views(); destroy_all_views();
@ -799,7 +802,7 @@ class Nitpicker::Session_component : public Genode::Rpc_object<Session>,
view->apply_origin_policy(_pointer_origin); view->apply_origin_policy(_pointer_origin);
_view_list.insert(view); _view_list.insert(view);
_ep.manage(view); _env.ep().manage(*view);
try { return _view_handle_registry.alloc(*view); } try { return _view_handle_registry.alloc(*view); }
catch (View_handle_registry::Out_of_memory) { catch (View_handle_registry::Out_of_memory) {
@ -840,7 +843,7 @@ class Nitpicker::Session_component : public Genode::Rpc_object<Session>,
: View_handle(); : View_handle();
}; };
try { return _ep.apply(view_cap, lambda); } try { return _env.ep().rpc_ep().apply(view_cap, lambda); }
catch (View_handle_registry::Out_of_memory) { catch (View_handle_registry::Out_of_memory) {
throw Nitpicker::Session::Out_of_metadata(); } throw Nitpicker::Session::Out_of_metadata(); }
} }
@ -862,7 +865,7 @@ class Nitpicker::Session_component : public Genode::Rpc_object<Session>,
_view_handle_registry.free(handle); } _view_handle_registry.free(handle); }
catch (View_handle_registry::Lookup_failed) { catch (View_handle_registry::Lookup_failed) {
PWRN("view lookup failed while releasing view handle"); Genode::warning("view lookup failed while releasing view handle");
return; return;
} }
} }
@ -878,7 +881,7 @@ class Nitpicker::Session_component : public Genode::Rpc_object<Session>,
try { try {
_execute_command(_command_buffer.get(i)); } _execute_command(_command_buffer.get(i)); }
catch (View_handle_registry::Lookup_failed) { catch (View_handle_registry::Lookup_failed) {
PWRN("view lookup failed during command execution"); } Genode::warning("view lookup failed during command execution"); }
} }
} }
@ -911,7 +914,7 @@ class Nitpicker::Session_component : public Genode::Rpc_object<Session>,
{ {
/* check permission by comparing session labels */ /* check permission by comparing session labels */
if (!_focus_change_permitted()) { if (!_focus_change_permitted()) {
PWRN("unauthorized focus change requesed by %s", label().string()); Genode::warning("unauthorized focus change requesed by ", label().string());
return; return;
} }
@ -920,7 +923,7 @@ class Nitpicker::Session_component : public Genode::Rpc_object<Session>,
{ {
_mode.next_focused_session(session); _mode.next_focused_session(session);
}; };
_ep.apply(session_cap, lambda); _env.ep().rpc_ep().apply(session_cap, lambda);
/* /*
* To avoid changing the focus in the middle of a drag operation, * To avoid changing the focus in the middle of a drag operation,
@ -968,16 +971,16 @@ class Nitpicker::Session_component : public Genode::Rpc_object<Session>,
if (::Session::texture()) { if (::Session::texture()) {
enum { PRESERVED_RAM = 128*1024 }; enum { PRESERVED_RAM = 128*1024 };
if (env()->ram_session()->avail() > _buffer_size + PRESERVED_RAM) { if (_env.ram().avail() > _buffer_size + PRESERVED_RAM) {
src_texture = static_cast<Texture<PT> const *>(::Session::texture()); src_texture = static_cast<Texture<PT> const *>(::Session::texture());
} else { } else {
PWRN("not enough RAM to preserve buffer content during resize"); Genode::warning("not enough RAM to preserve buffer content during resize");
_release_buffer(); _release_buffer();
} }
} }
Chunky_dataspace_texture<PT> * const texture = Chunky_dataspace_texture<PT> * const texture = new (&_session_alloc)
new (&_session_alloc) Chunky_dataspace_texture<PT>(size, use_alpha); Chunky_dataspace_texture<PT>(_env.ram(), _env.rm(), size, use_alpha);
/* copy old buffer content into new buffer and release old buffer */ /* copy old buffer content into new buffer and release old buffer */
if (src_texture) { if (src_texture) {
@ -1009,6 +1012,8 @@ class Nitpicker::Root : public Genode::Root_component<Session_component>
{ {
private: private:
Env &_env;
Attached_rom_dataspace const &_config;
Session_list &_session_list; Session_list &_session_list;
Domain_registry const &_domain_registry; Domain_registry const &_domain_registry;
Global_keys &_global_keys; Global_keys &_global_keys;
@ -1023,15 +1028,14 @@ class Nitpicker::Root : public Genode::Root_component<Session_component>
Session_component *_create_session(const char *args) Session_component *_create_session(const char *args)
{ {
PINF("create session with args: %s\n", args);
size_t const ram_quota = Arg_string::find_arg(args, "ram_quota").ulong_value(0); size_t const ram_quota = Arg_string::find_arg(args, "ram_quota").ulong_value(0);
size_t const required_quota = Input::Session_component::ev_ds_size() size_t const required_quota = Input::Session_component::ev_ds_size()
+ Genode::align_addr(sizeof(Session::Command_buffer), 12); + Genode::align_addr(sizeof(Session::Command_buffer), 12);
if (ram_quota < required_quota) { if (ram_quota < required_quota) {
PWRN("Insufficient dontated ram_quota (%zd bytes), require %zd bytes", Genode::warning("Insufficient dontated ram_quota (", ram_quota,
ram_quota, required_quota); " bytes), require ", required_quota, " bytes");
throw Root::Quota_exceeded(); throw Root::Quota_exceeded();
} }
@ -1041,14 +1045,14 @@ class Nitpicker::Root : public Genode::Root_component<Session_component>
bool const provides_default_bg = (label == "backdrop"); bool const provides_default_bg = (label == "backdrop");
Session_component *session = new (md_alloc()) Session_component *session = new (md_alloc())
Session_component(label, _view_stack, _mode, Session_component(_env, label, _view_stack, _mode,
_pointer_origin, *ep(), _framebuffer, _pointer_origin, _framebuffer,
provides_default_bg, *md_alloc(), unused_quota, provides_default_bg, *md_alloc(), unused_quota,
_focus_reporter); _focus_reporter);
session->apply_session_policy(_domain_registry); session->apply_session_policy(_config.xml(), _domain_registry);
_session_list.insert(session); _session_list.insert(session);
_global_keys.apply_config(_session_list); _global_keys.apply_config(_config.xml(), _session_list);
return session; return session;
} }
@ -1062,7 +1066,7 @@ class Nitpicker::Root : public Genode::Root_component<Session_component>
void _destroy_session(Session_component *session) void _destroy_session(Session_component *session)
{ {
_session_list.remove(session); _session_list.remove(session);
_global_keys.apply_config(_session_list); _global_keys.apply_config(_config.xml(), _session_list);
session->destroy_all_views(); session->destroy_all_views();
_mode.forget(*session); _mode.forget(*session);
@ -1075,13 +1079,14 @@ class Nitpicker::Root : public Genode::Root_component<Session_component>
/** /**
* Constructor * Constructor
*/ */
Root(Session_list &session_list, Root(Env &env, Attached_rom_dataspace const &config,
Domain_registry const &domain_registry, Global_keys &global_keys, Session_list &session_list, Domain_registry const &domain_registry,
Rpc_entrypoint &session_ep, View_stack &view_stack, Mode &mode, Global_keys &global_keys, View_stack &view_stack, Mode &mode,
::View &pointer_origin, Allocator &md_alloc, ::View &pointer_origin, Allocator &md_alloc,
Framebuffer::Session &framebuffer, Genode::Reporter &focus_reporter) Framebuffer::Session &framebuffer, Genode::Reporter &focus_reporter)
: :
Root_component<Session_component>(&session_ep, &md_alloc), Root_component<Session_component>(&env.ep().rpc_ep(), &md_alloc),
_env(env), _config(config),
_session_list(session_list), _domain_registry(domain_registry), _session_list(session_list), _domain_registry(domain_registry),
_global_keys(global_keys), _view_stack(view_stack), _mode(mode), _global_keys(global_keys), _view_stack(view_stack), _mode(mode),
_pointer_origin(pointer_origin), _framebuffer(framebuffer), _pointer_origin(pointer_origin), _framebuffer(framebuffer),
@ -1092,7 +1097,7 @@ class Nitpicker::Root : public Genode::Root_component<Session_component>
struct Nitpicker::Main struct Nitpicker::Main
{ {
Server::Entrypoint &ep; Env &env;
/* /*
* Sessions to the required external services * Sessions to the required external services
@ -1100,8 +1105,7 @@ struct Nitpicker::Main
Framebuffer::Connection framebuffer; Framebuffer::Connection framebuffer;
Input::Connection input; Input::Connection input;
Input::Event * const ev_buf = Input::Event * const ev_buf = env.rm().attach(input.dataspace());
env()->rm_session()->attach(input.dataspace());
typedef Pixel_rgb565 PT; /* physical pixel type */ typedef Pixel_rgb565 PT; /* physical pixel type */
@ -1129,9 +1133,9 @@ struct Nitpicker::Main
Genode::Volatile_object<Framebuffer_screen> fb_screen = { framebuffer }; Genode::Volatile_object<Framebuffer_screen> fb_screen = { framebuffer };
void handle_fb_mode(unsigned); void handle_fb_mode();
Signal_rpc_member<Main> fb_mode_dispatcher = { ep, *this, &Main::handle_fb_mode }; Signal_handler<Main> fb_mode_handler = { env.ep(), *this, &Main::handle_fb_mode };
/* /*
* User-input policy * User-input policy
@ -1144,8 +1148,9 @@ struct Nitpicker::Main
* Construct empty domain registry. The initial version will be replaced * Construct empty domain registry. The initial version will be replaced
* on the first call of 'handle_config'. * on the first call of 'handle_config'.
*/ */
Genode::Heap domain_registry_heap { env.ram(), env.rm() };
Genode::Volatile_object<Domain_registry> domain_registry { Genode::Volatile_object<Domain_registry> domain_registry {
*env()->heap(), Genode::Xml_node("<config/>") }; domain_registry_heap, Genode::Xml_node("<config/>") };
User_state user_state = { global_keys, fb_screen->screen.size() }; User_state user_state = { global_keys, fb_screen->screen.size() };
@ -1159,33 +1164,35 @@ struct Nitpicker::Main
/* /*
* Initialize Nitpicker root interface * Initialize Nitpicker root interface
*/ */
Genode::Sliced_heap sliced_heap = { env()->ram_session(), env()->rm_session() }; Genode::Sliced_heap sliced_heap { env.ram(), env.rm() };
Genode::Reporter pointer_reporter = { "pointer" }; Genode::Reporter pointer_reporter = { "pointer" };
Genode::Reporter hover_reporter = { "hover" }; Genode::Reporter hover_reporter = { "hover" };
Genode::Reporter focus_reporter = { "focus" }; Genode::Reporter focus_reporter = { "focus" };
Root<PT> np_root = { session_list, *domain_registry, global_keys, Genode::Attached_rom_dataspace config { env, "config" };
ep.rpc_ep(), user_state, user_state, pointer_origin,
Root<PT> np_root = { env, config, session_list, *domain_registry,
global_keys, user_state, user_state, pointer_origin,
sliced_heap, framebuffer, focus_reporter }; sliced_heap, framebuffer, focus_reporter };
/* /*
* Configuration-update dispatcher, executed in the context of the RPC * Configuration-update handler, executed in the context of the RPC
* entrypoint. * entrypoint.
* *
* In addition to installing the signal dispatcher, we trigger first signal * In addition to installing the signal handler, we trigger first signal
* manually to turn the initial configuration into effect. * manually to turn the initial configuration into effect.
*/ */
void handle_config(unsigned); void handle_config();
Signal_rpc_member<Main> config_dispatcher = { ep, *this, &Main::handle_config}; Signal_handler<Main> config_handler = { env.ep(), *this, &Main::handle_config};
/** /**
* Signal handler invoked on the reception of user input * Signal handler invoked on the reception of user input
*/ */
void handle_input(unsigned); void handle_input();
Signal_rpc_member<Main> input_dispatcher = { ep, *this, &Main::handle_input }; Signal_handler<Main> input_handler = { env.ep(), *this, &Main::handle_input };
/* /*
* Dispatch input and redraw periodically * Dispatch input and redraw periodically
@ -1226,24 +1233,24 @@ struct Nitpicker::Main
rect.w(), rect.h()); }); rect.w(), rect.h()); });
} }
Main(Server::Entrypoint &ep) : ep(ep) Main(Env &env) : env(env)
{ {
user_state.default_background(background); user_state.default_background(background);
user_state.stack(pointer_origin); user_state.stack(pointer_origin);
user_state.stack(background); user_state.stack(background);
config()->sigh(config_dispatcher); config.sigh(config_handler);
handle_config(0); handle_config();
framebuffer.sync_sigh(input_dispatcher); framebuffer.sync_sigh(input_handler);
framebuffer.mode_sigh(fb_mode_dispatcher); framebuffer.mode_sigh(fb_mode_handler);
env()->parent()->announce(ep.manage(np_root)); env.parent().announce(env.ep().manage(np_root));
} }
}; };
void Nitpicker::Main::handle_input(unsigned) void Nitpicker::Main::handle_input()
{ {
period_cnt++; period_cnt++;
@ -1312,11 +1319,10 @@ void Nitpicker::Main::handle_input(unsigned)
/** /**
* Helper function for 'handle_config' * Helper function for 'handle_config'
*/ */
static void configure_reporter(Genode::Reporter &reporter) static void configure_reporter(Genode::Xml_node config, Genode::Reporter &reporter)
{ {
try { try {
Genode::Xml_node config_xml = Genode::config()->xml_node(); reporter.enabled(config.sub_node("report")
reporter.enabled(config_xml.sub_node("report")
.attribute_value(reporter.name().string(), false)); .attribute_value(reporter.name().string(), false));
} catch (...) { } catch (...) {
reporter.enabled(false); reporter.enabled(false);
@ -1324,38 +1330,38 @@ static void configure_reporter(Genode::Reporter &reporter)
} }
void Nitpicker::Main::handle_config(unsigned) void Nitpicker::Main::handle_config()
{ {
config()->reload(); config.update();
/* update global keys policy */ /* update global keys policy */
global_keys.apply_config(session_list); global_keys.apply_config(config.xml(), session_list);
/* update background color */ /* update background color */
try { try {
config()->xml_node().sub_node("background") config.xml().sub_node("background")
.attribute("color").value(&background.color); .attribute("color").value(&background.color);
} catch (...) { } } catch (...) { }
/* enable or disable redraw debug mode */ /* enable or disable redraw debug mode */
tmp_fb = config()->xml_node().attribute_value("flash", false) tmp_fb = config.xml().attribute_value("flash", false)
? &framebuffer ? &framebuffer
: nullptr; : nullptr;
configure_reporter(pointer_reporter); configure_reporter(config.xml(), pointer_reporter);
configure_reporter(hover_reporter); configure_reporter(config.xml(), hover_reporter);
configure_reporter(focus_reporter); configure_reporter(config.xml(), focus_reporter);
/* update domain registry and session policies */ /* update domain registry and session policies */
for (::Session *s = session_list.first(); s; s = s->next()) for (::Session *s = session_list.first(); s; s = s->next())
s->reset_domain(); s->reset_domain();
try { try {
domain_registry.construct(*env()->heap(), config()->xml_node()); } domain_registry.construct(domain_registry_heap, config.xml()); }
catch (...) { } catch (...) { }
for (::Session *s = session_list.first(); s; s = s->next()) for (::Session *s = session_list.first(); s; s = s->next())
s->apply_session_policy(*domain_registry); s->apply_session_policy(config.xml(), *domain_registry);
user_state.apply_origin_policy(pointer_origin); user_state.apply_origin_policy(pointer_origin);
@ -1370,7 +1376,7 @@ void Nitpicker::Main::handle_config(unsigned)
} }
void Nitpicker::Main::handle_fb_mode(unsigned) void Nitpicker::Main::handle_fb_mode()
{ {
/* reconstruct framebuffer screen and menu bar */ /* reconstruct framebuffer screen and menu bar */
fb_screen.construct(framebuffer); fb_screen.construct(framebuffer);
@ -1390,18 +1396,13 @@ void Nitpicker::Main::handle_fb_mode(unsigned)
} }
/************ /***************
** Server ** ** Component **
************/ ***************/
namespace Server { namespace Component {
char const *name() { return "nitpicker_ep"; } Genode::size_t stack_size() { return 4*1024*sizeof(long); }
size_t stack_size() { return 4*1024*sizeof(long); } void construct(Genode::Env &env) { static Nitpicker::Main nitpicker(env); }
void construct(Entrypoint &ep)
{
static Nitpicker::Main nitpicker(ep);
}
} }

View File

@ -196,17 +196,17 @@ class Session : public Session_list::Element
* Select the policy that matches the label. If multiple policies * Select the policy that matches the label. If multiple policies
* match, select the one with the largest number of characters. * match, select the one with the largest number of characters.
*/ */
void apply_session_policy(Domain_registry const &domain_registry) void apply_session_policy(Genode::Xml_node config,
Domain_registry const &domain_registry)
{ {
reset_domain(); reset_domain();
try { try {
Genode::Session_policy policy(_label); Genode::Session_policy policy(_label, config);
/* read domain attribute */ /* read domain attribute */
if (!policy.has_attribute("domain")) { if (!policy.has_attribute("domain")) {
PERR("policy for label \"%s\" lacks domain declaration", Genode::error("policy for label \"", _label, "\" lacks domain declaration");
_label.string());
return; return;
} }
@ -221,10 +221,11 @@ class Session : public Session_list::Element
_domain = domain_registry.lookup(name); _domain = domain_registry.lookup(name);
if (!_domain) if (!_domain)
PERR("policy for label \"%s\" specifies nonexistent domain \"%s\"", Genode::error("policy for label \"", _label,
_label.string(), name.string()); "\" specifies nonexistent domain \"", name, "\"");
} catch (...) { PERR("no policy matching label \"%s\"", _label.string()); } } catch (...) {
Genode::error("no policy matching label \"", _label, "\""); }
} }
}; };

View File

@ -1,5 +1,5 @@
TARGET = nitpicker TARGET = nitpicker
LIBS = base blit config server LIBS = base blit
SRC_CC = main.cc \ SRC_CC = main.cc \
view_stack.cc \ view_stack.cc \
view.cc \ view.cc \

View File

@ -11,7 +11,6 @@
* under the terms of the GNU General Public License version 2. * under the terms of the GNU General Public License version 2.
*/ */
#include <base/printf.h>
#include <os/pixel_rgb565.h> #include <os/pixel_rgb565.h>
#include <nitpicker_gfx/texture_painter.h> #include <nitpicker_gfx/texture_painter.h>