~unity-team/qtmir/no-upstart-notification

« back to all changes in this revision

Viewing changes to src/platforms/mirserver/qteventfeeder.h

  • Committer: CI bot
  • Author(s): Daniel d'Andrada
  • Date: 2014-09-07 19:42:14 UTC
  • mfrom: (239.1.6 missingTouchEnd-lp1295623)
  • Revision ID: ps-jenkins@lists.canonical.com-20140907194214-1eq13l827gavf65i
QtEventFeeder: validate touches before sending them to Qt

Make sure we send a tidy touch event stream to Qt as some of it
(QQuickWindow) is vulnerable to things like missing touch releases.

Also properly ignore unsupported motion event actions such as hovering.
 Fixes: 1295623
Approved by: Gerry Boland, PS Jenkins bot

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
#include <mir/input/input_dispatcher.h>
23
23
#include <mir/shell/input_targeter.h>
24
24
 
 
25
#include <qpa/qwindowsysteminterface.h>
 
26
 
25
27
class QTouchDevice;
26
28
 
27
29
/*
30
32
class QtEventFeeder : public mir::input::InputDispatcher
31
33
{
32
34
public:
33
 
    QtEventFeeder();
 
35
    // Interface between QtEventFeeder and the actual QWindowSystemInterface functions
 
36
    // and other related Qt methods and objects to enable replacing them with mocks in
 
37
    // pure unit tests.
 
38
    // TODO - Make it work with multimonitor scenarios
 
39
    class QtWindowSystemInterface {
 
40
        public:
 
41
        virtual ~QtWindowSystemInterface() {}
 
42
        virtual bool hasTargetWindow() = 0;
 
43
        virtual QRect targetWindowGeometry() = 0;
 
44
        virtual void registerTouchDevice(QTouchDevice *device) = 0;
 
45
        virtual void handleExtendedKeyEvent(ulong timestamp, QEvent::Type type, int key,
 
46
                Qt::KeyboardModifiers modifiers,
 
47
                quint32 nativeScanCode, quint32 nativeVirtualKey,
 
48
                quint32 nativeModifiers,
 
49
                const QString& text = QString(), bool autorep = false,
 
50
                ushort count = 1) = 0;
 
51
        virtual void handleTouchEvent(ulong timestamp, QTouchDevice *device,
 
52
                const QList<struct QWindowSystemInterface::TouchPoint> &points,
 
53
                Qt::KeyboardModifiers mods = Qt::NoModifier) = 0;
 
54
    };
 
55
 
 
56
    QtEventFeeder(QtWindowSystemInterface *windowSystem = nullptr);
 
57
    virtual ~QtEventFeeder();
34
58
 
35
59
    static const int MirEventActionMask;
36
60
    static const int MirEventActionPointerIndexMask;
45
69
private:
46
70
    void dispatchKey(MirKeyEvent const& event);
47
71
    void dispatchMotion(MirMotionEvent const& event);
 
72
    void validateTouches(QList<QWindowSystemInterface::TouchPoint> &touchPoints);
 
73
    bool validateTouch(QWindowSystemInterface::TouchPoint &touchPoint);
48
74
 
49
75
    QTouchDevice *mTouchDevice;
 
76
    QtWindowSystemInterface *mQtWindowSystem;
 
77
 
 
78
    // Maps the id of an active touch to its last known state
 
79
    QHash<int, QWindowSystemInterface::TouchPoint> mActiveTouches;
50
80
};
51
81
 
52
82
#endif // MIR_QT_EVENT_FEEDER_H