8b7977e87ad923b95f73ab6e6e29fc5de7da1c1a
[profile/ivi/qtbase.git] / src / gui / kernel / qguiapplication_p.h
1 /****************************************************************************
2 **
3 ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/
5 **
6 ** This file is part of the QtGui module of the Qt Toolkit.
7 **
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.
16 **
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.
20 **
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.
28 **
29 ** Other Usage
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.
32 **
33 **
34 **
35 **
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41
42 #ifndef QGUIAPPLICATION_P_H
43 #define QGUIAPPLICATION_P_H
44
45 #include <QtGui/qguiapplication.h>
46
47 #include <QtCore/QPointF>
48 #include <QtCore/private/qcoreapplication_p.h>
49
50 #include <QtCore/private/qthread_p.h>
51
52 #include <QWindowSystemInterface>
53 #include "private/qwindowsysteminterface_qpa_p.h"
54 #include "private/qshortcutmap_p.h"
55 #include <qicon.h>
56
57 QT_BEGIN_HEADER
58
59 QT_BEGIN_NAMESPACE
60
61 class QPlatformIntegration;
62 class QPlatformTheme;
63 class QPlatformDragQtResponse;
64 struct QDrawHelperGammaTables;
65
66 class Q_GUI_EXPORT QGuiApplicationPrivate : public QCoreApplicationPrivate
67 {
68     Q_DECLARE_PUBLIC(QGuiApplication)
69 public:
70     QGuiApplicationPrivate(int &argc, char **argv, int flags);
71     ~QGuiApplicationPrivate();
72
73     void createPlatformIntegration();
74     void createEventDispatcher();
75     void setEventDispatcher(QAbstractEventDispatcher *eventDispatcher);
76
77     virtual void notifyLayoutDirectionChange();
78     virtual void notifyActiveWindowChange(QWindow *previous);
79
80     virtual bool shouldQuit();
81
82     static Qt::KeyboardModifiers modifier_buttons;
83     static Qt::MouseButtons mouse_buttons;
84
85     static QPlatformIntegration *platform_integration;
86
87     static QPlatformIntegration *platformIntegration()
88     { return platform_integration; }
89
90     static QPlatformTheme *platform_theme;
91
92     static QPlatformTheme *platformTheme()
93     { return platform_theme; }
94
95     static QAbstractEventDispatcher *qt_qpa_core_dispatcher()
96     { return QCoreApplication::instance()->d_func()->threadData->eventDispatcher; }
97
98     static void processMouseEvent(QWindowSystemInterfacePrivate::MouseEvent *e);
99     static void processKeyEvent(QWindowSystemInterfacePrivate::KeyEvent *e);
100     static void processWheelEvent(QWindowSystemInterfacePrivate::WheelEvent *e);
101     static void processTouchEvent(QWindowSystemInterfacePrivate::TouchEvent *e);
102
103     static void processCloseEvent(QWindowSystemInterfacePrivate::CloseEvent *e);
104
105     static void processGeometryChangeEvent(QWindowSystemInterfacePrivate::GeometryChangeEvent *e);
106
107     static void processEnterEvent(QWindowSystemInterfacePrivate::EnterEvent *e);
108     static void processLeaveEvent(QWindowSystemInterfacePrivate::LeaveEvent *e);
109
110     static void processActivatedEvent(QWindowSystemInterfacePrivate::ActivatedWindowEvent *e);
111     static void processWindowStateChangedEvent(QWindowSystemInterfacePrivate::WindowStateChangedEvent *e);
112
113     static void processWindowSystemEvent(QWindowSystemInterfacePrivate::WindowSystemEvent *e);
114
115     static void reportScreenOrientationChange(QScreen *screen);
116     static void reportScreenOrientationChange(QWindowSystemInterfacePrivate::ScreenOrientationEvent *e);
117     static void reportGeometryChange(QWindowSystemInterfacePrivate::ScreenGeometryEvent *e);
118     static void reportAvailableGeometryChange(QWindowSystemInterfacePrivate::ScreenAvailableGeometryEvent *e);
119     static void reportLogicalDotsPerInchChange(QWindowSystemInterfacePrivate::ScreenLogicalDotsPerInchEvent *e);
120     static void reportRefreshRateChange(QWindowSystemInterfacePrivate::ScreenRefreshRateEvent *e);
121     static void processThemeChanged(QWindowSystemInterfacePrivate::ThemeChangeEvent *tce);
122
123     static void processExposeEvent(QWindowSystemInterfacePrivate::ExposeEvent *e);
124
125     static void processFileOpenEvent(QWindowSystemInterfacePrivate::FileOpenEvent *e);
126
127     static void processTabletEvent(QWindowSystemInterfacePrivate::TabletEvent *e);
128     static void processTabletEnterProximityEvent(QWindowSystemInterfacePrivate::TabletEnterProximityEvent *e);
129     static void processTabletLeaveProximityEvent(QWindowSystemInterfacePrivate::TabletLeaveProximityEvent *e);
130
131 #ifndef QT_NO_DRAGANDDROP
132     static QPlatformDragQtResponse processDrag(QWindow *w, const QMimeData *dropData, const QPoint &p, Qt::DropActions supportedActions);
133     static QPlatformDropQtResponse processDrop(QWindow *w, const QMimeData *dropData, const QPoint &p, Qt::DropActions supportedActions);
134 #endif
135
136     static bool processNativeEvent(QWindow *window, const QByteArray &eventType, void *message, long *result);
137
138     static void sendQWindowEventToQPlatformWindow(QWindow *window, QEvent *event);
139
140     static inline Qt::Alignment visualAlignment(Qt::LayoutDirection direction, Qt::Alignment alignment)
141     {
142         if (!(alignment & Qt::AlignHorizontal_Mask))
143             alignment |= Qt::AlignLeft;
144         if ((alignment & Qt::AlignAbsolute) == 0 && (alignment & (Qt::AlignLeft | Qt::AlignRight))) {
145             if (direction == Qt::RightToLeft)
146                 alignment ^= (Qt::AlignLeft | Qt::AlignRight);
147             alignment |= Qt::AlignAbsolute;
148         }
149         return alignment;
150     }
151
152     static void emitLastWindowClosed();
153
154     QPixmap getPixmapCursor(Qt::CursorShape cshape);
155
156     void q_updateFocusObject(QObject *object);
157
158     static QGuiApplicationPrivate *instance() { return self; }
159
160     static QString *platform_name;
161
162     QWindowList modalWindowList;
163     static void showModalWindow(QWindow *window);
164     static void hideModalWindow(QWindow *window);
165     virtual bool isWindowBlocked(QWindow *window, QWindow **blockingWindow = 0) const;
166
167     static Qt::MouseButtons buttons;
168     static ulong mousePressTime;
169     static Qt::MouseButton mousePressButton;
170     static int mousePressX;
171     static int mousePressY;
172     static int mouse_double_click_distance;
173     static QPointF lastCursorPosition;
174     static bool tabletState;
175     static QWindow *tabletPressTarget;
176
177 #ifndef QT_NO_CLIPBOARD
178     static QClipboard *qt_clipboard;
179 #endif
180
181     static QPalette *app_pal;
182
183     static QWindowList window_list;
184     static QWindow *focus_window;
185
186 #ifndef QT_NO_CURSOR
187     QList<QCursor> cursor_list;
188 #endif
189     static QList<QScreen *> screen_list;
190
191     static QFont *app_font;
192
193     QStyleHints *styleHints;
194     static bool obey_desktop_settings;
195     QInputMethod *inputMethod;
196
197     static QList<QObject *> generic_plugin_list;
198 #ifndef QT_NO_SHORTCUT
199     QShortcutMap shortcutMap;
200 #endif
201
202     struct ActiveTouchPointsKey {
203         ActiveTouchPointsKey(QTouchDevice *dev, int id) : device(dev), touchPointId(id) { }
204         QTouchDevice *device;
205         int touchPointId;
206     };
207     struct ActiveTouchPointsValue {
208         QWeakPointer<QWindow> window;
209         QWeakPointer<QObject> target;
210         QTouchEvent::TouchPoint touchPoint;
211     };
212     QHash<ActiveTouchPointsKey, ActiveTouchPointsValue> activeTouchPoints;
213     QEvent::Type lastTouchType;
214     struct SynthesizedMouseData {
215         SynthesizedMouseData(const QPointF &p, const QPointF &sp, QWindow *w)
216             : pos(p), screenPos(sp), window(w) { }
217         QPointF pos;
218         QPointF screenPos;
219         QWeakPointer<QWindow> window;
220     };
221     QHash<QWindow *, SynthesizedMouseData> synthesizedMousePoints;
222
223     static int mouseEventCaps(QMouseEvent *event);
224     static QVector2D mouseEventVelocity(QMouseEvent *event);
225     static void setMouseEventCapsAndVelocity(QMouseEvent *event, int caps, const QVector2D &velocity);
226     static void setMouseEventCapsAndVelocity(QMouseEvent *event, QMouseEvent *other);
227
228     const QDrawHelperGammaTables *gammaTables();
229
230     // hook reimplemented in QApplication to apply the QStyle function on the QIcon
231     virtual QPixmap applyQIconStyleHelper(QIcon::Mode, const QPixmap &basePixmap) const { return basePixmap; }
232
233 protected:
234     virtual void notifyThemeChanged();
235
236 private:
237     void init();
238
239     static QGuiApplicationPrivate *self;
240     static QTouchDevice *m_fakeTouchDevice;
241     static int m_fakeMouseSourcePointId;
242     QAtomicPointer<QDrawHelperGammaTables> m_gammaTables;
243 };
244
245 Q_GUI_EXPORT uint qHash(const QGuiApplicationPrivate::ActiveTouchPointsKey &k);
246
247 Q_GUI_EXPORT bool operator==(const QGuiApplicationPrivate::ActiveTouchPointsKey &a,
248                              const QGuiApplicationPrivate::ActiveTouchPointsKey &b);
249
250 QT_END_NAMESPACE
251
252 QT_END_HEADER
253
254 #endif // QGUIAPPLICATION_P_H