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_QPA_P_H
43 #define QGUIAPPLICATION_QPA_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_qpa_p.h"
54 #include "private/qshortcutmap_p.h"
60 class QPlatformIntegration;
63 class Q_GUI_EXPORT QGuiApplicationPrivate : public QCoreApplicationPrivate
65 Q_DECLARE_PUBLIC(QGuiApplication)
67 QGuiApplicationPrivate(int &argc, char **argv, int flags);
68 ~QGuiApplicationPrivate();
70 void createPlatformIntegration();
71 void createEventDispatcher();
72 void setEventDispatcher(QAbstractEventDispatcher *eventDispatcher);
74 virtual void notifyLayoutDirectionChange();
75 virtual void notifyActiveWindowChange(QWindow *previous);
77 virtual bool shouldQuit();
79 static Qt::KeyboardModifiers modifier_buttons;
80 static Qt::MouseButtons mouse_buttons;
82 static QPlatformIntegration *platform_integration;
84 static QPlatformIntegration *platformIntegration()
85 { return platform_integration; }
87 static QPlatformTheme *platform_theme;
89 static QPlatformTheme *platformTheme()
90 { return platform_theme; }
92 static QAbstractEventDispatcher *qt_qpa_core_dispatcher()
93 { return QCoreApplication::instance()->d_func()->threadData->eventDispatcher; }
95 static void processMouseEvent(QWindowSystemInterfacePrivate::MouseEvent *e);
96 static void processKeyEvent(QWindowSystemInterfacePrivate::KeyEvent *e);
97 static void processWheelEvent(QWindowSystemInterfacePrivate::WheelEvent *e);
98 static void processTouchEvent(QWindowSystemInterfacePrivate::TouchEvent *e);
100 static void processCloseEvent(QWindowSystemInterfacePrivate::CloseEvent *e);
102 static void processGeometryChangeEvent(QWindowSystemInterfacePrivate::GeometryChangeEvent *e);
104 static void processEnterEvent(QWindowSystemInterfacePrivate::EnterEvent *e);
105 static void processLeaveEvent(QWindowSystemInterfacePrivate::LeaveEvent *e);
107 static void processActivatedEvent(QWindowSystemInterfacePrivate::ActivatedWindowEvent *e);
108 static void processWindowStateChangedEvent(QWindowSystemInterfacePrivate::WindowStateChangedEvent *e);
110 static void processWindowSystemEvent(QWindowSystemInterfacePrivate::WindowSystemEvent *e);
112 static void reportScreenOrientationChange(QScreen *screen);
113 static void reportScreenOrientationChange(QWindowSystemInterfacePrivate::ScreenOrientationEvent *e);
114 static void reportGeometryChange(QWindowSystemInterfacePrivate::ScreenGeometryEvent *e);
115 static void reportAvailableGeometryChange(QWindowSystemInterfacePrivate::ScreenAvailableGeometryEvent *e);
116 static void reportLogicalDotsPerInchChange(QWindowSystemInterfacePrivate::ScreenLogicalDotsPerInchEvent *e);
117 static void processThemeChanged(QWindowSystemInterfacePrivate::ThemeChangeEvent *tce);
119 static void processMapEvent(QWindowSystemInterfacePrivate::MapEvent *e);
120 static void processUnmapEvent(QWindowSystemInterfacePrivate::UnmapEvent *e);
122 static void processExposeEvent(QWindowSystemInterfacePrivate::ExposeEvent *e);
124 static Qt::DropAction processDrag(QWindow *w, QMimeData *dropData, const QPoint &p);
125 static Qt::DropAction processDrop(QWindow *w, QMimeData *dropData, const QPoint &p);
127 static bool processNativeEvent(QWindow *window, const QByteArray &eventType, void *message, long *result);
129 static inline Qt::Alignment visualAlignment(Qt::LayoutDirection direction, Qt::Alignment alignment)
131 if (!(alignment & Qt::AlignHorizontal_Mask))
132 alignment |= Qt::AlignLeft;
133 if ((alignment & Qt::AlignAbsolute) == 0 && (alignment & (Qt::AlignLeft | Qt::AlignRight))) {
134 if (direction == Qt::RightToLeft)
135 alignment ^= (Qt::AlignLeft | Qt::AlignRight);
136 alignment |= Qt::AlignAbsolute;
141 static void emitLastWindowClosed();
143 QPixmap getPixmapCursor(Qt::CursorShape cshape);
145 static QGuiApplicationPrivate *instance() { return self; }
147 static bool app_do_modal;
149 static Qt::MouseButtons buttons;
150 static ulong mousePressTime;
151 static Qt::MouseButton mousePressButton;
152 static int mousePressX;
153 static int mousePressY;
154 static int mouse_double_click_distance;
155 static QPointF lastCursorPosition;
157 #ifndef QT_NO_CLIPBOARD
158 static QClipboard *qt_clipboard;
161 static QPalette *app_pal;
163 static QWindowList window_list;
164 static QWindow *focus_window;
167 QList<QCursor> cursor_list;
169 static QList<QScreen *> screen_list;
171 static QFont *app_font;
173 QStyleHints *styleHints;
174 static bool obey_desktop_settings;
175 QInputMethod *inputMethod;
177 static QList<QObject *> generic_plugin_list;
178 #ifndef QT_NO_SHORTCUT
179 QShortcutMap shortcutMap;
182 struct ActiveTouchPointsKey {
183 ActiveTouchPointsKey(QTouchDevice *dev, int id) : device(dev), touchPointId(id) { }
184 QTouchDevice *device;
187 struct ActiveTouchPointsValue {
188 QWeakPointer<QWindow> window;
189 QWeakPointer<QObject> target;
190 QTouchEvent::TouchPoint touchPoint;
192 QHash<ActiveTouchPointsKey, ActiveTouchPointsValue> activeTouchPoints;
193 QEvent::Type lastTouchType;
194 struct SynthesizedMouseData {
195 SynthesizedMouseData(const QPointF &p, const QPointF &sp, QWindow *w)
196 : pos(p), screenPos(sp), window(w) { }
199 QWeakPointer<QWindow> window;
201 QHash<QWindow *, SynthesizedMouseData> synthesizedMousePoints;
204 virtual void notifyThemeChanged();
209 static QGuiApplicationPrivate *self;
210 static QTouchDevice *m_fakeTouchDevice;
211 static int m_fakeMouseSourcePointId;
214 Q_GUI_EXPORT uint qHash(const QGuiApplicationPrivate::ActiveTouchPointsKey &k);
216 Q_GUI_EXPORT bool operator==(const QGuiApplicationPrivate::ActiveTouchPointsKey &a,
217 const QGuiApplicationPrivate::ActiveTouchPointsKey &b);
223 #endif // QGUIAPPLICATION_QPA_P_H