mirror of
https://github.com/genodelabs/genode.git
synced 2024-12-19 13:47:56 +00:00
parent
2b7fcf5cae
commit
5f4ead01bb
@ -17,8 +17,7 @@
|
||||
/* Genode includes */
|
||||
#include <util/string.h>
|
||||
#include <ram_session/client.h>
|
||||
#include <os/server.h>
|
||||
#include <os/attached_dataspace.h>
|
||||
#include <base/attached_dataspace.h>
|
||||
#include <os/reporter.h>
|
||||
#include <nitpicker_session/connection.h>
|
||||
#include <input_session/client.h>
|
||||
@ -32,14 +31,13 @@
|
||||
namespace Wm { class Main;
|
||||
using Genode::size_t;
|
||||
using Genode::Allocator;
|
||||
using Server::Entrypoint;
|
||||
using Genode::Ram_session_client;
|
||||
using Genode::Ram_session_capability;
|
||||
using Genode::Arg_string;
|
||||
using Genode::Object_pool;
|
||||
using Genode::Attached_dataspace;
|
||||
using Genode::Attached_ram_dataspace;
|
||||
using Genode::Signal_rpc_member;
|
||||
using Genode::Signal_handler;
|
||||
using Genode::Reporter;
|
||||
}
|
||||
|
||||
@ -159,15 +157,17 @@ struct Wm::Decorator_nitpicker_session : Genode::Rpc_object<Nitpicker::Session>,
|
||||
typedef Nitpicker::View_capability View_capability;
|
||||
typedef Nitpicker::Session::View_handle View_handle;
|
||||
|
||||
Genode::Env &_env;
|
||||
|
||||
Ram_session_client _ram;
|
||||
|
||||
Nitpicker::Connection _nitpicker_session { "decorator" };
|
||||
Nitpicker::Connection _nitpicker_session { _env, "decorator" };
|
||||
|
||||
Genode::Signal_context_capability _mode_sigh;
|
||||
|
||||
typedef Nitpicker::Session::Command_buffer Command_buffer;
|
||||
|
||||
Attached_ram_dataspace _command_ds { &_ram, sizeof(Command_buffer) };
|
||||
Attached_ram_dataspace _command_ds { _ram, _env.rm(), sizeof(Command_buffer) };
|
||||
|
||||
Command_buffer &_command_buffer = *_command_ds.local_addr<Command_buffer>();
|
||||
|
||||
@ -182,41 +182,41 @@ struct Wm::Decorator_nitpicker_session : Genode::Rpc_object<Nitpicker::Session>,
|
||||
/* XXX don't allocate content-registry entries from heap */
|
||||
Decorator_content_registry _content_registry { *Genode::env()->heap() };
|
||||
|
||||
Entrypoint &_ep;
|
||||
|
||||
Allocator &_md_alloc;
|
||||
|
||||
/* Nitpicker::Connection requires a valid input session */
|
||||
Input::Session_component _dummy_input_component;
|
||||
Input::Session_capability _dummy_input_component_cap =
|
||||
_ep.manage(_dummy_input_component);
|
||||
_env.ep().manage(_dummy_input_component);
|
||||
|
||||
Signal_rpc_member<Decorator_nitpicker_session>
|
||||
_input_dispatcher { _ep, *this, &Decorator_nitpicker_session::_input_handler };
|
||||
Signal_handler<Decorator_nitpicker_session>
|
||||
_input_handler { _env.ep(), *this, &Decorator_nitpicker_session::_handle_input };
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* \param ep entrypoint used for dispatching signals
|
||||
*/
|
||||
Decorator_nitpicker_session(Ram_session_capability ram,
|
||||
Entrypoint &ep, Allocator &md_alloc,
|
||||
Decorator_nitpicker_session(Genode::Env &env,
|
||||
Ram_session_capability ram,
|
||||
Allocator &md_alloc,
|
||||
Reporter &pointer_reporter,
|
||||
Last_motion &last_motion,
|
||||
Input::Session_component &window_layouter_input,
|
||||
Decorator_content_callback &content_callback)
|
||||
:
|
||||
_env(env),
|
||||
_ram(ram),
|
||||
_pointer_reporter(pointer_reporter),
|
||||
_last_motion(last_motion),
|
||||
_window_layouter_input(window_layouter_input),
|
||||
_content_callback(content_callback),
|
||||
_ep(ep), _md_alloc(md_alloc)
|
||||
_md_alloc(md_alloc)
|
||||
{
|
||||
_nitpicker_session.input()->sigh(_input_dispatcher);
|
||||
_nitpicker_session.input()->sigh(_input_handler);
|
||||
}
|
||||
|
||||
void _input_handler(unsigned)
|
||||
void _handle_input()
|
||||
{
|
||||
while (_nitpicker_session.input()->pending())
|
||||
_nitpicker_session.input()->for_each_event([&] (Input::Event const &ev) {
|
||||
|
@ -15,13 +15,9 @@
|
||||
#define _LAYOUTER_NITPICKER_H_
|
||||
|
||||
/* Genode includes */
|
||||
#include <os/server.h>
|
||||
#include <input/component.h>
|
||||
#include <nitpicker_session/connection.h>
|
||||
|
||||
namespace Wm { using Server::Entrypoint; }
|
||||
|
||||
|
||||
namespace Wm {
|
||||
struct Layouter_nitpicker_session;
|
||||
struct Layouter_nitpicker_service;
|
||||
|
@ -12,11 +12,11 @@
|
||||
*/
|
||||
|
||||
/* Genode includes */
|
||||
#include <os/server.h>
|
||||
#include <nitpicker_session/client.h>
|
||||
#include <framebuffer_session/client.h>
|
||||
#include <cap_session/connection.h>
|
||||
#include <os/attached_rom_dataspace.h>
|
||||
#include <base/component.h>
|
||||
#include <base/attached_rom_dataspace.h>
|
||||
#include <base/heap.h>
|
||||
#include <util/reconstructible.h>
|
||||
#include <util/xml_node.h>
|
||||
|
||||
@ -38,15 +38,15 @@ namespace Wm {
|
||||
|
||||
struct Wm::Main
|
||||
{
|
||||
Server::Entrypoint &ep;
|
||||
Genode::Env &env;
|
||||
|
||||
Genode::Cap_connection cap;
|
||||
Genode::Heap heap { env.ram(), env.rm() };
|
||||
|
||||
/* currently focused window, reported by the layouter */
|
||||
Attached_rom_dataspace focus_rom { "focus" };
|
||||
Attached_rom_dataspace focus_rom { env, "focus" };
|
||||
|
||||
/* resize requests, issued by the layouter */
|
||||
Attached_rom_dataspace resize_request_rom { "resize_request" };
|
||||
Attached_rom_dataspace resize_request_rom { env, "resize_request" };
|
||||
|
||||
/* pointer position to be consumed by the layouter */
|
||||
Reporter pointer_reporter = { "pointer" };
|
||||
@ -57,16 +57,16 @@ struct Wm::Main
|
||||
/* request to the layouter to set the focus */
|
||||
Reporter focus_request_reporter = { "focus_request" };
|
||||
|
||||
Window_registry window_registry { *env()->heap(), window_list_reporter };
|
||||
Window_registry window_registry { heap, window_list_reporter };
|
||||
|
||||
Nitpicker::Connection focus_nitpicker_session;
|
||||
|
||||
Nitpicker::Root nitpicker_root { ep, window_registry,
|
||||
*env()->heap(), env()->ram_session_cap(),
|
||||
Nitpicker::Root nitpicker_root { env, window_registry,
|
||||
heap, env.ram_session_cap(),
|
||||
pointer_reporter, focus_request_reporter,
|
||||
focus_nitpicker_session };
|
||||
|
||||
void handle_focus_update(unsigned)
|
||||
void handle_focus_update()
|
||||
{
|
||||
try {
|
||||
focus_rom.update();
|
||||
@ -90,9 +90,10 @@ struct Wm::Main
|
||||
}
|
||||
}
|
||||
|
||||
Genode::Signal_rpc_member<Main> focus_dispatcher = { ep, *this, &Main::handle_focus_update };
|
||||
Genode::Signal_handler<Main> focus_handler = {
|
||||
env.ep(), *this, &Main::handle_focus_update };
|
||||
|
||||
void handle_resize_request_update(unsigned)
|
||||
void handle_resize_request_update()
|
||||
{
|
||||
try {
|
||||
resize_request_rom.update();
|
||||
@ -122,10 +123,10 @@ struct Wm::Main
|
||||
} catch (...) { /* no resize-request model available */ }
|
||||
}
|
||||
|
||||
Genode::Signal_rpc_member<Main> resize_request_dispatcher =
|
||||
{ ep, *this, &Main::handle_resize_request_update };
|
||||
Genode::Signal_handler<Main> resize_request_handler =
|
||||
{ env.ep(), *this, &Main::handle_resize_request_update };
|
||||
|
||||
Main(Server::Entrypoint &ep) : ep(ep)
|
||||
Main(Genode::Env &env) : env(env)
|
||||
{
|
||||
pointer_reporter.enabled(true);
|
||||
|
||||
@ -135,24 +136,18 @@ struct Wm::Main
|
||||
|
||||
focus_request_reporter.enabled(true);
|
||||
|
||||
focus_rom.sigh(focus_dispatcher);
|
||||
resize_request_rom.sigh(resize_request_dispatcher);
|
||||
focus_rom.sigh(focus_handler);
|
||||
resize_request_rom.sigh(resize_request_handler);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/************
|
||||
** Server **
|
||||
************/
|
||||
/***************
|
||||
** Component **
|
||||
***************/
|
||||
|
||||
namespace Server {
|
||||
Genode::size_t Component::stack_size() {
|
||||
return 16*1024*sizeof(long); }
|
||||
|
||||
char const *name() { return "desktop_ep"; }
|
||||
|
||||
size_t stack_size() { return 16*1024*sizeof(long); }
|
||||
|
||||
void construct(Entrypoint &ep)
|
||||
{
|
||||
static Wm::Main desktop(ep);
|
||||
}
|
||||
}
|
||||
void Component::construct(Genode::Env &env) {
|
||||
static Wm::Main desktop(env); }
|
||||
|
@ -17,13 +17,11 @@
|
||||
/* Genode includes */
|
||||
#include <util/list.h>
|
||||
#include <base/tslab.h>
|
||||
#include <os/server.h>
|
||||
#include <os/surface.h>
|
||||
#include <os/attached_ram_dataspace.h>
|
||||
#include <base/attached_ram_dataspace.h>
|
||||
#include <os/session_policy.h>
|
||||
#include <os/reporter.h>
|
||||
#include <os/session_policy.h>
|
||||
#include <cap_session/connection.h>
|
||||
#include <root/component.h>
|
||||
#include <nitpicker_session/connection.h>
|
||||
#include <input_session/capability.h>
|
||||
@ -43,7 +41,7 @@ namespace Wm {
|
||||
using Genode::Allocator;
|
||||
using Genode::Affinity;
|
||||
using Genode::static_cap_cast;
|
||||
using Genode::Signal_rpc_member;
|
||||
using Genode::Signal_handler;
|
||||
using Genode::Ram_session_capability;
|
||||
using Genode::Weak_ptr;
|
||||
using Genode::Locked_ptr;
|
||||
@ -434,13 +432,14 @@ class Wm::Nitpicker::Session_component : public Rpc_object<Nitpicker::Session>,
|
||||
|
||||
typedef Nitpicker::Session::View_handle View_handle;
|
||||
|
||||
Genode::Env &_env;
|
||||
|
||||
Session_label _session_label;
|
||||
Ram_session_client _ram;
|
||||
Nitpicker::Connection _session { _session_label.string() };
|
||||
Nitpicker::Connection _session { _env, _session_label.string() };
|
||||
|
||||
Window_registry &_window_registry;
|
||||
Session_control_fn &_session_control_fn;
|
||||
Entrypoint &_ep;
|
||||
Tslab<Top_level_view, 4000> _top_level_view_alloc;
|
||||
Tslab<Child_view, 4000> _child_view_alloc;
|
||||
List<Top_level_view> _top_level_views;
|
||||
@ -476,8 +475,8 @@ class Wm::Nitpicker::Session_component : public Rpc_object<Nitpicker::Session>,
|
||||
Input::Session_client _nitpicker_input { _session.input_session() };
|
||||
Attached_dataspace _nitpicker_input_ds { _nitpicker_input.dataspace() };
|
||||
|
||||
Signal_rpc_member<Session_component> _input_dispatcher {
|
||||
_ep, *this, &Session_component::_input_handler };
|
||||
Signal_handler<Session_component> _input_handler {
|
||||
_env.ep(), *this, &Session_component::_handle_input };
|
||||
|
||||
Point _input_origin() const
|
||||
{
|
||||
@ -538,7 +537,7 @@ class Wm::Nitpicker::Session_component : public Rpc_object<Nitpicker::Session>,
|
||||
|
||||
bool _first_motion = true;
|
||||
|
||||
void _input_handler(unsigned)
|
||||
void _handle_input()
|
||||
{
|
||||
Point const input_origin = _input_origin();
|
||||
|
||||
@ -610,14 +609,14 @@ class Wm::Nitpicker::Session_component : public Rpc_object<Nitpicker::Session>,
|
||||
void _destroy_top_level_view(Top_level_view &view)
|
||||
{
|
||||
_top_level_views.remove(&view);
|
||||
_ep.dissolve(view);
|
||||
_env.ep().dissolve(view);
|
||||
Genode::destroy(&_top_level_view_alloc, &view);
|
||||
}
|
||||
|
||||
void _destroy_child_view(Child_view &view)
|
||||
{
|
||||
_child_views.remove(&view);
|
||||
_ep.dissolve(view);
|
||||
_env.ep().dissolve(view);
|
||||
Genode::destroy(&_child_view_alloc, &view);
|
||||
}
|
||||
|
||||
@ -709,26 +708,26 @@ class Wm::Nitpicker::Session_component : public Rpc_object<Nitpicker::Session>,
|
||||
*
|
||||
* \param ep entrypoint used for managing the views
|
||||
*/
|
||||
Session_component(Ram_session_capability ram,
|
||||
Session_component(Genode::Env &env,
|
||||
Ram_session_capability ram,
|
||||
Window_registry &window_registry,
|
||||
Entrypoint &ep,
|
||||
Allocator &session_alloc,
|
||||
Session_label const &session_label,
|
||||
Click_handler &click_handler,
|
||||
Session_control_fn &session_control_fn)
|
||||
:
|
||||
_env(env),
|
||||
_session_label(session_label),
|
||||
_ram(ram),
|
||||
_window_registry(window_registry),
|
||||
_session_control_fn(session_control_fn),
|
||||
_ep(ep),
|
||||
_top_level_view_alloc(&session_alloc),
|
||||
_child_view_alloc(&session_alloc),
|
||||
_input_session_cap(_ep.manage(_input_session)),
|
||||
_input_session_cap(env.ep().manage(_input_session)),
|
||||
_click_handler(click_handler),
|
||||
_view_handle_registry(session_alloc)
|
||||
{
|
||||
_nitpicker_input.sigh(_input_dispatcher);
|
||||
_nitpicker_input.sigh(_input_handler);
|
||||
_input_session.event_queue().enabled(true);
|
||||
}
|
||||
|
||||
@ -740,7 +739,7 @@ class Wm::Nitpicker::Session_component : public Rpc_object<Nitpicker::Session>,
|
||||
while (Child_view *view = _child_views.first())
|
||||
_destroy_view_object(*view);
|
||||
|
||||
_ep.dissolve(_input_session);
|
||||
_env.ep().dissolve(_input_session);
|
||||
}
|
||||
|
||||
void upgrade(char const *args)
|
||||
@ -847,7 +846,7 @@ class Wm::Nitpicker::Session_component : public Rpc_object<Nitpicker::Session>,
|
||||
{
|
||||
try {
|
||||
View &view = _create_view_object(parent);
|
||||
_ep.manage(view);
|
||||
_env.ep().manage(view);
|
||||
return _view_handle_registry.alloc(view);
|
||||
}
|
||||
catch (View_handle_registry::Lookup_failed) {
|
||||
@ -868,7 +867,7 @@ class Wm::Nitpicker::Session_component : public Rpc_object<Nitpicker::Session>,
|
||||
|
||||
View_handle view_handle(View_capability view_cap, View_handle handle) override
|
||||
{
|
||||
return _ep.rpc_ep().apply(view_cap, [&] (View *view) {
|
||||
return _env.ep().rpc_ep().apply(view_cap, [&] (View *view) {
|
||||
return (view) ? _view_handle_registry.alloc(*view, handle)
|
||||
: View_handle(); });
|
||||
}
|
||||
@ -994,7 +993,9 @@ class Wm::Nitpicker::Root : public Genode::Rpc_object<Genode::Typed_root<Session
|
||||
{
|
||||
private:
|
||||
|
||||
Entrypoint &_ep;
|
||||
Genode::Env &_env;
|
||||
|
||||
Genode::Attached_rom_dataspace _config { _env, "config" };
|
||||
|
||||
Allocator &_md_alloc;
|
||||
|
||||
@ -1014,8 +1015,7 @@ class Wm::Nitpicker::Root : public Genode::Rpc_object<Genode::Typed_root<Session
|
||||
|
||||
Input::Session_component _window_layouter_input;
|
||||
|
||||
Input::Session_capability _window_layouter_input_cap {
|
||||
_ep.manage(_window_layouter_input) };
|
||||
Input::Session_capability _window_layouter_input_cap { _env.ep().manage(_window_layouter_input) };
|
||||
|
||||
/* handler that forwards clicks into unfocused windows to the layouter */
|
||||
struct Click_handler : Nitpicker::Click_handler
|
||||
@ -1092,13 +1092,14 @@ class Wm::Nitpicker::Root : public Genode::Rpc_object<Genode::Typed_root<Session
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
Root(Entrypoint &ep,
|
||||
Root(Genode::Env &env,
|
||||
Window_registry &window_registry, Allocator &md_alloc,
|
||||
Ram_session_capability ram,
|
||||
Reporter &pointer_reporter, Reporter &focus_request_reporter,
|
||||
Nitpicker::Session &focus_nitpicker_session)
|
||||
:
|
||||
_ep(ep), _md_alloc(md_alloc), _ram(ram),
|
||||
_env(env),
|
||||
_md_alloc(md_alloc), _ram(ram),
|
||||
_pointer_reporter(pointer_reporter),
|
||||
_focus_request_reporter(focus_request_reporter),
|
||||
_window_registry(window_registry),
|
||||
@ -1106,7 +1107,7 @@ class Wm::Nitpicker::Root : public Genode::Rpc_object<Genode::Typed_root<Session
|
||||
{
|
||||
_window_layouter_input.event_queue().enabled(true);
|
||||
|
||||
Genode::env()->parent()->announce(_ep.manage(*this));
|
||||
env.parent().announce(env.ep().manage(*this));
|
||||
}
|
||||
|
||||
|
||||
@ -1127,7 +1128,8 @@ class Wm::Nitpicker::Root : public Genode::Rpc_object<Genode::Typed_root<Session
|
||||
* Determine session policy
|
||||
*/
|
||||
try {
|
||||
Genode::Xml_node policy = Genode::Session_policy(session_label);
|
||||
Genode::Xml_node policy =
|
||||
Genode::Session_policy(session_label, _config.xml());
|
||||
|
||||
char const *role_attr = "role";
|
||||
if (policy.has_attribute(role_attr)) {
|
||||
@ -1149,23 +1151,23 @@ class Wm::Nitpicker::Root : public Genode::Rpc_object<Genode::Typed_root<Session
|
||||
case ROLE_REGULAR:
|
||||
{
|
||||
auto session = new (_md_alloc)
|
||||
Session_component(_ram, _window_registry,
|
||||
_ep, _md_alloc, session_label,
|
||||
Session_component(_env, _ram, _window_registry,
|
||||
_md_alloc, session_label,
|
||||
_click_handler, *this);
|
||||
_sessions.insert(session);
|
||||
return _ep.manage(*session);
|
||||
return _env.ep().manage(*session);
|
||||
}
|
||||
|
||||
case ROLE_DECORATOR:
|
||||
{
|
||||
auto session = new (_md_alloc)
|
||||
Decorator_nitpicker_session(_ram, _ep, _md_alloc,
|
||||
Decorator_nitpicker_session(_env, _ram, _md_alloc,
|
||||
_pointer_reporter,
|
||||
_last_motion,
|
||||
_window_layouter_input,
|
||||
*this);
|
||||
_decorator_sessions.insert(session);
|
||||
return _ep.manage(*session);
|
||||
return _env.ep().manage(*session);
|
||||
}
|
||||
|
||||
case ROLE_LAYOUTER:
|
||||
@ -1174,7 +1176,7 @@ class Wm::Nitpicker::Root : public Genode::Rpc_object<Genode::Typed_root<Session
|
||||
Layouter_nitpicker_session(*Genode::env()->ram_session(),
|
||||
_window_layouter_input_cap);
|
||||
|
||||
return _ep.manage(*_layouter_session);
|
||||
return _env.ep().manage(*_layouter_session);
|
||||
}
|
||||
|
||||
case ROLE_DIRECT:
|
||||
@ -1182,7 +1184,7 @@ class Wm::Nitpicker::Root : public Genode::Rpc_object<Genode::Typed_root<Session
|
||||
Direct_nitpicker_session *session = new (_md_alloc)
|
||||
Direct_nitpicker_session(session_label);
|
||||
|
||||
return _ep.manage(*session);
|
||||
return _env.ep().manage(*session);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1217,18 +1219,18 @@ class Wm::Nitpicker::Root : public Genode::Rpc_object<Genode::Typed_root<Session
|
||||
if (direct_session)
|
||||
direct_session->upgrade(args.string());
|
||||
};
|
||||
_ep.rpc_ep().apply(session_cap, lambda);
|
||||
_env.ep().rpc_ep().apply(session_cap, lambda);
|
||||
}
|
||||
|
||||
void close(Genode::Session_capability session_cap) override
|
||||
{
|
||||
Genode::Rpc_entrypoint &ep = _ep.rpc_ep();
|
||||
Genode::Rpc_entrypoint &ep = _env.ep().rpc_ep();
|
||||
|
||||
Session_component *regular_session =
|
||||
ep.apply(session_cap, [this] (Session_component *session) {
|
||||
if (session) {
|
||||
_sessions.remove(session);
|
||||
_ep.dissolve(*session);
|
||||
_env.ep().dissolve(*session);
|
||||
}
|
||||
return session;
|
||||
});
|
||||
@ -1240,7 +1242,7 @@ class Wm::Nitpicker::Root : public Genode::Rpc_object<Genode::Typed_root<Session
|
||||
Direct_nitpicker_session *direct_session =
|
||||
ep.apply(session_cap, [this] (Direct_nitpicker_session *session) {
|
||||
if (session) {
|
||||
_ep.dissolve(*session);
|
||||
_env.ep().dissolve(*session);
|
||||
}
|
||||
return session;
|
||||
});
|
||||
@ -1253,7 +1255,7 @@ class Wm::Nitpicker::Root : public Genode::Rpc_object<Genode::Typed_root<Session
|
||||
ep.apply(session_cap, [this] (Decorator_nitpicker_session *session) {
|
||||
if (session) {
|
||||
_decorator_sessions.remove(session);
|
||||
_ep.dissolve(*session);
|
||||
_env.ep().dissolve(*session);
|
||||
}
|
||||
return session;
|
||||
});
|
||||
@ -1263,7 +1265,7 @@ class Wm::Nitpicker::Root : public Genode::Rpc_object<Genode::Typed_root<Session
|
||||
}
|
||||
|
||||
auto layouter_lambda = [this] (Layouter_nitpicker_session *session) {
|
||||
_ep.dissolve(*_layouter_session);
|
||||
this->_env.ep().dissolve(*_layouter_session);
|
||||
_layouter_session = nullptr;
|
||||
return session;
|
||||
};
|
||||
|
@ -1,4 +1,4 @@
|
||||
TARGET = wm
|
||||
SRC_CC = main.cc
|
||||
LIBS = base server config
|
||||
LIBS = base
|
||||
INC_DIR += $(PRG_DIR)
|
||||
|
Loading…
Reference in New Issue
Block a user