1 /****************************************************************************
3 ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/
6 ** This file is part of the QtGui module of the Qt Toolkit.
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** GNU Lesser General Public License Usage
10 ** This file may be used under the terms of the GNU Lesser General Public
11 ** License version 2.1 as published by the Free Software Foundation and
12 ** appearing in the file LICENSE.LGPL included in the packaging of this
13 ** file. Please review the following information to ensure the GNU Lesser
14 ** General Public License version 2.1 requirements will be met:
15 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
17 ** In addition, as a special exception, Nokia gives you certain additional
18 ** rights. These rights are described in the Nokia Qt LGPL Exception
19 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
21 ** GNU General Public License Usage
22 ** Alternatively, this file may be used under the terms of the GNU General
23 ** Public License version 3.0 as published by the Free Software Foundation
24 ** and appearing in the file LICENSE.GPL included in the packaging of this
25 ** file. Please review the following information to ensure the GNU General
26 ** Public License version 3.0 requirements will be met:
27 ** http://www.gnu.org/copyleft/gpl.html.
30 ** Alternatively, this file may be used in accordance with the terms and
31 ** conditions contained in a signed written agreement between you and Nokia.
40 ****************************************************************************/
41 #ifndef QWINDOWSYSTEMINTERFACE_QPA_P_H
42 #define QWINDOWSYSTEMINTERFACE_QPA_P_H
44 #include "qwindowsysteminterface_qpa.h"
46 #include <QElapsedTimer>
53 class QWindowSystemInterfacePrivate {
68 ScreenAvailableGeometry,
69 ScreenLogicalDotsPerInch,
79 class WindowSystemEvent {
81 explicit WindowSystemEvent(EventType t)
82 : type(t), synthetic(false) { }
83 virtual ~WindowSystemEvent() { }
88 class CloseEvent : public WindowSystemEvent {
90 explicit CloseEvent(QWindow *w)
91 : WindowSystemEvent(Close), window(w) { }
92 QPointer<QWindow> window;
95 class GeometryChangeEvent : public WindowSystemEvent {
97 GeometryChangeEvent(QWindow *tlw, const QRect &newGeometry)
98 : WindowSystemEvent(GeometryChange), tlw(tlw), newGeometry(newGeometry)
100 QPointer<QWindow> tlw;
104 class EnterEvent : public WindowSystemEvent {
106 explicit EnterEvent(QWindow *enter)
107 : WindowSystemEvent(Enter), enter(enter)
109 QPointer<QWindow> enter;
112 class LeaveEvent : public WindowSystemEvent {
114 explicit LeaveEvent(QWindow *leave)
115 : WindowSystemEvent(Leave), leave(leave)
117 QPointer<QWindow> leave;
120 class ActivatedWindowEvent : public WindowSystemEvent {
122 explicit ActivatedWindowEvent(QWindow *activatedWindow)
123 : WindowSystemEvent(ActivatedWindow), activated(activatedWindow)
125 QPointer<QWindow> activated;
128 class WindowStateChangedEvent : public WindowSystemEvent {
130 WindowStateChangedEvent(QWindow *_window, Qt::WindowState _newState)
131 : WindowSystemEvent(WindowStateChanged), window(_window), newState(_newState)
134 QPointer<QWindow> window;
135 Qt::WindowState newState;
138 class UserEvent : public WindowSystemEvent {
140 UserEvent(QWindow * w, ulong time, EventType t)
141 : WindowSystemEvent(t), window(w), nullWindow(w == 0), timestamp(time) { }
142 QPointer<QWindow> window;
144 unsigned long timestamp;
147 class InputEvent: public UserEvent {
149 InputEvent(QWindow * w, ulong time, EventType t, Qt::KeyboardModifiers mods)
150 : UserEvent(w, time, t), modifiers(mods) {}
151 Qt::KeyboardModifiers modifiers;
154 class MouseEvent : public InputEvent {
156 MouseEvent(QWindow * w, ulong time, const QPointF & local, const QPointF & global,
157 Qt::MouseButtons b, Qt::KeyboardModifiers mods)
158 : InputEvent(w, time, Mouse, mods), localPos(local), globalPos(global), buttons(b) { }
161 Qt::MouseButtons buttons;
164 class WheelEvent : public InputEvent {
166 WheelEvent(QWindow *w, ulong time, const QPointF & local, const QPointF & global, QPoint pixelD, QPoint angleD, int qt4D, Qt::Orientation qt4O,
167 Qt::KeyboardModifiers mods)
168 : InputEvent(w, time, Wheel, mods), pixelDelta(pixelD), angleDelta(angleD), qt4Delta(qt4D), qt4Orientation(qt4O), localPos(local), globalPos(global) { }
172 Qt::Orientation qt4Orientation;
177 class KeyEvent : public InputEvent {
179 KeyEvent(QWindow *w, ulong time, QEvent::Type t, int k, Qt::KeyboardModifiers mods, const QString & text = QString(), bool autorep = false, ushort count = 1)
180 :InputEvent(w, time, Key, mods), key(k), unicode(text), repeat(autorep),
181 repeatCount(count), keyType(t),
182 nativeScanCode(0), nativeVirtualKey(0), nativeModifiers(0) { }
183 KeyEvent(QWindow *w, ulong time, QEvent::Type t, int k, Qt::KeyboardModifiers mods,
184 quint32 nativeSC, quint32 nativeVK, quint32 nativeMods,
185 const QString & text = QString(), bool autorep = false, ushort count = 1)
186 :InputEvent(w, time, Key, mods), key(k), unicode(text), repeat(autorep),
187 repeatCount(count), keyType(t),
188 nativeScanCode(nativeSC), nativeVirtualKey(nativeVK), nativeModifiers(nativeMods) { }
193 QEvent::Type keyType;
194 quint32 nativeScanCode;
195 quint32 nativeVirtualKey;
196 quint32 nativeModifiers;
199 class TouchEvent : public InputEvent {
201 TouchEvent(QWindow *w, ulong time, QEvent::Type t, QTouchDevice *dev,
202 const QList<QTouchEvent::TouchPoint> &p, Qt::KeyboardModifiers mods)
203 :InputEvent(w, time, Touch, mods), device(dev), points(p), touchType(t) { }
204 QTouchDevice *device;
205 QList<QTouchEvent::TouchPoint> points;
206 QEvent::Type touchType;
209 class ScreenOrientationEvent : public WindowSystemEvent {
211 ScreenOrientationEvent(QScreen *s, Qt::ScreenOrientation o)
212 : WindowSystemEvent(ScreenOrientation), screen(s), orientation(o) { }
213 QPointer<QScreen> screen;
214 Qt::ScreenOrientation orientation;
217 class ScreenGeometryEvent : public WindowSystemEvent {
219 ScreenGeometryEvent(QScreen *s, const QRect &g)
220 : WindowSystemEvent(ScreenGeometry), screen(s), geometry(g) { }
221 QPointer<QScreen> screen;
225 class ScreenAvailableGeometryEvent : public WindowSystemEvent {
227 ScreenAvailableGeometryEvent(QScreen *s, const QRect &g)
228 : WindowSystemEvent(ScreenAvailableGeometry), screen(s), availableGeometry(g) { }
229 QPointer<QScreen> screen;
230 QRect availableGeometry;
233 class ScreenLogicalDotsPerInchEvent : public WindowSystemEvent {
235 ScreenLogicalDotsPerInchEvent(QScreen *s, qreal dx, qreal dy)
236 : WindowSystemEvent(ScreenLogicalDotsPerInch), screen(s), dpiX(dx), dpiY(dy) { }
237 QPointer<QScreen> screen;
242 class ScreenRefreshRateEvent : public WindowSystemEvent {
244 ScreenRefreshRateEvent(QScreen *s, qreal r)
245 : WindowSystemEvent(ScreenRefreshRate), screen(s), rate(r) { }
246 QPointer<QScreen> screen;
250 class ThemeChangeEvent : public WindowSystemEvent {
252 explicit ThemeChangeEvent(QWindow * w)
253 : WindowSystemEvent(ThemeChange), window(w) { }
254 QPointer<QWindow> window;
257 class ExposeEvent : public WindowSystemEvent {
259 ExposeEvent(QWindow *exposed, const QRegion ®ion);
260 QPointer<QWindow> exposed;
265 class FileOpenEvent : public WindowSystemEvent {
267 FileOpenEvent(const QString& fileName)
268 : WindowSystemEvent(FileOpen), fileName(fileName)
273 class TabletEvent : public InputEvent {
275 static void handleTabletEvent(QWindow *w, bool down, const QPointF &local, const QPointF &global,
276 int device, int pointerType, qreal pressure, int xTilt, int yTilt,
277 qreal tangentialPressure, qreal rotation, int z, qint64 uid,
278 Qt::KeyboardModifiers modifiers = Qt::NoModifier);
280 TabletEvent(QWindow *w, ulong time, bool down, const QPointF &local, const QPointF &global,
281 int device, int pointerType, qreal pressure, int xTilt, int yTilt, qreal tpressure,
282 qreal rotation, int z, qint64 uid, Qt::KeyboardModifiers mods)
283 : InputEvent(w, time, Tablet, Qt::NoModifier),
284 down(down), local(local), global(global), device(device), pointerType(pointerType),
285 pressure(pressure), xTilt(xTilt), yTilt(yTilt), tangentialPressure(tpressure),
286 rotation(rotation), z(z), uid(uid), mods(mods) { }
295 qreal tangentialPressure;
299 Qt::KeyboardModifiers mods;
302 class TabletEnterProximityEvent : public InputEvent {
304 TabletEnterProximityEvent(ulong time, int device, int pointerType, qint64 uid)
305 : InputEvent(0, time, TabletEnterProximity, Qt::NoModifier),
306 device(device), pointerType(pointerType), uid(uid) { }
312 class TabletLeaveProximityEvent : public InputEvent {
314 TabletLeaveProximityEvent(ulong time, int device, int pointerType, qint64 uid)
315 : InputEvent(0, time, TabletLeaveProximity, Qt::NoModifier),
316 device(device), pointerType(pointerType), uid(uid) { }
322 static QList<WindowSystemEvent *> windowSystemEventQueue;
323 static QMutex queueMutex;
325 static int windowSystemEventsQueued();
326 static WindowSystemEvent * getWindowSystemEvent();
327 static void queueWindowSystemEvent(WindowSystemEvent *ev);
329 static QElapsedTimer eventTime;
331 static QList<QTouchEvent::TouchPoint> convertTouchPoints(const QList<QWindowSystemInterface::TouchPoint> &points, QEvent::Type *type);
337 #endif // QWINDOWSYSTEMINTERFACE_QPA_P_H