2
* Copyright (C) 2013-2016 Canonical, Ltd.
4
* This program is free software: you can redistribute it and/or modify it under
5
* the terms of the GNU Lesser General Public License version 3, as published by
6
* the Free Software Foundation.
8
* This program is distributed in the hope that it will be useful, but WITHOUT
9
* ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
10
* SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11
* Lesser General Public License for more details.
13
* You should have received a copy of the GNU Lesser General Public License
14
* along with this program. If not, see <http://www.gnu.org/licenses/>.
17
#ifndef MIR_QT_EVENT_FEEDER_H
18
#define MIR_QT_EVENT_FEEDER_H
20
#include <mir_toolkit/event.h>
22
#include <qpa/qwindowsysteminterface.h>
28
Fills Qt's event loop with input events from Mir
33
// Interface between QtEventFeeder and the actual QWindowSystemInterface functions
34
// and other related Qt methods and objects to enable replacing them with mocks in
36
class QtWindowSystemInterface {
38
virtual ~QtWindowSystemInterface() {}
39
virtual void setScreensModel(const QSharedPointer<ScreensModel> &sc) = 0;
40
virtual QWindow* getWindowForTouchPoint(const QPoint &point) = 0;
41
virtual QWindow* focusedWindow() = 0;
42
virtual void registerTouchDevice(QTouchDevice *device) = 0;
43
virtual void handleExtendedKeyEvent(QWindow *window, ulong timestamp, QEvent::Type type, int key,
44
Qt::KeyboardModifiers modifiers,
45
quint32 nativeScanCode, quint32 nativeVirtualKey,
46
quint32 nativeModifiers,
47
const QString& text = QString(), bool autorep = false,
48
ushort count = 1) = 0;
49
virtual void handleTouchEvent(QWindow *window, ulong timestamp, QTouchDevice *device,
50
const QList<struct QWindowSystemInterface::TouchPoint> &points,
51
Qt::KeyboardModifiers mods = Qt::NoModifier) = 0;
52
virtual void handleMouseEvent(ulong timestamp, QPointF relative, QPointF absolute, Qt::MouseButtons buttons,
53
Qt::KeyboardModifiers modifiers) = 0;
54
virtual void handleWheelEvent(ulong timestamp, QPointF absolute, QPoint angleDelta,
55
Qt::KeyboardModifiers modifiers) = 0;
58
QtEventFeeder(const QSharedPointer<ScreensModel> &screensModel);
59
QtEventFeeder(const QSharedPointer<ScreensModel> &screensModel,
60
QtWindowSystemInterface *windowSystem);
61
virtual ~QtEventFeeder();
63
void dispatchKey(MirKeyboardEvent const* event);
64
void dispatchTouch(MirTouchEvent const* event);
65
void dispatchPointer(MirPointerEvent const* event);
67
bool dispatch(MirEvent const& event); // FIXME used only in tests
70
void validateTouches(QWindow *window, ulong timestamp, QList<QWindowSystemInterface::TouchPoint> &touchPoints);
71
bool validateTouch(QWindowSystemInterface::TouchPoint &touchPoint);
72
void sendActiveTouchRelease(QWindow *window, ulong timestamp, int id);
74
QString touchesToString(const QList<struct QWindowSystemInterface::TouchPoint> &points);
76
QTouchDevice *mTouchDevice;
77
QtWindowSystemInterface *mQtWindowSystem;
79
// Maps the id of an active touch to its last known state
80
QHash<int, QWindowSystemInterface::TouchPoint> mActiveTouches;
83
#endif // MIR_QT_EVENT_FEEDER_H