Pass LibInput::Device* through the event handlers
Summary: The signals emitted by LibInput::Connection carry the Device for which the input event was received. This Device is passed to the input handlers. Custom event classes are added which extend QMouseEvent, QKeyEvent and QWheelEvent respectively and expose the Device. The Device is only passed around as a forward declared pointer, so even if compiled without libinput support, it should still compile. Event handlers which need to get access to the Device can now just cast the event pointer to the custom class and access it. This can be used in future to handle device specific key codes, etc. As we don't have a proper event classes for touch events the event handlers do not yet have access to the Device. Here the internal API needs to be adjusted in future. Reviewers: #plasma Subscribers: plasma-devel Tags: #plasma Differential Revision: https://phabricator.kde.org/D1667
This commit is contained in:
parent
6d090cd263
commit
69cbb40903
15 changed files with 361 additions and 59 deletions
|
@ -352,6 +352,7 @@ set(kwin_KDEINIT_SRCS
|
|||
focuschain.cpp
|
||||
globalshortcuts.cpp
|
||||
input.cpp
|
||||
input_event.cpp
|
||||
keyboard_input.cpp
|
||||
pointer_input.cpp
|
||||
touch_input.cpp
|
||||
|
|
|
@ -6,3 +6,12 @@ add_executable(testLibinputDevice ${testLibinputDevice_SRCS})
|
|||
target_link_libraries( testLibinputDevice Qt5::Test)
|
||||
add_test(kwin-testLibinputDevice testLibinputDevice)
|
||||
ecm_mark_as_test(testLibinputDevice)
|
||||
|
||||
########################################################
|
||||
# Test Input Events
|
||||
########################################################
|
||||
set( testInputEvents_SRCS input_event_test.cpp mock_libinput.cpp ../../libinput/device.cpp ../../input_event.cpp )
|
||||
add_executable(testInputEvents ${testInputEvents_SRCS})
|
||||
target_link_libraries( testInputEvents Qt5::Test Qt5::Gui)
|
||||
add_test(kwin-testInputEvents testInputEvents)
|
||||
ecm_mark_as_test(testInputEvents)
|
||||
|
|
150
autotests/libinput/input_event_test.cpp
Normal file
150
autotests/libinput/input_event_test.cpp
Normal file
|
@ -0,0 +1,150 @@
|
|||
/********************************************************************
|
||||
KWin - the KDE window manager
|
||||
This file is part of the KDE project.
|
||||
|
||||
Copyright (C) 2016 Martin Gräßlin <mgraesslin@kde.org>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*********************************************************************/
|
||||
#include "mock_libinput.h"
|
||||
#include "../../libinput/device.h"
|
||||
#include "../input_event.h"
|
||||
|
||||
#include <QtTest/QtTest>
|
||||
|
||||
using namespace KWin;
|
||||
using namespace KWin::LibInput;
|
||||
|
||||
class InputEventsTest : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
private Q_SLOTS:
|
||||
void testInitMouseEvent_data();
|
||||
void testInitMouseEvent();
|
||||
void testInitKeyEvent_data();
|
||||
void testInitKeyEvent();
|
||||
void testInitWheelEvent_data();
|
||||
void testInitWheelEvent();
|
||||
};
|
||||
|
||||
void InputEventsTest::testInitMouseEvent_data()
|
||||
{
|
||||
QTest::addColumn<QEvent::Type>("type");
|
||||
|
||||
QTest::newRow("Press") << QEvent::MouseButtonPress;
|
||||
QTest::newRow("Release") << QEvent::MouseButtonRelease;
|
||||
QTest::newRow("Move") << QEvent::MouseMove;
|
||||
}
|
||||
|
||||
void InputEventsTest::testInitMouseEvent()
|
||||
{
|
||||
// this test verifies that a MouseEvent is constructed correctly
|
||||
|
||||
// first create the test LibInput::Device
|
||||
libinput_device device;
|
||||
Device d(&device);
|
||||
|
||||
QFETCH(QEvent::Type, type);
|
||||
// now create our own event
|
||||
MouseEvent event(type, QPointF(100, 200), Qt::LeftButton, Qt::LeftButton | Qt::RightButton,
|
||||
Qt::ShiftModifier | Qt::ControlModifier, 300, &d);
|
||||
// and verify the contract of QMouseEvent
|
||||
QCOMPARE(event.type(), type);
|
||||
QCOMPARE(event.globalPos(), QPoint(100, 200));
|
||||
QCOMPARE(event.screenPos(), QPointF(100, 200));
|
||||
QCOMPARE(event.localPos(), QPointF(100, 200));
|
||||
QCOMPARE(event.button(), Qt::LeftButton);
|
||||
QCOMPARE(event.buttons(), Qt::LeftButton | Qt::RightButton);
|
||||
QCOMPARE(event.modifiers(), Qt::ShiftModifier | Qt::ControlModifier);
|
||||
QCOMPARE(event.timestamp(), 300ul);
|
||||
// and our custom argument
|
||||
QCOMPARE(event.device(), &d);
|
||||
}
|
||||
|
||||
void InputEventsTest::testInitKeyEvent_data()
|
||||
{
|
||||
QTest::addColumn<QEvent::Type>("type");
|
||||
QTest::addColumn<bool>("autorepeat");
|
||||
|
||||
QTest::newRow("Press") << QEvent::KeyPress << false;
|
||||
QTest::newRow("Repeat") << QEvent::KeyPress << true;
|
||||
QTest::newRow("Release") << QEvent::KeyRelease << false;
|
||||
}
|
||||
|
||||
void InputEventsTest::testInitKeyEvent()
|
||||
{
|
||||
// this test verifies that a KeyEvent is constructed correctly
|
||||
|
||||
// first create the test LibInput::Device
|
||||
libinput_device device;
|
||||
Device d(&device);
|
||||
|
||||
// setup event
|
||||
QFETCH(QEvent::Type, type);
|
||||
QFETCH(bool, autorepeat);
|
||||
KeyEvent event(type, Qt::Key_Space, Qt::ShiftModifier | Qt::ControlModifier, 200, 300,
|
||||
QStringLiteral(" "), autorepeat, 400, &d);
|
||||
// and verify the contract of QKeyEvent
|
||||
QCOMPARE(event.type(), type);
|
||||
QCOMPARE(event.isAutoRepeat(), autorepeat);
|
||||
QCOMPARE(event.key(), int(Qt::Key_Space));
|
||||
QCOMPARE(event.nativeScanCode(), 200u);
|
||||
QCOMPARE(event.nativeVirtualKey(), 300u);
|
||||
QCOMPARE(event.text(), QStringLiteral(" "));
|
||||
QCOMPARE(event.count(), 1);
|
||||
QCOMPARE(event.nativeModifiers(), 0u);
|
||||
QCOMPARE(event.modifiers(), Qt::ShiftModifier | Qt::ControlModifier);
|
||||
QCOMPARE(event.timestamp(), 400ul);
|
||||
// and our custom argument
|
||||
QCOMPARE(event.device(), &d);
|
||||
}
|
||||
|
||||
void InputEventsTest::testInitWheelEvent_data()
|
||||
{
|
||||
QTest::addColumn<Qt::Orientation>("orientation");
|
||||
QTest::addColumn<qreal>("delta");
|
||||
QTest::addColumn<QPoint>("expectedAngleDelta");
|
||||
|
||||
QTest::newRow("horiz") << Qt::Horizontal << 3.0 << QPoint(3, 0);
|
||||
QTest::newRow("vert") << Qt::Vertical << 2.0 << QPoint(0, 2);
|
||||
}
|
||||
|
||||
void InputEventsTest::testInitWheelEvent()
|
||||
{
|
||||
// this test verifies that a WheelEvent is constructed correctly
|
||||
|
||||
// first create the test LibInput::Device
|
||||
libinput_device device;
|
||||
Device d(&device);
|
||||
|
||||
// setup event
|
||||
QFETCH(Qt::Orientation, orientation);
|
||||
QFETCH(qreal, delta);
|
||||
WheelEvent event(QPointF(100, 200), delta, orientation, Qt::LeftButton | Qt::RightButton,
|
||||
Qt::ShiftModifier | Qt::ControlModifier, 300, &d);
|
||||
// compare QWheelEvent contract
|
||||
QCOMPARE(event.type(), QEvent::Wheel);
|
||||
QCOMPARE(event.posF(), QPointF(100, 200));
|
||||
QCOMPARE(event.globalPosF(), QPointF(100, 200));
|
||||
QCOMPARE(event.buttons(), Qt::LeftButton | Qt::RightButton);
|
||||
QCOMPARE(event.modifiers(), Qt::ShiftModifier | Qt::ControlModifier);
|
||||
QCOMPARE(event.timestamp(), 300ul);
|
||||
QTEST(event.angleDelta(), "expectedAngleDelta");
|
||||
// and our custom argument
|
||||
QCOMPARE(event.device(), &d);
|
||||
|
||||
}
|
||||
|
||||
QTEST_GUILESS_MAIN(InputEventsTest)
|
||||
#include "input_event_test.moc"
|
|
@ -35,6 +35,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
#include "workspace.h"
|
||||
#if HAVE_INPUT
|
||||
#include "libinput/connection.h"
|
||||
#include "libinput/device.h"
|
||||
#endif
|
||||
#include "platform.h"
|
||||
#include "shell_client.h"
|
||||
|
@ -1105,14 +1106,14 @@ void InputRedirection::setupLibInput()
|
|||
connect(conn, &LibInput::Connection::pointerAxisChanged, m_pointer, &PointerInputRedirection::processAxis);
|
||||
connect(conn, &LibInput::Connection::keyChanged, m_keyboard, &KeyboardInputRedirection::processKey);
|
||||
connect(conn, &LibInput::Connection::pointerMotion, this,
|
||||
[this] (QPointF delta, uint32_t time) {
|
||||
m_pointer->processMotion(m_pointer->pos() + delta, time);
|
||||
[this] (QPointF delta, uint32_t time, LibInput::Device *device) {
|
||||
m_pointer->processMotion(m_pointer->pos() + delta, time, device);
|
||||
}
|
||||
);
|
||||
connect(conn, &LibInput::Connection::pointerMotionAbsolute, this,
|
||||
[this] (QPointF orig, QPointF screen, uint32_t time) {
|
||||
[this] (QPointF orig, QPointF screen, uint32_t time, LibInput::Device *device) {
|
||||
Q_UNUSED(orig)
|
||||
m_pointer->processMotion(screen, time);
|
||||
m_pointer->processMotion(screen, time, device);
|
||||
}
|
||||
);
|
||||
connect(conn, &LibInput::Connection::touchDown, m_touch, &TouchInputRedirection::processDown);
|
||||
|
|
50
input_event.cpp
Normal file
50
input_event.cpp
Normal file
|
@ -0,0 +1,50 @@
|
|||
/********************************************************************
|
||||
KWin - the KDE window manager
|
||||
This file is part of the KDE project.
|
||||
|
||||
Copyright (C) 2016 Martin Gräßlin <mgraesslin@kde.org>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*********************************************************************/
|
||||
#include "input_event.h"
|
||||
|
||||
namespace KWin
|
||||
{
|
||||
|
||||
MouseEvent::MouseEvent(QEvent::Type type, const QPointF &pos, Qt::MouseButton button,
|
||||
Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers,
|
||||
quint32 timestamp, LibInput::Device *device)
|
||||
: QMouseEvent(type, pos, pos, button, buttons, modifiers)
|
||||
, m_device(device)
|
||||
{
|
||||
setTimestamp(timestamp);
|
||||
}
|
||||
|
||||
WheelEvent::WheelEvent(const QPointF &pos, qreal delta, Qt::Orientation orientation, Qt::MouseButtons buttons,
|
||||
Qt::KeyboardModifiers modifiers, quint32 timestamp, LibInput::Device *device)
|
||||
: QWheelEvent(pos, pos, QPoint(), (orientation == Qt::Horizontal) ? QPoint(delta, 0) : QPoint(0, delta), delta, orientation, buttons, modifiers)
|
||||
, m_device(device)
|
||||
{
|
||||
setTimestamp(timestamp);
|
||||
}
|
||||
|
||||
KeyEvent::KeyEvent(QEvent::Type type, Qt::Key key, Qt::KeyboardModifiers modifiers, quint32 code, quint32 keysym,
|
||||
const QString &text, bool autorepeat, quint32 timestamp, LibInput::Device *device)
|
||||
: QKeyEvent(type, key, modifiers, code, keysym, 0, text, autorepeat)
|
||||
, m_device(device)
|
||||
{
|
||||
setTimestamp(timestamp);
|
||||
}
|
||||
|
||||
}
|
76
input_event.h
Normal file
76
input_event.h
Normal file
|
@ -0,0 +1,76 @@
|
|||
/********************************************************************
|
||||
KWin - the KDE window manager
|
||||
This file is part of the KDE project.
|
||||
|
||||
Copyright (C) 2016 Martin Gräßlin <mgraesslin@kde.org>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*********************************************************************/
|
||||
#ifndef KWIN_INPUT_EVENT_H
|
||||
#define KWIN_INPUT_EVENT_H
|
||||
#include <QInputEvent>
|
||||
|
||||
namespace KWin
|
||||
{
|
||||
|
||||
namespace LibInput
|
||||
{
|
||||
class Device;
|
||||
}
|
||||
|
||||
class MouseEvent : public QMouseEvent
|
||||
{
|
||||
public:
|
||||
explicit MouseEvent(QEvent::Type type, const QPointF &pos, Qt::MouseButton button, Qt::MouseButtons buttons,
|
||||
Qt::KeyboardModifiers modifiers, quint32 timestamp, LibInput::Device *device);
|
||||
|
||||
LibInput::Device *device() const {
|
||||
return m_device;
|
||||
}
|
||||
|
||||
private:
|
||||
LibInput::Device *m_device;
|
||||
};
|
||||
|
||||
class WheelEvent : public QWheelEvent
|
||||
{
|
||||
public:
|
||||
explicit WheelEvent(const QPointF &pos, qreal delta, Qt::Orientation orientation, Qt::MouseButtons buttons,
|
||||
Qt::KeyboardModifiers modifiers, quint32 timestamp, LibInput::Device *device);
|
||||
|
||||
LibInput::Device *device() const {
|
||||
return m_device;
|
||||
}
|
||||
|
||||
private:
|
||||
LibInput::Device *m_device;
|
||||
};
|
||||
|
||||
class KeyEvent : public QKeyEvent
|
||||
{
|
||||
public:
|
||||
explicit KeyEvent(QEvent::Type type, Qt::Key key, Qt::KeyboardModifiers modifiers, quint32 code, quint32 keysym,
|
||||
const QString &text, bool autorepeat, quint32 timestamp, LibInput::Device *device);
|
||||
|
||||
LibInput::Device *device() const {
|
||||
return m_device;
|
||||
}
|
||||
|
||||
private:
|
||||
LibInput::Device *m_device;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
|
@ -18,6 +18,7 @@ You should have received a copy of the GNU General Public License
|
|||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*********************************************************************/
|
||||
#include "keyboard_input.h"
|
||||
#include "input_event.h"
|
||||
#include "abstract_client.h"
|
||||
#include "options.h"
|
||||
#include "utils.h"
|
||||
|
@ -447,7 +448,7 @@ void KeyboardInputRedirection::update()
|
|||
}
|
||||
}
|
||||
|
||||
void KeyboardInputRedirection::processKey(uint32_t key, InputRedirection::KeyboardKeyState state, uint32_t time)
|
||||
void KeyboardInputRedirection::processKey(uint32_t key, InputRedirection::KeyboardKeyState state, uint32_t time, LibInput::Device *device)
|
||||
{
|
||||
if (!m_inited) {
|
||||
return;
|
||||
|
@ -478,15 +479,15 @@ void KeyboardInputRedirection::processKey(uint32_t key, InputRedirection::Keyboa
|
|||
}
|
||||
|
||||
const xkb_keysym_t keySym = m_xkb->toKeysym(key);
|
||||
QKeyEvent event(type,
|
||||
m_xkb->toQtKey(keySym),
|
||||
m_xkb->modifiers(),
|
||||
key,
|
||||
keySym,
|
||||
0,
|
||||
m_xkb->toString(m_xkb->toKeysym(key)),
|
||||
autoRepeat);
|
||||
event.setTimestamp(time);
|
||||
KeyEvent event(type,
|
||||
m_xkb->toQtKey(keySym),
|
||||
m_xkb->modifiers(),
|
||||
key,
|
||||
keySym,
|
||||
m_xkb->toString(m_xkb->toKeysym(key)),
|
||||
autoRepeat,
|
||||
time,
|
||||
device);
|
||||
if (state == InputRedirection::KeyboardKeyPressed) {
|
||||
if (m_xkb->shouldKeyRepeat(key) && waylandServer()->seat()->keyRepeatDelay() != 0) {
|
||||
QTimer *timer = new QTimer;
|
||||
|
|
|
@ -42,6 +42,11 @@ namespace KWin
|
|||
class InputRedirection;
|
||||
class Toplevel;
|
||||
|
||||
namespace LibInput
|
||||
{
|
||||
class Device;
|
||||
}
|
||||
|
||||
class Xkb
|
||||
{
|
||||
public:
|
||||
|
@ -96,7 +101,7 @@ public:
|
|||
/**
|
||||
* @internal
|
||||
*/
|
||||
void processKey(uint32_t key, InputRedirection::KeyboardKeyState state, uint32_t time);
|
||||
void processKey(uint32_t key, InputRedirection::KeyboardKeyState state, uint32_t time, LibInput::Device *device = nullptr);
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
|
|
|
@ -283,7 +283,7 @@ void Connection::processEvents()
|
|||
}
|
||||
case LIBINPUT_EVENT_KEYBOARD_KEY: {
|
||||
KeyEvent *ke = static_cast<KeyEvent*>(event.data());
|
||||
emit keyChanged(ke->key(), ke->state(), ke->time());
|
||||
emit keyChanged(ke->key(), ke->state(), ke->time(), ke->device());
|
||||
break;
|
||||
}
|
||||
case LIBINPUT_EVENT_POINTER_AXIS: {
|
||||
|
@ -312,13 +312,13 @@ void Connection::processEvents()
|
|||
}
|
||||
}
|
||||
for (auto it = deltas.constBegin(); it != deltas.constEnd(); ++it) {
|
||||
emit pointerAxisChanged(it.key(), it.value().delta, it.value().time);
|
||||
emit pointerAxisChanged(it.key(), it.value().delta, it.value().time, pe->device());
|
||||
}
|
||||
break;
|
||||
}
|
||||
case LIBINPUT_EVENT_POINTER_BUTTON: {
|
||||
PointerEvent *pe = static_cast<PointerEvent*>(event.data());
|
||||
emit pointerButtonChanged(pe->button(), pe->buttonState(), pe->time());
|
||||
emit pointerButtonChanged(pe->button(), pe->buttonState(), pe->time(), pe->device());
|
||||
break;
|
||||
}
|
||||
case LIBINPUT_EVENT_POINTER_MOTION: {
|
||||
|
@ -336,35 +336,35 @@ void Connection::processEvents()
|
|||
break;
|
||||
}
|
||||
}
|
||||
emit pointerMotion(delta, latestTime);
|
||||
emit pointerMotion(delta, latestTime, pe->device());
|
||||
break;
|
||||
}
|
||||
case LIBINPUT_EVENT_POINTER_MOTION_ABSOLUTE: {
|
||||
PointerEvent *pe = static_cast<PointerEvent*>(event.data());
|
||||
emit pointerMotionAbsolute(pe->absolutePos(), pe->absolutePos(m_size), pe->time());
|
||||
emit pointerMotionAbsolute(pe->absolutePos(), pe->absolutePos(m_size), pe->time(), pe->device());
|
||||
break;
|
||||
}
|
||||
case LIBINPUT_EVENT_TOUCH_DOWN: {
|
||||
TouchEvent *te = static_cast<TouchEvent*>(event.data());
|
||||
emit touchDown(te->id(), te->absolutePos(m_size), te->time());
|
||||
emit touchDown(te->id(), te->absolutePos(m_size), te->time(), te->device());
|
||||
break;
|
||||
}
|
||||
case LIBINPUT_EVENT_TOUCH_UP: {
|
||||
TouchEvent *te = static_cast<TouchEvent*>(event.data());
|
||||
emit touchUp(te->id(), te->time());
|
||||
emit touchUp(te->id(), te->time(), te->device());
|
||||
break;
|
||||
}
|
||||
case LIBINPUT_EVENT_TOUCH_MOTION: {
|
||||
TouchEvent *te = static_cast<TouchEvent*>(event.data());
|
||||
emit touchMotion(te->id(), te->absolutePos(m_size), te->time());
|
||||
emit touchMotion(te->id(), te->absolutePos(m_size), te->time(), te->device());
|
||||
break;
|
||||
}
|
||||
case LIBINPUT_EVENT_TOUCH_CANCEL: {
|
||||
emit touchCanceled();
|
||||
emit touchCanceled(event->device());
|
||||
break;
|
||||
}
|
||||
case LIBINPUT_EVENT_TOUCH_FRAME: {
|
||||
emit touchFrame();
|
||||
emit touchFrame(event->device());
|
||||
break;
|
||||
}
|
||||
default:
|
||||
|
|
|
@ -83,16 +83,16 @@ public:
|
|||
}
|
||||
|
||||
Q_SIGNALS:
|
||||
void keyChanged(quint32 key, KWin::InputRedirection::KeyboardKeyState, quint32 time);
|
||||
void pointerButtonChanged(quint32 button, KWin::InputRedirection::PointerButtonState state, quint32 time);
|
||||
void pointerMotionAbsolute(QPointF orig, QPointF screen, quint32 time);
|
||||
void pointerMotion(QPointF delta, quint32 time);
|
||||
void pointerAxisChanged(KWin::InputRedirection::PointerAxis axis, qreal delta, quint32 time);
|
||||
void touchFrame();
|
||||
void touchCanceled();
|
||||
void touchDown(qint32 id, const QPointF &absolutePos, quint32 time);
|
||||
void touchUp(qint32 id, quint32 time);
|
||||
void touchMotion(qint32 id, const QPointF &absolutePos, quint32 time);
|
||||
void keyChanged(quint32 key, KWin::InputRedirection::KeyboardKeyState, quint32 time, KWin::LibInput::Device *device);
|
||||
void pointerButtonChanged(quint32 button, KWin::InputRedirection::PointerButtonState state, quint32 time, KWin::LibInput::Device *device);
|
||||
void pointerMotionAbsolute(QPointF orig, QPointF screen, quint32 time, KWin::LibInput::Device *device);
|
||||
void pointerMotion(QPointF delta, quint32 time, KWin::LibInput::Device *device);
|
||||
void pointerAxisChanged(KWin::InputRedirection::PointerAxis axis, qreal delta, quint32 time, KWin::LibInput::Device *device);
|
||||
void touchFrame(KWin::LibInput::Device *device);
|
||||
void touchCanceled(KWin::LibInput::Device *device);
|
||||
void touchDown(qint32 id, const QPointF &absolutePos, quint32 time, KWin::LibInput::Device *device);
|
||||
void touchUp(qint32 id, quint32 time, KWin::LibInput::Device *device);
|
||||
void touchMotion(qint32 id, const QPointF &absolutePos, quint32 time, KWin::LibInput::Device *device);
|
||||
void hasKeyboardChanged(bool);
|
||||
void hasAlphaNumericKeyboardChanged(bool);
|
||||
void hasPointerChanged(bool);
|
||||
|
|
|
@ -20,6 +20,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
#include "pointer_input.h"
|
||||
#include "platform.h"
|
||||
#include "effects.h"
|
||||
#include "input_event.h"
|
||||
#include "screens.h"
|
||||
#include "shell_client.h"
|
||||
#include "wayland_cursor_theme.h"
|
||||
|
@ -159,15 +160,14 @@ void PointerInputRedirection::init()
|
|||
updateAfterScreenChange();
|
||||
}
|
||||
|
||||
void PointerInputRedirection::processMotion(const QPointF &pos, uint32_t time)
|
||||
void PointerInputRedirection::processMotion(const QPointF &pos, uint32_t time, LibInput::Device *device)
|
||||
{
|
||||
if (!m_inited) {
|
||||
return;
|
||||
}
|
||||
updatePosition(pos);
|
||||
QMouseEvent event(QEvent::MouseMove, m_pos.toPoint(), m_pos.toPoint(),
|
||||
Qt::NoButton, m_qtButtons, m_input->keyboardModifiers());
|
||||
event.setTimestamp(time);
|
||||
MouseEvent event(QEvent::MouseMove, m_pos, Qt::NoButton, m_qtButtons,
|
||||
m_input->keyboardModifiers(), time, device);
|
||||
|
||||
const auto &filters = m_input->filters();
|
||||
for (auto it = filters.begin(), end = filters.end(); it != end; it++) {
|
||||
|
@ -177,7 +177,7 @@ void PointerInputRedirection::processMotion(const QPointF &pos, uint32_t time)
|
|||
}
|
||||
}
|
||||
|
||||
void PointerInputRedirection::processButton(uint32_t button, InputRedirection::PointerButtonState state, uint32_t time)
|
||||
void PointerInputRedirection::processButton(uint32_t button, InputRedirection::PointerButtonState state, uint32_t time, LibInput::Device *device)
|
||||
{
|
||||
if (!m_inited) {
|
||||
return;
|
||||
|
@ -197,9 +197,8 @@ void PointerInputRedirection::processButton(uint32_t button, InputRedirection::P
|
|||
return;
|
||||
}
|
||||
|
||||
QMouseEvent event(type, m_pos.toPoint(), m_pos.toPoint(),
|
||||
buttonToQtMouseButton(button), m_qtButtons, m_input->keyboardModifiers());
|
||||
event.setTimestamp(time);
|
||||
MouseEvent event(type, m_pos, buttonToQtMouseButton(button), m_qtButtons,
|
||||
m_input->keyboardModifiers(), time, device);
|
||||
|
||||
const auto &filters = m_input->filters();
|
||||
for (auto it = filters.begin(), end = filters.end(); it != end; it++) {
|
||||
|
@ -209,7 +208,7 @@ void PointerInputRedirection::processButton(uint32_t button, InputRedirection::P
|
|||
}
|
||||
}
|
||||
|
||||
void PointerInputRedirection::processAxis(InputRedirection::PointerAxis axis, qreal delta, uint32_t time)
|
||||
void PointerInputRedirection::processAxis(InputRedirection::PointerAxis axis, qreal delta, uint32_t time, LibInput::Device *device)
|
||||
{
|
||||
if (!m_inited) {
|
||||
return;
|
||||
|
@ -220,13 +219,9 @@ void PointerInputRedirection::processAxis(InputRedirection::PointerAxis axis, qr
|
|||
|
||||
emit m_input->pointerAxisChanged(axis, delta);
|
||||
|
||||
QWheelEvent wheelEvent(m_pos, m_pos, QPoint(),
|
||||
(axis == InputRedirection::PointerAxisHorizontal) ? QPoint(delta, 0) : QPoint(0, delta),
|
||||
delta,
|
||||
WheelEvent wheelEvent(m_pos, delta,
|
||||
(axis == InputRedirection::PointerAxisHorizontal) ? Qt::Horizontal : Qt::Vertical,
|
||||
m_qtButtons,
|
||||
m_input->keyboardModifiers());
|
||||
wheelEvent.setTimestamp(time);
|
||||
m_qtButtons, m_input->keyboardModifiers(), time, device);
|
||||
|
||||
const auto &filters = m_input->filters();
|
||||
for (auto it = filters.begin(), end = filters.end(); it != end; it++) {
|
||||
|
|
|
@ -42,6 +42,11 @@ namespace Decoration
|
|||
class DecoratedClientImpl;
|
||||
}
|
||||
|
||||
namespace LibInput
|
||||
{
|
||||
class Device;
|
||||
}
|
||||
|
||||
class KWIN_EXPORT PointerInputRedirection : public InputDeviceHandler
|
||||
{
|
||||
Q_OBJECT
|
||||
|
@ -72,15 +77,15 @@ public:
|
|||
/**
|
||||
* @internal
|
||||
*/
|
||||
void processMotion(const QPointF &pos, uint32_t time);
|
||||
void processMotion(const QPointF &pos, uint32_t time, LibInput::Device *device = nullptr);
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
void processButton(uint32_t button, InputRedirection::PointerButtonState state, uint32_t time);
|
||||
void processButton(uint32_t button, InputRedirection::PointerButtonState state, uint32_t time, LibInput::Device *device = nullptr);
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
void processAxis(InputRedirection::PointerAxis axis, qreal delta, uint32_t time);
|
||||
void processAxis(InputRedirection::PointerAxis axis, qreal delta, uint32_t time, LibInput::Device *device = nullptr);
|
||||
|
||||
private:
|
||||
void updatePosition(const QPointF &pos);
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
*/
|
||||
#include "../input.h"
|
||||
#include "../libinput/connection.h"
|
||||
#include "../libinput/device.h"
|
||||
#include "../logind.h"
|
||||
|
||||
#include <QCoreApplication>
|
||||
|
|
|
@ -144,8 +144,9 @@ void TouchInputRedirection::removeId(quint32 internalId)
|
|||
m_idMapper.remove(internalId);
|
||||
}
|
||||
|
||||
void TouchInputRedirection::processDown(qint32 id, const QPointF &pos, quint32 time)
|
||||
void TouchInputRedirection::processDown(qint32 id, const QPointF &pos, quint32 time, LibInput::Device *device)
|
||||
{
|
||||
Q_UNUSED(device)
|
||||
if (!m_inited) {
|
||||
return;
|
||||
}
|
||||
|
@ -159,8 +160,9 @@ void TouchInputRedirection::processDown(qint32 id, const QPointF &pos, quint32 t
|
|||
m_windowUpdatedInCycle = false;
|
||||
}
|
||||
|
||||
void TouchInputRedirection::processUp(qint32 id, quint32 time)
|
||||
void TouchInputRedirection::processUp(qint32 id, quint32 time, LibInput::Device *device)
|
||||
{
|
||||
Q_UNUSED(device)
|
||||
if (!m_inited) {
|
||||
return;
|
||||
}
|
||||
|
@ -174,8 +176,9 @@ void TouchInputRedirection::processUp(qint32 id, quint32 time)
|
|||
m_windowUpdatedInCycle = false;
|
||||
}
|
||||
|
||||
void TouchInputRedirection::processMotion(qint32 id, const QPointF &pos, quint32 time)
|
||||
void TouchInputRedirection::processMotion(qint32 id, const QPointF &pos, quint32 time, LibInput::Device *device)
|
||||
{
|
||||
Q_UNUSED(device)
|
||||
if (!m_inited) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -37,6 +37,11 @@ namespace Decoration
|
|||
class DecoratedClientImpl;
|
||||
}
|
||||
|
||||
namespace LibInput
|
||||
{
|
||||
class Device;
|
||||
}
|
||||
|
||||
class TouchInputRedirection : public InputDeviceHandler
|
||||
{
|
||||
Q_OBJECT
|
||||
|
@ -47,9 +52,9 @@ public:
|
|||
void update(const QPointF &pos = QPointF());
|
||||
void init();
|
||||
|
||||
void processDown(qint32 id, const QPointF &pos, quint32 time);
|
||||
void processUp(qint32 id, quint32 time);
|
||||
void processMotion(qint32 id, const QPointF &pos, quint32 time);
|
||||
void processDown(qint32 id, const QPointF &pos, quint32 time, LibInput::Device *device = nullptr);
|
||||
void processUp(qint32 id, quint32 time, LibInput::Device *device = nullptr);
|
||||
void processMotion(qint32 id, const QPointF &pos, quint32 time, LibInput::Device *device = nullptr);
|
||||
void cancel();
|
||||
void frame();
|
||||
|
||||
|
|
Loading…
Reference in a new issue