mirror of
https://github.com/genodelabs/genode.git
synced 2025-06-20 16:10:29 +00:00
Add Input::Session::exclusive() interface
This interface allows a GUI client to express the intent to exclusively observe relative motion events while locking the absolute pointer position. This patch merely extends the interface without implementing it. As this change touches os/include/input/component.h, it moves the manage/dissolve operations into the class, ensuring the call of dissolve at destruction time. Issue #5355
This commit is contained in:
committed by
Christian Helmuth
parent
318d641266
commit
d7830a0ce6
@ -22,26 +22,25 @@
|
||||
namespace Input { struct Session_client; }
|
||||
|
||||
|
||||
class Input::Session_client : public Genode::Rpc_client<Session>
|
||||
class Input::Session_client : public Rpc_client<Session>
|
||||
{
|
||||
private:
|
||||
|
||||
Genode::Attached_dataspace _event_ds;
|
||||
Attached_dataspace _event_ds;
|
||||
|
||||
Genode::size_t const _max_events =
|
||||
_event_ds.size() / sizeof(Input::Event);
|
||||
size_t const _max_events = _event_ds.size() / sizeof(Input::Event);
|
||||
|
||||
friend class Input::Binding;
|
||||
|
||||
public:
|
||||
|
||||
Session_client(Genode::Region_map &local_rm, Session_capability session)
|
||||
Session_client(Region_map &local_rm, Session_capability session)
|
||||
:
|
||||
Genode::Rpc_client<Session>(session),
|
||||
Rpc_client<Session>(session),
|
||||
_event_ds(local_rm, call<Rpc_dataspace>())
|
||||
{ }
|
||||
|
||||
Genode::Dataspace_capability dataspace() override {
|
||||
Dataspace_capability dataspace() override {
|
||||
return call<Rpc_dataspace>(); }
|
||||
|
||||
bool pending() const override {
|
||||
@ -50,9 +49,12 @@ class Input::Session_client : public Genode::Rpc_client<Session>
|
||||
int flush() override {
|
||||
return call<Rpc_flush>(); }
|
||||
|
||||
void sigh(Genode::Signal_context_capability sigh) override {
|
||||
void sigh(Signal_context_capability sigh) override {
|
||||
call<Rpc_sigh>(sigh); }
|
||||
|
||||
void exclusive(bool enabled) override {
|
||||
call<Rpc_exclusive>(enabled); }
|
||||
|
||||
/**
|
||||
* Flush and apply functor to pending events
|
||||
*
|
||||
@ -61,10 +63,10 @@ class Input::Session_client : public Genode::Rpc_client<Session>
|
||||
*/
|
||||
void for_each_event(auto const &fn)
|
||||
{
|
||||
Genode::size_t const n = Genode::min((Genode::size_t)call<Rpc_flush>(), _max_events);
|
||||
size_t const n = min((size_t)call<Rpc_flush>(), _max_events);
|
||||
|
||||
Event const *ev_buf = _event_ds.local_addr<const Event>();
|
||||
for (Genode::size_t i = 0; i < n; ++i)
|
||||
for (size_t i = 0; i < n; ++i)
|
||||
fn(ev_buf[i]);
|
||||
}
|
||||
};
|
||||
|
@ -19,7 +19,12 @@
|
||||
#include <session/session.h>
|
||||
#include <base/signal.h>
|
||||
|
||||
namespace Input { struct Session; }
|
||||
namespace Input {
|
||||
|
||||
using namespace Genode;
|
||||
|
||||
struct Session;
|
||||
}
|
||||
|
||||
|
||||
struct Input::Session : Genode::Session
|
||||
@ -41,7 +46,7 @@ struct Input::Session : Genode::Session
|
||||
/**
|
||||
* Return capability to event buffer dataspace
|
||||
*/
|
||||
virtual Genode::Dataspace_capability dataspace() = 0;
|
||||
virtual Dataspace_capability dataspace() = 0;
|
||||
|
||||
/**
|
||||
* Request input state
|
||||
@ -60,19 +65,26 @@ struct Input::Session : Genode::Session
|
||||
/**
|
||||
* Register signal handler to be notified on arrival of new input
|
||||
*/
|
||||
virtual void sigh(Genode::Signal_context_capability) = 0;
|
||||
virtual void sigh(Signal_context_capability) = 0;
|
||||
|
||||
/**
|
||||
* Express intent to receive relative pointer events exclusively
|
||||
*/
|
||||
virtual void exclusive(bool) = 0;
|
||||
|
||||
|
||||
/*********************
|
||||
** RPC declaration **
|
||||
*********************/
|
||||
|
||||
GENODE_RPC(Rpc_dataspace, Genode::Dataspace_capability, dataspace);
|
||||
GENODE_RPC(Rpc_pending, bool, pending);
|
||||
GENODE_RPC(Rpc_flush, int, flush);
|
||||
GENODE_RPC(Rpc_sigh, void, sigh, Genode::Signal_context_capability);
|
||||
GENODE_RPC(Rpc_dataspace, Dataspace_capability, dataspace);
|
||||
GENODE_RPC(Rpc_pending, bool, pending);
|
||||
GENODE_RPC(Rpc_flush, int, flush);
|
||||
GENODE_RPC(Rpc_sigh, void, sigh, Signal_context_capability);
|
||||
GENODE_RPC(Rpc_exclusive, void, exclusive, bool);
|
||||
|
||||
GENODE_RPC_INTERFACE(Rpc_dataspace, Rpc_pending, Rpc_flush, Rpc_sigh);
|
||||
GENODE_RPC_INTERFACE(Rpc_dataspace, Rpc_pending, Rpc_flush, Rpc_sigh,
|
||||
Rpc_exclusive);
|
||||
};
|
||||
|
||||
#endif /* _INCLUDE__INPUT_SESSION__INPUT_SESSION_H_ */
|
||||
|
Reference in New Issue
Block a user