9b817035a485c2d544650f793e85694d1b433bd6
[profile/ivi/qtbase.git] / src / gui / kernel / qguiapplication_p.h
1 /****************************************************************************
2 **
3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
4 ** All rights reserved.
5 ** Contact: Nokia Corporation (qt-info@nokia.com)
6 **
7 ** This file is part of the QtGui module of the Qt Toolkit.
8 **
9 ** $QT_BEGIN_LICENSE:LGPL$
10 ** GNU Lesser General Public License Usage
11 ** This file may be used under the terms of the GNU Lesser General Public
12 ** License version 2.1 as published by the Free Software Foundation and
13 ** appearing in the file LICENSE.LGPL included in the packaging of this
14 ** file. Please review the following information to ensure the GNU Lesser
15 ** General Public License version 2.1 requirements will be met:
16 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
17 **
18 ** In addition, as a special exception, Nokia gives you certain additional
19 ** rights. These rights are described in the Nokia Qt LGPL Exception
20 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
21 **
22 ** GNU General Public License Usage
23 ** Alternatively, this file may be used under the terms of the GNU General
24 ** Public License version 3.0 as published by the Free Software Foundation
25 ** and appearing in the file LICENSE.GPL included in the packaging of this
26 ** file. Please review the following information to ensure the GNU General
27 ** Public License version 3.0 requirements will be met:
28 ** http://www.gnu.org/copyleft/gpl.html.
29 **
30 ** Other Usage
31 ** Alternatively, this file may be used in accordance with the terms and
32 ** conditions contained in a signed written agreement between you and Nokia.
33 **
34 **
35 **
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41
42 #ifndef QGUIAPPLICATION_QPA_P_H
43 #define QGUIAPPLICATION_QPA_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 "QtGui/qplatformintegration_qpa.h"
55
56 QT_BEGIN_HEADER
57
58 QT_BEGIN_NAMESPACE
59
60 QT_MODULE(Gui)
61
62 class Q_GUI_EXPORT QGuiApplicationPrivate : public QCoreApplicationPrivate
63 {
64     Q_DECLARE_PUBLIC(QGuiApplication)
65 public:
66     QGuiApplicationPrivate(int &argc, char **argv, int flags);
67     ~QGuiApplicationPrivate();
68
69     void createPlatformIntegration();
70     void createEventDispatcher();
71     void setEventDispatcher(QAbstractEventDispatcher *eventDispatcher);
72
73     virtual void notifyLayoutDirectionChange();
74     virtual void notifyActiveWindowChange(QWindow *previous);
75
76     static Qt::KeyboardModifiers modifier_buttons;
77     static Qt::MouseButtons mouse_buttons;
78
79     static QPlatformIntegration *platform_integration;
80
81     static QPlatformIntegration *platformIntegration()
82     { return platform_integration; }
83
84     enum KeyPlatform {
85         KB_Win = 1,
86         KB_Mac = 2,
87         KB_X11 = 4,
88         KB_KDE = 8,
89         KB_Gnome = 16,
90         KB_CDE = 32,
91         KB_S60 = 64,
92         KB_All = 0xffff
93     };
94
95     static uint currentKeyPlatform();
96
97     static QAbstractEventDispatcher *qt_qpa_core_dispatcher()
98     { return QCoreApplication::instance()->d_func()->threadData->eventDispatcher; }
99
100     static void processMouseEvent(QWindowSystemInterfacePrivate::MouseEvent *e);
101     static void processKeyEvent(QWindowSystemInterfacePrivate::KeyEvent *e);
102     static void processWheelEvent(QWindowSystemInterfacePrivate::WheelEvent *e);
103     static void processTouchEvent(QWindowSystemInterfacePrivate::TouchEvent *e);
104
105     static void processCloseEvent(QWindowSystemInterfacePrivate::CloseEvent *e);
106
107     static void processGeometryChangeEvent(QWindowSystemInterfacePrivate::GeometryChangeEvent *e);
108
109     static void processEnterEvent(QWindowSystemInterfacePrivate::EnterEvent *e);
110     static void processLeaveEvent(QWindowSystemInterfacePrivate::LeaveEvent *e);
111
112     static void processActivatedEvent(QWindowSystemInterfacePrivate::ActivatedWindowEvent *e);
113     static void processWindowStateChangedEvent(QWindowSystemInterfacePrivate::WindowStateChangedEvent *e);
114
115     static void processWindowSystemEvent(QWindowSystemInterfacePrivate::WindowSystemEvent *e);
116
117     static void reportScreenCount(QWindowSystemInterfacePrivate::ScreenCountEvent *e);
118     static void reportGeometryChange(QWindowSystemInterfacePrivate::ScreenGeometryEvent *e);
119     static void reportAvailableGeometryChange(QWindowSystemInterfacePrivate::ScreenAvailableGeometryEvent *e);
120
121     static void processMapEvent(QWindowSystemInterfacePrivate::MapEvent *e);
122     static void processUnmapEvent(QWindowSystemInterfacePrivate::UnmapEvent *e);
123
124     static void processExposeEvent(QWindowSystemInterfacePrivate::ExposeEvent *e);
125
126     static Qt::DropAction processDrag(QWindow *w, QMimeData *dropData, const QPoint &p);
127     static Qt::DropAction processDrop(QWindow *w, QMimeData *dropData, const QPoint &p);
128
129     static inline Qt::Alignment visualAlignment(Qt::LayoutDirection direction, Qt::Alignment alignment)
130     {
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;
137         }
138         return alignment;
139     }
140
141     static void emitLastWindowClosed();
142
143     QPixmap getPixmapCursor(Qt::CursorShape cshape);
144
145     static QGuiApplicationPrivate *instance() { return self; }
146
147     static bool app_do_modal;
148
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;
156
157 #ifndef QT_NO_CLIPBOARD
158     static QClipboard *qt_clipboard;
159 #endif
160
161     static QPalette *app_pal;
162
163     static QWindowList window_list;
164     static QWindow *active_window;
165
166 #ifndef QT_NO_CURSOR
167     QList<QCursor> cursor_list;
168 #endif
169     static QList<QScreen *> screen_list;
170
171     static QFont *app_font;
172
173     QStyleHints *styleHints;
174     QInputPanel *inputPanel;
175
176     static bool quitOnLastWindowClosed;
177
178     QString qmljs_debug_arguments; // a string containing arguments for js/qml debugging.
179     inline QString qmljsDebugArgumentsString() { return qmljs_debug_arguments; }
180
181 private:
182     void init();
183
184     static QGuiApplicationPrivate *self;
185
186     QMap<int, QWeakPointer<QWindow> > windowForTouchPointId;
187     QMap<int, QTouchEvent::TouchPoint> appCurrentTouchPoints;
188 };
189
190 QT_END_NAMESPACE
191
192 QT_END_HEADER
193
194 #endif // QGUIAPPLICATION_QPA_P_H