~lukas-kde/miral/shellchrome-windowinfo

« back to all changes in this revision

Viewing changes to miral-qt/src/platforms/mirserver/qteventfeeder.h

  • Committer: Larry Price
  • Date: 2016-09-13 16:19:29 UTC
  • mto: (330.4.1 miral)
  • mto: This revision was merged to the branch mainline in revision 352.
  • Revision ID: larry.price@canonical.com-20160913161929-vs9ka1capmljq1es
Removing miral-qt from release branch, updating copyright file, and adding GPL3 license to root dir

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * Copyright (C) 2013-2016 Canonical, Ltd.
3
 
 *
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.
7
 
 *
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.
12
 
 *
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/>.
15
 
 */
16
 
 
17
 
#ifndef MIR_QT_EVENT_FEEDER_H
18
 
#define MIR_QT_EVENT_FEEDER_H
19
 
 
20
 
#include <mir_toolkit/event.h>
21
 
 
22
 
#include <qpa/qwindowsysteminterface.h>
23
 
 
24
 
class QTouchDevice;
25
 
class ScreensModel;
26
 
 
27
 
/*
28
 
  Fills Qt's event loop with input events from Mir
29
 
 */
30
 
class QtEventFeeder
31
 
{
32
 
public:
33
 
    // Interface between QtEventFeeder and the actual QWindowSystemInterface functions
34
 
    // and other related Qt methods and objects to enable replacing them with mocks in
35
 
    // pure unit tests.
36
 
    class QtWindowSystemInterface {
37
 
        public:
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;
56
 
    };
57
 
 
58
 
    QtEventFeeder(const QSharedPointer<ScreensModel> &screensModel);
59
 
    QtEventFeeder(const QSharedPointer<ScreensModel> &screensModel,
60
 
                  QtWindowSystemInterface *windowSystem);
61
 
    virtual ~QtEventFeeder();
62
 
 
63
 
    void dispatchKey(MirKeyboardEvent const* event);
64
 
    void dispatchTouch(MirTouchEvent const* event);
65
 
    void dispatchPointer(MirPointerEvent const* event);
66
 
 
67
 
    bool dispatch(MirEvent const& event); // FIXME used only in tests
68
 
 
69
 
private:
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);
73
 
 
74
 
    QString touchesToString(const QList<struct QWindowSystemInterface::TouchPoint> &points);
75
 
 
76
 
    QTouchDevice *mTouchDevice;
77
 
    QtWindowSystemInterface *mQtWindowSystem;
78
 
 
79
 
    // Maps the id of an active touch to its last known state
80
 
    QHash<int, QWindowSystemInterface::TouchPoint> mActiveTouches;
81
 
};
82
 
 
83
 
#endif // MIR_QT_EVENT_FEEDER_H