From d7a9be72ea5bd00f9080f7409c85f51f1ac1c0e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Wed, 26 Nov 2014 13:04:36 +0100 Subject: [PATCH] Get event timestamp from SeatInterface in KeyboardInterface --- .../autotests/client/test_wayland_seat.cpp | 16 ++++++++-------- src/wayland/keyboard_interface.cpp | 10 ++-------- src/wayland/keyboard_interface.h | 1 - src/wayland/tests/renderingservertest.cpp | 4 ++-- 4 files changed, 12 insertions(+), 19 deletions(-) diff --git a/src/wayland/autotests/client/test_wayland_seat.cpp b/src/wayland/autotests/client/test_wayland_seat.cpp index 21184f9e67..112cd5f008 100644 --- a/src/wayland/autotests/client/test_wayland_seat.cpp +++ b/src/wayland/autotests/client/test_wayland_seat.cpp @@ -529,11 +529,11 @@ void TestWaylandSeat::testKeyboard() wl_display_flush(m_connection->display()); QTest::qWait(100); - serverKeyboard->updateTimestamp(1); + m_seatInterface->setTimestamp(1); serverKeyboard->keyPressed(KEY_K); - serverKeyboard->updateTimestamp(2); + m_seatInterface->setTimestamp(2); serverKeyboard->keyPressed(KEY_D); - serverKeyboard->updateTimestamp(3); + m_seatInterface->setTimestamp(3); serverKeyboard->keyPressed(KEY_E); QSignalSpy modifierSpy(keyboard, SIGNAL(modifiersChanged(quint32,quint32,quint32,quint32))); @@ -554,19 +554,19 @@ void TestWaylandSeat::testKeyboard() QSignalSpy keyChangedSpy(keyboard, SIGNAL(keyChanged(quint32,KWayland::Client::Keyboard::KeyState,quint32))); QVERIFY(keyChangedSpy.isValid()); - serverKeyboard->updateTimestamp(4); + m_seatInterface->setTimestamp(4); serverKeyboard->keyReleased(KEY_E); QVERIFY(keyChangedSpy.wait()); - serverKeyboard->updateTimestamp(5); + m_seatInterface->setTimestamp(5); serverKeyboard->keyReleased(KEY_D); QVERIFY(keyChangedSpy.wait()); - serverKeyboard->updateTimestamp(6); + m_seatInterface->setTimestamp(6); serverKeyboard->keyReleased(KEY_K); QVERIFY(keyChangedSpy.wait()); - serverKeyboard->updateTimestamp(7); + m_seatInterface->setTimestamp(7); serverKeyboard->keyPressed(KEY_F1); QVERIFY(keyChangedSpy.wait()); - serverKeyboard->updateTimestamp(8); + m_seatInterface->setTimestamp(8); serverKeyboard->keyReleased(KEY_F1); QVERIFY(keyChangedSpy.wait()); diff --git a/src/wayland/keyboard_interface.cpp b/src/wayland/keyboard_interface.cpp index 4f352bbd8e..26877768ee 100644 --- a/src/wayland/keyboard_interface.cpp +++ b/src/wayland/keyboard_interface.cpp @@ -76,7 +76,6 @@ public: }; FocusedSurface focusedSurface; QHash keyStates; - quint32 eventTime = 0; QMetaObject::Connection destroyConnection; private: @@ -246,7 +245,7 @@ void KeyboardInterface::keyPressed(quint32 key) { d->updateKey(key, Private::KeyState::Pressed); if (d->focusedSurface.surface && d->focusedSurface.keyboard) { - wl_keyboard_send_key(d->focusedSurface.keyboard, d->seat->display()->nextSerial(), d->eventTime, key, WL_KEYBOARD_KEY_STATE_PRESSED); + wl_keyboard_send_key(d->focusedSurface.keyboard, d->seat->display()->nextSerial(), d->seat->timestamp(), key, WL_KEYBOARD_KEY_STATE_PRESSED); } } @@ -254,7 +253,7 @@ void KeyboardInterface::keyReleased(quint32 key) { d->updateKey(key, Private::KeyState::Released); if (d->focusedSurface.surface && d->focusedSurface.keyboard) { - wl_keyboard_send_key(d->focusedSurface.keyboard, d->seat->display()->nextSerial(), d->eventTime, key, WL_KEYBOARD_KEY_STATE_RELEASED); + wl_keyboard_send_key(d->focusedSurface.keyboard, d->seat->display()->nextSerial(), d->seat->timestamp(), key, WL_KEYBOARD_KEY_STATE_RELEASED); } } @@ -268,11 +267,6 @@ void KeyboardInterface::Private::updateKey(quint32 key, KeyState state) it.value() = state; } -void KeyboardInterface::updateTimestamp(quint32 time) -{ - d->eventTime = time; -} - void KeyboardInterface::updateModifiers(quint32 depressed, quint32 latched, quint32 locked, quint32 group) { d->modifiers.depressed = depressed; diff --git a/src/wayland/keyboard_interface.h b/src/wayland/keyboard_interface.h index d5e3cbce50..541f34255c 100644 --- a/src/wayland/keyboard_interface.h +++ b/src/wayland/keyboard_interface.h @@ -44,7 +44,6 @@ public: void createInterfae(wl_client *client, wl_resource *parentResource, uint32_t id); - void updateTimestamp(quint32 time); void setKeymap(int fd, quint32 size); void keyPressed(quint32 key); void keyReleased(quint32 key); diff --git a/src/wayland/tests/renderingservertest.cpp b/src/wayland/tests/renderingservertest.cpp index 78e006de55..7b72f5c627 100644 --- a/src/wayland/tests/renderingservertest.cpp +++ b/src/wayland/tests/renderingservertest.cpp @@ -115,7 +115,7 @@ void CompositorWindow::keyPressEvent(QKeyEvent *event) keyboard->setFocusedSurface(m_stackingOrder.last()->surface()); } } - keyboard->updateTimestamp(event->timestamp()); + m_seat->setTimestamp(event->timestamp()); keyboard->keyPressed(event->nativeScanCode() - 8); } @@ -126,7 +126,7 @@ void CompositorWindow::keyReleaseEvent(QKeyEvent *event) return; } const auto keyboard = m_seat->keyboard(); - keyboard->updateTimestamp(event->timestamp()); + m_seat->setTimestamp(event->timestamp()); keyboard->keyReleased(event->nativeScanCode() - 8); }