mirror of
https://github.com/genodelabs/genode.git
synced 2024-12-24 07:46:42 +00:00
parent
0f8fcab3bd
commit
fd533b0c93
@ -116,10 +116,24 @@ void QNitpickerPlatformWindow::_process_key_event(Input::Event *ev)
|
||||
{
|
||||
const bool pressed = (ev->type() == Input::Event::PRESS);
|
||||
const int keycode = ev->code();
|
||||
|
||||
if (pressed) {
|
||||
_last_keycode = keycode;
|
||||
_key_repeat_timer->start(KEY_REPEAT_DELAY_MS);
|
||||
} else
|
||||
_key_repeat_timer->stop();
|
||||
|
||||
_keyboard_handler.processKeycode(keycode, pressed, false);
|
||||
}
|
||||
|
||||
|
||||
void QNitpickerPlatformWindow::_key_repeat()
|
||||
{
|
||||
_key_repeat_timer->start(KEY_REPEAT_RATE_MS);
|
||||
_keyboard_handler.processKeycode(_last_keycode, true, true);
|
||||
}
|
||||
|
||||
|
||||
void QNitpickerPlatformWindow::_handle_input(unsigned int)
|
||||
{
|
||||
for (int i = 0, num_ev = _input_session.flush(); i < num_ev; i++) {
|
||||
@ -241,6 +255,8 @@ QNitpickerPlatformWindow::QNitpickerPlatformWindow(QWindow *window,
|
||||
_resize_handle(!window->flags().testFlag(Qt::Popup)),
|
||||
_decoration(!window->flags().testFlag(Qt::Popup)),
|
||||
_egl_surface(EGL_NO_SURFACE),
|
||||
_key_repeat_timer(this),
|
||||
_last_keycode(0),
|
||||
_input_signal_dispatcher(_signal_receiver, *this,
|
||||
&QNitpickerPlatformWindow::_input),
|
||||
_mode_changed_signal_dispatcher(_signal_receiver, *this,
|
||||
@ -274,6 +290,9 @@ QNitpickerPlatformWindow::QNitpickerPlatformWindow(QWindow *window,
|
||||
connect(this, SIGNAL(_mode_changed(unsigned int)),
|
||||
this, SLOT(_handle_mode_changed(unsigned int)),
|
||||
Qt::QueuedConnection);
|
||||
|
||||
connect(_key_repeat_timer, SIGNAL(timeout()),
|
||||
this, SLOT(_key_repeat()));
|
||||
}
|
||||
|
||||
QWindow *QNitpickerPlatformWindow::window() const
|
||||
|
@ -37,6 +37,11 @@ class QNitpickerPlatformWindow : public QObject, public QPlatformWindow
|
||||
|
||||
private:
|
||||
|
||||
enum {
|
||||
KEY_REPEAT_DELAY_MS = 500, /* 500 ms delay before first repetition */
|
||||
KEY_REPEAT_RATE_MS = 50 /* 50 ms delay between repetitions */
|
||||
};
|
||||
|
||||
Nitpicker::Connection _nitpicker_session;
|
||||
Framebuffer::Session_client _framebuffer_session;
|
||||
unsigned char *_framebuffer;
|
||||
@ -53,6 +58,8 @@ class QNitpickerPlatformWindow : public QObject, public QPlatformWindow
|
||||
bool _resize_handle;
|
||||
bool _decoration;
|
||||
EGLSurface _egl_surface;
|
||||
QMember<QTimer> _key_repeat_timer;
|
||||
int _last_keycode;
|
||||
|
||||
Genode::Signal_dispatcher<QNitpickerPlatformWindow> _input_signal_dispatcher;
|
||||
Genode::Signal_dispatcher<QNitpickerPlatformWindow> _mode_changed_signal_dispatcher;
|
||||
@ -67,6 +74,7 @@ class QNitpickerPlatformWindow : public QObject, public QPlatformWindow
|
||||
|
||||
void _handle_input(unsigned int);
|
||||
void _handle_mode_changed(unsigned int);
|
||||
void _key_repeat();
|
||||
|
||||
Q_SIGNALS:
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user