mirror of
https://github.com/genodelabs/genode.git
synced 2025-06-06 01:11:46 +00:00
loader: Adaptation to new nitpicker interface
This commit is contained in:
parent
8539239fc4
commit
7888e7be02
@ -21,41 +21,42 @@
|
|||||||
|
|
||||||
namespace Loader {
|
namespace Loader {
|
||||||
|
|
||||||
struct Session_client : Rpc_client<Session>
|
struct Session_client : Genode::Rpc_client<Session>
|
||||||
{
|
{
|
||||||
explicit Session_client(Loader::Session_capability session)
|
explicit Session_client(Loader::Session_capability session)
|
||||||
: Rpc_client<Session>(session) { }
|
: Rpc_client<Session>(session) { }
|
||||||
|
|
||||||
Dataspace_capability alloc_rom_module(Name const &name, size_t size) {
|
Dataspace_capability alloc_rom_module(Name const &name,
|
||||||
|
size_t size) override {
|
||||||
return call<Rpc_alloc_rom_module>(name, size); }
|
return call<Rpc_alloc_rom_module>(name, size); }
|
||||||
|
|
||||||
void commit_rom_module(Name const &name) {
|
void commit_rom_module(Name const &name) override {
|
||||||
call<Rpc_commit_rom_module>(name); }
|
call<Rpc_commit_rom_module>(name); }
|
||||||
|
|
||||||
void ram_quota(size_t quantum) {
|
void ram_quota(size_t quantum) override {
|
||||||
call<Rpc_ram_quota>(quantum); }
|
call<Rpc_ram_quota>(quantum); }
|
||||||
|
|
||||||
void constrain_geometry(int width, int height) {
|
void constrain_geometry(Area size) override {
|
||||||
call<Rpc_constrain_geometry>(width, height); }
|
call<Rpc_constrain_geometry>(size); }
|
||||||
|
|
||||||
void parent_view(Nitpicker::View_capability view) {
|
void parent_view(Nitpicker::View_capability view) override {
|
||||||
call<Rpc_parent_view>(view); }
|
call<Rpc_parent_view>(view); }
|
||||||
|
|
||||||
void view_ready_sigh(Signal_context_capability sigh) {
|
void view_ready_sigh(Signal_context_capability sigh) override {
|
||||||
call<Rpc_view_ready_sigh>(sigh); }
|
call<Rpc_view_ready_sigh>(sigh); }
|
||||||
|
|
||||||
void fault_sigh(Signal_context_capability sigh) {
|
void fault_sigh(Signal_context_capability sigh) override {
|
||||||
call<Rpc_fault_sigh>(sigh); }
|
call<Rpc_fault_sigh>(sigh); }
|
||||||
|
|
||||||
void start(Name const &binary, Name const &label = "",
|
void start(Name const &binary, Name const &label = "",
|
||||||
Native_pd_args const &pd_args = Native_pd_args()) {
|
Native_pd_args const &pd_args = Native_pd_args()) override {
|
||||||
call<Rpc_start>(binary, label, pd_args); }
|
call<Rpc_start>(binary, label, pd_args); }
|
||||||
|
|
||||||
Nitpicker::View_capability view() {
|
void view_geometry(Rect rect, Point offset) override {
|
||||||
return call<Rpc_view>(); }
|
call<Rpc_view_geometry>(rect, offset); }
|
||||||
|
|
||||||
View_geometry view_geometry() {
|
Area view_size() const override {
|
||||||
return call<Rpc_view_geometry>(); }
|
return call<Rpc_view_size>(); }
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,10 +21,18 @@
|
|||||||
#include <nitpicker_session/client.h>
|
#include <nitpicker_session/client.h>
|
||||||
#include <base/signal.h>
|
#include <base/signal.h>
|
||||||
#include <session/session.h>
|
#include <session/session.h>
|
||||||
|
#include <util/geometry.h>
|
||||||
|
|
||||||
namespace Loader {
|
namespace Loader {
|
||||||
|
|
||||||
using namespace Genode;
|
typedef Genode::Point<> Point;
|
||||||
|
typedef Genode::Area<> Area;
|
||||||
|
typedef Genode::Rect<> Rect;
|
||||||
|
|
||||||
|
using Genode::Dataspace_capability;
|
||||||
|
using Genode::Signal_context_capability;
|
||||||
|
using Genode::Native_pd_args;
|
||||||
|
using Genode::Meta::Type_tuple;
|
||||||
|
|
||||||
struct Session : Genode::Session
|
struct Session : Genode::Session
|
||||||
{
|
{
|
||||||
@ -41,18 +49,6 @@ namespace Loader {
|
|||||||
struct View_does_not_exist : Exception { };
|
struct View_does_not_exist : Exception { };
|
||||||
struct Rom_module_does_not_exist : Exception { };
|
struct Rom_module_does_not_exist : Exception { };
|
||||||
|
|
||||||
/**
|
|
||||||
* Return argument of 'view_geometry()'
|
|
||||||
*/
|
|
||||||
struct View_geometry
|
|
||||||
{
|
|
||||||
int width, height;
|
|
||||||
int buf_x, buf_y;
|
|
||||||
|
|
||||||
View_geometry(): width(0), height(0), buf_x(0), buf_y() {}
|
|
||||||
View_geometry(int w, int h, int x, int y): width(w), height(h), buf_x(x), buf_y(y) {}
|
|
||||||
};
|
|
||||||
|
|
||||||
typedef Genode::Rpc_in_buffer<64> Name;
|
typedef Genode::Rpc_in_buffer<64> Name;
|
||||||
typedef Genode::Rpc_in_buffer<128> Path;
|
typedef Genode::Rpc_in_buffer<128> Path;
|
||||||
|
|
||||||
@ -109,7 +105,7 @@ namespace Loader {
|
|||||||
* Calling this function prior 'start()' enables the virtualization
|
* Calling this function prior 'start()' enables the virtualization
|
||||||
* of the nitpicker session interface.
|
* of the nitpicker session interface.
|
||||||
*/
|
*/
|
||||||
virtual void constrain_geometry(int width, int height) = 0;
|
virtual void constrain_geometry(Area size) = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the parent view of the subsystem's view.
|
* Set the parent view of the subsystem's view.
|
||||||
@ -148,18 +144,14 @@ namespace Loader {
|
|||||||
Native_pd_args const &pd_args = Native_pd_args()) = 0;
|
Native_pd_args const &pd_args = Native_pd_args()) = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return first nitpicker view created by the loaded subsystem
|
* Set view geometry and buffer offset
|
||||||
*
|
|
||||||
* \throw View_does_not_exist
|
|
||||||
*/
|
*/
|
||||||
virtual Nitpicker::View_capability view() = 0;
|
virtual void view_geometry(Rect rect, Point offset) = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return view geometry as initialized by the loaded subsystem
|
* Return view size as initialized by the loaded subsystem
|
||||||
*
|
|
||||||
* \throw View_does_not_exist
|
|
||||||
*/
|
*/
|
||||||
virtual View_geometry view_geometry() = 0;
|
virtual Area view_size() const = 0;
|
||||||
|
|
||||||
|
|
||||||
/*******************
|
/*******************
|
||||||
@ -172,16 +164,18 @@ namespace Loader {
|
|||||||
GENODE_TYPE_LIST(Rom_module_does_not_exist),
|
GENODE_TYPE_LIST(Rom_module_does_not_exist),
|
||||||
Name const &);
|
Name const &);
|
||||||
GENODE_RPC(Rpc_ram_quota, void, ram_quota, size_t);
|
GENODE_RPC(Rpc_ram_quota, void, ram_quota, size_t);
|
||||||
GENODE_RPC(Rpc_constrain_geometry, void, constrain_geometry, int, int);
|
GENODE_RPC(Rpc_constrain_geometry, void, constrain_geometry, Area);
|
||||||
GENODE_RPC(Rpc_parent_view, void, parent_view, Nitpicker::View_capability);
|
GENODE_RPC(Rpc_parent_view, void, parent_view, Nitpicker::View_capability);
|
||||||
GENODE_RPC(Rpc_view_ready_sigh, void, view_ready_sigh, Signal_context_capability);
|
GENODE_RPC(Rpc_view_ready_sigh, void, view_ready_sigh, Signal_context_capability);
|
||||||
GENODE_RPC(Rpc_fault_sigh, void, fault_sigh, Signal_context_capability);
|
GENODE_RPC(Rpc_fault_sigh, void, fault_sigh, Signal_context_capability);
|
||||||
GENODE_RPC_THROW(Rpc_start, void, start,
|
GENODE_RPC_THROW(Rpc_start, void, start,
|
||||||
GENODE_TYPE_LIST(Rom_module_does_not_exist),
|
GENODE_TYPE_LIST(Rom_module_does_not_exist),
|
||||||
Name const &, Name const &, Native_pd_args const &);
|
Name const &, Name const &, Native_pd_args const &);
|
||||||
GENODE_RPC_THROW(Rpc_view, Nitpicker::View_capability, view,
|
GENODE_RPC_THROW(Rpc_view_geometry, void, view_geometry,
|
||||||
|
GENODE_TYPE_LIST(View_does_not_exist),
|
||||||
|
Rect, Point);
|
||||||
|
GENODE_RPC_THROW(Rpc_view_size, Area, view_size,
|
||||||
GENODE_TYPE_LIST(View_does_not_exist));
|
GENODE_TYPE_LIST(View_does_not_exist));
|
||||||
GENODE_RPC(Rpc_view_geometry, View_geometry, view_geometry);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* 'GENODE_RPC_INTERFACE' declaration done manually
|
* 'GENODE_RPC_INTERFACE' declaration done manually
|
||||||
@ -191,17 +185,17 @@ namespace Loader {
|
|||||||
* construct the type list by hand using nested type tuples instead
|
* construct the type list by hand using nested type tuples instead
|
||||||
* of employing the convenience macro 'GENODE_RPC_INTERFACE'.
|
* of employing the convenience macro 'GENODE_RPC_INTERFACE'.
|
||||||
*/
|
*/
|
||||||
typedef Meta::Type_tuple<Rpc_alloc_rom_module,
|
typedef Type_tuple<Rpc_alloc_rom_module,
|
||||||
Meta::Type_tuple<Rpc_commit_rom_module,
|
Type_tuple<Rpc_commit_rom_module,
|
||||||
Meta::Type_tuple<Rpc_ram_quota,
|
Type_tuple<Rpc_ram_quota,
|
||||||
Meta::Type_tuple<Rpc_constrain_geometry,
|
Type_tuple<Rpc_constrain_geometry,
|
||||||
Meta::Type_tuple<Rpc_parent_view,
|
Type_tuple<Rpc_parent_view,
|
||||||
Meta::Type_tuple<Rpc_view_ready_sigh,
|
Type_tuple<Rpc_view_ready_sigh,
|
||||||
Meta::Type_tuple<Rpc_fault_sigh,
|
Type_tuple<Rpc_fault_sigh,
|
||||||
Meta::Type_tuple<Rpc_start,
|
Type_tuple<Rpc_start,
|
||||||
Meta::Type_tuple<Rpc_view,
|
Type_tuple<Rpc_view_geometry,
|
||||||
Meta::Type_tuple<Rpc_view_geometry,
|
Type_tuple<Rpc_view_size,
|
||||||
Meta::Empty>
|
Genode::Meta::Empty>
|
||||||
> > > > > > > > > Rpc_functions;
|
> > > > > > > > > Rpc_functions;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -29,19 +29,18 @@ namespace Input {
|
|||||||
|
|
||||||
using namespace Genode;
|
using namespace Genode;
|
||||||
|
|
||||||
struct Transformer
|
typedef Genode::Point<> Motion_delta;
|
||||||
{
|
|
||||||
struct Delta { int const x, y; };
|
|
||||||
|
|
||||||
virtual Delta delta() = 0;
|
class Session_component;
|
||||||
};
|
}
|
||||||
|
|
||||||
class Session_component : public Rpc_object<Session>
|
|
||||||
{
|
class Input::Session_component : public Rpc_object<Session>
|
||||||
|
{
|
||||||
private:
|
private:
|
||||||
|
|
||||||
Session_client _real_input;
|
Session_client _real_input;
|
||||||
Transformer &_transformer;
|
Motion_delta &_motion_delta;
|
||||||
Event * const _ev_buf;
|
Event * const _ev_buf;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@ -50,9 +49,9 @@ namespace Input {
|
|||||||
* Constructor
|
* Constructor
|
||||||
*/
|
*/
|
||||||
Session_component(Session_capability real_input,
|
Session_component(Session_capability real_input,
|
||||||
Transformer &transformer)
|
Motion_delta &motion_delta)
|
||||||
:
|
:
|
||||||
_real_input(real_input), _transformer(transformer),
|
_real_input(real_input), _motion_delta(motion_delta),
|
||||||
_ev_buf(env()->rm_session()->attach(_real_input.dataspace()))
|
_ev_buf(env()->rm_session()->attach(_real_input.dataspace()))
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
@ -73,7 +72,7 @@ namespace Input {
|
|||||||
int flush() override
|
int flush() override
|
||||||
{
|
{
|
||||||
/* translate mouse position to child's coordinate system */
|
/* translate mouse position to child's coordinate system */
|
||||||
Transformer::Delta delta = _transformer.delta();
|
Motion_delta const delta = _motion_delta;
|
||||||
|
|
||||||
int const num_ev = _real_input.flush();
|
int const num_ev = _real_input.flush();
|
||||||
for (int i = 0; i < num_ev; i++) {
|
for (int i = 0; i < num_ev; i++) {
|
||||||
@ -88,8 +87,8 @@ namespace Input {
|
|||||||
|
|
||||||
ev = Input::Event(ev.type(),
|
ev = Input::Event(ev.type(),
|
||||||
ev.code(),
|
ev.code(),
|
||||||
ev.ax() - delta.x,
|
ev.ax() + delta.x(),
|
||||||
ev.ay() - delta.y,
|
ev.ay() + delta.y(),
|
||||||
ev.rx(),
|
ev.rx(),
|
||||||
ev.ry());
|
ev.ry());
|
||||||
}
|
}
|
||||||
@ -102,7 +101,6 @@ namespace Input {
|
|||||||
{
|
{
|
||||||
_real_input.sigh(sigh);
|
_real_input.sigh(sigh);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
|
||||||
|
|
||||||
#endif /* _INPUT_H_ */
|
#endif /* _INPUT_H_ */
|
||||||
|
@ -19,7 +19,6 @@
|
|||||||
#include <base/sleep.h>
|
#include <base/sleep.h>
|
||||||
#include <loader_session/loader_session.h>
|
#include <loader_session/loader_session.h>
|
||||||
#include <cap_session/connection.h>
|
#include <cap_session/connection.h>
|
||||||
#include <nitpicker_view/capability.h>
|
|
||||||
#include <root/component.h>
|
#include <root/component.h>
|
||||||
|
|
||||||
/* local includes */
|
/* local includes */
|
||||||
@ -33,9 +32,13 @@ namespace Loader {
|
|||||||
|
|
||||||
using namespace Genode;
|
using namespace Genode;
|
||||||
|
|
||||||
|
class Session_component;
|
||||||
|
class Root;
|
||||||
|
}
|
||||||
|
|
||||||
class Session_component : public Rpc_object<Session>
|
|
||||||
{
|
class Loader::Session_component : public Rpc_object<Session>
|
||||||
|
{
|
||||||
private:
|
private:
|
||||||
|
|
||||||
struct Local_rom_service : Service
|
struct Local_rom_service : Service
|
||||||
@ -173,25 +176,24 @@ namespace Loader {
|
|||||||
|
|
||||||
struct Local_nitpicker_service : Service
|
struct Local_nitpicker_service : Service
|
||||||
{
|
{
|
||||||
Rpc_entrypoint &ep;
|
Rpc_entrypoint &_ep;
|
||||||
|
Ram_session &_ram;
|
||||||
Allocator &_md_alloc;
|
Allocator &_md_alloc;
|
||||||
|
|
||||||
int _max_width;
|
Area _max_size;
|
||||||
int _max_height;
|
|
||||||
Nitpicker::View_capability _parent_view;
|
Nitpicker::View_capability _parent_view;
|
||||||
|
|
||||||
Signal_context_capability view_ready_sigh;
|
Signal_context_capability view_ready_sigh;
|
||||||
|
|
||||||
Nitpicker::Session_component *open_session;
|
Nitpicker::Session_component *open_session;
|
||||||
|
|
||||||
Local_nitpicker_service(Rpc_entrypoint &ep,
|
Local_nitpicker_service(Rpc_entrypoint &ep, Ram_session &ram,
|
||||||
Allocator &md_alloc)
|
Allocator &md_alloc)
|
||||||
:
|
:
|
||||||
Service("virtual_nitpicker"),
|
Service("virtual_nitpicker"),
|
||||||
ep(ep),
|
_ep(ep),
|
||||||
|
_ram(ram),
|
||||||
_md_alloc(md_alloc),
|
_md_alloc(md_alloc),
|
||||||
_max_width(-1),
|
|
||||||
_max_height(-1),
|
|
||||||
open_session(0)
|
open_session(0)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
@ -200,13 +202,13 @@ namespace Loader {
|
|||||||
if (!open_session)
|
if (!open_session)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
ep.dissolve(open_session);
|
_ep.dissolve(open_session);
|
||||||
destroy(&_md_alloc, open_session);
|
destroy(&_md_alloc, open_session);
|
||||||
}
|
}
|
||||||
|
|
||||||
void constrain_geometry(int width, int height)
|
void constrain_geometry(Area size)
|
||||||
{
|
{
|
||||||
_max_width = width, _max_height = height;
|
_max_size = size;
|
||||||
}
|
}
|
||||||
|
|
||||||
void parent_view(Nitpicker::View_capability view)
|
void parent_view(Nitpicker::View_capability view)
|
||||||
@ -221,14 +223,14 @@ namespace Loader {
|
|||||||
throw Unavailable();
|
throw Unavailable();
|
||||||
|
|
||||||
open_session = new (&_md_alloc)
|
open_session = new (&_md_alloc)
|
||||||
Nitpicker::Session_component(ep,
|
Nitpicker::Session_component(_ep,
|
||||||
_max_width,
|
_ram,
|
||||||
_max_height,
|
_max_size,
|
||||||
_parent_view,
|
_parent_view,
|
||||||
view_ready_sigh,
|
view_ready_sigh,
|
||||||
args);
|
args);
|
||||||
|
|
||||||
return ep.manage(open_session);
|
return _ep.manage(open_session);
|
||||||
}
|
}
|
||||||
|
|
||||||
void upgrade(Genode::Session_capability session, const char *) { }
|
void upgrade(Genode::Session_capability session, const char *) { }
|
||||||
@ -253,12 +255,12 @@ namespace Loader {
|
|||||||
/**
|
/**
|
||||||
* Return virtual nitpicker session component
|
* Return virtual nitpicker session component
|
||||||
*/
|
*/
|
||||||
Nitpicker::Session_component *_virtual_nitpicker_session()
|
Nitpicker::Session_component &_virtual_nitpicker_session() const
|
||||||
{
|
{
|
||||||
if (!_nitpicker_service.open_session)
|
if (!_nitpicker_service.open_session)
|
||||||
throw View_does_not_exist();
|
throw View_does_not_exist();
|
||||||
|
|
||||||
return _nitpicker_service.open_session;
|
return *_nitpicker_service.open_session;
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@ -275,7 +277,7 @@ namespace Loader {
|
|||||||
_ep(&cap, STACK_SIZE, "session_ep"),
|
_ep(&cap, STACK_SIZE, "session_ep"),
|
||||||
_rom_modules(_ram_session_client, _md_alloc),
|
_rom_modules(_ram_session_client, _md_alloc),
|
||||||
_rom_service(_ep, _md_alloc, _rom_modules),
|
_rom_service(_ep, _md_alloc, _rom_modules),
|
||||||
_nitpicker_service(_ep, _md_alloc),
|
_nitpicker_service(_ep, _ram_session_client, _md_alloc),
|
||||||
_child(0)
|
_child(0)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
@ -299,12 +301,12 @@ namespace Loader {
|
|||||||
** Loader session interface **
|
** Loader session interface **
|
||||||
******************************/
|
******************************/
|
||||||
|
|
||||||
Dataspace_capability alloc_rom_module(Name const &name, size_t size)
|
Dataspace_capability alloc_rom_module(Name const &name, size_t size) override
|
||||||
{
|
{
|
||||||
return _rom_modules.alloc_rom_module(name.string(), size);
|
return _rom_modules.alloc_rom_module(name.string(), size);
|
||||||
}
|
}
|
||||||
|
|
||||||
void commit_rom_module(Name const &name)
|
void commit_rom_module(Name const &name) override
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
_rom_modules.commit_rom_module(name.string()); }
|
_rom_modules.commit_rom_module(name.string()); }
|
||||||
@ -312,27 +314,27 @@ namespace Loader {
|
|||||||
throw Rom_module_does_not_exist(); }
|
throw Rom_module_does_not_exist(); }
|
||||||
}
|
}
|
||||||
|
|
||||||
void ram_quota(size_t quantum)
|
void ram_quota(size_t quantum) override
|
||||||
{
|
{
|
||||||
_subsystem_ram_quota_limit = quantum;
|
_subsystem_ram_quota_limit = quantum;
|
||||||
}
|
}
|
||||||
|
|
||||||
void constrain_geometry(int width, int height)
|
void constrain_geometry(Area size) override
|
||||||
{
|
{
|
||||||
_nitpicker_service.constrain_geometry(width, height);
|
_nitpicker_service.constrain_geometry(size);
|
||||||
}
|
}
|
||||||
|
|
||||||
void parent_view(Nitpicker::View_capability view)
|
void parent_view(Nitpicker::View_capability view) override
|
||||||
{
|
{
|
||||||
_nitpicker_service.parent_view(view);
|
_nitpicker_service.parent_view(view);
|
||||||
}
|
}
|
||||||
|
|
||||||
void view_ready_sigh(Signal_context_capability sigh)
|
void view_ready_sigh(Signal_context_capability sigh) override
|
||||||
{
|
{
|
||||||
_nitpicker_service.view_ready_sigh = sigh;
|
_nitpicker_service.view_ready_sigh = sigh;
|
||||||
}
|
}
|
||||||
|
|
||||||
void fault_sigh(Signal_context_capability sigh)
|
void fault_sigh(Signal_context_capability sigh) override
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* CPU exception handler for CPU sessions originating from the
|
* CPU exception handler for CPU sessions originating from the
|
||||||
@ -353,7 +355,7 @@ namespace Loader {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void start(Name const &binary_name, Name const &label,
|
void start(Name const &binary_name, Name const &label,
|
||||||
Genode::Native_pd_args const &pd_args)
|
Genode::Native_pd_args const &pd_args) override
|
||||||
{
|
{
|
||||||
if (_child) {
|
if (_child) {
|
||||||
PWRN("cannot start subsystem twice");
|
PWRN("cannot start subsystem twice");
|
||||||
@ -376,20 +378,20 @@ namespace Loader {
|
|||||||
throw Rom_module_does_not_exist(); }
|
throw Rom_module_does_not_exist(); }
|
||||||
}
|
}
|
||||||
|
|
||||||
Nitpicker::View_capability view()
|
void view_geometry(Rect rect, Point offset) override
|
||||||
{
|
{
|
||||||
return _virtual_nitpicker_session()->loader_view();
|
_virtual_nitpicker_session().loader_view_geometry(rect, offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
View_geometry view_geometry()
|
Area view_size() const override
|
||||||
{
|
{
|
||||||
return _virtual_nitpicker_session()->loader_view_geometry();
|
return _virtual_nitpicker_session().loader_view_size();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class Root : public Root_component<Session_component>
|
class Loader::Root : public Root_component<Session_component>
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
|
|
||||||
Ram_session &_ram;
|
Ram_session &_ram;
|
||||||
@ -420,8 +422,7 @@ namespace Loader {
|
|||||||
Root_component<Session_component>(&session_ep, &md_alloc),
|
Root_component<Session_component>(&session_ep, &md_alloc),
|
||||||
_ram(ram), _cap(cap)
|
_ram(ram), _cap(cap)
|
||||||
{ }
|
{ }
|
||||||
};
|
};
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
|
@ -19,196 +19,156 @@
|
|||||||
#include <util/arg_string.h>
|
#include <util/arg_string.h>
|
||||||
#include <util/misc_math.h>
|
#include <util/misc_math.h>
|
||||||
#include <base/signal.h>
|
#include <base/signal.h>
|
||||||
|
#include <os/attached_ram_dataspace.h>
|
||||||
#include <nitpicker_session/connection.h>
|
#include <nitpicker_session/connection.h>
|
||||||
#include <nitpicker_session/nitpicker_session.h>
|
#include <nitpicker_session/nitpicker_session.h>
|
||||||
#include <nitpicker_view/client.h>
|
|
||||||
|
|
||||||
/* local includes */
|
/* local includes */
|
||||||
#include <input.h>
|
#include <input.h>
|
||||||
|
|
||||||
namespace Nitpicker {
|
namespace Nitpicker { class Session_component; }
|
||||||
|
|
||||||
using namespace Genode;
|
|
||||||
|
|
||||||
/**
|
class Nitpicker::Session_component : public Genode::Rpc_object<Session>
|
||||||
* View interface provided to the loader client
|
{
|
||||||
*/
|
|
||||||
class Loader_view_component : public Rpc_object<View>
|
|
||||||
{
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
View_client _view; /* wrapped view */
|
|
||||||
|
|
||||||
int _x, _y, _buf_x, _buf_y;
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Signal handler to be notified once the geometry of the view is
|
||||||
|
* known.
|
||||||
*/
|
*/
|
||||||
Loader_view_component(View_capability view_cap)
|
Genode::Signal_context_capability _view_ready_sigh;
|
||||||
:
|
|
||||||
_view(view_cap), _x(0), _y(0), _buf_x(0), _buf_y(0)
|
|
||||||
{ }
|
|
||||||
|
|
||||||
int x() const { return _x; }
|
Genode::Rpc_entrypoint &_ep;
|
||||||
int y() const { return _y; }
|
|
||||||
int buf_x() const { return _buf_x; }
|
|
||||||
int buf_y() const { return _buf_y; }
|
|
||||||
|
|
||||||
|
Area _max_size;
|
||||||
/******************************
|
|
||||||
** Nitpicker view interface **
|
|
||||||
******************************/
|
|
||||||
|
|
||||||
int viewport(int x, int y, int w, int h,
|
|
||||||
int buf_x, int buf_y, bool redraw)
|
|
||||||
{
|
|
||||||
_x = x, _y = y, _buf_x = buf_x, _buf_y = buf_y;
|
|
||||||
|
|
||||||
return _view.viewport(x, y, w, h, buf_x, buf_y, redraw);
|
|
||||||
}
|
|
||||||
|
|
||||||
int stack(View_capability neighbor_cap, bool behind, bool redraw)
|
|
||||||
{
|
|
||||||
return _view.stack(neighbor_cap, behind, redraw);
|
|
||||||
}
|
|
||||||
|
|
||||||
int title(Title const &title)
|
|
||||||
{
|
|
||||||
return _view.title(title.string());
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* View interface exposed to the subsystem
|
|
||||||
*/
|
|
||||||
class View_component : public Rpc_object<View>
|
|
||||||
{
|
|
||||||
private:
|
|
||||||
|
|
||||||
View_client _view; /* wrapped view */
|
|
||||||
Signal_context_capability _sigh;
|
|
||||||
bool _viewport_initialized;
|
|
||||||
int _x, _y, _w, _h, _buf_x, _buf_y;
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructor
|
|
||||||
*/
|
|
||||||
View_component(View_capability view_cap,
|
|
||||||
Signal_context_capability sigh)
|
|
||||||
:
|
|
||||||
_view(view_cap), _sigh(sigh), _viewport_initialized(false),
|
|
||||||
_x(0), _y(0), _w(0), _h(0), _buf_x(0), _buf_y(0)
|
|
||||||
{ }
|
|
||||||
|
|
||||||
int x() const { return _x; }
|
|
||||||
int y() const { return _y; }
|
|
||||||
int w() const { return _w; }
|
|
||||||
int h() const { return _h; }
|
|
||||||
int buf_x() const { return _buf_x; }
|
|
||||||
int buf_y() const { return _buf_y; }
|
|
||||||
|
|
||||||
|
|
||||||
/******************************
|
|
||||||
** Nitpicker view interface **
|
|
||||||
******************************/
|
|
||||||
|
|
||||||
int viewport(int x, int y, int w, int h,
|
|
||||||
int buf_x, int buf_y, bool redraw)
|
|
||||||
{
|
|
||||||
_x = x; _y = y; _w = w; _h = h;
|
|
||||||
_buf_x = buf_x; _buf_y = buf_y;
|
|
||||||
|
|
||||||
if (_viewport_initialized)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
_viewport_initialized = true;
|
|
||||||
|
|
||||||
/* hide the view and let the application set the viewport */
|
|
||||||
int result = _view.viewport(0, 0, 0, 0, 0, 0, true);
|
|
||||||
|
|
||||||
/* signal readyness of the view */
|
|
||||||
if (_sigh.valid())
|
|
||||||
Signal_transmitter(_sigh).submit();
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
int stack(View_capability neighbor_cap, bool behind, bool redraw)
|
|
||||||
{
|
|
||||||
/*
|
|
||||||
* Only one child view is supported, so the stack request can
|
|
||||||
* be ignored.
|
|
||||||
*/
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int title(Title const &title)
|
|
||||||
{
|
|
||||||
return _view.title(title.string());
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
class Session_component : public Rpc_object<Session>,
|
|
||||||
public Input::Transformer
|
|
||||||
{
|
|
||||||
private:
|
|
||||||
|
|
||||||
Rpc_entrypoint &_ep;
|
|
||||||
|
|
||||||
int _max_width;
|
|
||||||
int _max_height;
|
|
||||||
|
|
||||||
Nitpicker::Connection _nitpicker;
|
Nitpicker::Connection _nitpicker;
|
||||||
View_capability _nitpicker_view;
|
|
||||||
|
|
||||||
View_component _proxy_view;
|
View_handle _parent_view_handle;
|
||||||
View_capability _proxy_view_cap;
|
|
||||||
|
|
||||||
Loader_view_component _loader_view;
|
/*
|
||||||
View_capability _loader_view_cap;
|
* Physical view
|
||||||
|
*/
|
||||||
|
View_handle _view_handle;
|
||||||
|
Rect _view_geometry;
|
||||||
|
Point _view_offset;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Geometry of virtual view presented to the loaded subsystem
|
||||||
|
*/
|
||||||
|
Rect _virt_view_geometry;
|
||||||
|
Point _virt_view_offset;
|
||||||
|
bool _virt_view_geometry_defined = false;
|
||||||
|
|
||||||
|
Input::Motion_delta _motion_delta;
|
||||||
|
|
||||||
Input::Session_component _proxy_input;
|
Input::Session_component _proxy_input;
|
||||||
Input::Session_capability _proxy_input_cap;
|
Input::Session_capability _proxy_input_cap;
|
||||||
|
|
||||||
static long _session_arg(const char *arg, const char *key) {
|
static long _session_arg(const char *arg, const char *key) {
|
||||||
return Arg_string::find_arg(arg, key).long_value(0); }
|
return Genode::Arg_string::find_arg(arg, key).long_value(0); }
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Command buffer
|
||||||
|
*/
|
||||||
|
typedef Nitpicker::Session::Command_buffer Command_buffer;
|
||||||
|
Genode::Attached_ram_dataspace _command_ds;
|
||||||
|
Command_buffer &_command_buffer = *_command_ds.local_addr<Command_buffer>();
|
||||||
|
|
||||||
|
void _propagate_view_offset()
|
||||||
|
{
|
||||||
|
_nitpicker.enqueue<Command::Offset>(_view_handle,
|
||||||
|
_view_offset + _virt_view_offset);
|
||||||
|
}
|
||||||
|
|
||||||
|
void _update_motion_delta()
|
||||||
|
{
|
||||||
|
_motion_delta = _virt_view_geometry.p1() - _view_geometry.p1();
|
||||||
|
}
|
||||||
|
|
||||||
|
void _execute_command(Command const &command)
|
||||||
|
{
|
||||||
|
switch (command.opcode) {
|
||||||
|
|
||||||
|
case Command::OP_GEOMETRY:
|
||||||
|
{
|
||||||
|
_virt_view_geometry = command.geometry.rect;
|
||||||
|
|
||||||
|
if (!_virt_view_geometry_defined)
|
||||||
|
Genode::Signal_transmitter(_view_ready_sigh).submit();
|
||||||
|
|
||||||
|
_virt_view_geometry_defined = true;
|
||||||
|
|
||||||
|
_update_motion_delta();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
case Command::OP_OFFSET:
|
||||||
|
{
|
||||||
|
_virt_view_offset = command.offset.offset;
|
||||||
|
_propagate_view_offset();
|
||||||
|
_nitpicker.execute();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
case Command::OP_TO_FRONT:
|
||||||
|
{
|
||||||
|
_nitpicker.enqueue<Command::To_front>(_view_handle, _parent_view_handle);
|
||||||
|
_nitpicker.execute();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
case Command::OP_TO_BACK:
|
||||||
|
{
|
||||||
|
PDBG("OP_TO_BACK not implemented");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
case Command::OP_BACKGROUND:
|
||||||
|
{
|
||||||
|
PDBG("OP_BACKGROUND not implemented");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
case Command::OP_TITLE:
|
||||||
|
{
|
||||||
|
_nitpicker.enqueue(command);
|
||||||
|
_nitpicker.execute();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
case Command::OP_NOP:
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*/
|
*/
|
||||||
Session_component(Rpc_entrypoint &ep,
|
Session_component(Genode::Rpc_entrypoint &ep,
|
||||||
int max_width,
|
Genode::Ram_session &ram,
|
||||||
int max_height,
|
Area max_size,
|
||||||
Nitpicker::View_capability parent_view,
|
Nitpicker::View_capability parent_view,
|
||||||
Signal_context_capability view_ready_sigh,
|
Genode::Signal_context_capability view_ready_sigh,
|
||||||
const char *args)
|
const char *args)
|
||||||
:
|
:
|
||||||
|
_view_ready_sigh(view_ready_sigh),
|
||||||
_ep(ep),
|
_ep(ep),
|
||||||
|
_max_size(max_size),
|
||||||
|
|
||||||
_max_width(max_width),
|
/* import parent view */
|
||||||
_max_height(max_height),
|
_parent_view_handle(_nitpicker.view_handle(parent_view)),
|
||||||
|
|
||||||
/* create Nitpicker view */
|
/* create nitpicker view */
|
||||||
_nitpicker_view(_nitpicker.create_view(parent_view)),
|
_view_handle(_nitpicker.create_view(_parent_view_handle)),
|
||||||
|
|
||||||
/* create proxy view component for the child */
|
_proxy_input(_nitpicker.input_session(), _motion_delta),
|
||||||
_proxy_view(_nitpicker_view, view_ready_sigh),
|
_proxy_input_cap(_ep.manage(&_proxy_input)),
|
||||||
_proxy_view_cap(_ep.manage(&_proxy_view)),
|
|
||||||
|
|
||||||
/* create view component accessed by the loader client */
|
_command_ds(&ram, sizeof(Command_buffer))
|
||||||
_loader_view(_nitpicker_view),
|
|
||||||
_loader_view_cap(_ep.manage(&_loader_view)),
|
|
||||||
|
|
||||||
_proxy_input(_nitpicker.input_session(), *this),
|
|
||||||
_proxy_input_cap(_ep.manage(&_proxy_input))
|
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
|
|
||||||
@ -226,88 +186,92 @@ namespace Nitpicker {
|
|||||||
return _proxy_input_cap;
|
return _proxy_input_cap;
|
||||||
}
|
}
|
||||||
|
|
||||||
View_capability create_view(View_capability) override
|
View_handle create_view(View_handle) override
|
||||||
{
|
{
|
||||||
return _proxy_view_cap;
|
return View_handle(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void destroy_view(View_capability view) override
|
void destroy_view(View_handle view) override { }
|
||||||
|
|
||||||
|
View_handle view_handle(View_capability, View_handle) override
|
||||||
{
|
{
|
||||||
_nitpicker.destroy_view(_nitpicker_view);
|
return View_handle();
|
||||||
}
|
}
|
||||||
|
|
||||||
int background(View_capability view) override
|
View_capability view_capability(View_handle) override
|
||||||
{
|
{
|
||||||
/* not forwarding to real nitpicker session */
|
return View_capability();
|
||||||
return 0;
|
}
|
||||||
|
|
||||||
|
void release_view_handle(View_handle) override { }
|
||||||
|
|
||||||
|
Genode::Dataspace_capability command_dataspace() override
|
||||||
|
{
|
||||||
|
return _command_ds.cap();
|
||||||
|
}
|
||||||
|
|
||||||
|
void execute() override
|
||||||
|
{
|
||||||
|
for (unsigned i = 0; i < _command_buffer.num(); i++)
|
||||||
|
_execute_command(_command_buffer.get(i));
|
||||||
}
|
}
|
||||||
|
|
||||||
Framebuffer::Mode mode() override
|
Framebuffer::Mode mode() override
|
||||||
{
|
{
|
||||||
int mode_width = (_max_width > -1) ?
|
int mode_width = _max_size.valid() ?
|
||||||
_max_width :
|
_max_size.w() :
|
||||||
_nitpicker.mode().width();
|
_nitpicker.mode().width();
|
||||||
|
|
||||||
int mode_height = (_max_height > -1) ?
|
int mode_height = _max_size.valid() ?
|
||||||
_max_height :
|
_max_size.h() :
|
||||||
_nitpicker.mode().height();
|
_nitpicker.mode().height();
|
||||||
|
|
||||||
return Framebuffer::Mode(mode_width, mode_height,
|
return Framebuffer::Mode(mode_width, mode_height,
|
||||||
_nitpicker.mode().format());
|
_nitpicker.mode().format());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void mode_sigh(Genode::Signal_context_capability) override { }
|
||||||
|
|
||||||
void buffer(Framebuffer::Mode mode, bool use_alpha) override
|
void buffer(Framebuffer::Mode mode, bool use_alpha) override
|
||||||
{
|
{
|
||||||
_nitpicker.buffer(mode, use_alpha);
|
_nitpicker.buffer(mode, use_alpha);
|
||||||
}
|
}
|
||||||
|
|
||||||
void focus(Capability<Session>) override { }
|
void focus(Genode::Capability<Session>) override { }
|
||||||
|
|
||||||
|
|
||||||
/**********************************
|
|
||||||
** Input::Transformer interface **
|
|
||||||
**********************************/
|
|
||||||
|
|
||||||
Input::Transformer::Delta delta()
|
|
||||||
{
|
|
||||||
/* translate mouse position to child's coordinate system */
|
|
||||||
Input::Transformer::Delta result = {
|
|
||||||
_loader_view.x() + _loader_view.buf_x() +
|
|
||||||
_proxy_view.x() + _proxy_view.buf_x(),
|
|
||||||
_loader_view.y() + _loader_view.buf_y() +
|
|
||||||
_proxy_view.y() + _proxy_view.buf_y() };
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Return the client-specific wrapper view for the Nitpicker view
|
|
||||||
* showing the child content
|
|
||||||
*/
|
|
||||||
View_capability loader_view() { return _loader_view_cap; }
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return geometry of loader view
|
* Return geometry of loader view
|
||||||
*/
|
*/
|
||||||
Loader::Session::View_geometry loader_view_geometry()
|
Area loader_view_size() const
|
||||||
{
|
{
|
||||||
int view_width = (_max_width > -1) ?
|
int const width = _max_size.valid()
|
||||||
min(_proxy_view.w(), _max_width) :
|
? Genode::min(_virt_view_geometry.w(), _max_size.w())
|
||||||
_proxy_view.w();
|
: _virt_view_geometry.w();
|
||||||
|
|
||||||
int view_height = (_max_height > -1) ?
|
int const height = _max_size.valid()
|
||||||
min(_proxy_view.h(), _max_height) :
|
? Genode::min(_virt_view_geometry.h(), _max_size.h())
|
||||||
_proxy_view.h();
|
: _virt_view_geometry.h();
|
||||||
|
|
||||||
Loader::Session::View_geometry result(
|
return Area(width, height);
|
||||||
view_width,
|
|
||||||
view_height,
|
|
||||||
_proxy_view.buf_x(),
|
|
||||||
_proxy_view.buf_y());
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
};
|
|
||||||
}
|
/**
|
||||||
|
* Define geometry of loader view
|
||||||
|
*/
|
||||||
|
void loader_view_geometry(Rect rect, Point offset)
|
||||||
|
{
|
||||||
|
typedef Nitpicker::Session::Command Command;
|
||||||
|
|
||||||
|
_view_geometry = rect;
|
||||||
|
_view_offset = offset;
|
||||||
|
|
||||||
|
_propagate_view_offset();
|
||||||
|
_nitpicker.enqueue<Command::Geometry>(_view_handle, _view_geometry);
|
||||||
|
_nitpicker.enqueue<Command::To_front>(_view_handle, _parent_view_handle);
|
||||||
|
_nitpicker.execute();
|
||||||
|
|
||||||
|
_update_motion_delta();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
#endif /* _NITPICKER_H_ */
|
#endif /* _NITPICKER_H_ */
|
||||||
|
@ -14,18 +14,16 @@
|
|||||||
#include <base/printf.h>
|
#include <base/printf.h>
|
||||||
#include <base/sleep.h>
|
#include <base/sleep.h>
|
||||||
#include <loader_session/connection.h>
|
#include <loader_session/connection.h>
|
||||||
#include <nitpicker_session/client.h>
|
|
||||||
#include <timer_session/connection.h>
|
#include <timer_session/connection.h>
|
||||||
|
|
||||||
using namespace Genode;
|
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
Loader::Connection loader(8*1024*1024);
|
Loader::Connection loader(8*1024*1024);
|
||||||
|
|
||||||
static Signal_receiver sig_rec;
|
static Genode::Signal_receiver sig_rec;
|
||||||
|
|
||||||
Signal_context sig_ctx;
|
Genode::Signal_context sig_ctx;
|
||||||
|
|
||||||
loader.view_ready_sigh(sig_rec.manage(&sig_ctx));
|
loader.view_ready_sigh(sig_rec.manage(&sig_ctx));
|
||||||
|
|
||||||
@ -33,31 +31,22 @@ int main(int argc, char **argv)
|
|||||||
|
|
||||||
sig_rec.wait_for_signal();
|
sig_rec.wait_for_signal();
|
||||||
|
|
||||||
Loader::Session::View_geometry geometry = loader.view_geometry();
|
Loader::Area size = loader.view_size();
|
||||||
Nitpicker::View_capability view_cap = loader.view();
|
|
||||||
|
|
||||||
static Nitpicker_connection nitpicker;
|
|
||||||
|
|
||||||
Nitpicker::Session::View_handle view_handle = nitpicker.view_handle(view_cap);
|
|
||||||
|
|
||||||
nitpicker.enqueue<Nitpicker::Session::Command::To_front>(view_handle);
|
|
||||||
nitpicker.execute();
|
|
||||||
|
|
||||||
Timer::Connection timer;
|
Timer::Connection timer;
|
||||||
|
|
||||||
while(1) {
|
while (1) {
|
||||||
|
|
||||||
for (unsigned i = 0; i < 10; i++) {
|
for (unsigned i = 0; i < 10; i++) {
|
||||||
|
|
||||||
Nitpicker::Rect rect(Nitpicker::Point(50*i, 50*i),
|
loader.view_geometry(Loader::Rect(Loader::Point(50*i, 50*i), size),
|
||||||
Nitpicker::Area(geometry.width, geometry.height));
|
Loader::Point(0, 0));
|
||||||
nitpicker.enqueue<Nitpicker::Session::Command::Geometry>(rect);
|
|
||||||
|
|
||||||
timer.msleep(1000);
|
timer.msleep(1000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sleep_forever();
|
Genode::sleep_forever();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user