2014-05-07 08:33:20 +00:00
|
|
|
/*
|
|
|
|
* \brief Input root component
|
|
|
|
* \author Norman Feske
|
|
|
|
* \date 2014-05-31
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
2017-02-20 12:23:52 +00:00
|
|
|
* Copyright (C) 2014-2017 Genode Labs GmbH
|
2014-05-07 08:33:20 +00:00
|
|
|
*
|
|
|
|
* This file is part of the Genode OS framework, which is distributed
|
2017-02-20 12:23:52 +00:00
|
|
|
* under the terms of the GNU Affero General Public License version 3.
|
2014-05-07 08:33:20 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _INPUT__ROOT_H_
|
|
|
|
#define _INPUT__ROOT_H_
|
|
|
|
|
|
|
|
/* Genode includes */
|
|
|
|
#include <os/static_root.h>
|
|
|
|
#include <input/component.h>
|
|
|
|
|
|
|
|
namespace Input { class Root_component; }
|
|
|
|
|
2015-03-04 20:12:14 +00:00
|
|
|
|
2014-05-07 08:33:20 +00:00
|
|
|
/*
|
|
|
|
* This input root component tracks if the session has been opened. If a client
|
|
|
|
* is connected, the 'Event_queue::enabled' gets enabled. This is useful to
|
|
|
|
* omit the enqueuing of input events into the event queue before any client is
|
|
|
|
* interested in receiving input events. If we would not drop such early input
|
|
|
|
* events, the queue might overflow when input events are generated at boot
|
|
|
|
* times.
|
|
|
|
*/
|
|
|
|
class Input::Root_component : public Genode::Static_root<Input::Session>
|
|
|
|
{
|
|
|
|
private:
|
|
|
|
|
|
|
|
Genode::Rpc_entrypoint &_ep;
|
|
|
|
Input::Session_component &_session;
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
Root_component(Genode::Rpc_entrypoint &ep, Input::Session_component &session)
|
|
|
|
:
|
|
|
|
Static_root<Input::Session>(ep.manage(&session)),
|
|
|
|
_ep(ep), _session(session)
|
|
|
|
{ }
|
|
|
|
|
|
|
|
~Root_component()
|
|
|
|
{
|
|
|
|
_ep.dissolve(&_session);
|
|
|
|
}
|
|
|
|
|
|
|
|
Genode::Capability<Genode::Session>
|
|
|
|
session(Genode::Root::Session_args const &args,
|
|
|
|
Genode::Affinity const &affinity) override
|
|
|
|
{
|
|
|
|
if (_session.event_queue().enabled())
|
Streamline exception types
This patch reduces the number of exception types by facilitating
globally defined exceptions for common usage patterns shared by most
services. In particular, RPC functions that demand a session-resource
upgrade not longer reflect this condition via a session-specific
exception but via the 'Out_of_ram' or 'Out_of_caps' types.
Furthermore, the 'Parent::Service_denied', 'Parent::Unavailable',
'Root::Invalid_args', 'Root::Unavailable', 'Service::Invalid_args',
'Service::Unavailable', and 'Local_service::Factory::Denied' types have
been replaced by the single 'Service_denied' exception type defined in
'session/session.h'.
This consolidation eases the error handling (there are fewer exceptions
to handle), alleviates the need to convert exceptions along the
session-creation call chain, and avoids possible aliasing problems
(catching the wrong type with the same name but living in a different
scope).
2017-05-07 20:03:22 +00:00
|
|
|
throw Genode::Service_denied();
|
2014-05-07 08:33:20 +00:00
|
|
|
|
|
|
|
_session.event_queue().enabled(true);
|
|
|
|
|
|
|
|
return Static_root<Input::Session>::session(args, affinity);
|
|
|
|
}
|
|
|
|
|
2017-09-22 09:33:24 +00:00
|
|
|
void close(Genode::Capability<Genode::Session>) override
|
2014-05-07 08:33:20 +00:00
|
|
|
{
|
|
|
|
_session.event_queue().enabled(false);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* _INPUT__ROOT_H_ */
|