mirror of
https://github.com/genodelabs/genode.git
synced 2025-06-16 22:28:18 +00:00
Use signals for delivering input events
This patch changes both the Input::Session interface and the skeleton for the server-side implementation of this interface ('input/component.h'). The Input::Session interface offers a new 'sigh' function, which can be called be the client to register a signal handler. The signal handler gets notified on the arrival of new input. This alleviates the need to poll for input events at the client side. The server-side skeleton for implementing input services underwent a redesign to make it more modular and robust. I.e., there are no global functions needed at the server side and the event-queue enable/disable mechanism is implemented at a central place (in the root component) rather than inside each driver. Fixes #46
This commit is contained in:
committed by
Christian Helmuth
parent
6c10bfe049
commit
0ed68a56b7
@ -66,11 +66,11 @@ namespace Input {
|
||||
** Input session interface **
|
||||
*****************************/
|
||||
|
||||
Dataspace_capability dataspace() { return _real_input.dataspace(); }
|
||||
Dataspace_capability dataspace() override { return _real_input.dataspace(); }
|
||||
|
||||
bool is_pending() const { return _real_input.is_pending(); }
|
||||
bool is_pending() const override { return _real_input.is_pending(); }
|
||||
|
||||
int flush()
|
||||
int flush() override
|
||||
{
|
||||
/* translate mouse position to child's coordinate system */
|
||||
Transformer::Delta delta = _transformer.delta();
|
||||
@ -97,6 +97,11 @@ namespace Input {
|
||||
|
||||
return num_ev;
|
||||
}
|
||||
|
||||
void sigh(Signal_context_capability sigh) override
|
||||
{
|
||||
_real_input.sigh(sigh);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -82,11 +82,11 @@ namespace Input {
|
||||
** Input session interface **
|
||||
*****************************/
|
||||
|
||||
Genode::Dataspace_capability dataspace() { return _to_input_ds; }
|
||||
Genode::Dataspace_capability dataspace() override { return _to_input_ds; }
|
||||
|
||||
bool is_pending() const { return _from_input->is_pending(); }
|
||||
bool is_pending() const override { return _from_input->is_pending(); }
|
||||
|
||||
int flush()
|
||||
int flush() override
|
||||
{
|
||||
/* flush events at input session */
|
||||
int num_events = _from_input->flush();
|
||||
@ -103,6 +103,11 @@ namespace Input {
|
||||
}
|
||||
return num_events;
|
||||
}
|
||||
|
||||
void sigh(Genode::Signal_context_capability sigh) override
|
||||
{
|
||||
_from_input->sigh(sigh);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -257,8 +257,19 @@ class Input::Session_component : public Genode::Rpc_object<Session>
|
||||
Event _ev_buf[MAX_EVENTS];
|
||||
unsigned _num_ev = 0;
|
||||
|
||||
Signal_context_capability _sigh;
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Wake up client
|
||||
*/
|
||||
void submit_signal()
|
||||
{
|
||||
if (_sigh.valid())
|
||||
Signal_transmitter(_sigh).submit();
|
||||
}
|
||||
|
||||
/**
|
||||
* Enqueue event into local event buffer of the input session
|
||||
*/
|
||||
@ -269,6 +280,8 @@ class Input::Session_component : public Genode::Rpc_object<Session>
|
||||
|
||||
/* insert event into local event buffer */
|
||||
_ev_buf[_num_ev++] = *ev;
|
||||
|
||||
submit_signal();
|
||||
}
|
||||
|
||||
|
||||
@ -276,11 +289,11 @@ class Input::Session_component : public Genode::Rpc_object<Session>
|
||||
** Input session interface **
|
||||
*****************************/
|
||||
|
||||
Dataspace_capability dataspace() { return _ev_ram_ds.cap(); }
|
||||
Dataspace_capability dataspace() override { return _ev_ram_ds.cap(); }
|
||||
|
||||
bool is_pending() const { return _num_ev > 0; }
|
||||
bool is_pending() const override { return _num_ev > 0; }
|
||||
|
||||
int flush()
|
||||
int flush() override
|
||||
{
|
||||
unsigned ev_cnt;
|
||||
|
||||
@ -292,6 +305,8 @@ class Input::Session_component : public Genode::Rpc_object<Session>
|
||||
_num_ev = 0;
|
||||
return ev_cnt;
|
||||
}
|
||||
|
||||
void sigh(Genode::Signal_context_capability sigh) override { _sigh = sigh; }
|
||||
};
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user