Merge remote-tracking branch 'gerrit/master' into newdocs
[profile/ivi/qtbase.git] / src / gui / kernel / qwindowsysteminterface.h
1 /****************************************************************************
2 **
3 ** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
5 **
6 ** This file is part of the QtGui module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.  For licensing terms and
14 ** conditions see http://qt.digia.com/licensing.  For further information
15 ** use the contact form at http://qt.digia.com/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file.  Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights.  These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file.  Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41 #ifndef QWINDOWSYSTEMINTERFACE_H
42 #define QWINDOWSYSTEMINTERFACE_H
43
44 //
45 //  W A R N I N G
46 //  -------------
47 //
48 // This file is part of the QPA API and is not meant to be used
49 // in applications. Usage of this API may make your code
50 // source and binary incompatible with future versions of Qt.
51 //
52
53 #include <QtCore/QTime>
54 #include <QtGui/qwindowdefs.h>
55 #include <QtCore/QEvent>
56 #include <QtCore/QAbstractEventDispatcher>
57 #include <QtGui/QScreen>
58 #include <QtGui/QWindow>
59 #include <QtCore/QWeakPointer>
60 #include <QtCore/QMutex>
61 #include <QtGui/QTouchEvent>
62 #include <QtCore/QEventLoop>
63 #include <QtGui/QVector2D>
64
65 QT_BEGIN_HEADER
66
67 QT_BEGIN_NAMESPACE
68
69 class QMimeData;
70 class QTouchDevice;
71 class QPlatformDragQtResponse;
72 class QPlatformDropQtResponse;
73
74
75 class Q_GUI_EXPORT QWindowSystemInterface
76 {
77 public:
78     static void handleMouseEvent(QWindow *w, const QPointF & local, const QPointF & global, Qt::MouseButtons b, Qt::KeyboardModifiers mods = Qt::NoModifier);
79     static void handleMouseEvent(QWindow *w, ulong timestamp, const QPointF & local, const QPointF & global, Qt::MouseButtons b, Qt::KeyboardModifiers mods = Qt::NoModifier);
80     static void handleFrameStrutMouseEvent(QWindow *w, const QPointF & local, const QPointF & global, Qt::MouseButtons b, Qt::KeyboardModifiers mods = Qt::NoModifier);
81     static void handleFrameStrutMouseEvent(QWindow *w, ulong timestamp, const QPointF & local, const QPointF & global, Qt::MouseButtons b, Qt::KeyboardModifiers mods = Qt::NoModifier);
82
83     static bool tryHandleShortcutEvent(QWindow *w, int k, Qt::KeyboardModifiers mods,
84                                                   const QString & text = QString(), bool autorep = false, ushort count = 1);
85     static bool tryHandleShortcutEvent(QWindow *w, ulong timestamp, int k, Qt::KeyboardModifiers mods,
86                                                   const QString & text = QString(), bool autorep = false, ushort count = 1);
87
88     static bool tryHandleExtendedShortcutEvent(QWindow *w, int k, Qt::KeyboardModifiers mods,
89                                                           quint32 nativeScanCode, quint32 nativeVirtualKey, quint32 nativeModifiers,
90                                                           const QString & text = QString(), bool autorep = false, ushort count = 1);
91     static bool tryHandleExtendedShortcutEvent(QWindow *w, ulong timestamp, int k, Qt::KeyboardModifiers mods,
92                                                           quint32 nativeScanCode, quint32 nativeVirtualKey, quint32 nativeModifiers,
93                                                           const QString & text = QString(), bool autorep = false, ushort count = 1);
94
95     static void handleKeyEvent(QWindow *w, QEvent::Type t, int k, Qt::KeyboardModifiers mods, const QString & text = QString(), bool autorep = false, ushort count = 1);
96     static void handleKeyEvent(QWindow *w, ulong timestamp, QEvent::Type t, int k, Qt::KeyboardModifiers mods, const QString & text = QString(), bool autorep = false, ushort count = 1);
97
98     static void handleExtendedKeyEvent(QWindow *w, QEvent::Type type, int key, Qt::KeyboardModifiers modifiers,
99                                        quint32 nativeScanCode, quint32 nativeVirtualKey,
100                                        quint32 nativeModifiers,
101                                        const QString& text = QString(), bool autorep = false,
102                                        ushort count = 1);
103     static void handleExtendedKeyEvent(QWindow *w, ulong timestamp, QEvent::Type type, int key, Qt::KeyboardModifiers modifiers,
104                                        quint32 nativeScanCode, quint32 nativeVirtualKey,
105                                        quint32 nativeModifiers,
106                                        const QString& text = QString(), bool autorep = false,
107                                        ushort count = 1);
108     static void handleWheelEvent(QWindow *w, const QPointF & local, const QPointF & global, QPoint pixelDelta, QPoint angleDelta, Qt::KeyboardModifiers mods = Qt::NoModifier);
109     static void handleWheelEvent(QWindow *w, ulong timestamp, const QPointF & local, const QPointF & global, QPoint pixelDelta, QPoint angleDelta, Qt::KeyboardModifiers mods = Qt::NoModifier);
110
111     // Wheel event compatibility functions. Will be removed: do not use.
112     static void handleWheelEvent(QWindow *w, const QPointF & local, const QPointF & global, int d, Qt::Orientation o, Qt::KeyboardModifiers mods = Qt::NoModifier);
113     static void handleWheelEvent(QWindow *w, ulong timestamp, const QPointF & local, const QPointF & global, int d, Qt::Orientation o, Qt::KeyboardModifiers mods = Qt::NoModifier);
114
115     struct TouchPoint {
116         TouchPoint() : id(0), pressure(0), state(Qt::TouchPointStationary), flags(0) { }
117         int id;                 // for application use
118         QPointF normalPosition; // touch device coordinates, (0 to 1, 0 to 1)
119         QRectF area;            // the touched area, centered at position in screen coordinates
120         qreal pressure;         // 0 to 1
121         Qt::TouchPointState state; //Qt::TouchPoint{Pressed|Moved|Stationary|Released}
122         QVector2D velocity;     // in screen coordinate system, pixels / seconds
123         QTouchEvent::TouchPoint::InfoFlags flags;
124         QVector<QPointF> rawPositions; // in screen coordinates
125     };
126
127     static void registerTouchDevice(QTouchDevice *device);
128     static void handleTouchEvent(QWindow *w, QTouchDevice *device,
129                                  const QList<struct TouchPoint> &points, Qt::KeyboardModifiers mods = Qt::NoModifier);
130     static void handleTouchEvent(QWindow *w, ulong timestamp, QTouchDevice *device,
131                                  const QList<struct TouchPoint> &points, Qt::KeyboardModifiers mods = Qt::NoModifier);
132     static void handleTouchCancelEvent(QWindow *w, QTouchDevice *device, Qt::KeyboardModifiers mods = Qt::NoModifier);
133     static void handleTouchCancelEvent(QWindow *w, ulong timestamp, QTouchDevice *device, Qt::KeyboardModifiers mods = Qt::NoModifier);
134
135     static void handleGeometryChange(QWindow *w, const QRect &newRect);
136     static void handleCloseEvent(QWindow *w);
137     static void handleEnterEvent(QWindow *w);
138     static void handleLeaveEvent(QWindow *w);
139     static void handleEnterLeaveEvent(QWindow *enter, QWindow *leave);
140     static void handleWindowActivated(QWindow *w);
141     static void handleWindowStateChanged(QWindow *w, Qt::WindowState newState);
142
143     static void handleExposeEvent(QWindow *tlw, const QRegion &region);
144
145 #ifndef QT_NO_DRAGANDDROP
146     // Drag and drop. These events are sent immediately.
147     static QPlatformDragQtResponse handleDrag(QWindow *w, const QMimeData *dropData, const QPoint &p, Qt::DropActions supportedActions);
148     static QPlatformDropQtResponse handleDrop(QWindow *w, const QMimeData *dropData, const QPoint &p, Qt::DropActions supportedActions);
149 #endif
150
151     static bool handleNativeEvent(QWindow *window, const QByteArray &eventType, void *message, long *result);
152
153     // Changes to the screen
154     static void handleScreenOrientationChange(QScreen *screen, Qt::ScreenOrientation newOrientation);
155     static void handleScreenGeometryChange(QScreen *screen, const QRect &newGeometry);
156     static void handleScreenAvailableGeometryChange(QScreen *screen, const QRect &newAvailableGeometry);
157     static void handleScreenLogicalDotsPerInchChange(QScreen *screen, qreal newDpiX, qreal newDpiY);
158     static void handleScreenRefreshRateChange(QScreen *screen, qreal newRefreshRate);
159
160     static void handleThemeChange(QWindow *tlw);
161
162     static void handleFileOpenEvent(const QString& fileName);
163
164     static void handleTabletEvent(QWindow *w, ulong timestamp, bool down, const QPointF &local, const QPointF &global,
165                                   int device, int pointerType, qreal pressure, int xTilt, int yTilt,
166                                   qreal tangentialPressure, qreal rotation, int z, qint64 uid,
167                                   Qt::KeyboardModifiers modifiers = Qt::NoModifier);
168     static void handleTabletEvent(QWindow *w, bool down, const QPointF &local, const QPointF &global,
169                                   int device, int pointerType, qreal pressure, int xTilt, int yTilt,
170                                   qreal tangentialPressure, qreal rotation, int z, qint64 uid,
171                                   Qt::KeyboardModifiers modifiers = Qt::NoModifier);
172     static void handleTabletEnterProximityEvent(ulong timestamp, int device, int pointerType, qint64 uid);
173     static void handleTabletEnterProximityEvent(int device, int pointerType, qint64 uid);
174     static void handleTabletLeaveProximityEvent(ulong timestamp, int device, int pointerType, qint64 uid);
175     static void handleTabletLeaveProximityEvent(int device, int pointerType, qint64 uid);
176
177     static void handlePlatformPanelEvent(QWindow *w);
178 #ifndef QT_NO_CONTEXTMENU
179     static void handleContextMenuEvent(QWindow *w, bool mouseTriggered,
180                                        const QPoint &pos, const QPoint &globalPos,
181                                        Qt::KeyboardModifiers modifiers);
182 #endif
183
184     // For event dispatcher implementations
185     static bool sendWindowSystemEvents(QEventLoop::ProcessEventsFlags flags);
186     static void setSynchronousWindowsSystemEvents(bool enable);
187     static void flushWindowSystemEvents();
188     static int windowSystemEventsQueued();
189
190 private:
191     static bool sendWindowSystemEventsImplementation(QEventLoop::ProcessEventsFlags flags);
192 };
193
194 QT_END_NAMESPACE
195 QT_END_HEADER
196 #endif // QWINDOWSYSTEMINTERFACE_H