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 ****************************************************************************/
42 #ifndef QGUIAPPLICATION_P_H
43 #define QGUIAPPLICATION_P_H
45 #include <QtGui/qguiapplication.h>
47 #include <QtCore/QPointF>
48 #include <QtCore/private/qcoreapplication_p.h>
50 #include <QtCore/private/qthread_p.h>
52 #include <QWindowSystemInterface>
53 #include "private/qwindowsysteminterface_p.h"
54 #include "private/qshortcutmap_p.h"
61 class QPlatformIntegration;
63 class QPlatformDragQtResponse;
64 struct QDrawHelperGammaTables;
65 #ifndef QT_NO_DRAGANDDROP
67 #endif // QT_NO_DRAGANDDROP
69 class Q_GUI_EXPORT QGuiApplicationPrivate : public QCoreApplicationPrivate
71 Q_DECLARE_PUBLIC(QGuiApplication)
73 QGuiApplicationPrivate(int &argc, char **argv, int flags);
74 ~QGuiApplicationPrivate();
76 void createPlatformIntegration();
77 void createEventDispatcher();
78 void setEventDispatcher(QAbstractEventDispatcher *eventDispatcher);
80 virtual void notifyLayoutDirectionChange();
81 virtual void notifyActiveWindowChange(QWindow *previous);
83 virtual bool shouldQuit();
85 static Qt::KeyboardModifiers modifier_buttons;
86 static Qt::MouseButtons mouse_buttons;
88 static QPlatformIntegration *platform_integration;
90 static QPlatformIntegration *platformIntegration()
91 { return platform_integration; }
93 static QPlatformTheme *platform_theme;
95 static QPlatformTheme *platformTheme()
96 { return platform_theme; }
98 static QAbstractEventDispatcher *qt_qpa_core_dispatcher()
100 if (QCoreApplication::instance())
101 return QCoreApplication::instance()->d_func()->threadData->eventDispatcher;
106 static void processMouseEvent(QWindowSystemInterfacePrivate::MouseEvent *e);
107 static void processKeyEvent(QWindowSystemInterfacePrivate::KeyEvent *e);
108 static void processWheelEvent(QWindowSystemInterfacePrivate::WheelEvent *e);
109 static void processTouchEvent(QWindowSystemInterfacePrivate::TouchEvent *e);
111 static void processCloseEvent(QWindowSystemInterfacePrivate::CloseEvent *e);
113 static void processGeometryChangeEvent(QWindowSystemInterfacePrivate::GeometryChangeEvent *e);
115 static void processEnterEvent(QWindowSystemInterfacePrivate::EnterEvent *e);
116 static void processLeaveEvent(QWindowSystemInterfacePrivate::LeaveEvent *e);
118 static void processActivatedEvent(QWindowSystemInterfacePrivate::ActivatedWindowEvent *e);
119 static void processWindowStateChangedEvent(QWindowSystemInterfacePrivate::WindowStateChangedEvent *e);
121 static void processWindowSystemEvent(QWindowSystemInterfacePrivate::WindowSystemEvent *e);
123 static void updateFilteredScreenOrientation(QScreen *screen);
124 static void reportScreenOrientationChange(QScreen *screen);
125 static void reportScreenOrientationChange(QWindowSystemInterfacePrivate::ScreenOrientationEvent *e);
126 static void reportGeometryChange(QWindowSystemInterfacePrivate::ScreenGeometryEvent *e);
127 static void reportAvailableGeometryChange(QWindowSystemInterfacePrivate::ScreenAvailableGeometryEvent *e);
128 static void reportLogicalDotsPerInchChange(QWindowSystemInterfacePrivate::ScreenLogicalDotsPerInchEvent *e);
129 static void reportRefreshRateChange(QWindowSystemInterfacePrivate::ScreenRefreshRateEvent *e);
130 static void processThemeChanged(QWindowSystemInterfacePrivate::ThemeChangeEvent *tce);
132 static void processExposeEvent(QWindowSystemInterfacePrivate::ExposeEvent *e);
134 static void processFileOpenEvent(QWindowSystemInterfacePrivate::FileOpenEvent *e);
136 static void processTabletEvent(QWindowSystemInterfacePrivate::TabletEvent *e);
137 static void processTabletEnterProximityEvent(QWindowSystemInterfacePrivate::TabletEnterProximityEvent *e);
138 static void processTabletLeaveProximityEvent(QWindowSystemInterfacePrivate::TabletLeaveProximityEvent *e);
140 #ifndef QT_NO_DRAGANDDROP
141 static QPlatformDragQtResponse processDrag(QWindow *w, const QMimeData *dropData, const QPoint &p, Qt::DropActions supportedActions);
142 static QPlatformDropQtResponse processDrop(QWindow *w, const QMimeData *dropData, const QPoint &p, Qt::DropActions supportedActions);
145 static bool processNativeEvent(QWindow *window, const QByteArray &eventType, void *message, long *result);
147 static void sendQWindowEventToQPlatformWindow(QWindow *window, QEvent *event);
149 static inline Qt::Alignment visualAlignment(Qt::LayoutDirection direction, Qt::Alignment alignment)
151 if (!(alignment & Qt::AlignHorizontal_Mask))
152 alignment |= Qt::AlignLeft;
153 if ((alignment & Qt::AlignAbsolute) == 0 && (alignment & (Qt::AlignLeft | Qt::AlignRight))) {
154 if (direction == Qt::RightToLeft)
155 alignment ^= (Qt::AlignLeft | Qt::AlignRight);
156 alignment |= Qt::AlignAbsolute;
161 static void emitLastWindowClosed();
163 QPixmap getPixmapCursor(Qt::CursorShape cshape);
165 void q_updateFocusObject(QObject *object);
167 static QGuiApplicationPrivate *instance() { return self; }
169 static QString *platform_name;
170 static QString *displayName;
172 QWindowList modalWindowList;
173 static void showModalWindow(QWindow *window);
174 static void hideModalWindow(QWindow *window);
175 static void updateBlockedStatus(QWindow *window);
176 virtual bool isWindowBlocked(QWindow *window, QWindow **blockingWindow = 0) const;
178 static Qt::MouseButtons buttons;
179 static ulong mousePressTime;
180 static Qt::MouseButton mousePressButton;
181 static int mousePressX;
182 static int mousePressY;
183 static int mouse_double_click_distance;
184 static QPointF lastCursorPosition;
185 static bool tabletState;
186 static QWindow *tabletPressTarget;
188 #ifndef QT_NO_CLIPBOARD
189 static QClipboard *qt_clipboard;
192 static QPalette *app_pal;
194 static QWindowList window_list;
195 static QWindow *focus_window;
198 QList<QCursor> cursor_list;
200 static QList<QScreen *> screen_list;
202 static QFont *app_font;
204 QStyleHints *styleHints;
205 static bool obey_desktop_settings;
206 QInputMethod *inputMethod;
208 static QList<QObject *> generic_plugin_list;
209 #ifndef QT_NO_SHORTCUT
210 QShortcutMap shortcutMap;
213 struct ActiveTouchPointsKey {
214 ActiveTouchPointsKey(QTouchDevice *dev, int id) : device(dev), touchPointId(id) { }
215 QTouchDevice *device;
218 struct ActiveTouchPointsValue {
219 QPointer<QWindow> window;
220 QPointer<QObject> target;
221 QTouchEvent::TouchPoint touchPoint;
223 QHash<ActiveTouchPointsKey, ActiveTouchPointsValue> activeTouchPoints;
224 QEvent::Type lastTouchType;
225 struct SynthesizedMouseData {
226 SynthesizedMouseData(const QPointF &p, const QPointF &sp, QWindow *w)
227 : pos(p), screenPos(sp), window(w) { }
230 QPointer<QWindow> window;
232 QHash<QWindow *, SynthesizedMouseData> synthesizedMousePoints;
234 static int mouseEventCaps(QMouseEvent *event);
235 static QVector2D mouseEventVelocity(QMouseEvent *event);
236 static void setMouseEventCapsAndVelocity(QMouseEvent *event, int caps, const QVector2D &velocity);
237 static void setMouseEventCapsAndVelocity(QMouseEvent *event, QMouseEvent *other);
239 const QDrawHelperGammaTables *gammaTables();
241 // hook reimplemented in QApplication to apply the QStyle function on the QIcon
242 virtual QPixmap applyQIconStyleHelper(QIcon::Mode, const QPixmap &basePixmap) const { return basePixmap; }
245 virtual void notifyThemeChanged();
246 #ifndef QT_NO_DRAGANDDROP
247 virtual void notifyDragStarted(const QDrag *);
248 #endif // QT_NO_DRAGANDDROP
251 friend class QDragManager;
255 static QGuiApplicationPrivate *self;
256 static QTouchDevice *m_fakeTouchDevice;
257 static int m_fakeMouseSourcePointId;
258 QAtomicPointer<QDrawHelperGammaTables> m_gammaTables;
261 Q_GUI_EXPORT uint qHash(const QGuiApplicationPrivate::ActiveTouchPointsKey &k);
263 Q_GUI_EXPORT bool operator==(const QGuiApplicationPrivate::ActiveTouchPointsKey &a,
264 const QGuiApplicationPrivate::ActiveTouchPointsKey &b);
270 #endif // QGUIAPPLICATION_P_H