mirror of
https://github.com/genodelabs/genode.git
synced 2024-12-21 22:47:50 +00:00
dialog: support Sandboxed_runtime::Event_handler
This allows applications to get hold of the raw input events, in particular keyboard input. Issue #5008
This commit is contained in:
parent
767ea7f5b1
commit
9fae8a7532
@ -43,6 +43,17 @@ class Dialog::Sandboxed_runtime : Noncopyable
|
|||||||
Allocator &_alloc;
|
Allocator &_alloc;
|
||||||
Sandbox &_sandbox;
|
Sandbox &_sandbox;
|
||||||
|
|
||||||
|
struct Optional_event_handler
|
||||||
|
{
|
||||||
|
Event_handler_base *_ptr;
|
||||||
|
|
||||||
|
void handle_event(Event const &event)
|
||||||
|
{
|
||||||
|
if (_ptr) _ptr->handle_event(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
} _optional_event_handler { };
|
||||||
|
|
||||||
using Views = Dictionary<View, Top_level_dialog::Name>;
|
using Views = Dictionary<View, Top_level_dialog::Name>;
|
||||||
|
|
||||||
Event::Seq_number _global_seq_number { 1 };
|
Event::Seq_number _global_seq_number { 1 };
|
||||||
@ -184,6 +195,8 @@ class Dialog::Sandboxed_runtime::View : private Views::Element
|
|||||||
|
|
||||||
Event::Seq_number &_global_seq_number;
|
Event::Seq_number &_global_seq_number;
|
||||||
|
|
||||||
|
Optional_event_handler &_optional_event_handler;
|
||||||
|
|
||||||
Top_level_dialog &_dialog;
|
Top_level_dialog &_dialog;
|
||||||
|
|
||||||
bool _dialog_hovered = false; /* used to cut hover feedback loop */
|
bool _dialog_hovered = false; /* used to cut hover feedback loop */
|
||||||
@ -346,6 +359,7 @@ class Dialog::Sandboxed_runtime::View : private Views::Element
|
|||||||
Views::Element(runtime._views, dialog.name),
|
Views::Element(runtime._views, dialog.name),
|
||||||
_env(runtime._env), _alloc(runtime._alloc),
|
_env(runtime._env), _alloc(runtime._alloc),
|
||||||
_global_seq_number(runtime._global_seq_number),
|
_global_seq_number(runtime._global_seq_number),
|
||||||
|
_optional_event_handler(runtime._optional_event_handler),
|
||||||
_dialog(dialog),
|
_dialog(dialog),
|
||||||
_menu_view_state(dialog.name, Ram_quota { 4*1024*1024 }, Cap_quota { 200 })
|
_menu_view_state(dialog.name, Ram_quota { 4*1024*1024 }, Cap_quota { 200 })
|
||||||
{ }
|
{ }
|
||||||
@ -361,18 +375,24 @@ class Dialog::Sandboxed_runtime::Event_handler : Event_handler_base
|
|||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
Sandboxed_runtime &_runtime;
|
||||||
|
|
||||||
T &_obj;
|
T &_obj;
|
||||||
|
|
||||||
void (T::*_member) (Event const &);
|
void (T::*_member) (Event const &);
|
||||||
void handle_event(Event const &event) override { (_obj.*_member)(event); }
|
void handle_event(Event const &event) override { (_obj.*_member)(event); }
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
Event_handler(Sandboxed_runtime &runtime, T &obj, void (T::*member)(Event const &))
|
Event_handler(Sandboxed_runtime &runtime, T &obj, void (T::*member)(Event const &))
|
||||||
: _obj(obj), _member(member)
|
:
|
||||||
|
_runtime(runtime), _obj(obj), _member(member)
|
||||||
{
|
{
|
||||||
/* register event handler at runtime */
|
/* register event handler at runtime */
|
||||||
(void)runtime;
|
_runtime._optional_event_handler._ptr = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
~Event_handler() { _runtime._optional_event_handler._ptr = nullptr; }
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* _INCLUDE__DIALOG__SANDBOXED_RUNTIME_H_ */
|
#endif /* _INCLUDE__DIALOG__SANDBOXED_RUNTIME_H_ */
|
||||||
|
@ -349,6 +349,8 @@ void Sandboxed_runtime::View::_handle_input_event(Input::Event const &event)
|
|||||||
_clack_seq_number.construct(_global_seq_number);
|
_clack_seq_number.construct(_global_seq_number);
|
||||||
|
|
||||||
_try_handle_click_and_clack();
|
_try_handle_click_and_clack();
|
||||||
|
|
||||||
|
_optional_event_handler.handle_event(Event { _global_seq_number, event });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user