mirror of
https://github.com/genodelabs/genode.git
synced 2024-12-24 07:46:42 +00:00
wm: replace Rpc_object by Session_object
This will ease the tracking of session resources. Issue #5340
This commit is contained in:
parent
a9b2d9bdc6
commit
cf507a0b86
@ -58,7 +58,7 @@ struct Wm::Decorator_content_callback : Interface
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
struct Wm::Decorator_gui_session : Genode::Rpc_object<Gui::Session>,
|
struct Wm::Decorator_gui_session : Genode::Session_object<Gui::Session>,
|
||||||
private List<Decorator_gui_session>::Element
|
private List<Decorator_gui_session>::Element
|
||||||
{
|
{
|
||||||
friend class List<Decorator_gui_session>;
|
friend class List<Decorator_gui_session>;
|
||||||
@ -119,18 +119,17 @@ struct Wm::Decorator_gui_session : Genode::Rpc_object<Gui::Session>,
|
|||||||
return { value };
|
return { value };
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructor
|
|
||||||
*
|
|
||||||
* \param ep entrypoint used for dispatching signals
|
|
||||||
*/
|
|
||||||
Decorator_gui_session(Genode::Env &env,
|
Decorator_gui_session(Genode::Env &env,
|
||||||
Genode::Ram_allocator &ram,
|
Genode::Ram_allocator &ram,
|
||||||
|
Resources const &resources,
|
||||||
|
Label const &label,
|
||||||
|
Diag const &diag,
|
||||||
Allocator &md_alloc,
|
Allocator &md_alloc,
|
||||||
Pointer::Tracker &pointer_tracker,
|
Pointer::Tracker &pointer_tracker,
|
||||||
Input::Session_component &window_layouter_input,
|
Input::Session_component &window_layouter_input,
|
||||||
Decorator_content_callback &content_callback)
|
Decorator_content_callback &content_callback)
|
||||||
:
|
:
|
||||||
|
Session_object<Gui::Session>(env.ep(), resources, label, diag),
|
||||||
_env(env),
|
_env(env),
|
||||||
_ram(ram),
|
_ram(ram),
|
||||||
_pointer_state(pointer_tracker),
|
_pointer_state(pointer_tracker),
|
||||||
|
@ -21,14 +21,12 @@
|
|||||||
namespace Wm { class Direct_gui_session; }
|
namespace Wm { class Direct_gui_session; }
|
||||||
|
|
||||||
|
|
||||||
class Wm::Direct_gui_session : public Genode::Rpc_object<Gui::Session>
|
class Wm::Direct_gui_session : public Genode::Session_object<Gui::Session>
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
|
|
||||||
Genode::Env &_env;
|
Genode::Env &_env;
|
||||||
|
|
||||||
Genode::Session_label _label;
|
|
||||||
|
|
||||||
Genode::Connection<Gui::Session> _connection {
|
Genode::Connection<Gui::Session> _connection {
|
||||||
_env, _label, Genode::Ram_quota { 36*1024 }, /* Args */ { } };
|
_env, _label, Genode::Ram_quota { 36*1024 }, /* Args */ { } };
|
||||||
|
|
||||||
@ -39,12 +37,10 @@ class Wm::Direct_gui_session : public Genode::Rpc_object<Gui::Session>
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
/**
|
Direct_gui_session(Genode::Env &env, auto &&... args)
|
||||||
* Constructor
|
|
||||||
*/
|
|
||||||
Direct_gui_session(Genode::Env &env, Genode::Session_label const &label)
|
|
||||||
:
|
:
|
||||||
_env(env), _label(label)
|
Session_object<Gui::Session>(env.ep(), args...),
|
||||||
|
_env(env)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
void upgrade(char const *args)
|
void upgrade(char const *args)
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
/* Genode includes */
|
/* Genode includes */
|
||||||
#include <util/list.h>
|
#include <util/list.h>
|
||||||
#include <base/tslab.h>
|
#include <base/tslab.h>
|
||||||
|
#include <base/session_object.h>
|
||||||
#include <os/surface.h>
|
#include <os/surface.h>
|
||||||
#include <base/attached_ram_dataspace.h>
|
#include <base/attached_ram_dataspace.h>
|
||||||
#include <os/session_policy.h>
|
#include <os/session_policy.h>
|
||||||
@ -471,7 +472,7 @@ class Wm::Gui::Child_view : public View, private List<Child_view>::Element
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class Wm::Gui::Session_component : public Rpc_object<Gui::Session>,
|
class Wm::Gui::Session_component : public Session_object<Gui::Session>,
|
||||||
private List<Session_component>::Element,
|
private List<Session_component>::Element,
|
||||||
private Input_origin_changed_handler
|
private Input_origin_changed_handler
|
||||||
{
|
{
|
||||||
@ -512,9 +513,8 @@ class Wm::Gui::Session_component : public Rpc_object<Gui::Session>,
|
|||||||
|
|
||||||
Genode::Env &_env;
|
Genode::Env &_env;
|
||||||
|
|
||||||
Session_label _session_label;
|
|
||||||
Genode::Ram_allocator &_ram;
|
Genode::Ram_allocator &_ram;
|
||||||
Real_gui _real_gui { _env, _session_label };
|
Real_gui _real_gui { _env, _label };
|
||||||
Window_registry &_window_registry;
|
Window_registry &_window_registry;
|
||||||
Tslab<Top_level_view, 8000> _top_level_view_alloc;
|
Tslab<Top_level_view, 8000> _top_level_view_alloc;
|
||||||
Tslab<Child_view, 7000> _child_view_alloc;
|
Tslab<Child_view, 7000> _child_view_alloc;
|
||||||
@ -782,21 +782,18 @@ class Wm::Gui::Session_component : public Rpc_object<Gui::Session>,
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructor
|
|
||||||
*
|
|
||||||
* \param ep entrypoint used for managing the views
|
|
||||||
*/
|
|
||||||
Session_component(Genode::Env &env,
|
Session_component(Genode::Env &env,
|
||||||
Genode::Ram_allocator &ram,
|
Genode::Ram_allocator &ram,
|
||||||
|
Resources const &resources,
|
||||||
|
Label const &label,
|
||||||
|
Diag const diag,
|
||||||
Window_registry &window_registry,
|
Window_registry &window_registry,
|
||||||
Allocator &session_alloc,
|
Allocator &session_alloc,
|
||||||
Session_label const &session_label,
|
|
||||||
Pointer::Tracker &pointer_tracker,
|
Pointer::Tracker &pointer_tracker,
|
||||||
Click_handler &click_handler)
|
Click_handler &click_handler)
|
||||||
:
|
:
|
||||||
|
Session_object<Gui::Session>(env.ep(), resources, label, diag),
|
||||||
_env(env),
|
_env(env),
|
||||||
_session_label(session_label),
|
|
||||||
_ram(ram),
|
_ram(ram),
|
||||||
_window_registry(window_registry),
|
_window_registry(window_registry),
|
||||||
_top_level_view_alloc(&session_alloc),
|
_top_level_view_alloc(&session_alloc),
|
||||||
@ -881,8 +878,6 @@ class Wm::Gui::Session_component : public Rpc_object<Gui::Session>,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Session_label session_label() const { return _session_label; }
|
|
||||||
|
|
||||||
bool matches_session_label(char const *selector) const
|
bool matches_session_label(char const *selector) const
|
||||||
{
|
{
|
||||||
using namespace Genode;
|
using namespace Genode;
|
||||||
@ -893,7 +888,7 @@ class Wm::Gui::Session_component : public Rpc_object<Gui::Session>,
|
|||||||
*
|
*
|
||||||
* The code snippet originates from nitpicker's 'gui_session.h'.
|
* The code snippet originates from nitpicker's 'gui_session.h'.
|
||||||
*/
|
*/
|
||||||
String<Session_label::capacity() + 4> const label(_session_label, " ->");
|
String<Session_label::capacity() + 4> const label(_label, " ->");
|
||||||
return strcmp(label.string(), selector, strlen(selector)) == 0;
|
return strcmp(label.string(), selector, strlen(selector)) == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1273,8 +1268,9 @@ class Wm::Gui::Root : public Genode::Rpc_object<Genode::Typed_root<Gui::Session>
|
|||||||
Genode::Session_capability session(Session_args const &args,
|
Genode::Session_capability session(Session_args const &args,
|
||||||
Affinity const &) override
|
Affinity const &) override
|
||||||
{
|
{
|
||||||
Genode::Session_label const session_label =
|
Genode::Session::Label const label = Genode::label_from_args(args.string());
|
||||||
Genode::label_from_args(args.string());
|
Genode::Session::Resources const resources = Genode::session_resources_from_args(args.string());
|
||||||
|
Genode::Session::Diag const diag = Genode::session_diag_from_args(args.string());
|
||||||
|
|
||||||
enum Role { ROLE_DECORATOR, ROLE_LAYOUTER, ROLE_REGULAR, ROLE_DIRECT };
|
enum Role { ROLE_DECORATOR, ROLE_LAYOUTER, ROLE_REGULAR, ROLE_DIRECT };
|
||||||
Role role = ROLE_REGULAR;
|
Role role = ROLE_REGULAR;
|
||||||
@ -1284,7 +1280,7 @@ class Wm::Gui::Root : public Genode::Rpc_object<Genode::Typed_root<Gui::Session>
|
|||||||
*/
|
*/
|
||||||
try {
|
try {
|
||||||
Genode::Xml_node policy =
|
Genode::Xml_node policy =
|
||||||
Genode::Session_policy(session_label, _config.xml());
|
Genode::Session_policy(label, _config.xml());
|
||||||
|
|
||||||
auto const value = policy.attribute_value("role", String<16>());
|
auto const value = policy.attribute_value("role", String<16>());
|
||||||
|
|
||||||
@ -1298,40 +1294,42 @@ class Wm::Gui::Root : public Genode::Rpc_object<Genode::Typed_root<Gui::Session>
|
|||||||
|
|
||||||
case ROLE_REGULAR:
|
case ROLE_REGULAR:
|
||||||
{
|
{
|
||||||
auto session = new (_md_alloc)
|
Session_component &session = *new (_md_alloc)
|
||||||
Session_component(_env, _ram, _window_registry,
|
Session_component(_env, _ram, resources, label, diag,
|
||||||
_md_alloc, session_label,
|
_window_registry, _md_alloc,
|
||||||
_pointer_tracker,
|
_pointer_tracker,
|
||||||
_click_handler);
|
_click_handler);
|
||||||
_sessions.insert(session);
|
_sessions.insert(&session);
|
||||||
return _env.ep().manage(*session);
|
return session.cap();
|
||||||
}
|
}
|
||||||
|
|
||||||
case ROLE_DECORATOR:
|
case ROLE_DECORATOR:
|
||||||
{
|
{
|
||||||
auto session = new (_md_alloc)
|
Decorator_gui_session &session = *new (_md_alloc)
|
||||||
Decorator_gui_session(_env, _ram, _md_alloc,
|
Decorator_gui_session(_env, _ram, resources, label, diag,
|
||||||
|
_md_alloc,
|
||||||
_pointer_tracker,
|
_pointer_tracker,
|
||||||
_window_layouter_input,
|
_window_layouter_input,
|
||||||
*this);
|
*this);
|
||||||
_decorator_sessions.insert(session);
|
_decorator_sessions.insert(&session);
|
||||||
return _env.ep().manage(*session);
|
return session.cap();
|
||||||
}
|
}
|
||||||
|
|
||||||
case ROLE_LAYOUTER:
|
case ROLE_LAYOUTER:
|
||||||
{
|
{
|
||||||
_layouter_session = new (_md_alloc)
|
_layouter_session = new (_md_alloc)
|
||||||
Layouter_gui_session(_env, _window_layouter_input_cap);
|
Layouter_gui_session(_env, resources, label, diag,
|
||||||
|
_window_layouter_input_cap);
|
||||||
|
|
||||||
return _env.ep().manage(*_layouter_session);
|
return _layouter_session->cap();
|
||||||
}
|
}
|
||||||
|
|
||||||
case ROLE_DIRECT:
|
case ROLE_DIRECT:
|
||||||
{
|
{
|
||||||
Direct_gui_session *session = new (_md_alloc)
|
Direct_gui_session &session = *new (_md_alloc)
|
||||||
Direct_gui_session(_env, session_label);
|
Direct_gui_session(_env, resources, label, diag);
|
||||||
|
|
||||||
return _env.ep().manage(*session);
|
return session.cap();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1375,10 +1373,8 @@ class Wm::Gui::Root : public Genode::Rpc_object<Genode::Typed_root<Gui::Session>
|
|||||||
|
|
||||||
Session_component *regular_session =
|
Session_component *regular_session =
|
||||||
ep.apply(session_cap, [this] (Session_component *session) {
|
ep.apply(session_cap, [this] (Session_component *session) {
|
||||||
if (session) {
|
if (session)
|
||||||
_sessions.remove(session);
|
_sessions.remove(session);
|
||||||
_env.ep().dissolve(*session);
|
|
||||||
}
|
|
||||||
return session;
|
return session;
|
||||||
});
|
});
|
||||||
if (regular_session) {
|
if (regular_session) {
|
||||||
@ -1388,9 +1384,6 @@ class Wm::Gui::Root : public Genode::Rpc_object<Genode::Typed_root<Gui::Session>
|
|||||||
|
|
||||||
Direct_gui_session *direct_session =
|
Direct_gui_session *direct_session =
|
||||||
ep.apply(session_cap, [this] (Direct_gui_session *session) {
|
ep.apply(session_cap, [this] (Direct_gui_session *session) {
|
||||||
if (session) {
|
|
||||||
_env.ep().dissolve(*session);
|
|
||||||
}
|
|
||||||
return session;
|
return session;
|
||||||
});
|
});
|
||||||
if (direct_session) {
|
if (direct_session) {
|
||||||
@ -1400,10 +1393,8 @@ class Wm::Gui::Root : public Genode::Rpc_object<Genode::Typed_root<Gui::Session>
|
|||||||
|
|
||||||
Decorator_gui_session *decorator_session =
|
Decorator_gui_session *decorator_session =
|
||||||
ep.apply(session_cap, [this] (Decorator_gui_session *session) {
|
ep.apply(session_cap, [this] (Decorator_gui_session *session) {
|
||||||
if (session) {
|
if (session)
|
||||||
_decorator_sessions.remove(session);
|
_decorator_sessions.remove(session);
|
||||||
_env.ep().dissolve(*session);
|
|
||||||
}
|
|
||||||
return session;
|
return session;
|
||||||
});
|
});
|
||||||
if (decorator_session) {
|
if (decorator_session) {
|
||||||
@ -1412,7 +1403,6 @@ class Wm::Gui::Root : public Genode::Rpc_object<Genode::Typed_root<Gui::Session>
|
|||||||
}
|
}
|
||||||
|
|
||||||
auto layouter_lambda = [this] (Layouter_gui_session *session) {
|
auto layouter_lambda = [this] (Layouter_gui_session *session) {
|
||||||
this->_env.ep().dissolve(*_layouter_session);
|
|
||||||
_layouter_session = nullptr;
|
_layouter_session = nullptr;
|
||||||
return session;
|
return session;
|
||||||
};
|
};
|
||||||
|
@ -24,7 +24,7 @@ namespace Wm {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
struct Wm::Layouter_gui_session : Genode::Rpc_object<Gui::Session>
|
struct Wm::Layouter_gui_session : Genode::Session_object<Gui::Session>
|
||||||
{
|
{
|
||||||
using View_capability = Gui::View_capability;
|
using View_capability = Gui::View_capability;
|
||||||
using View_id = Gui::View_id;
|
using View_id = Gui::View_id;
|
||||||
@ -41,8 +41,12 @@ struct Wm::Layouter_gui_session : Genode::Rpc_object<Gui::Session>
|
|||||||
Attached_ram_dataspace _command_ds;
|
Attached_ram_dataspace _command_ds;
|
||||||
|
|
||||||
Layouter_gui_session(Genode::Env &env,
|
Layouter_gui_session(Genode::Env &env,
|
||||||
|
Resources const &resources,
|
||||||
|
Label const &label,
|
||||||
|
Diag const &diag,
|
||||||
Input::Session_capability input_session_cap)
|
Input::Session_capability input_session_cap)
|
||||||
:
|
:
|
||||||
|
Session_object<Gui::Session>(env.ep(), resources, label, diag),
|
||||||
_input_session_cap(input_session_cap),
|
_input_session_cap(input_session_cap),
|
||||||
_mode_sigh_gui(env), _command_ds(env.ram(), env.rm(), 4096)
|
_mode_sigh_gui(env), _command_ds(env.ram(), env.rm(), 4096)
|
||||||
{ }
|
{ }
|
||||||
|
Loading…
Reference in New Issue
Block a user