| Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/gui/kernel/qguiapplication.cpp |
| Source code | Switch to Preprocessed file |
| Line | Source | Count | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | /**************************************************************************** | - | ||||||||||||||||||
| 2 | ** | - | ||||||||||||||||||
| 3 | ** Copyright (C) 2016 The Qt Company Ltd. | - | ||||||||||||||||||
| 4 | ** Copyright (C) 2016 Intel Corporation. | - | ||||||||||||||||||
| 5 | ** Contact: https://www.qt.io/licensing/ | - | ||||||||||||||||||
| 6 | ** | - | ||||||||||||||||||
| 7 | ** This file is part of the QtGui module of the Qt Toolkit. | - | ||||||||||||||||||
| 8 | ** | - | ||||||||||||||||||
| 9 | ** $QT_BEGIN_LICENSE:LGPL$ | - | ||||||||||||||||||
| 10 | ** Commercial License Usage | - | ||||||||||||||||||
| 11 | ** Licensees holding valid commercial Qt licenses may use this file in | - | ||||||||||||||||||
| 12 | ** accordance with the commercial license agreement provided with the | - | ||||||||||||||||||
| 13 | ** Software or, alternatively, in accordance with the terms contained in | - | ||||||||||||||||||
| 14 | ** a written agreement between you and The Qt Company. For licensing terms | - | ||||||||||||||||||
| 15 | ** and conditions see https://www.qt.io/terms-conditions. For further | - | ||||||||||||||||||
| 16 | ** information use the contact form at https://www.qt.io/contact-us. | - | ||||||||||||||||||
| 17 | ** | - | ||||||||||||||||||
| 18 | ** GNU Lesser General Public License Usage | - | ||||||||||||||||||
| 19 | ** Alternatively, this file may be used under the terms of the GNU Lesser | - | ||||||||||||||||||
| 20 | ** General Public License version 3 as published by the Free Software | - | ||||||||||||||||||
| 21 | ** Foundation and appearing in the file LICENSE.LGPL3 included in the | - | ||||||||||||||||||
| 22 | ** packaging of this file. Please review the following information to | - | ||||||||||||||||||
| 23 | ** ensure the GNU Lesser General Public License version 3 requirements | - | ||||||||||||||||||
| 24 | ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. | - | ||||||||||||||||||
| 25 | ** | - | ||||||||||||||||||
| 26 | ** GNU General Public License Usage | - | ||||||||||||||||||
| 27 | ** Alternatively, this file may be used under the terms of the GNU | - | ||||||||||||||||||
| 28 | ** General Public License version 2.0 or (at your option) the GNU General | - | ||||||||||||||||||
| 29 | ** Public license version 3 or any later version approved by the KDE Free | - | ||||||||||||||||||
| 30 | ** Qt Foundation. The licenses are as published by the Free Software | - | ||||||||||||||||||
| 31 | ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 | - | ||||||||||||||||||
| 32 | ** included in the packaging of this file. Please review the following | - | ||||||||||||||||||
| 33 | ** information to ensure the GNU General Public License requirements will | - | ||||||||||||||||||
| 34 | ** be met: https://www.gnu.org/licenses/gpl-2.0.html and | - | ||||||||||||||||||
| 35 | ** https://www.gnu.org/licenses/gpl-3.0.html. | - | ||||||||||||||||||
| 36 | ** | - | ||||||||||||||||||
| 37 | ** $QT_END_LICENSE$ | - | ||||||||||||||||||
| 38 | ** | - | ||||||||||||||||||
| 39 | ****************************************************************************/ | - | ||||||||||||||||||
| 40 | - | |||||||||||||||||||
| 41 | #include "qguiapplication.h" | - | ||||||||||||||||||
| 42 | - | |||||||||||||||||||
| 43 | #include "private/qguiapplication_p.h" | - | ||||||||||||||||||
| 44 | #include <qpa/qplatformintegrationfactory_p.h> | - | ||||||||||||||||||
| 45 | #include "private/qevent_p.h" | - | ||||||||||||||||||
| 46 | #include "qfont.h" | - | ||||||||||||||||||
| 47 | #include "qtouchdevice.h" | - | ||||||||||||||||||
| 48 | #include <qpa/qplatformfontdatabase.h> | - | ||||||||||||||||||
| 49 | #include <qpa/qplatformwindow.h> | - | ||||||||||||||||||
| 50 | #include <qpa/qplatformnativeinterface.h> | - | ||||||||||||||||||
| 51 | #include <qpa/qplatformtheme.h> | - | ||||||||||||||||||
| 52 | #include <qpa/qplatformintegration.h> | - | ||||||||||||||||||
| 53 | #include <qpa/qplatformdrag.h> | - | ||||||||||||||||||
| 54 | - | |||||||||||||||||||
| 55 | #include <QtCore/QAbstractEventDispatcher> | - | ||||||||||||||||||
| 56 | #include <QtCore/QVariant> | - | ||||||||||||||||||
| 57 | #include <QtCore/private/qcoreapplication_p.h> | - | ||||||||||||||||||
| 58 | #include <QtCore/private/qabstracteventdispatcher_p.h> | - | ||||||||||||||||||
| 59 | #include <QtCore/qmutex.h> | - | ||||||||||||||||||
| 60 | #include <QtCore/private/qthread_p.h> | - | ||||||||||||||||||
| 61 | #include <QtCore/qdir.h> | - | ||||||||||||||||||
| 62 | #include <QtCore/qlibraryinfo.h> | - | ||||||||||||||||||
| 63 | #include <QtCore/qnumeric.h> | - | ||||||||||||||||||
| 64 | #include <QtDebug> | - | ||||||||||||||||||
| 65 | #ifndef QT_NO_ACCESSIBILITY | - | ||||||||||||||||||
| 66 | #include "qaccessible.h" | - | ||||||||||||||||||
| 67 | #endif | - | ||||||||||||||||||
| 68 | #include <qpalette.h> | - | ||||||||||||||||||
| 69 | #include <qscreen.h> | - | ||||||||||||||||||
| 70 | #include "qsessionmanager.h" | - | ||||||||||||||||||
| 71 | #include <private/qscreen_p.h> | - | ||||||||||||||||||
| 72 | #include <private/qdrawhelper_p.h> | - | ||||||||||||||||||
| 73 | - | |||||||||||||||||||
| 74 | #include <QtGui/qgenericpluginfactory.h> | - | ||||||||||||||||||
| 75 | #include <QtGui/qstylehints.h> | - | ||||||||||||||||||
| 76 | #include <QtGui/qinputmethod.h> | - | ||||||||||||||||||
| 77 | #include <QtGui/qpixmapcache.h> | - | ||||||||||||||||||
| 78 | #include <qpa/qplatforminputcontext.h> | - | ||||||||||||||||||
| 79 | #include <qpa/qplatforminputcontext_p.h> | - | ||||||||||||||||||
| 80 | - | |||||||||||||||||||
| 81 | #include <qpa/qwindowsysteminterface.h> | - | ||||||||||||||||||
| 82 | #include <qpa/qwindowsysteminterface_p.h> | - | ||||||||||||||||||
| 83 | #include "private/qwindow_p.h" | - | ||||||||||||||||||
| 84 | #include "private/qcursor_p.h" | - | ||||||||||||||||||
| 85 | #include "private/qopenglcontext_p.h" | - | ||||||||||||||||||
| 86 | #include "private/qinputdevicemanager_p.h" | - | ||||||||||||||||||
| 87 | - | |||||||||||||||||||
| 88 | #include "private/qdnd_p.h" | - | ||||||||||||||||||
| 89 | #include <qpa/qplatformthemefactory_p.h> | - | ||||||||||||||||||
| 90 | - | |||||||||||||||||||
| 91 | #ifndef QT_NO_CURSOR | - | ||||||||||||||||||
| 92 | #include <qpa/qplatformcursor.h> | - | ||||||||||||||||||
| 93 | #endif | - | ||||||||||||||||||
| 94 | - | |||||||||||||||||||
| 95 | #include <QtGui/QPixmap> | - | ||||||||||||||||||
| 96 | - | |||||||||||||||||||
| 97 | #ifndef QT_NO_CLIPBOARD | - | ||||||||||||||||||
| 98 | #include <QtGui/QClipboard> | - | ||||||||||||||||||
| 99 | #endif | - | ||||||||||||||||||
| 100 | - | |||||||||||||||||||
| 101 | #ifndef QT_NO_LIBRARY | - | ||||||||||||||||||
| 102 | #include <QtCore/QLibrary> | - | ||||||||||||||||||
| 103 | #endif | - | ||||||||||||||||||
| 104 | - | |||||||||||||||||||
| 105 | #if defined(Q_OS_MAC) | - | ||||||||||||||||||
| 106 | # include "private/qcore_mac_p.h" | - | ||||||||||||||||||
| 107 | #elif defined(Q_OS_WIN) && !defined(Q_OS_WINCE) | - | ||||||||||||||||||
| 108 | # include <QtCore/qt_windows.h> | - | ||||||||||||||||||
| 109 | # include <QtCore/QLibraryInfo> | - | ||||||||||||||||||
| 110 | # if defined(Q_OS_WINPHONE) | - | ||||||||||||||||||
| 111 | # include <Objbase.h> | - | ||||||||||||||||||
| 112 | # endif | - | ||||||||||||||||||
| 113 | #endif // Q_OS_WIN && !Q_OS_WINCE | - | ||||||||||||||||||
| 114 | - | |||||||||||||||||||
| 115 | #include <ctype.h> | - | ||||||||||||||||||
| 116 | - | |||||||||||||||||||
| 117 | QT_BEGIN_NAMESPACE | - | ||||||||||||||||||
| 118 | - | |||||||||||||||||||
| 119 | // Helper macro for static functions to check on the existence of the application class. | - | ||||||||||||||||||
| 120 | #define CHECK_QAPP_INSTANCE(...) \ | - | ||||||||||||||||||
| 121 | if (Q_LIKELY(QCoreApplication::instance())) { \ | - | ||||||||||||||||||
| 122 | } else { \ | - | ||||||||||||||||||
| 123 | qWarning("Must construct a QGuiApplication first."); \ | - | ||||||||||||||||||
| 124 | return __VA_ARGS__; \ | - | ||||||||||||||||||
| 125 | } | - | ||||||||||||||||||
| 126 | - | |||||||||||||||||||
| 127 | Q_GUI_EXPORT bool qt_is_gui_used = true; | - | ||||||||||||||||||
| 128 | - | |||||||||||||||||||
| 129 | Qt::MouseButtons QGuiApplicationPrivate::mouse_buttons = Qt::NoButton; | - | ||||||||||||||||||
| 130 | Qt::KeyboardModifiers QGuiApplicationPrivate::modifier_buttons = Qt::NoModifier; | - | ||||||||||||||||||
| 131 | - | |||||||||||||||||||
| 132 | QPointF QGuiApplicationPrivate::lastCursorPosition(qInf(), qInf()); | - | ||||||||||||||||||
| 133 | - | |||||||||||||||||||
| Qt::MouseButtons QGuiApplicationPrivate::tabletState = Qt::NoButton; | ||||||||||||||||||||
| QWindow *QGuiApplicationPrivate::tabletPressTarget = 0;QWindow *QGuiApplicationPrivate::currentMouseWindow = 0; | ||||||||||||||||||||
| 135 | - | |||||||||||||||||||
| 136 | QString QGuiApplicationPrivate::styleOverride; | - | ||||||||||||||||||
| 137 | - | |||||||||||||||||||
| 138 | Qt::ApplicationState QGuiApplicationPrivate::applicationState = Qt::ApplicationInactive; | - | ||||||||||||||||||
| 139 | - | |||||||||||||||||||
| 140 | bool QGuiApplicationPrivate::highDpiScalingUpdated = false; | - | ||||||||||||||||||
| 141 | - | |||||||||||||||||||
| 142 | QVector<QGuiApplicationPrivate::TabletPointData> QGuiApplicationPrivate::tabletDevicePoints; | - | ||||||||||||||||||
| 143 | - | |||||||||||||||||||
| 144 | QPlatformIntegration *QGuiApplicationPrivate::platform_integration = 0; | - | ||||||||||||||||||
| 145 | QPlatformTheme *QGuiApplicationPrivate::platform_theme = 0; | - | ||||||||||||||||||
| 146 | - | |||||||||||||||||||
| 147 | QList<QObject *> QGuiApplicationPrivate::generic_plugin_list; | - | ||||||||||||||||||
| 148 | - | |||||||||||||||||||
| 149 | #ifndef QT_NO_SESSIONMANAGER | - | ||||||||||||||||||
| 150 | bool QGuiApplicationPrivate::is_fallback_session_management_enabled = true; | - | ||||||||||||||||||
| 151 | #endif | - | ||||||||||||||||||
| 152 | - | |||||||||||||||||||
| 153 | enum ApplicationResourceFlags | - | ||||||||||||||||||
| 154 | { | - | ||||||||||||||||||
| 155 | ApplicationPaletteExplicitlySet = 0x1, | - | ||||||||||||||||||
| 156 | ApplicationFontExplicitlySet = 0x2 | - | ||||||||||||||||||
| 157 | }; | - | ||||||||||||||||||
| 158 | - | |||||||||||||||||||
| 159 | static unsigned applicationResourceFlags = 0; | - | ||||||||||||||||||
| 160 | - | |||||||||||||||||||
| 161 | QIcon *QGuiApplicationPrivate::app_icon = 0; | - | ||||||||||||||||||
| 162 | - | |||||||||||||||||||
| 163 | QString *QGuiApplicationPrivate::platform_name = 0; | - | ||||||||||||||||||
| 164 | QString *QGuiApplicationPrivate::displayName = 0; | - | ||||||||||||||||||
| 165 | QString *QGuiApplicationPrivate::desktopFileName = 0; | - | ||||||||||||||||||
| 166 | - | |||||||||||||||||||
| 167 | QPalette *QGuiApplicationPrivate::app_pal = 0; // default application palette | - | ||||||||||||||||||
| 168 | - | |||||||||||||||||||
| 169 | Qt::MouseButtons QGuiApplicationPrivate::buttons = Qt::NoButton; | - | ||||||||||||||||||
| 170 | - | |||||||||||||||||||
| 171 | ulong QGuiApplicationPrivate::mousePressTime = 0; | - | ||||||||||||||||||
| 172 | Qt::MouseButton QGuiApplicationPrivate::mousePressButton = Qt::NoButton; | - | ||||||||||||||||||
| 173 | int QGuiApplicationPrivate::mousePressX = 0; | - | ||||||||||||||||||
| 174 | int QGuiApplicationPrivate::mousePressY = 0; | - | ||||||||||||||||||
| 175 | int QGuiApplicationPrivate::mouse_double_click_distance = -1; | - | ||||||||||||||||||
| 176 | - | |||||||||||||||||||
| 177 | QWindow *QGuiApplicationPrivate::currentMousePressWindow = 0; | - | ||||||||||||||||||
| 178 | - | |||||||||||||||||||
| 179 | static Qt::LayoutDirection layout_direction = Qt::LayoutDirectionAuto; | - | ||||||||||||||||||
| 180 | static bool force_reverse = false; | - | ||||||||||||||||||
| 181 | - | |||||||||||||||||||
| 182 | QGuiApplicationPrivate *QGuiApplicationPrivate::self = 0; | - | ||||||||||||||||||
| 183 | QTouchDevice *QGuiApplicationPrivate::m_fakeTouchDevice = 0; | - | ||||||||||||||||||
| 184 | int QGuiApplicationPrivate::m_fakeMouseSourcePointId = 0; | - | ||||||||||||||||||
| 185 | - | |||||||||||||||||||
| 186 | #ifndef QT_NO_CLIPBOARD | - | ||||||||||||||||||
| 187 | QClipboard *QGuiApplicationPrivate::qt_clipboard = 0; | - | ||||||||||||||||||
| 188 | #endif | - | ||||||||||||||||||
| 189 | - | |||||||||||||||||||
| 190 | QList<QScreen *> QGuiApplicationPrivate::screen_list; | - | ||||||||||||||||||
| 191 | - | |||||||||||||||||||
| 192 | QWindowList QGuiApplicationPrivate::window_list; | - | ||||||||||||||||||
| 193 | QWindow *QGuiApplicationPrivate::focus_window = 0; | - | ||||||||||||||||||
| 194 | - | |||||||||||||||||||
| 195 | static QBasicMutex applicationFontMutex; | - | ||||||||||||||||||
| 196 | QFont *QGuiApplicationPrivate::app_font = 0; | - | ||||||||||||||||||
| 197 | QStyleHints *QGuiApplicationPrivate::styleHints = Q_NULLPTR; | - | ||||||||||||||||||
| 198 | bool QGuiApplicationPrivate::obey_desktop_settings = true; | - | ||||||||||||||||||
| 199 | - | |||||||||||||||||||
| 200 | QInputDeviceManager *QGuiApplicationPrivate::m_inputDeviceManager = 0; | - | ||||||||||||||||||
| bool QGuiApplicationPrivate::scrollNoPhaseAllowed = false; | ||||||||||||||||||||
| 201 | - | |||||||||||||||||||
| 202 | static qreal fontSmoothingGamma = 1.7; | - | ||||||||||||||||||
| 203 | - | |||||||||||||||||||
| 204 | extern void qRegisterGuiVariant(); | - | ||||||||||||||||||
| 205 | #ifndef QT_NO_ANIMATION | - | ||||||||||||||||||
| 206 | extern void qRegisterGuiGetInterpolator(); | - | ||||||||||||||||||
| 207 | #endif | - | ||||||||||||||||||
| 208 | - | |||||||||||||||||||
| 209 | static bool qt_detectRTLLanguage() | - | ||||||||||||||||||
| 210 | { | - | ||||||||||||||||||
| 211 | return force_reverse ^ | - | ||||||||||||||||||
| 212 | (QGuiApplication::tr("QT_LAYOUT_DIRECTION", | - | ||||||||||||||||||
| 213 | "Translate this string to the string 'LTR' in left-to-right" | - | ||||||||||||||||||
| 214 | " languages or to 'RTL' in right-to-left languages (such as Hebrew" | - | ||||||||||||||||||
| 215 | " and Arabic) to get proper widget layout.") == QLatin1String("RTL")); | - | ||||||||||||||||||
| 216 | } | - | ||||||||||||||||||
| 217 | - | |||||||||||||||||||
| 218 | static void initPalette() | - | ||||||||||||||||||
| 219 | { | - | ||||||||||||||||||
| 220 | if (!QGuiApplicationPrivate::app_pal) | - | ||||||||||||||||||
| 221 | if (const QPalette *themePalette = QGuiApplicationPrivate::platformTheme()->palette()) | - | ||||||||||||||||||
| 222 | QGuiApplicationPrivate::app_pal = new QPalette(*themePalette); | - | ||||||||||||||||||
| 223 | if (!QGuiApplicationPrivate::app_pal) | - | ||||||||||||||||||
| 224 | QGuiApplicationPrivate::app_pal = new QPalette(Qt::gray); | - | ||||||||||||||||||
| 225 | } | - | ||||||||||||||||||
| 226 | - | |||||||||||||||||||
| 227 | static inline void clearPalette() | - | ||||||||||||||||||
| 228 | { | - | ||||||||||||||||||
| 229 | delete QGuiApplicationPrivate::app_pal; | - | ||||||||||||||||||
| 230 | QGuiApplicationPrivate::app_pal = 0; | - | ||||||||||||||||||
| 231 | } | - | ||||||||||||||||||
| 232 | - | |||||||||||||||||||
| 233 | static void initFontUnlocked() | - | ||||||||||||||||||
| 234 | { | - | ||||||||||||||||||
| 235 | if (!QGuiApplicationPrivate::app_font) { | - | ||||||||||||||||||
| 236 | if (const QPlatformTheme *theme = QGuiApplicationPrivate::platformTheme()) | - | ||||||||||||||||||
| 237 | if (const QFont *font = theme->font(QPlatformTheme::SystemFont)) | - | ||||||||||||||||||
| 238 | QGuiApplicationPrivate::app_font = new QFont(*font); | - | ||||||||||||||||||
| 239 | } | - | ||||||||||||||||||
| 240 | if (!QGuiApplicationPrivate::app_font) | - | ||||||||||||||||||
| 241 | QGuiApplicationPrivate::app_font = | - | ||||||||||||||||||
| 242 | new QFont(QGuiApplicationPrivate::platformIntegration()->fontDatabase()->defaultFont()); | - | ||||||||||||||||||
| 243 | } | - | ||||||||||||||||||
| 244 | - | |||||||||||||||||||
| 245 | static inline void clearFontUnlocked() | - | ||||||||||||||||||
| 246 | { | - | ||||||||||||||||||
| 247 | delete QGuiApplicationPrivate::app_font; | - | ||||||||||||||||||
| 248 | QGuiApplicationPrivate::app_font = 0; | - | ||||||||||||||||||
| 249 | } | - | ||||||||||||||||||
| 250 | - | |||||||||||||||||||
| 251 | // Using aggregate initialization instead of ctor so we can have a POD global static | - | ||||||||||||||||||
| 252 | #define Q_WINDOW_GEOMETRY_SPECIFICATION_INITIALIZER { Qt::TopLeftCorner, -1, -1, -1, -1 } | - | ||||||||||||||||||
| 253 | - | |||||||||||||||||||
| 254 | // Geometry specification for top level windows following the convention of the | - | ||||||||||||||||||
| 255 | // -geometry command line arguments in X11 (see XParseGeometry). | - | ||||||||||||||||||
| 256 | struct QWindowGeometrySpecification | - | ||||||||||||||||||
| 257 | { | - | ||||||||||||||||||
| 258 | static QWindowGeometrySpecification fromArgument(const QByteArray &a); | - | ||||||||||||||||||
| 259 | void applyTo(QWindow *window) const; | - | ||||||||||||||||||
| 260 | - | |||||||||||||||||||
| 261 | Qt::Corner corner; | - | ||||||||||||||||||
| 262 | int xOffset; | - | ||||||||||||||||||
| 263 | int yOffset; | - | ||||||||||||||||||
| 264 | int width; | - | ||||||||||||||||||
| 265 | int height; | - | ||||||||||||||||||
| 266 | }; | - | ||||||||||||||||||
| 267 | - | |||||||||||||||||||
| 268 | // Parse a token of a X11 geometry specification "200x100+10-20". | - | ||||||||||||||||||
| 269 | static inline int nextGeometryToken(const QByteArray &a, int &pos, char *op) | - | ||||||||||||||||||
| 270 | { | - | ||||||||||||||||||
| 271 | *op = 0; | - | ||||||||||||||||||
| 272 | const int size = a.size(); | - | ||||||||||||||||||
| 273 | if (pos >= size) | - | ||||||||||||||||||
| 274 | return -1; | - | ||||||||||||||||||
| 275 | - | |||||||||||||||||||
| 276 | *op = a.at(pos); | - | ||||||||||||||||||
| 277 | if (*op == '+' || *op == '-' || *op == 'x') | - | ||||||||||||||||||
| 278 | pos++; | - | ||||||||||||||||||
| 279 | else if (isdigit(*op)) | - | ||||||||||||||||||
| 280 | *op = 'x'; // If it starts with a digit, it is supposed to be a width specification. | - | ||||||||||||||||||
| 281 | else | - | ||||||||||||||||||
| 282 | return -1; | - | ||||||||||||||||||
| 283 | - | |||||||||||||||||||
| 284 | const int numberPos = pos; | - | ||||||||||||||||||
| 285 | for ( ; pos < size && isdigit(a.at(pos)); ++pos) ; | - | ||||||||||||||||||
| 286 | - | |||||||||||||||||||
| 287 | bool ok; | - | ||||||||||||||||||
| 288 | const int result = a.mid(numberPos, pos - numberPos).toInt(&ok); | - | ||||||||||||||||||
| 289 | return ok ? result : -1; | - | ||||||||||||||||||
| 290 | } | - | ||||||||||||||||||
| 291 | - | |||||||||||||||||||
| 292 | QWindowGeometrySpecification QWindowGeometrySpecification::fromArgument(const QByteArray &a) | - | ||||||||||||||||||
| 293 | { | - | ||||||||||||||||||
| 294 | QWindowGeometrySpecification result = Q_WINDOW_GEOMETRY_SPECIFICATION_INITIALIZER; | - | ||||||||||||||||||
| 295 | int pos = 0; | - | ||||||||||||||||||
| 296 | for (int i = 0; i < 4; ++i) { | - | ||||||||||||||||||
| 297 | char op; | - | ||||||||||||||||||
| 298 | const int value = nextGeometryToken(a, pos, &op); | - | ||||||||||||||||||
| 299 | if (value < 0) | - | ||||||||||||||||||
| 300 | break; | - | ||||||||||||||||||
| 301 | switch (op) { | - | ||||||||||||||||||
| 302 | case 'x': | - | ||||||||||||||||||
| 303 | (result.width >= 0 ? result.height : result.width) = value; | - | ||||||||||||||||||
| 304 | break; | - | ||||||||||||||||||
| 305 | case '+': | - | ||||||||||||||||||
| 306 | case '-': | - | ||||||||||||||||||
| 307 | if (result.xOffset >= 0) { | - | ||||||||||||||||||
| 308 | result.yOffset = value; | - | ||||||||||||||||||
| 309 | if (op == '-') | - | ||||||||||||||||||
| 310 | result.corner = result.corner == Qt::TopRightCorner ? Qt::BottomRightCorner : Qt::BottomLeftCorner; | - | ||||||||||||||||||
| 311 | } else { | - | ||||||||||||||||||
| 312 | result.xOffset = value; | - | ||||||||||||||||||
| 313 | if (op == '-') | - | ||||||||||||||||||
| 314 | result.corner = Qt::TopRightCorner; | - | ||||||||||||||||||
| 315 | } | - | ||||||||||||||||||
| 316 | } | - | ||||||||||||||||||
| 317 | } | - | ||||||||||||||||||
| 318 | return result; | - | ||||||||||||||||||
| 319 | } | - | ||||||||||||||||||
| 320 | - | |||||||||||||||||||
| 321 | void QWindowGeometrySpecification::applyTo(QWindow *window) const | - | ||||||||||||||||||
| 322 | { | - | ||||||||||||||||||
| 323 | QRect windowGeometry = window->frameGeometry(); | - | ||||||||||||||||||
| 324 | QSize size = windowGeometry.size(); | - | ||||||||||||||||||
| 325 | if (width >= 0 || height >= 0) { | - | ||||||||||||||||||
| 326 | const QSize windowMinimumSize = window->minimumSize(); | - | ||||||||||||||||||
| 327 | const QSize windowMaximumSize = window->maximumSize(); | - | ||||||||||||||||||
| 328 | if (width >= 0) | - | ||||||||||||||||||
| 329 | size.setWidth(qBound(windowMinimumSize.width(), width, windowMaximumSize.width())); | - | ||||||||||||||||||
| 330 | if (height >= 0) | - | ||||||||||||||||||
| 331 | size.setHeight(qBound(windowMinimumSize.height(), height, windowMaximumSize.height())); | - | ||||||||||||||||||
| 332 | window->resize(size); | - | ||||||||||||||||||
| 333 | } | - | ||||||||||||||||||
| 334 | if (xOffset >= 0 || yOffset >= 0) { | - | ||||||||||||||||||
| 335 | const QRect availableGeometry = window->screen()->virtualGeometry(); | - | ||||||||||||||||||
| 336 | QPoint topLeft = windowGeometry.topLeft(); | - | ||||||||||||||||||
| 337 | if (xOffset >= 0) { | - | ||||||||||||||||||
| 338 | topLeft.setX(corner == Qt::TopLeftCorner || corner == Qt::BottomLeftCorner ? | - | ||||||||||||||||||
| 339 | xOffset : | - | ||||||||||||||||||
| 340 | qMax(availableGeometry.right() - size.width() - xOffset, availableGeometry.left())); | - | ||||||||||||||||||
| 341 | } | - | ||||||||||||||||||
| 342 | if (yOffset >= 0) { | - | ||||||||||||||||||
| 343 | topLeft.setY(corner == Qt::TopLeftCorner || corner == Qt::TopRightCorner ? | - | ||||||||||||||||||
| 344 | yOffset : | - | ||||||||||||||||||
| 345 | qMax(availableGeometry.bottom() - size.height() - yOffset, availableGeometry.top())); | - | ||||||||||||||||||
| 346 | } | - | ||||||||||||||||||
| 347 | window->setFramePosition(topLeft); | - | ||||||||||||||||||
| 348 | } | - | ||||||||||||||||||
| 349 | } | - | ||||||||||||||||||
| 350 | - | |||||||||||||||||||
| 351 | static QWindowGeometrySpecification windowGeometrySpecification = Q_WINDOW_GEOMETRY_SPECIFICATION_INITIALIZER; | - | ||||||||||||||||||
| 352 | - | |||||||||||||||||||
| 353 | /*! | - | ||||||||||||||||||
| 354 | \macro qGuiApp | - | ||||||||||||||||||
| 355 | \relates QGuiApplication | - | ||||||||||||||||||
| 356 | - | |||||||||||||||||||
| 357 | A global pointer referring to the unique application object. | - | ||||||||||||||||||
| 358 | Only valid for use when that object is a QGuiApplication. | - | ||||||||||||||||||
| 359 | - | |||||||||||||||||||
| 360 | \sa QCoreApplication::instance(), qApp | - | ||||||||||||||||||
| 361 | */ | - | ||||||||||||||||||
| 362 | - | |||||||||||||||||||
| 363 | /*! | - | ||||||||||||||||||
| 364 | \class QGuiApplication | - | ||||||||||||||||||
| 365 | \brief The QGuiApplication class manages the GUI application's control | - | ||||||||||||||||||
| 366 | flow and main settings. | - | ||||||||||||||||||
| 367 | - | |||||||||||||||||||
| 368 | \inmodule QtGui | - | ||||||||||||||||||
| 369 | \since 5.0 | - | ||||||||||||||||||
| 370 | - | |||||||||||||||||||
| 371 | QGuiApplication contains the main event loop, where all events from the window | - | ||||||||||||||||||
| 372 | system and other sources are processed and dispatched. It also handles the | - | ||||||||||||||||||
| 373 | application's initialization and finalization, and provides session management. | - | ||||||||||||||||||
| 374 | In addition, QGuiApplication handles most of the system-wide and application-wide | - | ||||||||||||||||||
| 375 | settings. | - | ||||||||||||||||||
| 376 | - | |||||||||||||||||||
| 377 | For any GUI application using Qt, there is precisely \b one QGuiApplication | - | ||||||||||||||||||
| 378 | object no matter whether the application has 0, 1, 2 or more windows at | - | ||||||||||||||||||
| 379 | any given time. For non-GUI Qt applications, use QCoreApplication instead, | - | ||||||||||||||||||
| 380 | as it does not depend on the Qt GUI module. For QWidget based Qt applications, | - | ||||||||||||||||||
| 381 | use QApplication instead, as it provides some functionality needed for creating | - | ||||||||||||||||||
| 382 | QWidget instances. | - | ||||||||||||||||||
| 383 | - | |||||||||||||||||||
| 384 | The QGuiApplication object is accessible through the instance() function, which | - | ||||||||||||||||||
| 385 | returns a pointer equivalent to the global \l qApp pointer. | - | ||||||||||||||||||
| 386 | - | |||||||||||||||||||
| 387 | QGuiApplication's main areas of responsibility are: | - | ||||||||||||||||||
| 388 | \list | - | ||||||||||||||||||
| 389 | \li It initializes the application with the user's desktop settings, | - | ||||||||||||||||||
| 390 | such as palette(), font() and styleHints(). It keeps | - | ||||||||||||||||||
| 391 | track of these properties in case the user changes the desktop | - | ||||||||||||||||||
| 392 | globally, for example, through some kind of control panel. | - | ||||||||||||||||||
| 393 | - | |||||||||||||||||||
| 394 | \li It performs event handling, meaning that it receives events | - | ||||||||||||||||||
| 395 | from the underlying window system and dispatches them to the | - | ||||||||||||||||||
| 396 | relevant widgets. You can send your own events to windows by | - | ||||||||||||||||||
| 397 | using sendEvent() and postEvent(). | - | ||||||||||||||||||
| 398 | - | |||||||||||||||||||
| 399 | \li It parses common command line arguments and sets its internal | - | ||||||||||||||||||
| 400 | state accordingly. See the \l{QGuiApplication::QGuiApplication()} | - | ||||||||||||||||||
| 401 | {constructor documentation} below for more details. | - | ||||||||||||||||||
| 402 | - | |||||||||||||||||||
| 403 | \li It provides localization of strings that are visible to the | - | ||||||||||||||||||
| 404 | user via translate(). | - | ||||||||||||||||||
| 405 | - | |||||||||||||||||||
| 406 | \li It provides some magical objects like the clipboard(). | - | ||||||||||||||||||
| 407 | - | |||||||||||||||||||
| 408 | \li It knows about the application's windows. You can ask which | - | ||||||||||||||||||
| 409 | window is at a certain position using topLevelAt(), get a list of | - | ||||||||||||||||||
| 410 | topLevelWindows(), etc. | - | ||||||||||||||||||
| 411 | - | |||||||||||||||||||
| 412 | \li It manages the application's mouse cursor handling, see | - | ||||||||||||||||||
| 413 | setOverrideCursor() | - | ||||||||||||||||||
| 414 | - | |||||||||||||||||||
| 415 | \li It provides support for sophisticated \l{Session Management} | - | ||||||||||||||||||
| 416 | {session management}. This makes it possible for applications | - | ||||||||||||||||||
| 417 | to terminate gracefully when the user logs out, to cancel a | - | ||||||||||||||||||
| 418 | shutdown process if termination isn't possible and even to | - | ||||||||||||||||||
| 419 | preserve the entire application's state for a future session. | - | ||||||||||||||||||
| 420 | See isSessionRestored(), sessionId() and commitDataRequest() and | - | ||||||||||||||||||
| 421 | saveStateRequest() for details. | - | ||||||||||||||||||
| 422 | \endlist | - | ||||||||||||||||||
| 423 | - | |||||||||||||||||||
| 424 | Since the QGuiApplication object does so much initialization, it \e{must} be | - | ||||||||||||||||||
| 425 | created before any other objects related to the user interface are created. | - | ||||||||||||||||||
| 426 | QGuiApplication also deals with common command line arguments. Hence, it is | - | ||||||||||||||||||
| 427 | usually a good idea to create it \e before any interpretation or | - | ||||||||||||||||||
| 428 | modification of \c argv is done in the application itself. | - | ||||||||||||||||||
| 429 | - | |||||||||||||||||||
| 430 | \table | - | ||||||||||||||||||
| 431 | \header | - | ||||||||||||||||||
| 432 | \li{2,1} Groups of functions | - | ||||||||||||||||||
| 433 | - | |||||||||||||||||||
| 434 | \row | - | ||||||||||||||||||
| 435 | \li System settings | - | ||||||||||||||||||
| 436 | \li desktopSettingsAware(), | - | ||||||||||||||||||
| 437 | setDesktopSettingsAware(), | - | ||||||||||||||||||
| 438 | styleHints(), | - | ||||||||||||||||||
| 439 | palette(), | - | ||||||||||||||||||
| 440 | setPalette(), | - | ||||||||||||||||||
| 441 | font(), | - | ||||||||||||||||||
| 442 | setFont(). | - | ||||||||||||||||||
| 443 | - | |||||||||||||||||||
| 444 | \row | - | ||||||||||||||||||
| 445 | \li Event handling | - | ||||||||||||||||||
| 446 | \li exec(), | - | ||||||||||||||||||
| 447 | processEvents(), | - | ||||||||||||||||||
| 448 | exit(), | - | ||||||||||||||||||
| 449 | quit(). | - | ||||||||||||||||||
| 450 | sendEvent(), | - | ||||||||||||||||||
| 451 | postEvent(), | - | ||||||||||||||||||
| 452 | sendPostedEvents(), | - | ||||||||||||||||||
| 453 | removePostedEvents(), | - | ||||||||||||||||||
| 454 | hasPendingEvents(), | - | ||||||||||||||||||
| 455 | notify(). | - | ||||||||||||||||||
| 456 | - | |||||||||||||||||||
| 457 | \row | - | ||||||||||||||||||
| 458 | \li Windows | - | ||||||||||||||||||
| 459 | \li allWindows(), | - | ||||||||||||||||||
| 460 | topLevelWindows(), | - | ||||||||||||||||||
| 461 | focusWindow(), | - | ||||||||||||||||||
| 462 | clipboard(), | - | ||||||||||||||||||
| 463 | topLevelAt(). | - | ||||||||||||||||||
| 464 | - | |||||||||||||||||||
| 465 | \row | - | ||||||||||||||||||
| 466 | \li Advanced cursor handling | - | ||||||||||||||||||
| 467 | \li overrideCursor(), | - | ||||||||||||||||||
| 468 | setOverrideCursor(), | - | ||||||||||||||||||
| 469 | restoreOverrideCursor(). | - | ||||||||||||||||||
| 470 | - | |||||||||||||||||||
| 471 | \row | - | ||||||||||||||||||
| 472 | \li Session management | - | ||||||||||||||||||
| 473 | \li isSessionRestored(), | - | ||||||||||||||||||
| 474 | sessionId(), | - | ||||||||||||||||||
| 475 | commitDataRequest(), | - | ||||||||||||||||||
| 476 | saveStateRequest(). | - | ||||||||||||||||||
| 477 | - | |||||||||||||||||||
| 478 | \row | - | ||||||||||||||||||
| 479 | \li Miscellaneous | - | ||||||||||||||||||
| 480 | \li startingUp(), | - | ||||||||||||||||||
| 481 | closingDown(). | - | ||||||||||||||||||
| 482 | \endtable | - | ||||||||||||||||||
| 483 | - | |||||||||||||||||||
| 484 | \sa QCoreApplication, QAbstractEventDispatcher, QEventLoop | - | ||||||||||||||||||
| 485 | */ | - | ||||||||||||||||||
| 486 | - | |||||||||||||||||||
| 487 | /*! | - | ||||||||||||||||||
| 488 | Initializes the window system and constructs an application object with | - | ||||||||||||||||||
| 489 | \a argc command line arguments in \a argv. | - | ||||||||||||||||||
| 490 | - | |||||||||||||||||||
| 491 | \warning The data referred to by \a argc and \a argv must stay valid for | - | ||||||||||||||||||
| 492 | the entire lifetime of the QGuiApplication object. In addition, \a argc must | - | ||||||||||||||||||
| 493 | be greater than zero and \a argv must contain at least one valid character | - | ||||||||||||||||||
| 494 | string. | - | ||||||||||||||||||
| 495 | - | |||||||||||||||||||
| 496 | The global \c qApp pointer refers to this application object. Only one | - | ||||||||||||||||||
| 497 | application object should be created. | - | ||||||||||||||||||
| 498 | - | |||||||||||||||||||
| 499 | This application object must be constructed before any \l{QPaintDevice} | - | ||||||||||||||||||
| 500 | {paint devices} (including pixmaps, bitmaps etc.). | - | ||||||||||||||||||
| 501 | - | |||||||||||||||||||
| 502 | \note \a argc and \a argv might be changed as Qt removes command line | - | ||||||||||||||||||
| 503 | arguments that it recognizes. | - | ||||||||||||||||||
| 504 | - | |||||||||||||||||||
| 505 | \section1 Supported Command Line Options | - | ||||||||||||||||||
| 506 | - | |||||||||||||||||||
| 507 | All Qt programs automatically support a set of command-line options that | - | ||||||||||||||||||
| 508 | allow modifying the way Qt will interact with the windowing system. Some of | - | ||||||||||||||||||
| 509 | the options are also accessible via environment variables, which are the | - | ||||||||||||||||||
| 510 | preferred form if the application can launch GUI sub-processes or other | - | ||||||||||||||||||
| 511 | applications (environment variables will be inherited by child processes). | - | ||||||||||||||||||
| 512 | When in doubt, use the environment variables. | - | ||||||||||||||||||
| 513 | - | |||||||||||||||||||
| 514 | The options currently supported are the following: | - | ||||||||||||||||||
| 515 | \list | - | ||||||||||||||||||
| 516 | - | |||||||||||||||||||
| 517 | \li \c{-platform} \e {platformName[:options]}, specifies the | - | ||||||||||||||||||
| 518 | \l{Qt Platform Abstraction} (QPA) plugin. | - | ||||||||||||||||||
| 519 | - | |||||||||||||||||||
| 520 | Overridden by the \c QT_QPA_PLATFORM environment variable. | - | ||||||||||||||||||
| 521 | \li \c{-platformpluginpath} \e path, specifies the path to platform | - | ||||||||||||||||||
| 522 | plugins. | - | ||||||||||||||||||
| 523 | - | |||||||||||||||||||
| 524 | Overridden by the \c QT_QPA_PLATFORM_PLUGIN_PATH environment | - | ||||||||||||||||||
| 525 | variable. | - | ||||||||||||||||||
| 526 | - | |||||||||||||||||||
| 527 | \li \c{-platformtheme} \e platformTheme, specifies the platform theme. | - | ||||||||||||||||||
| 528 | - | |||||||||||||||||||
| 529 | Overridden by the \c QT_QPA_PLATFORMTHEME environment variable. | - | ||||||||||||||||||
| 530 | - | |||||||||||||||||||
| 531 | \li \c{-plugin} \e plugin, specifies additional plugins to load. The argument | - | ||||||||||||||||||
| 532 | may appear multiple times. | - | ||||||||||||||||||
| 533 | - | |||||||||||||||||||
| 534 | Overridden by the \c QT_QPA_GENERIC_PLUGINS environment variable. | - | ||||||||||||||||||
| 535 | - | |||||||||||||||||||
| 536 | \li \c{-qmljsdebugger=}, activates the QML/JS debugger with a specified port. | - | ||||||||||||||||||
| 537 | The value must be of format \c{port:1234}\e{[,block]}, where | - | ||||||||||||||||||
| 538 | \e block is optional | - | ||||||||||||||||||
| 539 | and will make the application wait until a debugger connects to it. | - | ||||||||||||||||||
| 540 | \li \c {-qwindowgeometry} \e geometry, specifies window geometry for | - | ||||||||||||||||||
| 541 | the main window using the X11-syntax. For example: | - | ||||||||||||||||||
| 542 | \c {-qwindowgeometry 100x100+50+50} | - | ||||||||||||||||||
| 543 | \li \c {-qwindowicon}, sets the default window icon | - | ||||||||||||||||||
| 544 | \li \c {-qwindowtitle}, sets the title of the first window | - | ||||||||||||||||||
| 545 | \li \c{-reverse}, sets the application's layout direction to | - | ||||||||||||||||||
| 546 | Qt::RightToLeft. This option is intended to aid debugging and should | - | ||||||||||||||||||
| 547 | not be used in production. The default value is automatically detected | - | ||||||||||||||||||
| 548 | from the user's locale (see also QLocale::textDirection()). | - | ||||||||||||||||||
| 549 | \li \c{-session} \e session, restores the application from an earlier | - | ||||||||||||||||||
| 550 | \l{Session Management}{session}. | - | ||||||||||||||||||
| 551 | \endlist | - | ||||||||||||||||||
| 552 | - | |||||||||||||||||||
| 553 | The following standard command line options are available for X11: | - | ||||||||||||||||||
| 554 | - | |||||||||||||||||||
| 555 | \list | - | ||||||||||||||||||
| 556 | \li \c {-display} \e {hostname:screen_number}, switches displays on X11. | - | ||||||||||||||||||
| 557 | - | |||||||||||||||||||
| 558 | Overrides the \c DISPLAY environment variable. | - | ||||||||||||||||||
| 559 | \li \c {-geometry} \e geometry, same as \c {-qwindowgeometry}. | - | ||||||||||||||||||
| 560 | \endlist | - | ||||||||||||||||||
| 561 | - | |||||||||||||||||||
| 562 | \section1 Platform-Specific Arguments | - | ||||||||||||||||||
| 563 | - | |||||||||||||||||||
| 564 | You can specify platform-specific arguments for the \c{-platform} option. | - | ||||||||||||||||||
| 565 | Place them after the platform plugin name following a colon as a | - | ||||||||||||||||||
| 566 | comma-separated list. For example, | - | ||||||||||||||||||
| 567 | \c{-platform windows:dialogs=xp,fontengine=freetype}. | - | ||||||||||||||||||
| 568 | - | |||||||||||||||||||
| 569 | The following parameters are available for \c {-platform windows}: | - | ||||||||||||||||||
| 570 | - | |||||||||||||||||||
| 571 | \list | - | ||||||||||||||||||
| 572 | \li \c {dialogs=[xp|none]}, \c xp uses XP-style native dialogs and | - | ||||||||||||||||||
| 573 | \c none disables them. | - | ||||||||||||||||||
| 574 | \li \c {fontengine=freetype}, uses the FreeType font engine. | - | ||||||||||||||||||
| 575 | \endlist | - | ||||||||||||||||||
| 576 | - | |||||||||||||||||||
| 577 | For more information about the platform-specific arguments available for | - | ||||||||||||||||||
| 578 | embedded Linux platforms, see \l{Qt for Embedded Linux}. | - | ||||||||||||||||||
| 579 | - | |||||||||||||||||||
| 580 | \sa arguments() QGuiApplication::platformName | - | ||||||||||||||||||
| 581 | */ | - | ||||||||||||||||||
| 582 | #ifdef Q_QDOC | - | ||||||||||||||||||
| 583 | QGuiApplication::QGuiApplication(int &argc, char **argv) | - | ||||||||||||||||||
| 584 | #else | - | ||||||||||||||||||
| 585 | QGuiApplication::QGuiApplication(int &argc, char **argv, int flags) | - | ||||||||||||||||||
| 586 | #endif | - | ||||||||||||||||||
| 587 | : QCoreApplication(*new QGuiApplicationPrivate(argc, argv, flags)) | - | ||||||||||||||||||
| 588 | { | - | ||||||||||||||||||
| 589 | d_func()->init(); | - | ||||||||||||||||||
| 590 | - | |||||||||||||||||||
| 591 | QCoreApplicationPrivate::eventDispatcher->startingUp(); | - | ||||||||||||||||||
| 592 | } | - | ||||||||||||||||||
| 593 | - | |||||||||||||||||||
| 594 | /*! | - | ||||||||||||||||||
| 595 | \internal | - | ||||||||||||||||||
| 596 | */ | - | ||||||||||||||||||
| 597 | QGuiApplication::QGuiApplication(QGuiApplicationPrivate &p) | - | ||||||||||||||||||
| 598 | : QCoreApplication(p) | - | ||||||||||||||||||
| 599 | { | - | ||||||||||||||||||
| 600 | } | - | ||||||||||||||||||
| 601 | - | |||||||||||||||||||
| 602 | /*! | - | ||||||||||||||||||
| 603 | Destructs the application. | - | ||||||||||||||||||
| 604 | */ | - | ||||||||||||||||||
| 605 | QGuiApplication::~QGuiApplication() | - | ||||||||||||||||||
| 606 | { | - | ||||||||||||||||||
| 607 | Q_D(QGuiApplication); | - | ||||||||||||||||||
| 608 | - | |||||||||||||||||||
| 609 | d->eventDispatcher->closingDown(); | - | ||||||||||||||||||
| 610 | d->eventDispatcher = 0; | - | ||||||||||||||||||
| 611 | - | |||||||||||||||||||
| 612 | #ifndef QT_NO_CLIPBOARD | - | ||||||||||||||||||
| 613 | delete QGuiApplicationPrivate::qt_clipboard; | - | ||||||||||||||||||
| 614 | QGuiApplicationPrivate::qt_clipboard = 0; | - | ||||||||||||||||||
| 615 | #endif | - | ||||||||||||||||||
| 616 | - | |||||||||||||||||||
| 617 | #ifndef QT_NO_SESSIONMANAGER | - | ||||||||||||||||||
| 618 | delete d->session_manager; | - | ||||||||||||||||||
| 619 | d->session_manager = 0; | - | ||||||||||||||||||
| 620 | #endif //QT_NO_SESSIONMANAGER | - | ||||||||||||||||||
| 621 | - | |||||||||||||||||||
| 622 | clearPalette(); | - | ||||||||||||||||||
| 623 | QFontDatabase::removeAllApplicationFonts(); | - | ||||||||||||||||||
| 624 | - | |||||||||||||||||||
| 625 | #ifndef QT_NO_CURSOR | - | ||||||||||||||||||
| 626 | d->cursor_list.clear(); | - | ||||||||||||||||||
| 627 | #endif | - | ||||||||||||||||||
| 628 | - | |||||||||||||||||||
| 629 | delete QGuiApplicationPrivate::app_icon; | - | ||||||||||||||||||
| 630 | QGuiApplicationPrivate::app_icon = 0; | - | ||||||||||||||||||
| 631 | delete QGuiApplicationPrivate::platform_name; | - | ||||||||||||||||||
| 632 | QGuiApplicationPrivate::platform_name = 0; | - | ||||||||||||||||||
| 633 | delete QGuiApplicationPrivate::displayName; | - | ||||||||||||||||||
| 634 | QGuiApplicationPrivate::displayName = 0; | - | ||||||||||||||||||
| 635 | delete QGuiApplicationPrivate::m_inputDeviceManager; | - | ||||||||||||||||||
| 636 | QGuiApplicationPrivate::m_inputDeviceManager = 0; | - | ||||||||||||||||||
| 637 | delete QGuiApplicationPrivate::desktopFileName; | - | ||||||||||||||||||
| 638 | QGuiApplicationPrivate::desktopFileName = 0; | - | ||||||||||||||||||
| 639 | } never executed: end of block | 0 | ||||||||||||||||||
| 640 | - | |||||||||||||||||||
| 641 | QGuiApplicationPrivate::QGuiApplicationPrivate(int &argc, char **argv, int flags) | - | ||||||||||||||||||
| 642 | : QCoreApplicationPrivate(argc, argv, flags), | - | ||||||||||||||||||
| 643 | inputMethod(0), | - | ||||||||||||||||||
| 644 | lastTouchType(QEvent::TouchEnd), | - | ||||||||||||||||||
| 645 | ownGlobalShareContext(false) | - | ||||||||||||||||||
| 646 | { | - | ||||||||||||||||||
| 647 | self = this; | - | ||||||||||||||||||
| 648 | application_type = QCoreApplicationPrivate::Gui; | - | ||||||||||||||||||
| 649 | #ifndef QT_NO_SESSIONMANAGER | - | ||||||||||||||||||
| 650 | is_session_restored = false; | - | ||||||||||||||||||
| 651 | is_saving_session = false; | - | ||||||||||||||||||
| 652 | #endif | - | ||||||||||||||||||
| 653 | } | - | ||||||||||||||||||
| 654 | - | |||||||||||||||||||
| 655 | /*! | - | ||||||||||||||||||
| 656 | \property QGuiApplication::applicationDisplayName | - | ||||||||||||||||||
| 657 | \brief the user-visible name of this application | - | ||||||||||||||||||
| 658 | \since 5.0 | - | ||||||||||||||||||
| 659 | - | |||||||||||||||||||
| 660 | This name is shown to the user, for instance in window titles. | - | ||||||||||||||||||
| 661 | It can be translated, if necessary. | - | ||||||||||||||||||
| 662 | - | |||||||||||||||||||
| 663 | If not set, the application display name defaults to the application name. | - | ||||||||||||||||||
| 664 | - | |||||||||||||||||||
| 665 | \sa applicationName | - | ||||||||||||||||||
| 666 | */ | - | ||||||||||||||||||
| 667 | void QGuiApplication::setApplicationDisplayName(const QString &name) | - | ||||||||||||||||||
| 668 | { | - | ||||||||||||||||||
| 669 | if (!QGuiApplicationPrivate::displayName) | - | ||||||||||||||||||
| 670 | QGuiApplicationPrivate::displayName = new QString; | - | ||||||||||||||||||
| 671 | *QGuiApplicationPrivate::displayName = name; | - | ||||||||||||||||||
| 672 | } | - | ||||||||||||||||||
| 673 | - | |||||||||||||||||||
| 674 | QString QGuiApplication::applicationDisplayName() | - | ||||||||||||||||||
| 675 | { | - | ||||||||||||||||||
| 676 | return QGuiApplicationPrivate::displayName ? *QGuiApplicationPrivate::displayName : applicationName(); | - | ||||||||||||||||||
| 677 | } | - | ||||||||||||||||||
| 678 | - | |||||||||||||||||||
| 679 | /*! | - | ||||||||||||||||||
| 680 | \property QGuiApplication::desktopFileName | - | ||||||||||||||||||
| 681 | \brief the base name of the desktop entry for this application | - | ||||||||||||||||||
| 682 | \since 5.7 | - | ||||||||||||||||||
| 683 | - | |||||||||||||||||||
| 684 | This is the file name, without the full path, of the desktop entry | - | ||||||||||||||||||
| 685 | that represents this application according to the freedesktop desktop | - | ||||||||||||||||||
| 686 | entry specification. | - | ||||||||||||||||||
| 687 | - | |||||||||||||||||||
| 688 | This property gives a precise indication of what desktop entry represents | - | ||||||||||||||||||
| 689 | the application and it is needed by the windowing system to retrieve | - | ||||||||||||||||||
| 690 | such information without resorting to imprecise heuristics. | - | ||||||||||||||||||
| 691 | - | |||||||||||||||||||
| 692 | The latest version of the freedesktop desktop entry specification can be obtained | - | ||||||||||||||||||
| 693 | \l{http://standards.freedesktop.org/desktop-entry-spec/latest/}{here}. | - | ||||||||||||||||||
| 694 | */ | - | ||||||||||||||||||
| 695 | void QGuiApplication::setDesktopFileName(const QString &name) | - | ||||||||||||||||||
| 696 | { | - | ||||||||||||||||||
| 697 | if (!QGuiApplicationPrivate::desktopFileName)
| 0 | ||||||||||||||||||
| 698 | QGuiApplicationPrivate::desktopFileName = new QString; never executed: QGuiApplicationPrivate::desktopFileName = new QString; | 0 | ||||||||||||||||||
| 699 | *QGuiApplicationPrivate::desktopFileName = name; | - | ||||||||||||||||||
| 700 | } never executed: end of block | 0 | ||||||||||||||||||
| 701 | - | |||||||||||||||||||
| 702 | QString QGuiApplication::desktopFileName() | - | ||||||||||||||||||
| 703 | { | - | ||||||||||||||||||
| 704 | return QGuiApplicationPrivate::desktopFileName ? *QGuiApplicationPrivate::desktopFileName : QString never executed: ();return QGuiApplicationPrivate::desktopFileName ? *QGuiApplicationPrivate::desktopFileName : QString();never executed: return QGuiApplicationPrivate::desktopFileName ? *QGuiApplicationPrivate::desktopFileName : QString(); | 0 | ||||||||||||||||||
| 705 | } | - | ||||||||||||||||||
| 706 | - | |||||||||||||||||||
| 707 | /*! | - | ||||||||||||||||||
| 708 | Returns the most recently shown modal window. If no modal windows are | - | ||||||||||||||||||
| 709 | visible, this function returns zero. | - | ||||||||||||||||||
| 710 | - | |||||||||||||||||||
| 711 | A modal window is a window which has its | - | ||||||||||||||||||
| 712 | \l{QWindow::modality}{modality} property set to Qt::WindowModal | - | ||||||||||||||||||
| 713 | or Qt::ApplicationModal. A modal window must be closed before the user can | - | ||||||||||||||||||
| 714 | continue with other parts of the program. | - | ||||||||||||||||||
| 715 | - | |||||||||||||||||||
| 716 | Modal window are organized in a stack. This function returns the modal | - | ||||||||||||||||||
| 717 | window at the top of the stack. | - | ||||||||||||||||||
| 718 | - | |||||||||||||||||||
| 719 | \sa Qt::WindowModality, QWindow::setModality() | - | ||||||||||||||||||
| 720 | */ | - | ||||||||||||||||||
| 721 | QWindow *QGuiApplication::modalWindow() | - | ||||||||||||||||||
| 722 | { | - | ||||||||||||||||||
| 723 | CHECK_QAPP_INSTANCE(Q_NULLPTR) | - | ||||||||||||||||||
| 724 | if (QGuiApplicationPrivate::self->modalWindowList.isEmpty()) | - | ||||||||||||||||||
| 725 | return 0; | - | ||||||||||||||||||
| 726 | return QGuiApplicationPrivate::self->modalWindowList.first(); | - | ||||||||||||||||||
| 727 | } | - | ||||||||||||||||||
| 728 | - | |||||||||||||||||||
| 729 | static void updateBlockedStatusRecursion(QWindow *window, bool shouldBeBlocked) | - | ||||||||||||||||||
| 730 | { | - | ||||||||||||||||||
| 731 | QWindowPrivate *p = qt_window_private(window); | - | ||||||||||||||||||
| 732 | if (p->blockedByModalWindow != shouldBeBlocked) {
| 0 | ||||||||||||||||||
| 733 | p->blockedByModalWindow = shouldBeBlocked; | - | ||||||||||||||||||
| 734 | QEvent e(shouldBeBlocked ? QEvent::WindowBlocked : QEvent::WindowUnblocked); | - | ||||||||||||||||||
| 735 | QGuiApplication::sendEvent(window, &e); | - | ||||||||||||||||||
| 736 | foreachfor (QObject *c ,: window->children()) { | - | ||||||||||||||||||
| 737 | if (c->isWindowType())
| 0 | ||||||||||||||||||
| 738 | updateBlockedStatusRecursion(static_cast<QWindow *>(c), shouldBeBlocked); never executed: updateBlockedStatusRecursion(static_cast<QWindow *>(c), shouldBeBlocked); | 0 | ||||||||||||||||||
| 739 | } never executed: end of block | 0 | ||||||||||||||||||
| 740 | } never executed: end of block | 0 | ||||||||||||||||||
| 741 | } never executed: end of block | 0 | ||||||||||||||||||
| 742 | - | |||||||||||||||||||
| 743 | void QGuiApplicationPrivate::updateBlockedStatus(QWindow *window) | - | ||||||||||||||||||
| 744 | { | - | ||||||||||||||||||
| 745 | bool shouldBeBlocked = false; | - | ||||||||||||||||||
| 746 | if (!QWindowPrivate::get(window)->isPopup() && !self->modalWindowList.isEmpty()) | - | ||||||||||||||||||
| 747 | shouldBeBlocked = self->isWindowBlocked(window); | - | ||||||||||||||||||
| 748 | updateBlockedStatusRecursion(window, shouldBeBlocked); | - | ||||||||||||||||||
| 749 | } | - | ||||||||||||||||||
| 750 | - | |||||||||||||||||||
| 751 | void QGuiApplicationPrivate::showModalWindow(QWindow *modal) | - | ||||||||||||||||||
| 752 | { | - | ||||||||||||||||||
| 753 | self->modalWindowList.prepend(modal); | - | ||||||||||||||||||
| 754 | - | |||||||||||||||||||
| 755 | // Send leave for currently entered window if it should be blocked | - | ||||||||||||||||||
| 756 | if (currentMouseWindow && !QWindowPrivate::get(currentMouseWindow)->isPopup()) { | - | ||||||||||||||||||
| 757 | bool shouldBeBlocked = self->isWindowBlocked(currentMouseWindow); | - | ||||||||||||||||||
| 758 | if (shouldBeBlocked) { | - | ||||||||||||||||||
| 759 | // Remove the new window from modalWindowList temporarily so leave can go through | - | ||||||||||||||||||
| 760 | self->modalWindowList.removeFirst(); | - | ||||||||||||||||||
| 761 | QEvent e(QEvent::Leave); | - | ||||||||||||||||||
| 762 | QGuiApplication::sendEvent(currentMouseWindow, &e); | - | ||||||||||||||||||
| 763 | currentMouseWindow = 0; | - | ||||||||||||||||||
| 764 | self->modalWindowList.prepend(modal); | - | ||||||||||||||||||
| 765 | } | - | ||||||||||||||||||
| 766 | } | - | ||||||||||||||||||
| 767 | - | |||||||||||||||||||
| 768 | QWindowList windows = QGuiApplication::topLevelWindows(); | - | ||||||||||||||||||
| 769 | for (int i = 0; i < windows.count(); ++i) { | - | ||||||||||||||||||
| 770 | QWindow *window = windows.at(i); | - | ||||||||||||||||||
| 771 | if (!window->d_func()->blockedByModalWindow) | - | ||||||||||||||||||
| 772 | updateBlockedStatus(window); | - | ||||||||||||||||||
| 773 | } | - | ||||||||||||||||||
| 774 | - | |||||||||||||||||||
| 775 | updateBlockedStatus(modal); | - | ||||||||||||||||||
| 776 | } | - | ||||||||||||||||||
| 777 | - | |||||||||||||||||||
| 778 | void QGuiApplicationPrivate::hideModalWindow(QWindow *window) | - | ||||||||||||||||||
| 779 | { | - | ||||||||||||||||||
| 780 | self->modalWindowList.removeAll(window); | - | ||||||||||||||||||
| 781 | - | |||||||||||||||||||
| 782 | QWindowList windows = QGuiApplication::topLevelWindows(); | - | ||||||||||||||||||
| 783 | for (int i = 0; i < windows.count(); ++i) { | - | ||||||||||||||||||
| 784 | QWindow *window = windows.at(i); | - | ||||||||||||||||||
| 785 | if (window->d_func()->blockedByModalWindow) | - | ||||||||||||||||||
| 786 | updateBlockedStatus(window); | - | ||||||||||||||||||
| 787 | } | - | ||||||||||||||||||
| 788 | } | - | ||||||||||||||||||
| 789 | - | |||||||||||||||||||
| 790 | /* | - | ||||||||||||||||||
| 791 | Returns \c true if \a window is blocked by a modal window. If \a | - | ||||||||||||||||||
| 792 | blockingWindow is non-zero, *blockingWindow will be set to the blocking | - | ||||||||||||||||||
| 793 | window (or to zero if \a window is not blocked). | - | ||||||||||||||||||
| 794 | */ | - | ||||||||||||||||||
| 795 | bool QGuiApplicationPrivate::isWindowBlocked(QWindow *window, QWindow **blockingWindow) const | - | ||||||||||||||||||
| 796 | { | - | ||||||||||||||||||
| 797 | QWindow *unused = 0; | - | ||||||||||||||||||
| 798 | if (!blockingWindow) | - | ||||||||||||||||||
| 799 | blockingWindow = &unused; | - | ||||||||||||||||||
| 800 | - | |||||||||||||||||||
| 801 | if (modalWindowList.isEmpty()) { | - | ||||||||||||||||||
| 802 | *blockingWindow = 0; | - | ||||||||||||||||||
| 803 | return false; | - | ||||||||||||||||||
| 804 | } | - | ||||||||||||||||||
| 805 | - | |||||||||||||||||||
| 806 | for (int i = 0; i < modalWindowList.count(); ++i) { | - | ||||||||||||||||||
| 807 | QWindow *modalWindow = modalWindowList.at(i); | - | ||||||||||||||||||
| 808 | - | |||||||||||||||||||
| 809 | { | - | ||||||||||||||||||
| 810 | // check if the modal window is our window or a (transient) parent of our window | - | ||||||||||||||||||
| 811 | QWindow *w = window; | - | ||||||||||||||||||
| 812 | while (w) { | - | ||||||||||||||||||
| 813 | if (w == modalWindow) { | - | ||||||||||||||||||
| 814 | *blockingWindow = 0; | - | ||||||||||||||||||
| 815 | return false; | - | ||||||||||||||||||
| 816 | } | - | ||||||||||||||||||
| 817 | QWindow *p = w->parent(); | - | ||||||||||||||||||
| 818 | if (!p) | - | ||||||||||||||||||
| 819 | p = w->transientParent(); | - | ||||||||||||||||||
| 820 | w = p; | - | ||||||||||||||||||
| 821 | } | - | ||||||||||||||||||
| 822 | } | - | ||||||||||||||||||
| 823 | - | |||||||||||||||||||
| 824 | Qt::WindowModality windowModality = modalWindow->modality(); | - | ||||||||||||||||||
| 825 | switch (windowModality) { | - | ||||||||||||||||||
| 826 | case Qt::ApplicationModal: | - | ||||||||||||||||||
| 827 | { | - | ||||||||||||||||||
| 828 | if (modalWindow != window) { | - | ||||||||||||||||||
| 829 | *blockingWindow = modalWindow; | - | ||||||||||||||||||
| 830 | return true; | - | ||||||||||||||||||
| 831 | } | - | ||||||||||||||||||
| 832 | break; | - | ||||||||||||||||||
| 833 | } | - | ||||||||||||||||||
| 834 | case Qt::WindowModal: | - | ||||||||||||||||||
| 835 | { | - | ||||||||||||||||||
| 836 | QWindow *w = window; | - | ||||||||||||||||||
| 837 | do { | - | ||||||||||||||||||
| 838 | QWindow *m = modalWindow; | - | ||||||||||||||||||
| 839 | do { | - | ||||||||||||||||||
| 840 | if (m == w) { | - | ||||||||||||||||||
| 841 | *blockingWindow = m; | - | ||||||||||||||||||
| 842 | return true; | - | ||||||||||||||||||
| 843 | } | - | ||||||||||||||||||
| 844 | QWindow *p = m->parent(); | - | ||||||||||||||||||
| 845 | if (!p) | - | ||||||||||||||||||
| 846 | p = m->transientParent(); | - | ||||||||||||||||||
| 847 | m = p; | - | ||||||||||||||||||
| 848 | } while (m); | - | ||||||||||||||||||
| 849 | QWindow *p = w->parent(); | - | ||||||||||||||||||
| 850 | if (!p) | - | ||||||||||||||||||
| 851 | p = w->transientParent(); | - | ||||||||||||||||||
| 852 | w = p; | - | ||||||||||||||||||
| 853 | } while (w); | - | ||||||||||||||||||
| 854 | break; | - | ||||||||||||||||||
| 855 | } | - | ||||||||||||||||||
| 856 | default: | - | ||||||||||||||||||
| 857 | Q_ASSERT_X(false, "QGuiApplication", "internal error, a modal widget cannot be modeless"); | - | ||||||||||||||||||
| 858 | break; | - | ||||||||||||||||||
| 859 | } | - | ||||||||||||||||||
| 860 | } | - | ||||||||||||||||||
| 861 | *blockingWindow = 0; | - | ||||||||||||||||||
| 862 | return false; | - | ||||||||||||||||||
| 863 | } | - | ||||||||||||||||||
| 864 | - | |||||||||||||||||||
| 865 | /*! | - | ||||||||||||||||||
| 866 | Returns the QWindow that receives events tied to focus, | - | ||||||||||||||||||
| 867 | such as key events. | - | ||||||||||||||||||
| 868 | */ | - | ||||||||||||||||||
| 869 | QWindow *QGuiApplication::focusWindow() | - | ||||||||||||||||||
| 870 | { | - | ||||||||||||||||||
| 871 | return QGuiApplicationPrivate::focus_window; | - | ||||||||||||||||||
| 872 | } | - | ||||||||||||||||||
| 873 | - | |||||||||||||||||||
| 874 | /*! | - | ||||||||||||||||||
| 875 | \fn QGuiApplication::focusObjectChanged(QObject *focusObject) | - | ||||||||||||||||||
| 876 | - | |||||||||||||||||||
| 877 | This signal is emitted when final receiver of events tied to focus is changed. | - | ||||||||||||||||||
| 878 | \a focusObject is the new receiver. | - | ||||||||||||||||||
| 879 | - | |||||||||||||||||||
| 880 | \sa focusObject() | - | ||||||||||||||||||
| 881 | */ | - | ||||||||||||||||||
| 882 | - | |||||||||||||||||||
| 883 | /*! | - | ||||||||||||||||||
| 884 | \fn QGuiApplication::focusWindowChanged(QWindow *focusWindow) | - | ||||||||||||||||||
| 885 | - | |||||||||||||||||||
| 886 | This signal is emitted when the focused window changes. | - | ||||||||||||||||||
| 887 | \a focusWindow is the new focused window. | - | ||||||||||||||||||
| 888 | - | |||||||||||||||||||
| 889 | \sa focusWindow() | - | ||||||||||||||||||
| 890 | */ | - | ||||||||||||||||||
| 891 | - | |||||||||||||||||||
| 892 | /*! | - | ||||||||||||||||||
| 893 | Returns the QObject in currently active window that will be final receiver of events | - | ||||||||||||||||||
| 894 | tied to focus, such as key events. | - | ||||||||||||||||||
| 895 | */ | - | ||||||||||||||||||
| 896 | QObject *QGuiApplication::focusObject() | - | ||||||||||||||||||
| 897 | { | - | ||||||||||||||||||
| 898 | if (focusWindow()) | - | ||||||||||||||||||
| 899 | return focusWindow()->focusObject(); | - | ||||||||||||||||||
| 900 | return 0; | - | ||||||||||||||||||
| 901 | } | - | ||||||||||||||||||
| 902 | - | |||||||||||||||||||
| 903 | /*! | - | ||||||||||||||||||
| 904 | \fn QGuiApplication::allWindows() | - | ||||||||||||||||||
| 905 | - | |||||||||||||||||||
| 906 | Returns a list of all the windows in the application. | - | ||||||||||||||||||
| 907 | - | |||||||||||||||||||
| 908 | The list is empty if there are no windows. | - | ||||||||||||||||||
| 909 | - | |||||||||||||||||||
| 910 | \sa topLevelWindows() | - | ||||||||||||||||||
| 911 | */ | - | ||||||||||||||||||
| 912 | QWindowList QGuiApplication::allWindows() | - | ||||||||||||||||||
| 913 | { | - | ||||||||||||||||||
| 914 | return QGuiApplicationPrivate::window_list; | - | ||||||||||||||||||
| 915 | } | - | ||||||||||||||||||
| 916 | - | |||||||||||||||||||
| 917 | /*! | - | ||||||||||||||||||
| 918 | \fn QGuiApplication::topLevelWindows() | - | ||||||||||||||||||
| 919 | - | |||||||||||||||||||
| 920 | Returns a list of the top-level windows in the application. | - | ||||||||||||||||||
| 921 | - | |||||||||||||||||||
| 922 | \sa allWindows() | - | ||||||||||||||||||
| 923 | */ | - | ||||||||||||||||||
| 924 | QWindowList QGuiApplication::topLevelWindows() | - | ||||||||||||||||||
| 925 | { | - | ||||||||||||||||||
| 926 | const QWindowList &list = QGuiApplicationPrivate::window_list; | - | ||||||||||||||||||
| 927 | QWindowList topLevelWindows; | - | ||||||||||||||||||
| 928 | for (int i = 0; i < list.size(); i++) { | - | ||||||||||||||||||
| 929 | if (!list.at(i)->parent() && list.at(i)->type() != Qt::Desktop) { | - | ||||||||||||||||||
| 930 | // Top windows of embedded QAxServers do not have QWindow parents, | - | ||||||||||||||||||
| 931 | // but they are not true top level windows, so do not include them. | - | ||||||||||||||||||
| 932 | const bool embedded = list.at(i)->handle() && list.at(i)->handle()->isEmbedded(); | - | ||||||||||||||||||
| 933 | if (!embedded) | - | ||||||||||||||||||
| 934 | topLevelWindows.prepend(list.at(i)); | - | ||||||||||||||||||
| 935 | } | - | ||||||||||||||||||
| 936 | } | - | ||||||||||||||||||
| 937 | return topLevelWindows; | - | ||||||||||||||||||
| 938 | } | - | ||||||||||||||||||
| 939 | - | |||||||||||||||||||
| 940 | QScreen *QGuiApplication::primaryScreen() | - | ||||||||||||||||||
| 941 | { | - | ||||||||||||||||||
| 942 | if (QGuiApplicationPrivate::screen_list.isEmpty()) | - | ||||||||||||||||||
| 943 | return 0; | - | ||||||||||||||||||
| 944 | return QGuiApplicationPrivate::screen_list.at(0); | - | ||||||||||||||||||
| 945 | } | - | ||||||||||||||||||
| 946 | - | |||||||||||||||||||
| 947 | /*! | - | ||||||||||||||||||
| 948 | Returns a list of all the screens associated with the | - | ||||||||||||||||||
| 949 | windowing system the application is connected to. | - | ||||||||||||||||||
| 950 | */ | - | ||||||||||||||||||
| 951 | QList<QScreen *> QGuiApplication::screens() | - | ||||||||||||||||||
| 952 | { | - | ||||||||||||||||||
| 953 | return QGuiApplicationPrivate::screen_list; | - | ||||||||||||||||||
| 954 | } | - | ||||||||||||||||||
| 955 | - | |||||||||||||||||||
| 956 | /*! | - | ||||||||||||||||||
| 957 | \fn void QGuiApplication::screenAdded(QScreen *screen) | - | ||||||||||||||||||
| 958 | - | |||||||||||||||||||
| 959 | This signal is emitted whenever a new screen \a screen has been added to the system. | - | ||||||||||||||||||
| 960 | - | |||||||||||||||||||
| 961 | \sa screens(), primaryScreen, screenRemoved() | - | ||||||||||||||||||
| 962 | */ | - | ||||||||||||||||||
| 963 | - | |||||||||||||||||||
| 964 | /*! | - | ||||||||||||||||||
| 965 | \fn void QGuiApplication::screenRemoved(QScreen *screen) | - | ||||||||||||||||||
| 966 | - | |||||||||||||||||||
| 967 | This signal is emitted whenever a \a screen is removed from the system. It | - | ||||||||||||||||||
| 968 | provides an opportunity to manage the windows on the screen before Qt falls back | - | ||||||||||||||||||
| 969 | to moving them to the primary screen. | - | ||||||||||||||||||
| 970 | - | |||||||||||||||||||
| 971 | \sa screens(), screenAdded(), QObject::destroyed(), QWindow::setScreen() | - | ||||||||||||||||||
| 972 | - | |||||||||||||||||||
| 973 | \since 5.4 | - | ||||||||||||||||||
| 974 | */ | - | ||||||||||||||||||
| 975 | - | |||||||||||||||||||
| 976 | - | |||||||||||||||||||
| 977 | /*! | - | ||||||||||||||||||
| 978 | \property QGuiApplication::primaryScreen | - | ||||||||||||||||||
| 979 | - | |||||||||||||||||||
| 980 | \brief the primary (or default) screen of the application. | - | ||||||||||||||||||
| 981 | - | |||||||||||||||||||
| 982 | This will be the screen where QWindows are initially shown, unless otherwise specified. | - | ||||||||||||||||||
| 983 | - | |||||||||||||||||||
| 984 | The primaryScreenChanged signal was introduced in Qt 5.6. | - | ||||||||||||||||||
| 985 | - | |||||||||||||||||||
| 986 | \sa screens() | - | ||||||||||||||||||
| 987 | */ | - | ||||||||||||||||||
| 988 | - | |||||||||||||||||||
| 989 | /*! | - | ||||||||||||||||||
| 990 | Returns the highest screen device pixel ratio found on | - | ||||||||||||||||||
| 991 | the system. This is the ratio between physical pixels and | - | ||||||||||||||||||
| 992 | device-independent pixels. | - | ||||||||||||||||||
| 993 | - | |||||||||||||||||||
| 994 | Use this function only when you don't know which window you are targeting. | - | ||||||||||||||||||
| 995 | If you do know the target window, use QWindow::devicePixelRatio() instead. | - | ||||||||||||||||||
| 996 | - | |||||||||||||||||||
| 997 | \sa QWindow::devicePixelRatio() | - | ||||||||||||||||||
| 998 | */ | - | ||||||||||||||||||
| 999 | qreal QGuiApplication::devicePixelRatio() const | - | ||||||||||||||||||
| 1000 | { | - | ||||||||||||||||||
| 1001 | // Cache topDevicePixelRatio, iterate through the screen list once only. | - | ||||||||||||||||||
| 1002 | static qreal topDevicePixelRatio = 0.0; | - | ||||||||||||||||||
| 1003 | if (!qFuzzyIsNull(topDevicePixelRatio)) {
| 0 | ||||||||||||||||||
| 1004 | return topDevicePixelRatio; never executed: return topDevicePixelRatio; | 0 | ||||||||||||||||||
| 1005 | } | - | ||||||||||||||||||
| 1006 | - | |||||||||||||||||||
| 1007 | topDevicePixelRatio = 1.0; // make sure we never return 0. | - | ||||||||||||||||||
| 1008 | foreachfor (QScreen *screen ,: qAsConst(QGuiApplicationPrivate::screen_list) {)) | - | ||||||||||||||||||
| 1009 | topDevicePixelRatio = qMax(topDevicePixelRatio, screen->devicePixelRatio()); never executed: topDevicePixelRatio = qMax(topDevicePixelRatio, screen->devicePixelRatio()); | 0 | ||||||||||||||||||
| 1010 | - | |||||||||||||||||||
| 1011 | }return topDevicePixelRatio; never executed: return topDevicePixelRatio; | 0 | ||||||||||||||||||
| 1012 | } | - | ||||||||||||||||||
| 1013 | - | |||||||||||||||||||
| 1014 | /*! | - | ||||||||||||||||||
| 1015 | Returns the top level window at the given position \a pos, if any. | - | ||||||||||||||||||
| 1016 | */ | - | ||||||||||||||||||
| 1017 | QWindow *QGuiApplication::topLevelAt(const QPoint &pos) | - | ||||||||||||||||||
| 1018 | { | - | ||||||||||||||||||
| 1019 | const QList<QScreen *> screens = QGuiApplication::screens(); | - | ||||||||||||||||||
| 1020 | if (!screens.isEmpty()) {
| 0 | ||||||||||||||||||
| 1021 | const QList<QScreen *> primaryScreens = screens.first()->virtualSiblings(); | - | ||||||||||||||||||
| 1022 | QScreen *windowScreen = Q_NULLPTR; | - | ||||||||||||||||||
| 1023 | - | |||||||||||||||||||
| 1024 | // Find the window on the primary virtual desktop first | - | ||||||||||||||||||
| 1025 | foreachfor (QScreen *screen ,: primaryScreens) { | - | ||||||||||||||||||
| 1026 | if (screen->geometry().contains(pos)) {
| 0 | ||||||||||||||||||
| 1027 | windowScreen = screen; | - | ||||||||||||||||||
| 1028 | break; never executed: break; | 0 | ||||||||||||||||||
| 1029 | } | - | ||||||||||||||||||
| 1030 | } never executed: end of block | 0 | ||||||||||||||||||
| 1031 | - | |||||||||||||||||||
| 1032 | // If the window is not found on primary virtual desktop, find it on all screens | - | ||||||||||||||||||
| 1033 | // except the first which was for sure in the previous loop. Some other screens | - | ||||||||||||||||||
| 1034 | // may repeat. Find only when there is more than one virtual desktop. | - | ||||||||||||||||||
| 1035 | if (!windowScreen && screens.count() != primaryScreens.count()) {
| 0 | ||||||||||||||||||
| 1036 | for (int i = 1; i < screens.size(); ++i) {
| 0 | ||||||||||||||||||
| 1037 | QScreen *screen = screens[.at(i];); | - | ||||||||||||||||||
| 1038 | if (screen->geometry().contains(pos)) {
| 0 | ||||||||||||||||||
| 1039 | windowScreen = screen; | - | ||||||||||||||||||
| 1040 | break; never executed: break; | 0 | ||||||||||||||||||
| 1041 | } | - | ||||||||||||||||||
| 1042 | } never executed: end of block | 0 | ||||||||||||||||||
| 1043 | } never executed: end of block | 0 | ||||||||||||||||||
| 1044 | - | |||||||||||||||||||
| 1045 | if (windowScreen) {
| 0 | ||||||||||||||||||
| 1046 | const QPoint devicePosition = QHighDpi::toNativePixels(pos, windowScreen); | - | ||||||||||||||||||
| 1047 | return windowScreen->handle()->topLevelAt(devicePosition); never executed: return windowScreen->handle()->topLevelAt(devicePosition); | 0 | ||||||||||||||||||
| 1048 | } | - | ||||||||||||||||||
| 1049 | } never executed: end of block | 0 | ||||||||||||||||||
| 1050 | return Q_NULLPTR; never executed: return nullptr; | 0 | ||||||||||||||||||
| 1051 | } | - | ||||||||||||||||||
| 1052 | - | |||||||||||||||||||
| 1053 | /*! | - | ||||||||||||||||||
| 1054 | \property QGuiApplication::platformName | - | ||||||||||||||||||
| 1055 | \brief The name of the underlying platform plugin. | - | ||||||||||||||||||
| 1056 | - | |||||||||||||||||||
| 1057 | The QPA platform plugins are located in \c {qtbase\src\plugins\platforms}. | - | ||||||||||||||||||
| 1058 | At the time of writing, the following platform plugin names are supported: | - | ||||||||||||||||||
| 1059 | - | |||||||||||||||||||
| 1060 | \list | - | ||||||||||||||||||
| 1061 | \li \c android | - | ||||||||||||||||||
| 1062 | \li \c cocoa is a platform plugin for \macos. | - | ||||||||||||||||||
| 1063 | \li \c directfb | - | ||||||||||||||||||
| 1064 | \li \c eglfs is a platform plugin for running Qt5 applications on top of | - | ||||||||||||||||||
| 1065 | EGL and OpenGL ES 2.0 without an actual windowing system (like X11 | - | ||||||||||||||||||
| 1066 | or Wayland). For more information, see \l{EGLFS}. | - | ||||||||||||||||||
| 1067 | \li \c ios | - | ||||||||||||||||||
| 1068 | \li \c kms is an experimental platform plugin using kernel modesetting | - | ||||||||||||||||||
| 1069 | and \l{http://dri.freedesktop.org/wiki/DRM}{DRM} (Direct Rendering | - | ||||||||||||||||||
| 1070 | Manager). | - | ||||||||||||||||||
| 1071 | \li \c linuxfb writes directly to the framebuffer. For more information, | - | ||||||||||||||||||
| 1072 | see \l{LinuxFB}. | - | ||||||||||||||||||
| 1073 | \li \c minimal is provided as an examples for developers who want to | - | ||||||||||||||||||
| 1074 | write their own platform plugins. However, you can use the plugin to | - | ||||||||||||||||||
| 1075 | run GUI applications in environments without a GUI, such as servers. | - | ||||||||||||||||||
| 1076 | \li \c minimalegl is an example plugin. | - | ||||||||||||||||||
| 1077 | \li \c offscreen | - | ||||||||||||||||||
| 1078 | \li \c openwfd | - | ||||||||||||||||||
| 1079 | \li \c qnx | - | ||||||||||||||||||
| 1080 | \li \c windows | - | ||||||||||||||||||
| 1081 | \li \c xcb is the X11 plugin used on regular desktop Linux platforms. | - | ||||||||||||||||||
| 1082 | \endlist | - | ||||||||||||||||||
| 1083 | - | |||||||||||||||||||
| 1084 | For more information about the platform plugins for embedded Linux devices, | - | ||||||||||||||||||
| 1085 | see \l{Qt for Embedded Linux}. | - | ||||||||||||||||||
| 1086 | */ | - | ||||||||||||||||||
| 1087 | - | |||||||||||||||||||
| 1088 | QString QGuiApplication::platformName() | - | ||||||||||||||||||
| 1089 | { | - | ||||||||||||||||||
| 1090 | return QGuiApplicationPrivate::platform_name ? | - | ||||||||||||||||||
| 1091 | *QGuiApplicationPrivate::platform_name : QString(); | - | ||||||||||||||||||
| 1092 | } | - | ||||||||||||||||||
| 1093 | - | |||||||||||||||||||
| 1094 | static void init_platform(const QString &pluginArgument, const QString &platformPluginPath, const QString &platformThemeName, int &argc, char **argv) | - | ||||||||||||||||||
| 1095 | { | - | ||||||||||||||||||
| 1096 | // Split into platform name and arguments | - | ||||||||||||||||||
| 1097 | QStringList arguments = pluginArgument.split(QLatin1Char(':')); | - | ||||||||||||||||||
| 1098 | const QString name = arguments.takeFirst().toLower(); | - | ||||||||||||||||||
| 1099 | QString argumentsKey = name; | - | ||||||||||||||||||
| 1100 | argumentsKey[0] = argumentsKey.at(0).toUpper(); | - | ||||||||||||||||||
| 1101 | arguments.append(QLibraryInfo::platformPluginArguments(argumentsKey)); | - | ||||||||||||||||||
| 1102 | - | |||||||||||||||||||
| 1103 | // Create the platform integration. | - | ||||||||||||||||||
| 1104 | QGuiApplicationPrivate::platform_integration = QPlatformIntegrationFactory::create(name, arguments, argc, argv, platformPluginPath); | - | ||||||||||||||||||
| 1105 | if (Q_UNLIKELY(!QGuiApplicationPrivate::platform_integration) {
| 0 | ||||||||||||||||||
QGuiApplicationPrivate::platform_name = new QString(name);
| ||||||||||||||||||||
} else
| ||||||||||||||||||||
| 1106 | QStringList keys = QPlatformIntegrationFactory::keys(platformPluginPath); | - | ||||||||||||||||||
| 1107 | - | |||||||||||||||||||
| 1108 | QString fatalMessage | - | ||||||||||||||||||
| 1109 | = QStringLiteral("This application failed to start because it could not find or load the Qt platform plugin \"%1\"\nin \"%2\".\n\n").arg(name, QDir::toNativeSeparators(platformPluginPath)); | - | ||||||||||||||||||
| 1110 | if (!keys.isEmpty()) {
| 0 | ||||||||||||||||||
| 1111 | fatalMessage += QStringLiteral("Available platform plugins are: %1.\n\n").arg( never executed: return qstring_literal_temp; | 0 | ||||||||||||||||||
| 1112 | keys.join(QStringLiteral(", "))); never executed: return qstring_literal_temp; | 0 | ||||||||||||||||||
| 1113 | } never executed: end of block | 0 | ||||||||||||||||||
| 1114 | fatalMessage += QStringLiteral("Reinstalling the application may fix this problem."); never executed: return qstring_literal_temp; | 0 | ||||||||||||||||||
| 1115 | #if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT) | - | ||||||||||||||||||
| 1116 | // Windows: Display message box unless it is a console application | - | ||||||||||||||||||
| 1117 | // or debug build showing an assert box. | - | ||||||||||||||||||
| 1118 | if (!QLibraryInfo::isDebugBuild() && !GetConsoleWindow()) | - | ||||||||||||||||||
| 1119 | MessageBox(0, (LPCTSTR)fatalMessage.utf16(), (LPCTSTR)(QCoreApplication::applicationName().utf16()), MB_OK | MB_ICONERROR); | - | ||||||||||||||||||
| 1120 | #endif // Q_OS_WIN && !Q_OS_WINCE && !Q_OS_WINRT | - | ||||||||||||||||||
| 1121 | qFatal("%s", qPrintable(fatalMessage)); | - | ||||||||||||||||||
| 1122 | return; never executed: return; | 0 | ||||||||||||||||||
| 1123 | } | - | ||||||||||||||||||
| 1124 | - | |||||||||||||||||||
| 1125 | QGuiApplicationPrivate::platform_name = new QString(name); | - | ||||||||||||||||||
| 1126 | - | |||||||||||||||||||
| 1127 | // Many platforms have created QScreens at this point. Finish initializing | - | ||||||||||||||||||
| 1128 | // QHighDpiScaling to be prepared for early calls to qt_defaultDpi(). | - | ||||||||||||||||||
| 1129 | if (QGuiApplication::primaryScreen()) {
| 0 | ||||||||||||||||||
| 1130 | QGuiApplicationPrivate::highDpiScalingUpdated = true; | - | ||||||||||||||||||
| 1131 | QHighDpiScaling::updateHighDpiScaling(); | - | ||||||||||||||||||
| 1132 | } never executed: end of block | 0 | ||||||||||||||||||
| 1133 | - | |||||||||||||||||||
| 1134 | // Create the platform theme: | - | ||||||||||||||||||
| 1135 | - | |||||||||||||||||||
| 1136 | // 1) Fetch the platform name from the environment if present. | - | ||||||||||||||||||
| 1137 | QStringList themeNames; | - | ||||||||||||||||||
| 1138 | if (!platformThemeName.isEmpty())
| 0 | ||||||||||||||||||
| 1139 | themeNames.append(platformThemeName); never executed: themeNames.append(platformThemeName); | 0 | ||||||||||||||||||
| 1140 | - | |||||||||||||||||||
| 1141 | // 2) Ask the platform integration for a list of theme names | - | ||||||||||||||||||
| 1142 | themeNames += QGuiApplicationPrivate::platform_integration->themeNames(); | - | ||||||||||||||||||
| 1143 | // 3) Look for a theme plugin. | - | ||||||||||||||||||
| 1144 | foreachfor (const QString &themeName ,: qAsConst(themeNames))) { | - | ||||||||||||||||||
| 1145 | QGuiApplicationPrivate::platform_theme = QPlatformThemeFactory::create(themeName, platformPluginPath); | - | ||||||||||||||||||
| 1146 | if (QGuiApplicationPrivate::platform_theme)
| 0 | ||||||||||||||||||
| 1147 | break; never executed: break; | 0 | ||||||||||||||||||
| 1148 | } never executed: end of block | 0 | ||||||||||||||||||
| 1149 | - | |||||||||||||||||||
| 1150 | // 4) If no theme plugin was found ask the platform integration to | - | ||||||||||||||||||
| 1151 | // create a theme | - | ||||||||||||||||||
| 1152 | if (!QGuiApplicationPrivate::platform_theme) {
| 0 | ||||||||||||||||||
| 1153 | foreachfor (const QString &themeName ,: qAsConst(themeNames))) { | - | ||||||||||||||||||
| 1154 | QGuiApplicationPrivate::platform_theme = QGuiApplicationPrivate::platform_integration->createPlatformTheme(themeName); | - | ||||||||||||||||||
| 1155 | if (QGuiApplicationPrivate::platform_theme)
| 0 | ||||||||||||||||||
| 1156 | break; never executed: break; | 0 | ||||||||||||||||||
| 1157 | } never executed: end of block | 0 | ||||||||||||||||||
| 1158 | // No error message; not having a theme plugin is allowed. | - | ||||||||||||||||||
| 1159 | } never executed: end of block | 0 | ||||||||||||||||||
| 1160 | - | |||||||||||||||||||
| 1161 | // 5) Fall back on the built-in "null" platform theme. | - | ||||||||||||||||||
| 1162 | if (!QGuiApplicationPrivate::platform_theme)
| 0 | ||||||||||||||||||
| 1163 | QGuiApplicationPrivate::platform_theme = new QPlatformTheme; never executed: QGuiApplicationPrivate::platform_theme = new QPlatformTheme; | 0 | ||||||||||||||||||
| 1164 | - | |||||||||||||||||||
| 1165 | #ifndef QT_NO_PROPERTIES | - | ||||||||||||||||||
| 1166 | // Set arguments as dynamic properties on the native interface as | - | ||||||||||||||||||
| 1167 | // boolean 'foo' or strings: 'foo=bar' | - | ||||||||||||||||||
| 1168 | if (!arguments.isEmpty()) {
| 0 | ||||||||||||||||||
| 1169 | if (QObject *nativeInterface = QGuiApplicationPrivate::platform_integration->nativeInterface()) {
| 0 | ||||||||||||||||||
| 1170 | foreachfor (const QString &argument ,: qAsConst(arguments))) { | - | ||||||||||||||||||
| 1171 | const int equalsPos = argument.indexOf(QLatin1Char('=')); | - | ||||||||||||||||||
| 1172 | const QByteArray name = | - | ||||||||||||||||||
| 1173 | equalsPos != -1 ? argument.left(equalsPos).toUtf8() : argument.toUtf8();
| 0 | ||||||||||||||||||
| 1174 | const QVariant value = | - | ||||||||||||||||||
| 1175 | equalsPos != -1 ? QVariant(argument.mid(equalsPos + 1)) : QVariant(true);
| 0 | ||||||||||||||||||
| 1176 | nativeInterface->setProperty(name.constData(), value); | - | ||||||||||||||||||
| 1177 | } never executed: end of block | 0 | ||||||||||||||||||
| 1178 | } never executed: end of block | 0 | ||||||||||||||||||
| 1179 | } never executed: end of block | 0 | ||||||||||||||||||
| 1180 | #endif | - | ||||||||||||||||||
| 1181 | - | |||||||||||||||||||
| 1182 | fontSmoothingGamma = QGuiApplicationPrivate::platformIntegration()->styleHint(QPlatformIntegration::FontSmoothingGamma).toReal(); | - | ||||||||||||||||||
| 1183 | } never executed: end of block | 0 | ||||||||||||||||||
| 1184 | - | |||||||||||||||||||
| 1185 | static void init_plugins(const QList<QByteArray> &pluginList) | - | ||||||||||||||||||
| 1186 | { | - | ||||||||||||||||||
| 1187 | for (int i = 0; i < pluginList.count(); ++i) { | - | ||||||||||||||||||
| 1188 | QByteArray pluginSpec = pluginList.at(i); | - | ||||||||||||||||||
| 1189 | int colonPos = pluginSpec.indexOf(':'); | - | ||||||||||||||||||
| 1190 | QObject *plugin; | - | ||||||||||||||||||
| 1191 | if (colonPos < 0) | - | ||||||||||||||||||
| 1192 | plugin = QGenericPluginFactory::create(QLatin1String(pluginSpec), QString()); | - | ||||||||||||||||||
| 1193 | else | - | ||||||||||||||||||
| 1194 | plugin = QGenericPluginFactory::create(QLatin1String(pluginSpec.mid(0, colonPos)), | - | ||||||||||||||||||
| 1195 | QLatin1String(pluginSpec.mid(colonPos+1))); | - | ||||||||||||||||||
| 1196 | if (plugin) | - | ||||||||||||||||||
| 1197 | QGuiApplicationPrivate::generic_plugin_list.append(plugin); | - | ||||||||||||||||||
| 1198 | else | - | ||||||||||||||||||
| 1199 | qWarning() << "No such plugin for spec " << pluginSpec; | - | ||||||||||||||||||
| 1200 | } | - | ||||||||||||||||||
| 1201 | } | - | ||||||||||||||||||
| 1202 | - | |||||||||||||||||||
| 1203 | void QGuiApplicationPrivate::createPlatformIntegration() | - | ||||||||||||||||||
| 1204 | { | - | ||||||||||||||||||
| 1205 | QCoreApplication::setAttribute(Qt::AA_DontUseNativeMenuBar, true);QHighDpiScaling::initHighDpiScaling(); | - | ||||||||||||||||||
| 1206 | - | |||||||||||||||||||
| 1207 | // Load the platform integration | - | ||||||||||||||||||
| 1208 | QString platformPluginPath = QString::fromLocal8Bit(qgetenv("QT_QPA_PLATFORM_PLUGIN_PATH")); | - | ||||||||||||||||||
| 1209 | - | |||||||||||||||||||
| 1210 | - | |||||||||||||||||||
| 1211 | QByteArray platformName; | - | ||||||||||||||||||
| 1212 | #ifdef QT_QPA_DEFAULT_PLATFORM_NAME | - | ||||||||||||||||||
| 1213 | platformName = QT_QPA_DEFAULT_PLATFORM_NAME; | - | ||||||||||||||||||
| 1214 | #endif | - | ||||||||||||||||||
| 1215 | QByteArray platformNameEnv = qgetenv("QT_QPA_PLATFORM"); | - | ||||||||||||||||||
| 1216 | if (!platformNameEnv.isEmpty()) {
| 0 | ||||||||||||||||||
| 1217 | platformName = platformNameEnv; | - | ||||||||||||||||||
| 1218 | } never executed: end of block | 0 | ||||||||||||||||||
| 1219 | - | |||||||||||||||||||
| 1220 | QString platformThemeName = QString::fromLocal8Bit(qgetenv("QT_QPA_PLATFORMTHEME")); | - | ||||||||||||||||||
| 1221 | - | |||||||||||||||||||
| 1222 | // Get command line params | - | ||||||||||||||||||
| 1223 | - | |||||||||||||||||||
| 1224 | QString icon; | - | ||||||||||||||||||
| 1225 | - | |||||||||||||||||||
| 1226 | int j = argc ? 1 : 0;
| 0 | ||||||||||||||||||
| 1227 | for (int i=1; i<argc; i++) {
| 0 | ||||||||||||||||||
| 1228 | if (!argv[i])
| 0 | ||||||||||||||||||
| 1229 | continue; never executed: continue; | 0 | ||||||||||||||||||
| 1230 | if (*argv[i] != '-') {
| 0 | ||||||||||||||||||
| 1231 | argv[j++] = argv[i]; | - | ||||||||||||||||||
| 1232 | continue; never executed: continue; | 0 | ||||||||||||||||||
| 1233 | } | - | ||||||||||||||||||
| 1234 | const bool isXcb = platformName == "xcb"; | - | ||||||||||||||||||
| 1235 | const char *arg = argv[i]; | - | ||||||||||||||||||
| 1236 | if (arg[1] == '-') // startsWith("--")
| 0 | ||||||||||||||||||
| 1237 | ++arg; never executed: ++arg; | 0 | ||||||||||||||||||
| 1238 | if (strcmp(arg, "-platformpluginpath") == 0) {
| 0 | ||||||||||||||||||
| 1239 | if (++i < argc)
| 0 | ||||||||||||||||||
| 1240 | platformPluginPath = QString::fromLocal8Bit(argv[i]); never executed: platformPluginPath = QString::fromLocal8Bit(argv[i]); | 0 | ||||||||||||||||||
| 1241 | } else if (strcmp(arg, "-platform") == 0) { never executed: end of block
| 0 | ||||||||||||||||||
| 1242 | if (++i < argc)
| 0 | ||||||||||||||||||
| 1243 | platformName = argv[i]; never executed: platformName = argv[i]; | 0 | ||||||||||||||||||
| 1244 | } else if (strcmp(arg, "-platformtheme") == 0) { never executed: end of block
| 0 | ||||||||||||||||||
| 1245 | if (++i < argc)
| 0 | ||||||||||||||||||
| 1246 | platformThemeName = QString::fromLocal8Bit(argv[i]); never executed: platformThemeName = QString::fromLocal8Bit(argv[i]); | 0 | ||||||||||||||||||
| 1247 | } else if (strcmp(arg, "-qwindowgeometry") == 0 || (isXcb && strcmp(arg, "-geometry") == 0)) { never executed: end of block
| 0 | ||||||||||||||||||
| 1248 | if (++i < argc)
| 0 | ||||||||||||||||||
| 1249 | windowGeometrySpecification = QWindowGeometrySpecification::fromArgument(argv[i]); never executed: windowGeometrySpecification = QWindowGeometrySpecification::fromArgument(argv[i]); | 0 | ||||||||||||||||||
| 1250 | } else if (strcmp(arg, "-qwindowtitle") == 0 || (isXcb && strcmp(arg, "-title") == 0)) { never executed: end of block
| 0 | ||||||||||||||||||
| 1251 | if (++i < argc)
| 0 | ||||||||||||||||||
| 1252 | firstWindowTitle = QString::fromLocal8Bit(argv[i]); never executed: firstWindowTitle = QString::fromLocal8Bit(argv[i]); | 0 | ||||||||||||||||||
| 1253 | } else if (strcmp(arg, "-qwindowicon") == 0 || (isXcb && strcmp(arg, "-icon") == 0)) { never executed: end of block
| 0 | ||||||||||||||||||
| 1254 | if (++i < argc) {
| 0 | ||||||||||||||||||
| 1255 | icon = QString::fromLocal8Bit(argv[i]); | - | ||||||||||||||||||
| 1256 | } never executed: end of block | 0 | ||||||||||||||||||
| 1257 | } else { never executed: end of block | 0 | ||||||||||||||||||
| 1258 | argv[j++] = argv[i]; | - | ||||||||||||||||||
| 1259 | } never executed: end of block | 0 | ||||||||||||||||||
| 1260 | } | - | ||||||||||||||||||
| 1261 | - | |||||||||||||||||||
| 1262 | if (j < argc) {
| 0 | ||||||||||||||||||
| 1263 | argv[j] = 0; | - | ||||||||||||||||||
| 1264 | argc = j; | - | ||||||||||||||||||
| 1265 | } never executed: end of block | 0 | ||||||||||||||||||
| 1266 | - | |||||||||||||||||||
| 1267 | init_platform(QLatin1String(platformName), platformPluginPath, platformThemeName, argc, argv); | - | ||||||||||||||||||
| 1268 | - | |||||||||||||||||||
| 1269 | if (!icon.isEmpty())
| 0 | ||||||||||||||||||
| 1270 | forcedWindowIcon = QDir::isAbsolutePath(icon) ? QIcon(icon) : QIcon::fromTheme(icon); never executed: forcedWindowIcon = QDir::isAbsolutePath(icon) ? QIcon(icon) : QIcon::fromTheme(icon);
| 0 | ||||||||||||||||||
| 1271 | } never executed: end of block | 0 | ||||||||||||||||||
| 1272 | - | |||||||||||||||||||
| 1273 | /*! | - | ||||||||||||||||||
| 1274 | Called from QCoreApplication::init() | - | ||||||||||||||||||
| 1275 | - | |||||||||||||||||||
| 1276 | Responsible for creating an event dispatcher when QCoreApplication | - | ||||||||||||||||||
| 1277 | decides that it needs one (because a custom one has not been set). | - | ||||||||||||||||||
| 1278 | */ | - | ||||||||||||||||||
| 1279 | void QGuiApplicationPrivate::createEventDispatcher() | - | ||||||||||||||||||
| 1280 | { | - | ||||||||||||||||||
| 1281 | Q_ASSERT(!eventDispatcher); | - | ||||||||||||||||||
| 1282 | - | |||||||||||||||||||
| 1283 | if (platform_integration == 0) | - | ||||||||||||||||||
| 1284 | createPlatformIntegration(); | - | ||||||||||||||||||
| 1285 | - | |||||||||||||||||||
| 1286 | // The platform integration should not mess with the event dispatcher | - | ||||||||||||||||||
| 1287 | Q_ASSERT(!eventDispatcher); | - | ||||||||||||||||||
| 1288 | - | |||||||||||||||||||
| 1289 | eventDispatcher = platform_integration->createEventDispatcher(); | - | ||||||||||||||||||
| 1290 | } | - | ||||||||||||||||||
| 1291 | - | |||||||||||||||||||
| 1292 | void QGuiApplicationPrivate::eventDispatcherReady() | - | ||||||||||||||||||
| 1293 | { | - | ||||||||||||||||||
| 1294 | if (platform_integration == 0) | - | ||||||||||||||||||
| 1295 | createPlatformIntegration(); | - | ||||||||||||||||||
| 1296 | - | |||||||||||||||||||
| 1297 | platform_integration->initialize(); | - | ||||||||||||||||||
| 1298 | - | |||||||||||||||||||
| 1299 | // All platforms should have added screens at this point. Finish | - | ||||||||||||||||||
| 1300 | // QHighDpiScaling initialization if it has not been done so already. | - | ||||||||||||||||||
| 1301 | if (!QGuiApplicationPrivate::highDpiScalingUpdated) | - | ||||||||||||||||||
| 1302 | QHighDpiScaling::updateHighDpiScaling(); | - | ||||||||||||||||||
| 1303 | } | - | ||||||||||||||||||
| 1304 | - | |||||||||||||||||||
| 1305 | void QGuiApplicationPrivate::init() | - | ||||||||||||||||||
| 1306 | { | - | ||||||||||||||||||
| 1307 | QCoreApplicationPrivate::init(); | - | ||||||||||||||||||
| 1308 | - | |||||||||||||||||||
| 1309 | QCoreApplicationPrivate::is_app_running = false; // Starting up. | - | ||||||||||||||||||
| 1310 | - | |||||||||||||||||||
| 1311 | bool loadTestability = false; | - | ||||||||||||||||||
| 1312 | QList<QByteArray> pluginList; | - | ||||||||||||||||||
| 1313 | // Get command line params | - | ||||||||||||||||||
| 1314 | #ifndef QT_NO_SESSIONMANAGER | - | ||||||||||||||||||
| 1315 | QString session_id; | - | ||||||||||||||||||
| 1316 | QString session_key; | - | ||||||||||||||||||
| 1317 | # if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) | - | ||||||||||||||||||
| 1318 | wchar_t guidstr[40]; | - | ||||||||||||||||||
| 1319 | GUID guid; | - | ||||||||||||||||||
| 1320 | CoCreateGuid(&guid); | - | ||||||||||||||||||
| 1321 | StringFromGUID2(guid, guidstr, 40); | - | ||||||||||||||||||
| 1322 | session_id = QString::fromWCharArray(guidstr); | - | ||||||||||||||||||
| 1323 | CoCreateGuid(&guid); | - | ||||||||||||||||||
| 1324 | StringFromGUID2(guid, guidstr, 40); | - | ||||||||||||||||||
| 1325 | session_key = QString::fromWCharArray(guidstr); | - | ||||||||||||||||||
| 1326 | # endif | - | ||||||||||||||||||
| 1327 | #endif | - | ||||||||||||||||||
| 1328 | QString s; | - | ||||||||||||||||||
| 1329 | int j = argc ? 1 : 0;
| 0 | ||||||||||||||||||
| 1330 | for (int i=1; i<argc; i++) {
| 0 | ||||||||||||||||||
| 1331 | if (!argv[i])
| 0 | ||||||||||||||||||
| 1332 | continue; never executed: continue; | 0 | ||||||||||||||||||
| 1333 | if (*argv[i] != '-') {
| 0 | ||||||||||||||||||
| 1334 | argv[j++] = argv[i]; | - | ||||||||||||||||||
| 1335 | continue; never executed: continue; | 0 | ||||||||||||||||||
| 1336 | } | - | ||||||||||||||||||
| 1337 | const char *arg = argv[i]; | - | ||||||||||||||||||
| 1338 | if (arg[1] == '-') // startsWith("--")
| 0 | ||||||||||||||||||
| 1339 | ++arg; never executed: ++arg; | 0 | ||||||||||||||||||
| 1340 | if (strcmp(arg, "-plugin") == 0) {
| 0 | ||||||||||||||||||
| 1341 | if (++i < argc)
| 0 | ||||||||||||||||||
| 1342 | pluginList << argv[i]; never executed: pluginList << argv[i]; | 0 | ||||||||||||||||||
| 1343 | } else if (strcmp(arg, "-reverse") == 0) { never executed: end of block
| 0 | ||||||||||||||||||
| 1344 | force_reverse = true; | - | ||||||||||||||||||
| 1345 | #ifdef Q_OS_MAC | - | ||||||||||||||||||
| 1346 | } else if (strncmp(arg, "-psn_", 5) == 0) { | - | ||||||||||||||||||
| 1347 | // eat "-psn_xxxx" on Mac, which is passed when starting an app from Finder. | - | ||||||||||||||||||
| 1348 | // special hack to change working directory (for an app bundle) when running from finder | - | ||||||||||||||||||
| 1349 | if (QDir::currentPath() == QLatin1String("/")) { | - | ||||||||||||||||||
| 1350 | QCFType<CFURLRef> bundleURL(CFBundleCopyBundleURL(CFBundleGetMainBundle())); | - | ||||||||||||||||||
| 1351 | QString qbundlePath = QCFString(CFURLCopyFileSystemPath(bundleURL, | - | ||||||||||||||||||
| 1352 | kCFURLPOSIXPathStyle)); | - | ||||||||||||||||||
| 1353 | if (qbundlePath.endsWith(QLatin1String(".app"))) | - | ||||||||||||||||||
| 1354 | QDir::setCurrent(qbundlePath.section(QLatin1Char('/'), 0, -2)); | - | ||||||||||||||||||
| 1355 | } | - | ||||||||||||||||||
| 1356 | #endif | - | ||||||||||||||||||
| 1357 | #ifndef QT_NO_SESSIONMANAGER | - | ||||||||||||||||||
| 1358 | } else if (strcmp(arg, "-session") == 0 && i < argc - 1) { never executed: end of block
| 0 | ||||||||||||||||||
| 1359 | ++i; | - | ||||||||||||||||||
| 1360 | if (argv[i] && *argv[i]) {
| 0 | ||||||||||||||||||
| 1361 | session_id = QString::fromLatin1(argv[i]); | - | ||||||||||||||||||
| 1362 | int p = session_id.indexOf(QLatin1Char('_')); | - | ||||||||||||||||||
| 1363 | if (p >= 0) {
| 0 | ||||||||||||||||||
| 1364 | session_key = session_id.mid(p +1); | - | ||||||||||||||||||
| 1365 | session_id = session_id.left(p); | - | ||||||||||||||||||
| 1366 | } never executed: end of block | 0 | ||||||||||||||||||
| 1367 | is_session_restored = true; | - | ||||||||||||||||||
| 1368 | } never executed: end of block | 0 | ||||||||||||||||||
| 1369 | #endif | - | ||||||||||||||||||
| 1370 | } else if (strcmp(arg, "-testability") == 0) { never executed: end of block
| 0 | ||||||||||||||||||
| 1371 | loadTestability = true; | - | ||||||||||||||||||
| 1372 | } else if (strncmp(arg, "-style=", 7) == 0) { never executed: end of block
| 0 | ||||||||||||||||||
| 1373 | s = QString::fromLocal8Bit(arg + 7).toLower();); | - | ||||||||||||||||||
| 1374 | } else if (strcmp(arg, "-style") == 0 && i < argc - 1) { never executed: end of block
| 0 | ||||||||||||||||||
| 1375 | s = QString::fromLocal8Bit(argv[++i]).toLower();]); | - | ||||||||||||||||||
| 1376 | } else { never executed: end of block | 0 | ||||||||||||||||||
| 1377 | argv[j++] = argv[i]; | - | ||||||||||||||||||
| 1378 | } never executed: end of block | 0 | ||||||||||||||||||
| 1379 | - | |||||||||||||||||||
| 1380 | if (!s.isEmpty())
| 0 | ||||||||||||||||||
| 1381 | styleOverride = s; never executed: styleOverride = s; | 0 | ||||||||||||||||||
| 1382 | } never executed: end of block | 0 | ||||||||||||||||||
| 1383 | - | |||||||||||||||||||
| 1384 | if (j < argc) {
| 0 | ||||||||||||||||||
| 1385 | argv[j] = 0; | - | ||||||||||||||||||
| 1386 | argc = j; | - | ||||||||||||||||||
| 1387 | } never executed: end of block | 0 | ||||||||||||||||||
| 1388 | - | |||||||||||||||||||
| 1389 | // Load environment exported generic plugins | - | ||||||||||||||||||
| 1390 | QByteArray envPlugins = qgetenv("QT_QPA_GENERIC_PLUGINS"); | - | ||||||||||||||||||
| 1391 | if (!envPlugins.isEmpty())
| 0 | ||||||||||||||||||
| 1392 | { never executed: pluginList += envPlugins.split(','); | 0 | ||||||||||||||||||
| foreach (const QByteArray &plugin, never executed: pluginList += envPlugins.split(','))pluginList += envPlugins.split(',');never executed: pluginList += envPlugins.split(','); | ||||||||||||||||||||
| pluginList << plugin; never executed: pluginList += envPlugins.split(','); | ||||||||||||||||||||
| } never executed: );pluginList += envPlugins.split(',');never executed: pluginList += envPlugins.split(','); | ||||||||||||||||||||
| 1393 | - | |||||||||||||||||||
| 1394 | if (platform_integration == 0)
| 0 | ||||||||||||||||||
| 1395 | createPlatformIntegration(); never executed: createPlatformIntegration(); | 0 | ||||||||||||||||||
| 1396 | - | |||||||||||||||||||
| 1397 | initPalette(); | - | ||||||||||||||||||
| 1398 | QFont::initialize(); | - | ||||||||||||||||||
| 1399 | - | |||||||||||||||||||
| 1400 | mouse_double_click_distance = platformTheme()->themeHint(QPlatformTheme::MouseDoubleClickDistance).toInt(); | - | ||||||||||||||||||
| 1401 | - | |||||||||||||||||||
| 1402 | #ifndef QT_NO_CURSOR | - | ||||||||||||||||||
| 1403 | QCursorData::initialize(); | - | ||||||||||||||||||
| 1404 | #endif | - | ||||||||||||||||||
| 1405 | - | |||||||||||||||||||
| 1406 | // trigger registering of QVariant's GUI types | - | ||||||||||||||||||
| 1407 | qRegisterGuiVariant(); | - | ||||||||||||||||||
| 1408 | - | |||||||||||||||||||
| 1409 | #ifndef QT_NO_ANIMATION | - | ||||||||||||||||||
| 1410 | // trigger registering of animation interpolators | - | ||||||||||||||||||
| 1411 | qRegisterGuiGetInterpolator(); | - | ||||||||||||||||||
| 1412 | #endif | - | ||||||||||||||||||
| 1413 | - | |||||||||||||||||||
| 1414 | // set a global share context when enabled unless there is already one | - | ||||||||||||||||||
| 1415 | #ifndef QT_NO_OPENGL | - | ||||||||||||||||||
| 1416 | if (qApp->testAttribute(Qt::AA_ShareOpenGLContexts) && !qt_gl_global_share_context()) {
| 0 | ||||||||||||||||||
| 1417 | QOpenGLContext *ctx = new QOpenGLContext; | - | ||||||||||||||||||
| 1418 | ctx->setFormat(QSurfaceFormat::defaultFormat()); | - | ||||||||||||||||||
| 1419 | ctx->create(); | - | ||||||||||||||||||
| 1420 | qt_gl_set_global_share_context(ctx); | - | ||||||||||||||||||
| 1421 | ownGlobalShareContext = true; | - | ||||||||||||||||||
| 1422 | } never executed: end of block | 0 | ||||||||||||||||||
| 1423 | #endif | - | ||||||||||||||||||
| 1424 | - | |||||||||||||||||||
| 1425 | QWindowSystemInterfacePrivate::eventTime.start(); | - | ||||||||||||||||||
| 1426 | - | |||||||||||||||||||
| 1427 | is_app_running = true; | - | ||||||||||||||||||
| 1428 | init_plugins(pluginList); | - | ||||||||||||||||||
| 1429 | QWindowSystemInterface::flushWindowSystemEvents(); | - | ||||||||||||||||||
| 1430 | - | |||||||||||||||||||
| 1431 | #ifndef QT_NO_SESSIONMANAGER | - | ||||||||||||||||||
| 1432 | Q_Q(QGuiApplication); | - | ||||||||||||||||||
| 1433 | - | |||||||||||||||||||
| 1434 | // connect to the session manager | - | ||||||||||||||||||
| 1435 | session_manager = new QSessionManager(q, session_id, session_key); | - | ||||||||||||||||||
| 1436 | #endif | - | ||||||||||||||||||
| 1437 | - | |||||||||||||||||||
| 1438 | #ifndef QT_NO_LIBRARY | - | ||||||||||||||||||
| 1439 | if (qEnvironmentVariableIntValue("QT_LOAD_TESTABILITY") > 0)
| 0 | ||||||||||||||||||
| 1440 | loadTestability = true; never executed: loadTestability = true; | 0 | ||||||||||||||||||
| 1441 | - | |||||||||||||||||||
| 1442 | if (loadTestability) {
| 0 | ||||||||||||||||||
| 1443 | QLibrary testLib(QStringLiteral("qttestability")); | - | ||||||||||||||||||
| 1444 | if (Q_UNLIKELY(!testLib.load())())) {
| 0 | ||||||||||||||||||
| 1445 | qCritical() << "Library qttestability load failed:" << testLib.errorString(); | - | ||||||||||||||||||
| 1446 | } else never executed: {end of blocknever executed: end of block | 0 | ||||||||||||||||||
| 1447 | typedef void (*TasInitialize)(void); | - | ||||||||||||||||||
| 1448 | TasInitialize initFunction = (TasInitialize)testLib.resolve("qt_testability_init"); | - | ||||||||||||||||||
| 1449 | if (initFunction) {Q_UNLIKELY(!initFunction();
| 0 | ||||||||||||||||||
} else
| ||||||||||||||||||||
| 1450 | qCritical() << ("Library qttestability resolve failed!"; | - | ||||||||||||||||||
| }); | ||||||||||||||||||||
| 1451 | } else { never executed: end of block | 0 | ||||||||||||||||||
| 1452 | qCritical() << "Library qttestability load failed:" << testLib.errorStringinitFunction(); | - | ||||||||||||||||||
| 1453 | } never executed: end of block | 0 | ||||||||||||||||||
| 1454 | } | - | ||||||||||||||||||
| 1455 | } | - | ||||||||||||||||||
| 1456 | #else | - | ||||||||||||||||||
| 1457 | Q_UNUSED(loadTestability); | - | ||||||||||||||||||
| 1458 | #endif // QT_NO_LIBRARY | - | ||||||||||||||||||
| 1459 | - | |||||||||||||||||||
| 1460 | if (layout_direction == Qt::LayoutDirectionAuto || force_reverse)
| 0 | ||||||||||||||||||
| 1461 | QGuiApplication::setLayoutDirection(qt_detectRTLLanguage() ? Qt::RightToLeft : Qt::LeftToRight); never executed: QGuiApplication::setLayoutDirection(qt_detectRTLLanguage() ? Qt::RightToLeft : Qt::LeftToRight); | 0 | ||||||||||||||||||
| scrollNoPhaseAllowed = qEnvironmentVariableIsSet("QT_ENABLE_MOUSE_WHEEL_TRACKING" never executed: );QGuiApplication::setLayoutDirection(qt_detectRTLLanguage() ? Qt::RightToLeft : Qt::LeftToRight);never executed: QGuiApplication::setLayoutDirection(qt_detectRTLLanguage() ? Qt::RightToLeft : Qt::LeftToRight); | ||||||||||||||||||||
| 1462 | } never executed: end of block | 0 | ||||||||||||||||||
| 1463 | - | |||||||||||||||||||
| 1464 | extern void qt_cleanupFontDatabase(); | - | ||||||||||||||||||
| 1465 | - | |||||||||||||||||||
| 1466 | QGuiApplicationPrivate::~QGuiApplicationPrivate() | - | ||||||||||||||||||
| 1467 | { | - | ||||||||||||||||||
| 1468 | is_app_closing = true; | - | ||||||||||||||||||
| 1469 | is_app_running = false; | - | ||||||||||||||||||
| 1470 | - | |||||||||||||||||||
| 1471 | for (int i = 0; i < generic_plugin_list.count(); ++i) | - | ||||||||||||||||||
| 1472 | delete generic_plugin_list.at(i); | - | ||||||||||||||||||
| 1473 | generic_plugin_list.clear(); | - | ||||||||||||||||||
| 1474 | - | |||||||||||||||||||
| 1475 | clearFontUnlocked(); | - | ||||||||||||||||||
| 1476 | - | |||||||||||||||||||
| 1477 | QFont::cleanup(); | - | ||||||||||||||||||
| 1478 | - | |||||||||||||||||||
| 1479 | #ifndef QT_NO_CURSOR | - | ||||||||||||||||||
| 1480 | QCursorData::cleanup(); | - | ||||||||||||||||||
| 1481 | #endif | - | ||||||||||||||||||
| 1482 | - | |||||||||||||||||||
| 1483 | layout_direction = Qt::LeftToRight; | - | ||||||||||||||||||
| 1484 | - | |||||||||||||||||||
| 1485 | cleanupThreadData(); | - | ||||||||||||||||||
| 1486 | - | |||||||||||||||||||
| 1487 | delete QGuiApplicationPrivate::styleHints; | - | ||||||||||||||||||
| 1488 | QGuiApplicationPrivate::styleHints = Q_NULLPTR; | - | ||||||||||||||||||
| 1489 | delete inputMethod; | - | ||||||||||||||||||
| 1490 | - | |||||||||||||||||||
| 1491 | qt_cleanupFontDatabase(); | - | ||||||||||||||||||
| 1492 | - | |||||||||||||||||||
| 1493 | QPixmapCache::clear(); | - | ||||||||||||||||||
| 1494 | - | |||||||||||||||||||
| 1495 | #ifndef QT_NO_OPENGL | - | ||||||||||||||||||
| 1496 | if (ownGlobalShareContext) { | - | ||||||||||||||||||
| 1497 | delete qt_gl_global_share_context(); | - | ||||||||||||||||||
| 1498 | qt_gl_set_global_share_context(0); | - | ||||||||||||||||||
| 1499 | } | - | ||||||||||||||||||
| 1500 | #endif | - | ||||||||||||||||||
| 1501 | - | |||||||||||||||||||
| 1502 | platform_integration->destroy(); | - | ||||||||||||||||||
| 1503 | - | |||||||||||||||||||
| 1504 | delete platform_theme; | - | ||||||||||||||||||
| 1505 | platform_theme = 0; | - | ||||||||||||||||||
| 1506 | delete platform_integration; | - | ||||||||||||||||||
| 1507 | platform_integration = 0; | - | ||||||||||||||||||
| 1508 | delete m_gammaTables.load(); | - | ||||||||||||||||||
| 1509 | - | |||||||||||||||||||
| 1510 | window_list.clear(); | - | ||||||||||||||||||
| 1511 | } | - | ||||||||||||||||||
| 1512 | - | |||||||||||||||||||
| 1513 | #if 0 | - | ||||||||||||||||||
| 1514 | #ifndef QT_NO_CURSOR | - | ||||||||||||||||||
| 1515 | QCursor *overrideCursor(); | - | ||||||||||||||||||
| 1516 | void setOverrideCursor(const QCursor &); | - | ||||||||||||||||||
| 1517 | void changeOverrideCursor(const QCursor &); | - | ||||||||||||||||||
| 1518 | void restoreOverrideCursor(); | - | ||||||||||||||||||
| 1519 | #endif | - | ||||||||||||||||||
| 1520 | - | |||||||||||||||||||
| 1521 | static QFont font(); | - | ||||||||||||||||||
| 1522 | static QFont font(const QWidget*); | - | ||||||||||||||||||
| 1523 | static QFont font(const char *className); | - | ||||||||||||||||||
| 1524 | static void setFont(const QFont &, const char* className = 0); | - | ||||||||||||||||||
| 1525 | static QFontMetrics fontMetrics(); | - | ||||||||||||||||||
| 1526 | - | |||||||||||||||||||
| 1527 | #ifndef QT_NO_CLIPBOARD | - | ||||||||||||||||||
| 1528 | static QClipboard *clipboard(); | - | ||||||||||||||||||
| 1529 | #endif | - | ||||||||||||||||||
| 1530 | #endif | - | ||||||||||||||||||
| 1531 | - | |||||||||||||||||||
| 1532 | /*! | - | ||||||||||||||||||
| 1533 | Returns the current state of the modifier keys on the keyboard. The current | - | ||||||||||||||||||
| 1534 | state is updated sychronously as the event queue is emptied of events that | - | ||||||||||||||||||
| 1535 | will spontaneously change the keyboard state (QEvent::KeyPress and | - | ||||||||||||||||||
| 1536 | QEvent::KeyRelease events). | - | ||||||||||||||||||
| 1537 | - | |||||||||||||||||||
| 1538 | It should be noted this may not reflect the actual keys held on the input | - | ||||||||||||||||||
| 1539 | device at the time of calling but rather the modifiers as last reported in | - | ||||||||||||||||||
| 1540 | one of the above events. If no keys are being held Qt::NoModifier is | - | ||||||||||||||||||
| 1541 | returned. | - | ||||||||||||||||||
| 1542 | - | |||||||||||||||||||
| 1543 | \sa mouseButtons(), queryKeyboardModifiers() | - | ||||||||||||||||||
| 1544 | */ | - | ||||||||||||||||||
| 1545 | Qt::KeyboardModifiers QGuiApplication::keyboardModifiers() | - | ||||||||||||||||||
| 1546 | { | - | ||||||||||||||||||
| 1547 | return QGuiApplicationPrivate::modifier_buttons; | - | ||||||||||||||||||
| 1548 | } | - | ||||||||||||||||||
| 1549 | - | |||||||||||||||||||
| 1550 | /*! | - | ||||||||||||||||||
| 1551 | \fn Qt::KeyboardModifiers QGuiApplication::queryKeyboardModifiers() | - | ||||||||||||||||||
| 1552 | - | |||||||||||||||||||
| 1553 | Queries and returns the state of the modifier keys on the keyboard. | - | ||||||||||||||||||
| 1554 | Unlike keyboardModifiers, this method returns the actual keys held | - | ||||||||||||||||||
| 1555 | on the input device at the time of calling the method. | - | ||||||||||||||||||
| 1556 | - | |||||||||||||||||||
| 1557 | It does not rely on the keypress events having been received by this | - | ||||||||||||||||||
| 1558 | process, which makes it possible to check the modifiers while moving | - | ||||||||||||||||||
| 1559 | a window, for instance. Note that in most cases, you should use | - | ||||||||||||||||||
| 1560 | keyboardModifiers(), which is faster and more accurate since it contains | - | ||||||||||||||||||
| 1561 | the state of the modifiers as they were when the currently processed | - | ||||||||||||||||||
| 1562 | event was received. | - | ||||||||||||||||||
| 1563 | - | |||||||||||||||||||
| 1564 | \sa keyboardModifiers() | - | ||||||||||||||||||
| 1565 | */ | - | ||||||||||||||||||
| 1566 | Qt::KeyboardModifiers QGuiApplication::queryKeyboardModifiers() | - | ||||||||||||||||||
| 1567 | { | - | ||||||||||||||||||
| 1568 | CHECK_QAPP_INSTANCE(Qt::KeyboardModifiers(0)) | - | ||||||||||||||||||
| 1569 | QPlatformIntegration *pi = QGuiApplicationPrivate::platformIntegration(); | - | ||||||||||||||||||
| 1570 | return pi->queryKeyboardModifiers(); | - | ||||||||||||||||||
| 1571 | } | - | ||||||||||||||||||
| 1572 | - | |||||||||||||||||||
| 1573 | /*! | - | ||||||||||||||||||
| 1574 | Returns the current state of the buttons on the mouse. The current state is | - | ||||||||||||||||||
| 1575 | updated syncronously as the event queue is emptied of events that will | - | ||||||||||||||||||
| 1576 | spontaneously change the mouse state (QEvent::MouseButtonPress and | - | ||||||||||||||||||
| 1577 | QEvent::MouseButtonRelease events). | - | ||||||||||||||||||
| 1578 | - | |||||||||||||||||||
| 1579 | It should be noted this may not reflect the actual buttons held on the | - | ||||||||||||||||||
| 1580 | input device at the time of calling but rather the mouse buttons as last | - | ||||||||||||||||||
| 1581 | reported in one of the above events. If no mouse buttons are being held | - | ||||||||||||||||||
| 1582 | Qt::NoButton is returned. | - | ||||||||||||||||||
| 1583 | - | |||||||||||||||||||
| 1584 | \sa keyboardModifiers() | - | ||||||||||||||||||
| 1585 | */ | - | ||||||||||||||||||
| 1586 | Qt::MouseButtons QGuiApplication::mouseButtons() | - | ||||||||||||||||||
| 1587 | { | - | ||||||||||||||||||
| 1588 | return QGuiApplicationPrivate::mouse_buttons; | - | ||||||||||||||||||
| 1589 | } | - | ||||||||||||||||||
| 1590 | - | |||||||||||||||||||
| 1591 | /*! | - | ||||||||||||||||||
| 1592 | Returns the platform's native interface, for platform specific | - | ||||||||||||||||||
| 1593 | functionality. | - | ||||||||||||||||||
| 1594 | */ | - | ||||||||||||||||||
| 1595 | QPlatformNativeInterface *QGuiApplication::platformNativeInterface() | - | ||||||||||||||||||
| 1596 | { | - | ||||||||||||||||||
| 1597 | QPlatformIntegration *pi = QGuiApplicationPrivate::platformIntegration(); | - | ||||||||||||||||||
| 1598 | return pi ? pi->nativeInterface() : 0; | - | ||||||||||||||||||
| 1599 | } | - | ||||||||||||||||||
| 1600 | - | |||||||||||||||||||
| 1601 | /*! | - | ||||||||||||||||||
| 1602 | Returns a function pointer from the platformplugin matching \a function | - | ||||||||||||||||||
| 1603 | */ | - | ||||||||||||||||||
| 1604 | QFunctionPointer QGuiApplication::platformFunction(const QByteArray &function) | - | ||||||||||||||||||
| 1605 | { | - | ||||||||||||||||||
| 1606 | QPlatformIntegration *pi = QGuiApplicationPrivate::platformIntegration(); | - | ||||||||||||||||||
| 1607 | if (!pi) {
| 0 | ||||||||||||||||||
| 1608 | qWarning() << ("QGuiApplication::platformFunction(): Must construct a QGuiApplication before accessing a platform function";); | - | ||||||||||||||||||
| 1609 | return Q_NULLPTR; never executed: return nullptr; | 0 | ||||||||||||||||||
| 1610 | } | - | ||||||||||||||||||
| 1611 | - | |||||||||||||||||||
| 1612 | return pi->nativeInterface() ? pi->nativeInterface()->platformFunction(function) : Q_NULLPTR; never executed: return pi->nativeInterface() ? pi->nativeInterface()->platformFunction(function) : nullptr; | 0 | ||||||||||||||||||
| 1613 | } | - | ||||||||||||||||||
| 1614 | - | |||||||||||||||||||
| 1615 | /*! | - | ||||||||||||||||||
| 1616 | Enters the main event loop and waits until exit() is called, and then | - | ||||||||||||||||||
| 1617 | returns the value that was set to exit() (which is 0 if exit() is called | - | ||||||||||||||||||
| 1618 | via quit()). | - | ||||||||||||||||||
| 1619 | - | |||||||||||||||||||
| 1620 | It is necessary to call this function to start event handling. The main | - | ||||||||||||||||||
| 1621 | event loop receives events from the window system and dispatches these to | - | ||||||||||||||||||
| 1622 | the application widgets. | - | ||||||||||||||||||
| 1623 | - | |||||||||||||||||||
| 1624 | Generally, no user interaction can take place before calling exec(). | - | ||||||||||||||||||
| 1625 | - | |||||||||||||||||||
| 1626 | To make your application perform idle processing, e.g., executing a special | - | ||||||||||||||||||
| 1627 | function whenever there are no pending events, use a QTimer with 0 timeout. | - | ||||||||||||||||||
| 1628 | More advanced idle processing schemes can be achieved using processEvents(). | - | ||||||||||||||||||
| 1629 | - | |||||||||||||||||||
| 1630 | We recommend that you connect clean-up code to the | - | ||||||||||||||||||
| 1631 | \l{QCoreApplication::}{aboutToQuit()} signal, instead of putting it in your | - | ||||||||||||||||||
| 1632 | application's \c{main()} function. This is because, on some platforms, the | - | ||||||||||||||||||
| 1633 | QApplication::exec() call may not return. | - | ||||||||||||||||||
| 1634 | - | |||||||||||||||||||
| 1635 | \sa quitOnLastWindowClosed, quit(), exit(), processEvents(), | - | ||||||||||||||||||
| 1636 | QCoreApplication::exec() | - | ||||||||||||||||||
| 1637 | */ | - | ||||||||||||||||||
| 1638 | int QGuiApplication::exec() | - | ||||||||||||||||||
| 1639 | { | - | ||||||||||||||||||
| 1640 | #ifndef QT_NO_ACCESSIBILITY | - | ||||||||||||||||||
| 1641 | QAccessible::setRootObject(qApp); | - | ||||||||||||||||||
| 1642 | #endif | - | ||||||||||||||||||
| 1643 | return QCoreApplication::exec(); | - | ||||||||||||||||||
| 1644 | } | - | ||||||||||||||||||
| 1645 | - | |||||||||||||||||||
| 1646 | /*! \reimp | - | ||||||||||||||||||
| 1647 | */ | - | ||||||||||||||||||
| 1648 | bool QGuiApplication::notify(QObject *object, QEvent *event) | - | ||||||||||||||||||
| 1649 | { | - | ||||||||||||||||||
| 1650 | if (object->isWindowType()) | - | ||||||||||||||||||
| 1651 | QGuiApplicationPrivate::sendQWindowEventToQPlatformWindow(static_cast<QWindow *>(object), event); | - | ||||||||||||||||||
| 1652 | return QCoreApplication::notify(object, event); | - | ||||||||||||||||||
| 1653 | } | - | ||||||||||||||||||
| 1654 | - | |||||||||||||||||||
| 1655 | /*! \reimp | - | ||||||||||||||||||
| 1656 | */ | - | ||||||||||||||||||
| 1657 | bool QGuiApplication::event(QEvent *e) | - | ||||||||||||||||||
| 1658 | { | - | ||||||||||||||||||
| 1659 | if(e->type() == QEvent::LanguageChange) { | - | ||||||||||||||||||
| 1660 | setLayoutDirection(qt_detectRTLLanguage()?Qt::RightToLeft:Qt::LeftToRight); | - | ||||||||||||||||||
| 1661 | } | - | ||||||||||||||||||
| 1662 | return QCoreApplication::event(e); | - | ||||||||||||||||||
| 1663 | } | - | ||||||||||||||||||
| 1664 | - | |||||||||||||||||||
| 1665 | /*! | - | ||||||||||||||||||
| 1666 | \internal | - | ||||||||||||||||||
| 1667 | */ | - | ||||||||||||||||||
| 1668 | bool QGuiApplication::compressEvent(QEvent *event, QObject *receiver, QPostEventList *postedEvents) | - | ||||||||||||||||||
| 1669 | { | - | ||||||||||||||||||
| 1670 | return QCoreApplication::compressEvent(event, receiver, postedEvents); | - | ||||||||||||||||||
| 1671 | } | - | ||||||||||||||||||
| 1672 | - | |||||||||||||||||||
| 1673 | void QGuiApplicationPrivate::sendQWindowEventToQPlatformWindow(QWindow *window, QEvent *event) | - | ||||||||||||||||||
| 1674 | { | - | ||||||||||||||||||
| 1675 | if (!window) | - | ||||||||||||||||||
| 1676 | return; | - | ||||||||||||||||||
| 1677 | QPlatformWindow *platformWindow = window->handle(); | - | ||||||||||||||||||
| 1678 | if (!platformWindow) | - | ||||||||||||||||||
| 1679 | return; | - | ||||||||||||||||||
| 1680 | // spontaneous events come from the platform integration already, we don't need to send the events back | - | ||||||||||||||||||
| 1681 | if (event->spontaneous()) | - | ||||||||||||||||||
| 1682 | return; | - | ||||||||||||||||||
| 1683 | // let the platform window do any handling it needs to as well | - | ||||||||||||||||||
| 1684 | platformWindow->windowEvent(event); | - | ||||||||||||||||||
| 1685 | } | - | ||||||||||||||||||
| 1686 | - | |||||||||||||||||||
| 1687 | bool QGuiApplicationPrivate::processNativeEvent(QWindow *window, const QByteArray &eventType, void *message, long *result) | - | ||||||||||||||||||
| 1688 | { | - | ||||||||||||||||||
| 1689 | return window->nativeEvent(eventType, message, result); | - | ||||||||||||||||||
| 1690 | } | - | ||||||||||||||||||
| 1691 | - | |||||||||||||||||||
| 1692 | void QGuiApplicationPrivate::processWindowSystemEvent(QWindowSystemInterfacePrivate::WindowSystemEvent *e) | - | ||||||||||||||||||
| 1693 | { | - | ||||||||||||||||||
| 1694 | switch(e->type) { | - | ||||||||||||||||||
| 1695 | case QWindowSystemInterfacePrivate::FrameStrutMouse: | - | ||||||||||||||||||
| 1696 | case QWindowSystemInterfacePrivate::Mouse: | - | ||||||||||||||||||
| 1697 | QGuiApplicationPrivate::processMouseEvent(static_cast<QWindowSystemInterfacePrivate::MouseEvent *>(e)); | - | ||||||||||||||||||
| 1698 | break; | - | ||||||||||||||||||
| 1699 | case QWindowSystemInterfacePrivate::Wheel: | - | ||||||||||||||||||
| 1700 | QGuiApplicationPrivate::processWheelEvent(static_cast<QWindowSystemInterfacePrivate::WheelEvent *>(e)); | - | ||||||||||||||||||
| 1701 | break; | - | ||||||||||||||||||
| 1702 | case QWindowSystemInterfacePrivate::Key: | - | ||||||||||||||||||
| 1703 | QGuiApplicationPrivate::processKeyEvent(static_cast<QWindowSystemInterfacePrivate::KeyEvent *>(e)); | - | ||||||||||||||||||
| 1704 | break; | - | ||||||||||||||||||
| 1705 | case QWindowSystemInterfacePrivate::Touch: | - | ||||||||||||||||||
| 1706 | QGuiApplicationPrivate::processTouchEvent(static_cast<QWindowSystemInterfacePrivate::TouchEvent *>(e)); | - | ||||||||||||||||||
| 1707 | break; | - | ||||||||||||||||||
| 1708 | case QWindowSystemInterfacePrivate::GeometryChange: | - | ||||||||||||||||||
| 1709 | QGuiApplicationPrivate::processGeometryChangeEvent(static_cast<QWindowSystemInterfacePrivate::GeometryChangeEvent*>(e)); | - | ||||||||||||||||||
| 1710 | break; | - | ||||||||||||||||||
| 1711 | case QWindowSystemInterfacePrivate::Enter: | - | ||||||||||||||||||
| 1712 | QGuiApplicationPrivate::processEnterEvent(static_cast<QWindowSystemInterfacePrivate::EnterEvent *>(e)); | - | ||||||||||||||||||
| 1713 | break; | - | ||||||||||||||||||
| 1714 | case QWindowSystemInterfacePrivate::Leave: | - | ||||||||||||||||||
| 1715 | QGuiApplicationPrivate::processLeaveEvent(static_cast<QWindowSystemInterfacePrivate::LeaveEvent *>(e)); | - | ||||||||||||||||||
| 1716 | break; | - | ||||||||||||||||||
| 1717 | case QWindowSystemInterfacePrivate::ActivatedWindow: | - | ||||||||||||||||||
| 1718 | QGuiApplicationPrivate::processActivatedEvent(static_cast<QWindowSystemInterfacePrivate::ActivatedWindowEvent *>(e)); | - | ||||||||||||||||||
| 1719 | break; | - | ||||||||||||||||||
| 1720 | case QWindowSystemInterfacePrivate::WindowStateChanged: | - | ||||||||||||||||||
| 1721 | QGuiApplicationPrivate::processWindowStateChangedEvent(static_cast<QWindowSystemInterfacePrivate::WindowStateChangedEvent *>(e)); | - | ||||||||||||||||||
| 1722 | break; | - | ||||||||||||||||||
| 1723 | case QWindowSystemInterfacePrivate::WindowScreenChanged: | - | ||||||||||||||||||
| 1724 | QGuiApplicationPrivate::processWindowScreenChangedEvent(static_cast<QWindowSystemInterfacePrivate::WindowScreenChangedEvent *>(e)); | - | ||||||||||||||||||
| 1725 | break; | - | ||||||||||||||||||
| 1726 | case QWindowSystemInterfacePrivate::ApplicationStateChanged: { | - | ||||||||||||||||||
| 1727 | QWindowSystemInterfacePrivate::ApplicationStateChangedEvent * changeEvent = static_cast<QWindowSystemInterfacePrivate::ApplicationStateChangedEvent *>(e); | - | ||||||||||||||||||
| 1728 | QGuiApplicationPrivate::setApplicationState(changeEvent->newState, changeEvent->forcePropagate); } | - | ||||||||||||||||||
| 1729 | break; | - | ||||||||||||||||||
| 1730 | case QWindowSystemInterfacePrivate::FlushEvents: { | - | ||||||||||||||||||
| 1731 | QWindowSystemInterfacePrivate::FlushEventsEvent *flushEventsEvent = static_cast<QWindowSystemInterfacePrivate::FlushEventsEvent *>(e); | - | ||||||||||||||||||
| 1732 | QWindowSystemInterface::deferredFlushWindowSystemEvents(flushEventsEvent->flags); } | - | ||||||||||||||||||
| 1733 | break; | - | ||||||||||||||||||
| 1734 | case QWindowSystemInterfacePrivate::Close: | - | ||||||||||||||||||
| 1735 | QGuiApplicationPrivate::processCloseEvent( | - | ||||||||||||||||||
| 1736 | static_cast<QWindowSystemInterfacePrivate::CloseEvent *>(e)); | - | ||||||||||||||||||
| 1737 | break; | - | ||||||||||||||||||
| 1738 | case QWindowSystemInterfacePrivate::ScreenOrientation: | - | ||||||||||||||||||
| 1739 | QGuiApplicationPrivate::reportScreenOrientationChange( | - | ||||||||||||||||||
| 1740 | static_cast<QWindowSystemInterfacePrivate::ScreenOrientationEvent *>(e)); | - | ||||||||||||||||||
| 1741 | break; | - | ||||||||||||||||||
| 1742 | case QWindowSystemInterfacePrivate::ScreenGeometry: | - | ||||||||||||||||||
| 1743 | QGuiApplicationPrivate::reportGeometryChange( | - | ||||||||||||||||||
| 1744 | static_cast<QWindowSystemInterfacePrivate::ScreenGeometryEvent *>(e)); | - | ||||||||||||||||||
| 1745 | break; | - | ||||||||||||||||||
| 1746 | case QWindowSystemInterfacePrivate::ScreenLogicalDotsPerInch: | - | ||||||||||||||||||
| 1747 | QGuiApplicationPrivate::reportLogicalDotsPerInchChange( | - | ||||||||||||||||||
| 1748 | static_cast<QWindowSystemInterfacePrivate::ScreenLogicalDotsPerInchEvent *>(e)); | - | ||||||||||||||||||
| 1749 | break; | - | ||||||||||||||||||
| 1750 | case QWindowSystemInterfacePrivate::ScreenRefreshRate: | - | ||||||||||||||||||
| 1751 | QGuiApplicationPrivate::reportRefreshRateChange( | - | ||||||||||||||||||
| 1752 | static_cast<QWindowSystemInterfacePrivate::ScreenRefreshRateEvent *>(e)); | - | ||||||||||||||||||
| 1753 | break; | - | ||||||||||||||||||
| 1754 | case QWindowSystemInterfacePrivate::ThemeChange: | - | ||||||||||||||||||
| 1755 | QGuiApplicationPrivate::processThemeChanged( | - | ||||||||||||||||||
| 1756 | static_cast<QWindowSystemInterfacePrivate::ThemeChangeEvent *>(e)); | - | ||||||||||||||||||
| 1757 | break; | - | ||||||||||||||||||
| 1758 | case QWindowSystemInterfacePrivate::Expose: | - | ||||||||||||||||||
| 1759 | QGuiApplicationPrivate::processExposeEvent(static_cast<QWindowSystemInterfacePrivate::ExposeEvent *>(e)); | - | ||||||||||||||||||
| 1760 | break; | - | ||||||||||||||||||
| 1761 | case QWindowSystemInterfacePrivate::Tablet: | - | ||||||||||||||||||
| 1762 | QGuiApplicationPrivate::processTabletEvent( | - | ||||||||||||||||||
| 1763 | static_cast<QWindowSystemInterfacePrivate::TabletEvent *>(e)); | - | ||||||||||||||||||
| 1764 | break; | - | ||||||||||||||||||
| 1765 | case QWindowSystemInterfacePrivate::TabletEnterProximity: | - | ||||||||||||||||||
| 1766 | QGuiApplicationPrivate::processTabletEnterProximityEvent( | - | ||||||||||||||||||
| 1767 | static_cast<QWindowSystemInterfacePrivate::TabletEnterProximityEvent *>(e)); | - | ||||||||||||||||||
| 1768 | break; | - | ||||||||||||||||||
| 1769 | case QWindowSystemInterfacePrivate::TabletLeaveProximity: | - | ||||||||||||||||||
| 1770 | QGuiApplicationPrivate::processTabletLeaveProximityEvent( | - | ||||||||||||||||||
| 1771 | static_cast<QWindowSystemInterfacePrivate::TabletLeaveProximityEvent *>(e)); | - | ||||||||||||||||||
| 1772 | break; | - | ||||||||||||||||||
| 1773 | #ifndef QT_NO_GESTURES | - | ||||||||||||||||||
| 1774 | case QWindowSystemInterfacePrivate::Gesture: | - | ||||||||||||||||||
| 1775 | QGuiApplicationPrivate::processGestureEvent( | - | ||||||||||||||||||
| 1776 | static_cast<QWindowSystemInterfacePrivate::GestureEvent *>(e)); | - | ||||||||||||||||||
| 1777 | break; | - | ||||||||||||||||||
| 1778 | #endif | - | ||||||||||||||||||
| 1779 | case QWindowSystemInterfacePrivate::PlatformPanel: | - | ||||||||||||||||||
| 1780 | QGuiApplicationPrivate::processPlatformPanelEvent( | - | ||||||||||||||||||
| 1781 | static_cast<QWindowSystemInterfacePrivate::PlatformPanelEvent *>(e)); | - | ||||||||||||||||||
| 1782 | break; | - | ||||||||||||||||||
| 1783 | case QWindowSystemInterfacePrivate::FileOpen: | - | ||||||||||||||||||
| 1784 | QGuiApplicationPrivate::processFileOpenEvent( | - | ||||||||||||||||||
| 1785 | static_cast<QWindowSystemInterfacePrivate::FileOpenEvent *>(e)); | - | ||||||||||||||||||
| 1786 | break; | - | ||||||||||||||||||
| 1787 | #ifndef QT_NO_CONTEXTMENU | - | ||||||||||||||||||
| 1788 | case QWindowSystemInterfacePrivate::ContextMenu: | - | ||||||||||||||||||
| 1789 | QGuiApplicationPrivate::processContextMenuEvent( | - | ||||||||||||||||||
| 1790 | static_cast<QWindowSystemInterfacePrivate::ContextMenuEvent *>(e)); | - | ||||||||||||||||||
| 1791 | break; | - | ||||||||||||||||||
| 1792 | #endif | - | ||||||||||||||||||
| 1793 | case QWindowSystemInterfacePrivate::EnterWhatsThisMode: | - | ||||||||||||||||||
| 1794 | QGuiApplication::postEvent(QGuiApplication::instance(), new QEvent(QEvent::EnterWhatsThisMode)); | - | ||||||||||||||||||
| 1795 | break; | - | ||||||||||||||||||
| 1796 | default: | - | ||||||||||||||||||
| 1797 | qWarning() << "Unknown user input event type:" << e->type; | - | ||||||||||||||||||
| 1798 | break; | - | ||||||||||||||||||
| 1799 | } | - | ||||||||||||||||||
| 1800 | } | - | ||||||||||||||||||
| 1801 | - | |||||||||||||||||||
| 1802 | void QGuiApplicationPrivate::processMouseEvent(QWindowSystemInterfacePrivate::MouseEvent *e) | - | ||||||||||||||||||
| 1803 | { | - | ||||||||||||||||||
| 1804 | QEvent::Type type; | - | ||||||||||||||||||
| 1805 | Qt::MouseButtons stateChange = e->buttons ^ buttons; | - | ||||||||||||||||||
| 1806 | if (e->globalPos != QGuiApplicationPrivate::lastCursorPosition && (stateChange != Qt::NoButton)) {
| 0 | ||||||||||||||||||
| 1807 | // A mouse event should not change both position and buttons at the same time. Instead we | - | ||||||||||||||||||
| 1808 | // should first send a move event followed by a button changed event. Since this is not the case | - | ||||||||||||||||||
| 1809 | // with the current event, we split it in two. | - | ||||||||||||||||||
| 1810 | QWindowSystemInterfacePrivate::MouseEvent mouseButtonEvent( | - | ||||||||||||||||||
| 1811 | e->window.data(), e->timestamp, e->type, e->localPos, e->globalPos, e->buttons, e->modifiers, e->source); | - | ||||||||||||||||||
| 1812 | if (e->flags & QWindowSystemInterfacePrivate::WindowSystemEvent::Synthetic)
| 0 | ||||||||||||||||||
| 1813 | mouseButtonEvent.flags |= QWindowSystemInterfacePrivate::WindowSystemEvent::Synthetic; never executed: mouseButtonEvent.flags |= QWindowSystemInterfacePrivate::WindowSystemEvent::Synthetic; | 0 | ||||||||||||||||||
| 1814 | e->buttons = buttons; | - | ||||||||||||||||||
| 1815 | processMouseEvent(e); | - | ||||||||||||||||||
| 1816 | processMouseEvent(&mouseButtonEvent); | - | ||||||||||||||||||
| 1817 | return; never executed: return; | 0 | ||||||||||||||||||
| 1818 | } | - | ||||||||||||||||||
| 1819 | - | |||||||||||||||||||
| 1820 | QWindow *window = e->window.data(); | - | ||||||||||||||||||
| 1821 | modifier_buttons = e->modifiers; | - | ||||||||||||||||||
| 1822 | - | |||||||||||||||||||
| 1823 | QPointF localPoint = e->localPos; | - | ||||||||||||||||||
| 1824 | QPointF globalPoint = e->globalPos; | - | ||||||||||||||||||
| 1825 | - | |||||||||||||||||||
| 1826 | if (e->nullWindow()) {
| 0 | ||||||||||||||||||
| 1827 | window = QGuiApplication::topLevelAt(globalPoint.toPoint()); | - | ||||||||||||||||||
| 1828 | if (window) {
| 0 | ||||||||||||||||||
| 1829 | // Moves and the release following a press must go to the same | - | ||||||||||||||||||
| 1830 | // window, even if the cursor has moved on over another window. | - | ||||||||||||||||||
| 1831 | if (e->buttons != Qt::NoButton) {
| 0 | ||||||||||||||||||
| 1832 | if (!currentMousePressWindow)
| 0 | ||||||||||||||||||
| 1833 | currentMousePressWindow = window; never executed: currentMousePressWindow = window; | 0 | ||||||||||||||||||
| 1834 | else | - | ||||||||||||||||||
| 1835 | window = currentMousePressWindow; never executed: window = currentMousePressWindow; | 0 | ||||||||||||||||||
| 1836 | } else if (currentMousePressWindow) {
| 0 | ||||||||||||||||||
| 1837 | window = currentMousePressWindow; | - | ||||||||||||||||||
| 1838 | currentMousePressWindow = 0; | - | ||||||||||||||||||
| 1839 | } never executed: end of block | 0 | ||||||||||||||||||
| 1840 | QPointF delta = globalPoint - globalPoint.toPoint(); | - | ||||||||||||||||||
| 1841 | localPoint = window->mapFromGlobal(globalPoint.toPoint()) + delta; | - | ||||||||||||||||||
| 1842 | } never executed: end of block | 0 | ||||||||||||||||||
| 1843 | } never executed: end of block | 0 | ||||||||||||||||||
| 1844 | - | |||||||||||||||||||
| 1845 | Qt::MouseButton button = Qt::NoButton; | - | ||||||||||||||||||
| 1846 | bool doubleClick = false; | - | ||||||||||||||||||
| 1847 | const bool frameStrut = e->type == QWindowSystemInterfacePrivate::FrameStrutMouse; | - | ||||||||||||||||||
| 1848 | - | |||||||||||||||||||
| 1849 | if (QGuiApplicationPrivate::lastCursorPosition != globalPoint) {
| 0 | ||||||||||||||||||
| 1850 | type = frameStrut ? QEvent::NonClientAreaMouseMove : QEvent::MouseMove;
| 0 | ||||||||||||||||||
| 1851 | QGuiApplicationPrivate::lastCursorPosition = globalPoint; | - | ||||||||||||||||||
| 1852 | if (qAbs(globalPoint.x() - mousePressX) > mouse_double_click_distance||
| 0 | ||||||||||||||||||
| 1853 | qAbs(globalPoint.y() - mousePressY) > mouse_double_click_distance)
| 0 | ||||||||||||||||||
| 1854 | mousePressButton = Qt::NoButton; never executed: mousePressButton = Qt::NoButton; | 0 | ||||||||||||||||||
| 1855 | } else { // Check to see if a new button has been pressed/released. never executed: end of block | 0 | ||||||||||||||||||
| 1856 | for (int check = Qt::LeftButton; | - | ||||||||||||||||||
| 1857 | check <= int(Qt::MaxMouseButton);
| 0 | ||||||||||||||||||
| 1858 | check = check << 1) { | - | ||||||||||||||||||
| 1859 | if (check & stateChange) {
| 0 | ||||||||||||||||||
| 1860 | button = Qt::MouseButton(check); | - | ||||||||||||||||||
| 1861 | break; never executed: break; | 0 | ||||||||||||||||||
| 1862 | } | - | ||||||||||||||||||
| 1863 | } never executed: end of block | 0 | ||||||||||||||||||
| 1864 | if (button == Qt::NoButton) {
| 0 | ||||||||||||||||||
| 1865 | // Ignore mouse events that don't change the current state. | - | ||||||||||||||||||
| 1866 | return; never executed: return; | 0 | ||||||||||||||||||
| 1867 | } | - | ||||||||||||||||||
| 1868 | mouse_buttons = buttons = e->buttons; | - | ||||||||||||||||||
| 1869 | if (button & e->buttons) {
| 0 | ||||||||||||||||||
| 1870 | ulong doubleClickInterval = static_cast<ulong>(QGuiApplication::styleHints()->mouseDoubleClickInterval()); | - | ||||||||||||||||||
| 1871 | doubleClick = e->timestamp - mousePressTime < doubleClickInterval && button == mousePressButton;
| 0 | ||||||||||||||||||
| 1872 | type = frameStrut ? QEvent::NonClientAreaMouseButtonPress : QEvent::MouseButtonPress;
| 0 | ||||||||||||||||||
| 1873 | mousePressTime = e->timestamp; | - | ||||||||||||||||||
| 1874 | mousePressButton = button; | - | ||||||||||||||||||
| 1875 | const QPoint point = QGuiApplicationPrivate::lastCursorPosition.toPoint(); | - | ||||||||||||||||||
| 1876 | mousePressX = point.x(); | - | ||||||||||||||||||
| 1877 | mousePressY = point.y(); | - | ||||||||||||||||||
| 1878 | } else { never executed: end of block | 0 | ||||||||||||||||||
| 1879 | type = frameStrut ? QEvent::NonClientAreaMouseButtonRelease : QEvent::MouseButtonRelease;
| 0 | ||||||||||||||||||
| 1880 | } never executed: end of block | 0 | ||||||||||||||||||
| 1881 | } | - | ||||||||||||||||||
| 1882 | - | |||||||||||||||||||
| 1883 | if (!window)
| 0 | ||||||||||||||||||
| 1884 | return; never executed: return; | 0 | ||||||||||||||||||
| 1885 | - | |||||||||||||||||||
| 1886 | #ifndef QT_NO_CURSOR | - | ||||||||||||||||||
| 1887 | if (!e->synthetic()) {
| 0 | ||||||||||||||||||
| 1888 | if (const QScreen *screen = window->screen())
| 0 | ||||||||||||||||||
| 1889 | if (QPlatformCursor *cursor = screen->handle()->cursor()) {
| 0 | ||||||||||||||||||
| 1890 | const QPointF nativeLocalPoint = QHighDpi::toNativePixels(localPoint, screen); | - | ||||||||||||||||||
| 1891 | const QPointF nativeGlobalPoint = QHighDpi::toNativePixels(globalPoint, screen); | - | ||||||||||||||||||
| 1892 | QMouseEvent ev(type, nativeLocalPoint, nativeLocalPoint, nativeGlobalPoint, | - | ||||||||||||||||||
| 1893 | button, buttons, e->modifiers, e->source); | - | ||||||||||||||||||
| 1894 | ev.setTimestamp(e->timestamp); | - | ||||||||||||||||||
| 1895 | cursor->pointerEvent(ev); | - | ||||||||||||||||||
| 1896 | } never executed: end of block | 0 | ||||||||||||||||||
| 1897 | } never executed: end of block | 0 | ||||||||||||||||||
| 1898 | #endif | - | ||||||||||||||||||
| 1899 | - | |||||||||||||||||||
| 1900 | QMouseEvent ev(type, localPoint, localPoint, globalPoint, button, buttons, e->modifiers, e->source); | - | ||||||||||||||||||
| 1901 | ev.setTimestamp(e->timestamp); | - | ||||||||||||||||||
| 1902 | - | |||||||||||||||||||
| 1903 | if (window->d_func()->blockedByModalWindow&& !qApp->d_func()->popupActive())) {
| 0 | ||||||||||||||||||
| 1904 | // a modal window is blocking this window, don't allow mouse events through | - | ||||||||||||||||||
| 1905 | return; never executed: return; | 0 | ||||||||||||||||||
| 1906 | } | - | ||||||||||||||||||
| 1907 | - | |||||||||||||||||||
| 1908 | if (doubleClick && (ev.type() == QEvent::MouseButtonPress)) {
| 0 | ||||||||||||||||||
| 1909 | // QtBUG-25831, used to suppress delivery in qwidgetwindow.cpp | - | ||||||||||||||||||
| 1910 | setMouseEventFlags(&ev, ev.flags() | Qt::MouseEventCreatedDoubleClick); | - | ||||||||||||||||||
| 1911 | } never executed: end of block | 0 | ||||||||||||||||||
| 1912 | - | |||||||||||||||||||
| 1913 | QGuiApplication::sendSpontaneousEvent(window, &ev); | - | ||||||||||||||||||
| 1914 | e->eventAccepted = ev.isAccepted(); | - | ||||||||||||||||||
| 1915 | if (!e->synthetic() && !ev.isAccepted()
| 0 | ||||||||||||||||||
| 1916 | && !frameStrut
| 0 | ||||||||||||||||||
| 1917 | && qApp->testAttribute(Qt::AA_SynthesizeTouchForUnhandledMouseEvents)) {
| 0 | ||||||||||||||||||
| 1918 | if (!m_fakeTouchDevice) {
| 0 | ||||||||||||||||||
| 1919 | m_fakeTouchDevice = new QTouchDevice; | - | ||||||||||||||||||
| 1920 | QWindowSystemInterface::registerTouchDevice(m_fakeTouchDevice); | - | ||||||||||||||||||
| 1921 | } never executed: end of block | 0 | ||||||||||||||||||
| 1922 | QList<QWindowSystemInterface::TouchPoint> points; | - | ||||||||||||||||||
| 1923 | QWindowSystemInterface::TouchPoint point; | - | ||||||||||||||||||
| 1924 | point.id = 1; | - | ||||||||||||||||||
| 1925 | point.area = QRectF(globalPoint.x() - 2, globalPoint.y() - 2, 4, 4); | - | ||||||||||||||||||
| 1926 | - | |||||||||||||||||||
| 1927 | // only translate left button related events to | - | ||||||||||||||||||
| 1928 | // avoid strange touch event sequences when several | - | ||||||||||||||||||
| 1929 | // buttons are pressed | - | ||||||||||||||||||
| 1930 | if (type == QEvent::MouseButtonPress && button == Qt::LeftButton) {
| 0 | ||||||||||||||||||
| 1931 | point.state = Qt::TouchPointPressed; | - | ||||||||||||||||||
| 1932 | } else if (type == QEvent::MouseButtonRelease && button == Qt::LeftButton) { never executed: end of block
| 0 | ||||||||||||||||||
| 1933 | point.state = Qt::TouchPointReleased; | - | ||||||||||||||||||
| 1934 | } else if (type == QEvent::MouseMove && (buttons & Qt::LeftButton)) { never executed: end of block
| 0 | ||||||||||||||||||
| 1935 | point.state = Qt::TouchPointMoved; | - | ||||||||||||||||||
| 1936 | } else { never executed: end of block | 0 | ||||||||||||||||||
| 1937 | return; never executed: return; | 0 | ||||||||||||||||||
| 1938 | } | - | ||||||||||||||||||
| 1939 | - | |||||||||||||||||||
| 1940 | points << point; | - | ||||||||||||||||||
| 1941 | - | |||||||||||||||||||
| 1942 | QEvent::Type type; | - | ||||||||||||||||||
| 1943 | QList<QTouchEvent::TouchPoint> touchPoints = QWindowSystemInterfacePrivate::fromNativeTouchPoints(points, window, &type); | - | ||||||||||||||||||
| 1944 | - | |||||||||||||||||||
| 1945 | QWindowSystemInterfacePrivate::TouchEvent fake(window, e->timestamp, type, m_fakeTouchDevice, touchPoints, e->modifiers); | - | ||||||||||||||||||
| 1946 | fake.flags |= QWindowSystemInterfacePrivate::WindowSystemEvent::Synthetic; | - | ||||||||||||||||||
| 1947 | processTouchEvent(&fake); | - | ||||||||||||||||||
| 1948 | } never executed: end of block | 0 | ||||||||||||||||||
| 1949 | if (doubleClick) {
| 0 | ||||||||||||||||||
| 1950 | mousePressButton = Qt::NoButton; | - | ||||||||||||||||||
| 1951 | if (!e->window.isNull() || e->nullWindow()) { // QTBUG-36364, check if window closed in response to press
| 0 | ||||||||||||||||||
| 1952 | const QEvent::Type doubleClickType = frameStrut ? QEvent::NonClientAreaMouseButtonDblClick : QEvent::MouseButtonDblClick;
| 0 | ||||||||||||||||||
| 1953 | QMouseEvent dblClickEvent(doubleClickType, localPoint, localPoint, globalPoint, | - | ||||||||||||||||||
| 1954 | button, buttons, e->modifiers, e->source); | - | ||||||||||||||||||
| 1955 | dblClickEvent.setTimestamp(e->timestamp); | - | ||||||||||||||||||
| 1956 | QGuiApplication::sendSpontaneousEvent(window, &dblClickEvent); | - | ||||||||||||||||||
| 1957 | } never executed: end of block | 0 | ||||||||||||||||||
| 1958 | } never executed: end of block | 0 | ||||||||||||||||||
| 1959 | } never executed: end of block | 0 | ||||||||||||||||||
| 1960 | - | |||||||||||||||||||
| 1961 | void QGuiApplicationPrivate::processWheelEvent(QWindowSystemInterfacePrivate::WheelEvent *e) | - | ||||||||||||||||||
| 1962 | { | - | ||||||||||||||||||
| 1963 | #ifndef QT_NO_WHEELEVENT | - | ||||||||||||||||||
| 1964 | QWindow *window = e->window.data(); | - | ||||||||||||||||||
| 1965 | QPointF globalPoint = e->globalPos; | - | ||||||||||||||||||
| 1966 | QPointF localPoint = e->localPos; | - | ||||||||||||||||||
| 1967 | - | |||||||||||||||||||
| 1968 | if (e->nullWindow()) {
| 0 | ||||||||||||||||||
| 1969 | window = QGuiApplication::topLevelAt(globalPoint.toPoint()); | - | ||||||||||||||||||
| 1970 | if (window) {
| 0 | ||||||||||||||||||
| 1971 | QPointF delta = globalPoint - globalPoint.toPoint(); | - | ||||||||||||||||||
| 1972 | localPoint = window->mapFromGlobal(globalPoint.toPoint()) + delta; | - | ||||||||||||||||||
| 1973 | } never executed: end of block | 0 | ||||||||||||||||||
| 1974 | } never executed: end of block | 0 | ||||||||||||||||||
| 1975 | - | |||||||||||||||||||
| 1976 | if (!window)
| 0 | ||||||||||||||||||
| 1977 | return; never executed: return; | 0 | ||||||||||||||||||
| 1978 | - | |||||||||||||||||||
| 1979 | QGuiApplicationPrivate::lastCursorPosition = globalPoint; | - | ||||||||||||||||||
| 1980 | modifier_buttons = e->modifiers; | - | ||||||||||||||||||
| 1981 | - | |||||||||||||||||||
| 1982 | if (window->d_func()->blockedByModalWindow) {
| 0 | ||||||||||||||||||
| 1983 | // a modal window is blocking this window, don't allow wheel events through | - | ||||||||||||||||||
| 1984 | return; never executed: return; | 0 | ||||||||||||||||||
| 1985 | } | - | ||||||||||||||||||
| 1986 | - | |||||||||||||||||||
| 1987 | QWheelEvent ev(localPoint, globalPoint, e->pixelDelta, e->angleDelta, e->qt4Delta, e->qt4Orientation, | - | ||||||||||||||||||
| 1988 | buttons, e->modifiers, e->phase, e->source, e->inverted); | - | ||||||||||||||||||
| 1989 | ev.setTimestamp(e->timestamp); | - | ||||||||||||||||||
| 1990 | QGuiApplication::sendSpontaneousEvent(window, &ev); | - | ||||||||||||||||||
| 1991 | #endif /* ifndef QT_NO_WHEELEVENT */ | - | ||||||||||||||||||
| 1992 | } never executed: end of block | 0 | ||||||||||||||||||
| 1993 | - | |||||||||||||||||||
| 1994 | // Remember, Qt convention is: keyboard state is state *before* | - | ||||||||||||||||||
| 1995 | - | |||||||||||||||||||
| 1996 | void QGuiApplicationPrivate::processKeyEvent(QWindowSystemInterfacePrivate::KeyEvent *e) | - | ||||||||||||||||||
| 1997 | { | - | ||||||||||||||||||
| 1998 | QWindow *window = e->window.data(); | - | ||||||||||||||||||
| 1999 | modifier_buttons = e->modifiers; | - | ||||||||||||||||||
| 2000 | if (e->nullWindow()
| 0 | ||||||||||||||||||
| 2001 | #if defined(Q_OS_ANDROID) && !defined(Q_OS_ANDROID_NO_SDK) | - | ||||||||||||||||||
| 2002 | || e->key == Qt::Key_Back || e->key == Qt::Key_Menu | - | ||||||||||||||||||
| 2003 | #endif | - | ||||||||||||||||||
| 2004 | ) { | - | ||||||||||||||||||
| 2005 | window = QGuiApplication::focusWindow(); | - | ||||||||||||||||||
| 2006 | } never executed: end of block | 0 | ||||||||||||||||||
| 2007 | - | |||||||||||||||||||
| 2008 | #if !defined(Q_OS_OSX) | - | ||||||||||||||||||
| 2009 | // FIXME: Include OS X in this code path by passing the key event through | - | ||||||||||||||||||
| 2010 | // QPlatformInputContext::filterEvent(). | - | ||||||||||||||||||
| 2011 | if (e->keyType == QEvent::KeyPress && window) {
| 0 | ||||||||||||||||||
| 2012 | if (QWindowSystemInterface::handleShortcutEvent(window, e->timestamp, e->key, e->modifiers,
| 0 | ||||||||||||||||||
| 2013 | e->nativeScanCode, e->nativeVirtualKey, e->nativeModifiers, e->unicode, e->repeat, e->repeatCount))
| 0 | ||||||||||||||||||
| 2014 | return; never executed: return; | 0 | ||||||||||||||||||
| 2015 | } never executed: end of block | 0 | ||||||||||||||||||
| 2016 | #endif | - | ||||||||||||||||||
| 2017 | - | |||||||||||||||||||
| 2018 | QKeyEvent ev(e->keyType, e->key, e->modifiers, | - | ||||||||||||||||||
| 2019 | e->nativeScanCode, e->nativeVirtualKey, e->nativeModifiers, | - | ||||||||||||||||||
| 2020 | e->unicode, e->repeat, e->repeatCount); | - | ||||||||||||||||||
| 2021 | ev.setTimestamp(e->timestamp); | - | ||||||||||||||||||
| 2022 | - | |||||||||||||||||||
| 2023 | // only deliver key events when we have a window, and no modal window is blocking this window | - | ||||||||||||||||||
| 2024 | - | |||||||||||||||||||
| 2025 | if (window && !window->d_func()->blockedByModalWindow)
| 0 | ||||||||||||||||||
| 2026 | QGuiApplication::sendSpontaneousEvent(window, &ev); never executed: QGuiApplication::sendSpontaneousEvent(window, &ev); | 0 | ||||||||||||||||||
| 2027 | #if defined(Q_OS_ANDROID) && !defined(Q_OS_ANDROID_NO_SDK) | - | ||||||||||||||||||
| 2028 | else | - | ||||||||||||||||||
| 2029 | ev.setAccepted(false); | - | ||||||||||||||||||
| 2030 | - | |||||||||||||||||||
| 2031 | static bool backKeyPressAccepted = false; | - | ||||||||||||||||||
| 2032 | static bool menuKeyPressAccepted = false; | - | ||||||||||||||||||
| 2033 | if (e->keyType == QEvent::KeyPress) { | - | ||||||||||||||||||
| 2034 | backKeyPressAccepted = e->key == Qt::Key_Back && ev.isAccepted(); | - | ||||||||||||||||||
| 2035 | menuKeyPressAccepted = e->key == Qt::Key_Menu && ev.isAccepted(); | - | ||||||||||||||||||
| 2036 | } else if (e->keyType == QEvent::KeyRelease) { | - | ||||||||||||||||||
| 2037 | if (e->key == Qt::Key_Back && !backKeyPressAccepted && !ev.isAccepted()) { | - | ||||||||||||||||||
| 2038 | if (window) | - | ||||||||||||||||||
| 2039 | QWindowSystemInterface::handleCloseEvent(window); | - | ||||||||||||||||||
| 2040 | } else if (e->key == Qt::Key_Menu && !menuKeyPressAccepted && !ev.isAccepted()) { | - | ||||||||||||||||||
| 2041 | platform_theme->showPlatformMenuBar(); | - | ||||||||||||||||||
| 2042 | } | - | ||||||||||||||||||
| 2043 | } | - | ||||||||||||||||||
| 2044 | #endif | - | ||||||||||||||||||
| 2045 | e->eventAccepted = ev.isAccepted(); | - | ||||||||||||||||||
| 2046 | } never executed: end of block | 0 | ||||||||||||||||||
| 2047 | - | |||||||||||||||||||
| 2048 | void QGuiApplicationPrivate::processEnterEvent(QWindowSystemInterfacePrivate::EnterEvent *e) | - | ||||||||||||||||||
| 2049 | { | - | ||||||||||||||||||
| 2050 | if (!e->enter) | - | ||||||||||||||||||
| 2051 | return; | - | ||||||||||||||||||
| 2052 | if (e->enter.data()->d_func()->blockedByModalWindow) { | - | ||||||||||||||||||
| 2053 | // a modal window is blocking this window, don't allow enter events through | - | ||||||||||||||||||
| 2054 | return; | - | ||||||||||||||||||
| 2055 | } | - | ||||||||||||||||||
| 2056 | - | |||||||||||||||||||
| 2057 | currentMouseWindow = e->enter; | - | ||||||||||||||||||
| 2058 | - | |||||||||||||||||||
| 2059 | QEnterEvent event(e->localPos, e->localPos, e->globalPos); | - | ||||||||||||||||||
| 2060 | QCoreApplication::sendSpontaneousEvent(e->enter.data(), &event); | - | ||||||||||||||||||
| 2061 | } | - | ||||||||||||||||||
| 2062 | - | |||||||||||||||||||
| 2063 | void QGuiApplicationPrivate::processLeaveEvent(QWindowSystemInterfacePrivate::LeaveEvent *e) | - | ||||||||||||||||||
| 2064 | { | - | ||||||||||||||||||
| 2065 | if (!e->leave) | - | ||||||||||||||||||
| 2066 | return; | - | ||||||||||||||||||
| 2067 | if (e->leave.data()->d_func()->blockedByModalWindow) { | - | ||||||||||||||||||
| 2068 | // a modal window is blocking this window, don't allow leave events through | - | ||||||||||||||||||
| 2069 | return; | - | ||||||||||||||||||
| 2070 | } | - | ||||||||||||||||||
| 2071 | - | |||||||||||||||||||
| 2072 | currentMouseWindow = 0; | - | ||||||||||||||||||
| 2073 | - | |||||||||||||||||||
| 2074 | QEvent event(QEvent::Leave); | - | ||||||||||||||||||
| 2075 | QCoreApplication::sendSpontaneousEvent(e->leave.data(), &event); | - | ||||||||||||||||||
| 2076 | } | - | ||||||||||||||||||
| 2077 | - | |||||||||||||||||||
| 2078 | void QGuiApplicationPrivate::processActivatedEvent(QWindowSystemInterfacePrivate::ActivatedWindowEvent *e) | - | ||||||||||||||||||
| 2079 | { | - | ||||||||||||||||||
| 2080 | QWindow *previous = QGuiApplicationPrivate::focus_window; | - | ||||||||||||||||||
| 2081 | QWindow *newFocus = e->activated.data(); | - | ||||||||||||||||||
| 2082 | - | |||||||||||||||||||
| 2083 | if (previous == newFocus) | - | ||||||||||||||||||
| 2084 | return; | - | ||||||||||||||||||
| 2085 | - | |||||||||||||||||||
| 2086 | if (newFocus) | - | ||||||||||||||||||
| 2087 | if (QPlatformWindow *platformWindow = newFocus->handle()) | - | ||||||||||||||||||
| 2088 | if (platformWindow->isAlertState()) | - | ||||||||||||||||||
| 2089 | platformWindow->setAlertState(false); | - | ||||||||||||||||||
| 2090 | - | |||||||||||||||||||
| 2091 | QObject *previousFocusObject = previous ? previous->focusObject() : 0; | - | ||||||||||||||||||
| 2092 | - | |||||||||||||||||||
| 2093 | if (previous) { | - | ||||||||||||||||||
| 2094 | QFocusEvent focusAboutToChange(QEvent::FocusAboutToChange); | - | ||||||||||||||||||
| 2095 | QCoreApplication::sendSpontaneousEvent(previous, &focusAboutToChange); | - | ||||||||||||||||||
| 2096 | } | - | ||||||||||||||||||
| 2097 | - | |||||||||||||||||||
| 2098 | QGuiApplicationPrivate::focus_window = newFocus; | - | ||||||||||||||||||
| 2099 | if (!qApp) | - | ||||||||||||||||||
| 2100 | return; | - | ||||||||||||||||||
| 2101 | - | |||||||||||||||||||
| 2102 | if (previous) { | - | ||||||||||||||||||
| 2103 | Qt::FocusReason r = e->reason; | - | ||||||||||||||||||
| 2104 | if ((r == Qt::OtherFocusReason || r == Qt::ActiveWindowFocusReason) && | - | ||||||||||||||||||
| 2105 | newFocus && (newFocus->flags() & Qt::Popup) == Qt::Popup) | - | ||||||||||||||||||
| 2106 | r = Qt::PopupFocusReason; | - | ||||||||||||||||||
| 2107 | QFocusEvent focusOut(QEvent::FocusOut, r); | - | ||||||||||||||||||
| 2108 | QCoreApplication::sendSpontaneousEvent(previous, &focusOut); | - | ||||||||||||||||||
| 2109 | QObject::disconnect(previous, SIGNAL(focusObjectChanged(QObject*)), | - | ||||||||||||||||||
| 2110 | qApp, SLOT(_q_updateFocusObject(QObject*))); | - | ||||||||||||||||||
| 2111 | } else if (!platformIntegration()->hasCapability(QPlatformIntegration::ApplicationState)) { | - | ||||||||||||||||||
| 2112 | setApplicationState(Qt::ApplicationActive); | - | ||||||||||||||||||
| 2113 | } | - | ||||||||||||||||||
| 2114 | - | |||||||||||||||||||
| 2115 | if (QGuiApplicationPrivate::focus_window) { | - | ||||||||||||||||||
| 2116 | Qt::FocusReason r = e->reason; | - | ||||||||||||||||||
| 2117 | if ((r == Qt::OtherFocusReason || r == Qt::ActiveWindowFocusReason) && | - | ||||||||||||||||||
| 2118 | previous && (previous->flags() & Qt::Popup) == Qt::Popup) | - | ||||||||||||||||||
| 2119 | r = Qt::PopupFocusReason; | - | ||||||||||||||||||
| 2120 | QFocusEvent focusIn(QEvent::FocusIn, r); | - | ||||||||||||||||||
| 2121 | QCoreApplication::sendSpontaneousEvent(QGuiApplicationPrivate::focus_window, &focusIn); | - | ||||||||||||||||||
| 2122 | QObject::connect(QGuiApplicationPrivate::focus_window, SIGNAL(focusObjectChanged(QObject*)), | - | ||||||||||||||||||
| 2123 | qApp, SLOT(_q_updateFocusObject(QObject*))); | - | ||||||||||||||||||
| 2124 | } else if (!platformIntegration()->hasCapability(QPlatformIntegration::ApplicationState)) { | - | ||||||||||||||||||
| 2125 | setApplicationState(Qt::ApplicationInactive); | - | ||||||||||||||||||
| 2126 | } | - | ||||||||||||||||||
| 2127 | - | |||||||||||||||||||
| 2128 | if (self) { | - | ||||||||||||||||||
| 2129 | self->notifyActiveWindowChange(previous); | - | ||||||||||||||||||
| 2130 | - | |||||||||||||||||||
| 2131 | if (previousFocusObject != qApp->focusObject()) | - | ||||||||||||||||||
| 2132 | self->_q_updateFocusObject(qApp->focusObject()); | - | ||||||||||||||||||
| 2133 | } | - | ||||||||||||||||||
| 2134 | - | |||||||||||||||||||
| 2135 | emit qApp->focusWindowChanged(newFocus); | - | ||||||||||||||||||
| 2136 | if (previous) | - | ||||||||||||||||||
| 2137 | emit previous->activeChanged(); | - | ||||||||||||||||||
| 2138 | if (newFocus) | - | ||||||||||||||||||
| 2139 | emit newFocus->activeChanged(); | - | ||||||||||||||||||
| 2140 | } | - | ||||||||||||||||||
| 2141 | - | |||||||||||||||||||
| 2142 | void QGuiApplicationPrivate::processWindowStateChangedEvent(QWindowSystemInterfacePrivate::WindowStateChangedEvent *wse) | - | ||||||||||||||||||
| 2143 | { | - | ||||||||||||||||||
| 2144 | if (QWindow *window = wse->window.data()) { | - | ||||||||||||||||||
| 2145 | QWindowStateChangeEvent e(window->windowState()); | - | ||||||||||||||||||
| 2146 | window->d_func()->windowState = wse->newState; | - | ||||||||||||||||||
| 2147 | QGuiApplication::sendSpontaneousEvent(window, &e); | - | ||||||||||||||||||
| 2148 | } | - | ||||||||||||||||||
| 2149 | } | - | ||||||||||||||||||
| 2150 | - | |||||||||||||||||||
| 2151 | void QGuiApplicationPrivate::processWindowScreenChangedEvent(QWindowSystemInterfacePrivate::WindowScreenChangedEvent *wse) | - | ||||||||||||||||||
| 2152 | { | - | ||||||||||||||||||
| 2153 | if (QWindow *window = wse->window.data()) { | - | ||||||||||||||||||
| 2154 | if (window->isTopLevel()) { | - | ||||||||||||||||||
| 2155 | if (QScreen *screen = wse->screen.data()) | - | ||||||||||||||||||
| 2156 | window->d_func()->setTopLevelScreen(screen, false /* recreate */); | - | ||||||||||||||||||
| 2157 | else // Fall back to default behavior, and try to find some appropriate screen | - | ||||||||||||||||||
| 2158 | window->setScreen(0); | - | ||||||||||||||||||
| 2159 | } | - | ||||||||||||||||||
| 2160 | // we may have changed scaling, so trigger resize event if needed | - | ||||||||||||||||||
| 2161 | if (window->handle()) { | - | ||||||||||||||||||
| 2162 | QWindowSystemInterfacePrivate::GeometryChangeEvent gce(window, QHighDpi::fromNativePixels(window->handle()->geometry(), window), QRect()); | - | ||||||||||||||||||
| 2163 | processGeometryChangeEvent(&gce); | - | ||||||||||||||||||
| 2164 | } | - | ||||||||||||||||||
| 2165 | } | - | ||||||||||||||||||
| 2166 | } | - | ||||||||||||||||||
| 2167 | - | |||||||||||||||||||
| 2168 | void QGuiApplicationPrivate::processThemeChanged(QWindowSystemInterfacePrivate::ThemeChangeEvent *tce) | - | ||||||||||||||||||
| 2169 | { | - | ||||||||||||||||||
| 2170 | if (self) | - | ||||||||||||||||||
| 2171 | self->notifyThemeChanged(); | - | ||||||||||||||||||
| 2172 | if (QWindow *window = tce->window.data()) { | - | ||||||||||||||||||
| 2173 | QEvent e(QEvent::ThemeChange); | - | ||||||||||||||||||
| 2174 | QGuiApplication::sendSpontaneousEvent(window, &e); | - | ||||||||||||||||||
| 2175 | } | - | ||||||||||||||||||
| 2176 | } | - | ||||||||||||||||||
| 2177 | - | |||||||||||||||||||
| 2178 | void QGuiApplicationPrivate::processGeometryChangeEvent(QWindowSystemInterfacePrivate::GeometryChangeEvent *e) | - | ||||||||||||||||||
| 2179 | { | - | ||||||||||||||||||
| 2180 | if (e->tlw.isNull()) | - | ||||||||||||||||||
| 2181 | return; | - | ||||||||||||||||||
| 2182 | - | |||||||||||||||||||
| 2183 | QWindow *window = e->tlw.data(); | - | ||||||||||||||||||
| 2184 | if (!window) | - | ||||||||||||||||||
| 2185 | return; | - | ||||||||||||||||||
| 2186 | - | |||||||||||||||||||
| 2187 | QRect newRect = e->newGeometry; | - | ||||||||||||||||||
| 2188 | QRect oldRect = e->oldGeometry.isNull() ? window->d_func()->geometry : e->oldGeometry; | - | ||||||||||||||||||
| 2189 | - | |||||||||||||||||||
| 2190 | bool isResize = oldRect.size() != newRect.size(); | - | ||||||||||||||||||
| 2191 | bool isMove = oldRect.topLeft() != newRect.topLeft(); | - | ||||||||||||||||||
| 2192 | - | |||||||||||||||||||
| 2193 | window->d_func()->geometry = newRect; | - | ||||||||||||||||||
| 2194 | - | |||||||||||||||||||
| 2195 | if (isResize || window->d_func()->resizeEventPending) { | - | ||||||||||||||||||
| 2196 | QResizeEvent e(newRect.size(), oldRect.size()); | - | ||||||||||||||||||
| 2197 | QGuiApplication::sendSpontaneousEvent(window, &e); | - | ||||||||||||||||||
| 2198 | - | |||||||||||||||||||
| 2199 | window->d_func()->resizeEventPending = false; | - | ||||||||||||||||||
| 2200 | - | |||||||||||||||||||
| 2201 | if (oldRect.width() != newRect.width()) | - | ||||||||||||||||||
| 2202 | window->widthChanged(newRect.width()); | - | ||||||||||||||||||
| 2203 | if (oldRect.height() != newRect.height()) | - | ||||||||||||||||||
| 2204 | window->heightChanged(newRect.height()); | - | ||||||||||||||||||
| 2205 | } | - | ||||||||||||||||||
| 2206 | - | |||||||||||||||||||
| 2207 | if (isMove) { | - | ||||||||||||||||||
| 2208 | //### frame geometry | - | ||||||||||||||||||
| 2209 | QMoveEvent e(newRect.topLeft(), oldRect.topLeft()); | - | ||||||||||||||||||
| 2210 | QGuiApplication::sendSpontaneousEvent(window, &e); | - | ||||||||||||||||||
| 2211 | - | |||||||||||||||||||
| 2212 | if (oldRect.x() != newRect.x()) | - | ||||||||||||||||||
| 2213 | window->xChanged(newRect.x()); | - | ||||||||||||||||||
| 2214 | if (oldRect.y() != newRect.y()) | - | ||||||||||||||||||
| 2215 | window->yChanged(newRect.y()); | - | ||||||||||||||||||
| 2216 | } | - | ||||||||||||||||||
| 2217 | } | - | ||||||||||||||||||
| 2218 | - | |||||||||||||||||||
| 2219 | void QGuiApplicationPrivate::processCloseEvent(QWindowSystemInterfacePrivate::CloseEvent *e) | - | ||||||||||||||||||
| 2220 | { | - | ||||||||||||||||||
| 2221 | if (e->window.isNull()) | - | ||||||||||||||||||
| 2222 | return; | - | ||||||||||||||||||
| 2223 | if (e->window.data()->d_func()->blockedByModalWindow) { | - | ||||||||||||||||||
| 2224 | // a modal window is blocking this window, don't allow close events through | - | ||||||||||||||||||
| 2225 | return; | - | ||||||||||||||||||
| 2226 | } | - | ||||||||||||||||||
| 2227 | - | |||||||||||||||||||
| 2228 | QCloseEvent event; | - | ||||||||||||||||||
| 2229 | QGuiApplication::sendSpontaneousEvent(e->window.data(), &event); | - | ||||||||||||||||||
| 2230 | if (e->accepted) { | - | ||||||||||||||||||
| 2231 | *(e->accepted) = event.isAccepted(); | - | ||||||||||||||||||
| 2232 | } | - | ||||||||||||||||||
| 2233 | } | - | ||||||||||||||||||
| 2234 | - | |||||||||||||||||||
| 2235 | void QGuiApplicationPrivate::processFileOpenEvent(QWindowSystemInterfacePrivate::FileOpenEvent *e) | - | ||||||||||||||||||
| 2236 | { | - | ||||||||||||||||||
| 2237 | if (e->url.isEmpty()) | - | ||||||||||||||||||
| 2238 | return; | - | ||||||||||||||||||
| 2239 | - | |||||||||||||||||||
| 2240 | QFileOpenEvent event(e->url); | - | ||||||||||||||||||
| 2241 | QGuiApplication::sendSpontaneousEvent(qApp, &event); | - | ||||||||||||||||||
| 2242 | } | - | ||||||||||||||||||
| 2243 | - | |||||||||||||||||||
| 2244 | QGuiApplicationPrivate::TabletPointData &QGuiApplicationPrivate::tabletDevicePoint(qint64 deviceId) | - | ||||||||||||||||||
| 2245 | { | - | ||||||||||||||||||
| 2246 | for (int i = 0; i < tabletDevicePoints.size(); ++i) {
| 0 | ||||||||||||||||||
| 2247 | TabletPointData &pointData = tabletDevicePoints[i]; | - | ||||||||||||||||||
| 2248 | if (pointData.deviceId == deviceId)
| 0 | ||||||||||||||||||
| 2249 | return pointData; never executed: return pointData; | 0 | ||||||||||||||||||
| 2250 | } never executed: end of block | 0 | ||||||||||||||||||
| 2251 | - | |||||||||||||||||||
| 2252 | tabletDevicePoints.append(TabletPointData(deviceId)); | - | ||||||||||||||||||
| 2253 | return tabletDevicePoints.last(); never executed: return tabletDevicePoints.last(); | 0 | ||||||||||||||||||
| 2254 | } | - | ||||||||||||||||||
| 2255 | - | |||||||||||||||||||
| 2256 | void QGuiApplicationPrivate::processTabletEvent(QWindowSystemInterfacePrivate::TabletEvent *e) | - | ||||||||||||||||||
| 2257 | { | - | ||||||||||||||||||
| 2258 | #ifndef QT_NO_TABLETEVENT | - | ||||||||||||||||||
| 2259 | TabletPointData &pointData = tabletDevicePoint(e->uid); | - | ||||||||||||||||||
| 2260 | - | |||||||||||||||||||
| 2261 | QEvent::Type type = QEvent::TabletMove; | - | ||||||||||||||||||
| 2262 | if (e->buttons != tabletStatepointData.state)
| 0 | ||||||||||||||||||
| 2263 | type = (e->buttons > tabletStatepointData.state) ? QEvent::TabletPress : QEvent::TabletRelease; never executed: type = (e->buttons > pointData.state) ? QEvent::TabletPress : QEvent::TabletRelease;
| 0 | ||||||||||||||||||
| 2264 | - | |||||||||||||||||||
| 2265 | QWindow *window = e->window.data(); | - | ||||||||||||||||||
| 2266 | modifier_buttons = e->modifiers; | - | ||||||||||||||||||
| 2267 | - | |||||||||||||||||||
| 2268 | bool localValid = true; | - | ||||||||||||||||||
| 2269 | // If window is null, pick one based on the global position and make sure all | - | ||||||||||||||||||
| 2270 | // subsequent events up to the release are delivered to that same window. | - | ||||||||||||||||||
| 2271 | // If window is given, just send to that. | - | ||||||||||||||||||
| 2272 | if (type == QEvent::TabletPress) {
| 0 | ||||||||||||||||||
| 2273 | if (e->nullWindow()) {
| 0 | ||||||||||||||||||
| 2274 | window = QGuiApplication::topLevelAt(e->global.toPoint()); | - | ||||||||||||||||||
| 2275 | localValid = false; | - | ||||||||||||||||||
| 2276 | } never executed: end of block | 0 | ||||||||||||||||||
| 2277 | if (!window)
| 0 | ||||||||||||||||||
| 2278 | return; never executed: return; | 0 | ||||||||||||||||||
| 2279 | tabletPressTargetpointData.target = window; | - | ||||||||||||||||||
| 2280 | } else { never executed: end of block | 0 | ||||||||||||||||||
| 2281 | if (e->nullWindow()) {
| 0 | ||||||||||||||||||
| 2282 | window = tabletPressTargetpointData.target; | - | ||||||||||||||||||
| 2283 | localValid = false; | - | ||||||||||||||||||
| 2284 | } never executed: end of block | 0 | ||||||||||||||||||
| 2285 | if (type == QEvent::TabletRelease)
| 0 | ||||||||||||||||||
| 2286 | tabletPressTargetpointData.target = 0Q_NULLPTR; never executed: pointData.target = nullptr; | 0 | ||||||||||||||||||
| 2287 | if (!window)
| 0 | ||||||||||||||||||
| 2288 | return; never executed: return; | 0 | ||||||||||||||||||
| 2289 | } never executed: end of block | 0 | ||||||||||||||||||
| 2290 | QPointF local = e->local; | - | ||||||||||||||||||
| 2291 | if (!localValid) {
| 0 | ||||||||||||||||||
| 2292 | QPointF delta = e->global - e->global.toPoint(); | - | ||||||||||||||||||
| 2293 | local = window->mapFromGlobal(e->global.toPoint()) + delta; | - | ||||||||||||||||||
| 2294 | } never executed: end of block | 0 | ||||||||||||||||||
| 2295 | Qt::MouseButtons stateChange = e->buttons ^ tabletStatepointData.state; | - | ||||||||||||||||||
| 2296 | Qt::MouseButton button = Qt::NoButton; | - | ||||||||||||||||||
| 2297 | for (int check = Qt::LeftButton; check <= int(Qt::MaxMouseButton); check = check << 1) {
| 0 | ||||||||||||||||||
| 2298 | if (check & stateChange) {
| 0 | ||||||||||||||||||
| 2299 | button = Qt::MouseButton(check); | - | ||||||||||||||||||
| 2300 | break; never executed: break; | 0 | ||||||||||||||||||
| 2301 | } | - | ||||||||||||||||||
| 2302 | } never executed: end of block | 0 | ||||||||||||||||||
| 2303 | QTabletEvent ev(type, local, e->global, | - | ||||||||||||||||||
| 2304 | e->device, e->pointerType, e->pressure, e->xTilt, e->yTilt, | - | ||||||||||||||||||
| 2305 | e->tangentialPressure, e->rotation, e->z, | - | ||||||||||||||||||
| 2306 | e->modifiers, e->uid, button, e->buttons); | - | ||||||||||||||||||
| 2307 | ev.setAccepted(false); | - | ||||||||||||||||||
| 2308 | ev.setTimestamp(e->timestamp); | - | ||||||||||||||||||
| 2309 | QGuiApplication::sendSpontaneousEvent(window, &ev); | - | ||||||||||||||||||
| 2310 | tabletStatepointData.state = e->buttons; | - | ||||||||||||||||||
| 2311 | if (!ev.isAccepted() && !QWindowSystemInterfacePrivate::TabletEvent::platformSynthesizesMouse
| 0 | ||||||||||||||||||
| 2312 | && qApp->testAttribute(Qt::AA_SynthesizeMouseForUnhandledTabletEvents)) {
| 0 | ||||||||||||||||||
| 2313 | QWindowSystemInterfacePrivate::MouseEvent fake(window, e->timestamp, e->local, e->global, | - | ||||||||||||||||||
| 2314 | e->buttons, e->modifiers, Qt::MouseEventSynthesizedByQt); | - | ||||||||||||||||||
| 2315 | fake.flags |= QWindowSystemInterfacePrivate::WindowSystemEvent::Synthetic; | - | ||||||||||||||||||
| 2316 | processMouseEvent(&fake); | - | ||||||||||||||||||
| 2317 | } never executed: end of block | 0 | ||||||||||||||||||
| 2318 | #else | - | ||||||||||||||||||
| 2319 | Q_UNUSED(e) | - | ||||||||||||||||||
| 2320 | #endif | - | ||||||||||||||||||
| 2321 | } never executed: end of block | 0 | ||||||||||||||||||
| 2322 | - | |||||||||||||||||||
| 2323 | void QGuiApplicationPrivate::processTabletEnterProximityEvent(QWindowSystemInterfacePrivate::TabletEnterProximityEvent *e) | - | ||||||||||||||||||
| 2324 | { | - | ||||||||||||||||||
| 2325 | #ifndef QT_NO_TABLETEVENT | - | ||||||||||||||||||
| 2326 | QTabletEvent ev(QEvent::TabletEnterProximity, QPointF(), QPointF(), | - | ||||||||||||||||||
| 2327 | e->device, e->pointerType, 0, 0, 0, | - | ||||||||||||||||||
| 2328 | 0, 0, 0, | - | ||||||||||||||||||
| 2329 | Qt::NoModifier, e->uid, Qt::NoButton, tabletStatetabletDevicePoint(e->uid).state); | - | ||||||||||||||||||
| 2330 | ev.setTimestamp(e->timestamp); | - | ||||||||||||||||||
| 2331 | QGuiApplication::sendSpontaneousEvent(qGuiApp, &ev); | - | ||||||||||||||||||
| 2332 | #else | - | ||||||||||||||||||
| 2333 | Q_UNUSED(e) | - | ||||||||||||||||||
| 2334 | #endif | - | ||||||||||||||||||
| 2335 | } never executed: end of block | 0 | ||||||||||||||||||
| 2336 | - | |||||||||||||||||||
| 2337 | void QGuiApplicationPrivate::processTabletLeaveProximityEvent(QWindowSystemInterfacePrivate::TabletLeaveProximityEvent *e) | - | ||||||||||||||||||
| 2338 | { | - | ||||||||||||||||||
| 2339 | #ifndef QT_NO_TABLETEVENT | - | ||||||||||||||||||
| 2340 | QTabletEvent ev(QEvent::TabletLeaveProximity, QPointF(), QPointF(), | - | ||||||||||||||||||
| 2341 | e->device, e->pointerType, 0, 0, 0, | - | ||||||||||||||||||
| 2342 | 0, 0, 0, | - | ||||||||||||||||||
| 2343 | Qt::NoModifier, e->uid, Qt::NoButton, tabletStatetabletDevicePoint(e->uid).state); | - | ||||||||||||||||||
| 2344 | ev.setTimestamp(e->timestamp); | - | ||||||||||||||||||
| 2345 | QGuiApplication::sendSpontaneousEvent(qGuiApp, &ev); | - | ||||||||||||||||||
| 2346 | #else | - | ||||||||||||||||||
| 2347 | Q_UNUSED(e) | - | ||||||||||||||||||
| 2348 | #endif | - | ||||||||||||||||||
| 2349 | } never executed: end of block | 0 | ||||||||||||||||||
| 2350 | - | |||||||||||||||||||
| 2351 | #ifndef QT_NO_GESTURES | - | ||||||||||||||||||
| 2352 | void QGuiApplicationPrivate::processGestureEvent(QWindowSystemInterfacePrivate::GestureEvent *e) | - | ||||||||||||||||||
| 2353 | { | - | ||||||||||||||||||
| 2354 | if (e->window.isNull()) | - | ||||||||||||||||||
| 2355 | return; | - | ||||||||||||||||||
| 2356 | - | |||||||||||||||||||
| 2357 | QNativeGestureEvent ev(e->type, e->pos, e->pos, e->globalPos, e->realValue, e->sequenceId, e->intValue); | - | ||||||||||||||||||
| 2358 | ev.setTimestamp(e->timestamp); | - | ||||||||||||||||||
| 2359 | QGuiApplication::sendSpontaneousEvent(e->window, &ev); | - | ||||||||||||||||||
| 2360 | } | - | ||||||||||||||||||
| 2361 | #endif // QT_NO_GESTURES | - | ||||||||||||||||||
| 2362 | - | |||||||||||||||||||
| 2363 | void QGuiApplicationPrivate::processPlatformPanelEvent(QWindowSystemInterfacePrivate::PlatformPanelEvent *e) | - | ||||||||||||||||||
| 2364 | { | - | ||||||||||||||||||
| 2365 | if (!e->window) | - | ||||||||||||||||||
| 2366 | return; | - | ||||||||||||||||||
| 2367 | - | |||||||||||||||||||
| 2368 | if (e->window->d_func()->blockedByModalWindow) { | - | ||||||||||||||||||
| 2369 | // a modal window is blocking this window, don't allow events through | - | ||||||||||||||||||
| 2370 | return; | - | ||||||||||||||||||
| 2371 | } | - | ||||||||||||||||||
| 2372 | - | |||||||||||||||||||
| 2373 | QEvent ev(QEvent::PlatformPanel); | - | ||||||||||||||||||
| 2374 | QGuiApplication::sendSpontaneousEvent(e->window.data(), &ev); | - | ||||||||||||||||||
| 2375 | } | - | ||||||||||||||||||
| 2376 | - | |||||||||||||||||||
| 2377 | #ifndef QT_NO_CONTEXTMENU | - | ||||||||||||||||||
| 2378 | void QGuiApplicationPrivate::processContextMenuEvent(QWindowSystemInterfacePrivate::ContextMenuEvent *e) | - | ||||||||||||||||||
| 2379 | { | - | ||||||||||||||||||
| 2380 | // Widgets do not care about mouse triggered context menu events. Also, do not forward event | - | ||||||||||||||||||
| 2381 | // to a window blocked by a modal window. | - | ||||||||||||||||||
| 2382 | if (!e->window || e->mouseTriggered || e->window->d_func()->blockedByModalWindow) | - | ||||||||||||||||||
| 2383 | return; | - | ||||||||||||||||||
| 2384 | - | |||||||||||||||||||
| 2385 | QContextMenuEvent ev(QContextMenuEvent::Keyboard, e->pos, e->globalPos, e->modifiers); | - | ||||||||||||||||||
| 2386 | QGuiApplication::sendSpontaneousEvent(e->window.data(), &ev); | - | ||||||||||||||||||
| 2387 | } | - | ||||||||||||||||||
| 2388 | #endif | - | ||||||||||||||||||
| 2389 | - | |||||||||||||||||||
| 2390 | Q_GUI_EXPORT uint qHash(const QGuiApplicationPrivate::ActiveTouchPointsKey &k) | - | ||||||||||||||||||
| 2391 | { | - | ||||||||||||||||||
| 2392 | return qHash(k.device) + k.touchPointId; | - | ||||||||||||||||||
| 2393 | } | - | ||||||||||||||||||
| 2394 | - | |||||||||||||||||||
| 2395 | Q_GUI_EXPORT bool operator==(const QGuiApplicationPrivate::ActiveTouchPointsKey &a, | - | ||||||||||||||||||
| 2396 | const QGuiApplicationPrivate::ActiveTouchPointsKey &b) | - | ||||||||||||||||||
| 2397 | { | - | ||||||||||||||||||
| 2398 | return a.device == b.device | - | ||||||||||||||||||
| 2399 | && a.touchPointId == b.touchPointId; | - | ||||||||||||||||||
| 2400 | } | - | ||||||||||||||||||
| 2401 | - | |||||||||||||||||||
| 2402 | void QGuiApplicationPrivate::processTouchEvent(QWindowSystemInterfacePrivate::TouchEvent *e) | - | ||||||||||||||||||
| 2403 | { | - | ||||||||||||||||||
| 2404 | QGuiApplicationPrivate *d = self; | - | ||||||||||||||||||
| 2405 | modifier_buttons = e->modifiers; | - | ||||||||||||||||||
| 2406 | - | |||||||||||||||||||
| 2407 | if (e->touchType == QEvent::TouchCancel) {
| 0 | ||||||||||||||||||
| 2408 | // The touch sequence has been canceled (e.g. by the compositor). | - | ||||||||||||||||||
| 2409 | // Send the TouchCancel to all windows with active touches and clean up. | - | ||||||||||||||||||
| 2410 | QTouchEvent touchEvent(QEvent::TouchCancel, e->device, e->modifiers); | - | ||||||||||||||||||
| 2411 | touchEvent.setTimestamp(e->timestamp); | - | ||||||||||||||||||
| 2412 | QHash<ActiveTouchPointsKey, ActiveTouchPointsValue>::const_iterator it | - | ||||||||||||||||||
| 2413 | = self->activeTouchPoints.constBegin(), ite = self->activeTouchPoints.constEnd(); | - | ||||||||||||||||||
| 2414 | QSet<QWindow *> windowsNeedingCancel; | - | ||||||||||||||||||
| 2415 | while (it != ite) {
| 0 | ||||||||||||||||||
| 2416 | QWindow *w = it->window.data(); | - | ||||||||||||||||||
| 2417 | if (w)
| 0 | ||||||||||||||||||
| 2418 | windowsNeedingCancel.insert(w); never executed: windowsNeedingCancel.insert(w); | 0 | ||||||||||||||||||
| 2419 | ++it; | - | ||||||||||||||||||
| 2420 | } never executed: end of block | 0 | ||||||||||||||||||
| 2421 | for (QSet<QWindow *>::const_iterator winIt = windowsNeedingCancel.constBegin(), | - | ||||||||||||||||||
| 2422 | winItEnd = windowsNeedingCancel.constEnd(); winIt != winItEnd; ++winIt) {
| 0 | ||||||||||||||||||
| 2423 | touchEvent.setWindow(*winIt); | - | ||||||||||||||||||
| 2424 | QGuiApplication::sendSpontaneousEvent(*winIt, &touchEvent); | - | ||||||||||||||||||
| 2425 | } never executed: end of block | 0 | ||||||||||||||||||
| 2426 | if (!self->synthesizedMousePoints.isEmpty() && !e->synthetic()) {
| 0 | ||||||||||||||||||
| 2427 | for (QHash<QWindow *, SynthesizedMouseData>::const_iterator synthIt = self->synthesizedMousePoints.constBegin(), | - | ||||||||||||||||||
| 2428 | synthItEnd = self->synthesizedMousePoints.constEnd(); synthIt != synthItEnd; ++synthIt) {
| 0 | ||||||||||||||||||
| 2429 | if (!synthIt->window)
| 0 | ||||||||||||||||||
| 2430 | continue; never executed: continue; | 0 | ||||||||||||||||||
| 2431 | QWindowSystemInterfacePrivate::MouseEvent fake(synthIt->window.data(), | - | ||||||||||||||||||
| 2432 | e->timestamp, | - | ||||||||||||||||||
| 2433 | synthIt->pos, | - | ||||||||||||||||||
| 2434 | synthIt->screenPos, | - | ||||||||||||||||||
| 2435 | buttons & ~Qt::LeftButton, | - | ||||||||||||||||||
| 2436 | e->modifiers, | - | ||||||||||||||||||
| 2437 | Qt::MouseEventSynthesizedByQt); | - | ||||||||||||||||||
| 2438 | fake.flags |= QWindowSystemInterfacePrivate::WindowSystemEvent::Synthetic; | - | ||||||||||||||||||
| 2439 | processMouseEvent(&fake); | - | ||||||||||||||||||
| 2440 | } never executed: end of block | 0 | ||||||||||||||||||
| 2441 | self->synthesizedMousePoints.clear(); | - | ||||||||||||||||||
| 2442 | } never executed: end of block | 0 | ||||||||||||||||||
| 2443 | self->activeTouchPoints.clear(); | - | ||||||||||||||||||
| 2444 | self->lastTouchType = e->touchType; | - | ||||||||||||||||||
| 2445 | return; never executed: return; | 0 | ||||||||||||||||||
| 2446 | } | - | ||||||||||||||||||
| 2447 | - | |||||||||||||||||||
| 2448 | // Prevent sending ill-formed event sequences: Cancel can only be followed by a Begin. | - | ||||||||||||||||||
| 2449 | if (self->lastTouchType == QEvent::TouchCancel && e->touchType != QEvent::TouchBegin)
| 0 | ||||||||||||||||||
| 2450 | return; never executed: return; | 0 | ||||||||||||||||||
| 2451 | - | |||||||||||||||||||
| 2452 | self->lastTouchType = e->touchType; | - | ||||||||||||||||||
| 2453 | - | |||||||||||||||||||
| 2454 | QWindow *window = e->window.data(); | - | ||||||||||||||||||
| 2455 | typedef QPair<Qt::TouchPointStates, QList<QTouchEvent::TouchPoint> > StatesAndTouchPoints; | - | ||||||||||||||||||
| 2456 | QHash<QWindow *, StatesAndTouchPoints> windowsNeedingEvents; | - | ||||||||||||||||||
| 2457 | - | |||||||||||||||||||
| 2458 | for (int i = 0; i < e->points.count(); ++i) {
| 0 | ||||||||||||||||||
| 2459 | QTouchEvent::TouchPoint touchPoint = e->points.at(i); | - | ||||||||||||||||||
| 2460 | // explicitly detach from the original touch point that we got, so even | - | ||||||||||||||||||
| 2461 | // if the touchpoint structs are reused, we will make a copy that we'll | - | ||||||||||||||||||
| 2462 | // deliver to the user (which might want to store the struct for later use). | - | ||||||||||||||||||
| 2463 | touchPoint.d = touchPoint.d->detach(); | - | ||||||||||||||||||
| 2464 | - | |||||||||||||||||||
| 2465 | // update state | - | ||||||||||||||||||
| 2466 | QPointer<QWindow> w; | - | ||||||||||||||||||
| 2467 | QTouchEvent::TouchPoint previousTouchPoint; | - | ||||||||||||||||||
| 2468 | ActiveTouchPointsKey touchInfoKey(e->device, touchPoint.id()); | - | ||||||||||||||||||
| 2469 | ActiveTouchPointsValue &touchInfo = d->activeTouchPoints[touchInfoKey]; | - | ||||||||||||||||||
| 2470 | switch (touchPoint.state()) { | - | ||||||||||||||||||
| 2471 | case Qt::TouchPointPressed: never executed: case Qt::TouchPointPressed: | 0 | ||||||||||||||||||
| 2472 | if (e->device->type() == QTouchDevice::TouchPad) {
| 0 | ||||||||||||||||||
| 2473 | // on touch-pads, send all touch points to the same widget | - | ||||||||||||||||||
| 2474 | w = d->activeTouchPoints.isEmpty()
| 0 | ||||||||||||||||||
| 2475 | ? QPointer<QWindow>() | - | ||||||||||||||||||
| 2476 | : d->activeTouchPoints.constBegin().value().window; | - | ||||||||||||||||||
| 2477 | } never executed: end of block | 0 | ||||||||||||||||||
| 2478 | - | |||||||||||||||||||
| 2479 | if (!w) {
| 0 | ||||||||||||||||||
| 2480 | // determine which window this event will go to | - | ||||||||||||||||||
| 2481 | if (!window)
| 0 | ||||||||||||||||||
| 2482 | window = QGuiApplication::topLevelAt(touchPoint.screenPos().toPoint()); never executed: window = QGuiApplication::topLevelAt(touchPoint.screenPos().toPoint()); | 0 | ||||||||||||||||||
| 2483 | if (!window)
| 0 | ||||||||||||||||||
| 2484 | continue; never executed: continue; | 0 | ||||||||||||||||||
| 2485 | w = window; | - | ||||||||||||||||||
| 2486 | } never executed: end of block | 0 | ||||||||||||||||||
| 2487 | - | |||||||||||||||||||
| 2488 | touchInfo.window = w; | - | ||||||||||||||||||
| 2489 | touchPoint.d->startScreenPos = touchPoint.screenPos(); | - | ||||||||||||||||||
| 2490 | touchPoint.d->lastScreenPos = touchPoint.screenPos(); | - | ||||||||||||||||||
| 2491 | touchPoint.d->startNormalizedPos = touchPoint.normalizedPos(); | - | ||||||||||||||||||
| 2492 | touchPoint.d->lastNormalizedPos = touchPoint.normalizedPos(); | - | ||||||||||||||||||
| 2493 | if (touchPoint.pressure() < qreal(0.))
| 0 | ||||||||||||||||||
| 2494 | touchPoint.d->pressure = qreal(1.); never executed: touchPoint.d->pressure = qreal(1.); | 0 | ||||||||||||||||||
| 2495 | - | |||||||||||||||||||
| 2496 | touchInfo.touchPoint = touchPoint; | - | ||||||||||||||||||
| 2497 | break; never executed: break; | 0 | ||||||||||||||||||
| 2498 | - | |||||||||||||||||||
| 2499 | case Qt::TouchPointReleased: never executed: case Qt::TouchPointReleased: | 0 | ||||||||||||||||||
| 2500 | w = touchInfo.window; | - | ||||||||||||||||||
| 2501 | if (!w)
| 0 | ||||||||||||||||||
| 2502 | continue; never executed: continue; | 0 | ||||||||||||||||||
| 2503 | - | |||||||||||||||||||
| 2504 | previousTouchPoint = touchInfo.touchPoint; | - | ||||||||||||||||||
| 2505 | touchPoint.d->startScreenPos = previousTouchPoint.startScreenPos(); | - | ||||||||||||||||||
| 2506 | touchPoint.d->lastScreenPos = previousTouchPoint.screenPos(); | - | ||||||||||||||||||
| 2507 | touchPoint.d->startPos = previousTouchPoint.startPos(); | - | ||||||||||||||||||
| 2508 | touchPoint.d->lastPos = previousTouchPoint.pos(); | - | ||||||||||||||||||
| 2509 | touchPoint.d->startNormalizedPos = previousTouchPoint.startNormalizedPos(); | - | ||||||||||||||||||
| 2510 | touchPoint.d->lastNormalizedPos = previousTouchPoint.normalizedPos(); | - | ||||||||||||||||||
| 2511 | if (touchPoint.pressure() < qreal(0.))
| 0 | ||||||||||||||||||
| 2512 | touchPoint.d->pressure = qreal(0.); never executed: touchPoint.d->pressure = qreal(0.); | 0 | ||||||||||||||||||
| 2513 | - | |||||||||||||||||||
| 2514 | break; never executed: break; | 0 | ||||||||||||||||||
| 2515 | - | |||||||||||||||||||
| 2516 | default: never executed: default: | 0 | ||||||||||||||||||
| 2517 | w = touchInfo.window; | - | ||||||||||||||||||
| 2518 | if (!w)
| 0 | ||||||||||||||||||
| 2519 | continue; never executed: continue; | 0 | ||||||||||||||||||
| 2520 | - | |||||||||||||||||||
| 2521 | previousTouchPoint = touchInfo.touchPoint; | - | ||||||||||||||||||
| 2522 | touchPoint.d->startScreenPos = previousTouchPoint.startScreenPos(); | - | ||||||||||||||||||
| 2523 | touchPoint.d->lastScreenPos = previousTouchPoint.screenPos(); | - | ||||||||||||||||||
| 2524 | touchPoint.d->startPos = previousTouchPoint.startPos(); | - | ||||||||||||||||||
| 2525 | touchPoint.d->lastPos = previousTouchPoint.pos(); | - | ||||||||||||||||||
| 2526 | touchPoint.d->startNormalizedPos = previousTouchPoint.startNormalizedPos(); | - | ||||||||||||||||||
| 2527 | touchPoint.d->lastNormalizedPos = previousTouchPoint.normalizedPos(); | - | ||||||||||||||||||
| 2528 | if (touchPoint.pressure() < qreal(0.))
| 0 | ||||||||||||||||||
| 2529 | touchPoint.d->pressure = qreal(1.); never executed: touchPoint.d->pressure = qreal(1.); | 0 | ||||||||||||||||||
| 2530 | - | |||||||||||||||||||
| 2531 | // Stationary points might not be delivered down to the receiving item | - | ||||||||||||||||||
| 2532 | // and get their position transformed, keep the old values instead. | - | ||||||||||||||||||
| 2533 | if (touchPoint.state() != Qt::TouchPointStationary)
| 0 | ||||||||||||||||||
| 2534 | touchInfo.touchPoint = touchPoint; never executed: touchInfo.touchPoint = touchPoint; | 0 | ||||||||||||||||||
| 2535 | break; never executed: break; | 0 | ||||||||||||||||||
| 2536 | } | - | ||||||||||||||||||
| 2537 | - | |||||||||||||||||||
| 2538 | Q_ASSERT(w.data() != 0); | - | ||||||||||||||||||
| 2539 | - | |||||||||||||||||||
| 2540 | // make the *scene* functions return the same as the *screen* functions | - | ||||||||||||||||||
| 2541 | touchPoint.d->sceneRect = touchPoint.screenRect(); | - | ||||||||||||||||||
| 2542 | touchPoint.d->startScenePos = touchPoint.startScreenPos(); | - | ||||||||||||||||||
| 2543 | touchPoint.d->lastScenePos = touchPoint.lastScreenPos(); | - | ||||||||||||||||||
| 2544 | - | |||||||||||||||||||
| 2545 | StatesAndTouchPoints &maskAndPoints = windowsNeedingEvents[w.data()]; | - | ||||||||||||||||||
| 2546 | maskAndPoints.first |= touchPoint.state(); | - | ||||||||||||||||||
| 2547 | maskAndPoints.second.append(touchPoint); | - | ||||||||||||||||||
| 2548 | } never executed: end of block | 0 | ||||||||||||||||||
| 2549 | - | |||||||||||||||||||
| 2550 | if (windowsNeedingEvents.isEmpty())
| 0 | ||||||||||||||||||
| 2551 | return; never executed: return; | 0 | ||||||||||||||||||
| 2552 | - | |||||||||||||||||||
| 2553 | QHash<QWindow *, StatesAndTouchPoints>::ConstIterator it = windowsNeedingEvents.constBegin(); | - | ||||||||||||||||||
| 2554 | const QHash<QWindow *, StatesAndTouchPoints>::ConstIterator end = windowsNeedingEvents.constEnd(); | - | ||||||||||||||||||
| 2555 | for (; it != end; ++it) {
| 0 | ||||||||||||||||||
| 2556 | QWindow *w = it.key(); | - | ||||||||||||||||||
| 2557 | - | |||||||||||||||||||
| 2558 | QEvent::Type eventType; | - | ||||||||||||||||||
| 2559 | switch (it.value().first) { | - | ||||||||||||||||||
| 2560 | case Qt::TouchPointPressed: never executed: case Qt::TouchPointPressed: | 0 | ||||||||||||||||||
| 2561 | eventType = QEvent::TouchBegin; | - | ||||||||||||||||||
| 2562 | break; never executed: break; | 0 | ||||||||||||||||||
| 2563 | case Qt::TouchPointReleased: never executed: case Qt::TouchPointReleased: | 0 | ||||||||||||||||||
| 2564 | eventType = QEvent::TouchEnd; | - | ||||||||||||||||||
| 2565 | break; never executed: break; | 0 | ||||||||||||||||||
| 2566 | case Qt::TouchPointStationary: never executed: case Qt::TouchPointStationary: | 0 | ||||||||||||||||||
| 2567 | // don't send the event if nothing changed | - | ||||||||||||||||||
| 2568 | continue; never executed: continue; | 0 | ||||||||||||||||||
| 2569 | default: never executed: default: | 0 | ||||||||||||||||||
| 2570 | eventType = QEvent::TouchUpdate; | - | ||||||||||||||||||
| 2571 | break; never executed: break; | 0 | ||||||||||||||||||
| 2572 | } | - | ||||||||||||||||||
| 2573 | - | |||||||||||||||||||
| 2574 | if (w->d_func()->blockedByModalWindow) {
| 0 | ||||||||||||||||||
| 2575 | // a modal window is blocking this window, don't allow touch events through | - | ||||||||||||||||||
| 2576 | - | |||||||||||||||||||
| 2577 | // QTBUG-37371 temporary fix; TODO: revisit in 5.4 when we have a forwarding solution | - | ||||||||||||||||||
| 2578 | if (eventType == QEvent::TouchEnd) {
| 0 | ||||||||||||||||||
| 2579 | // but don't leave dangling state: e.g. | - | ||||||||||||||||||
| 2580 | // QQuickWindowPrivate::itemForTouchPointId needs to be cleared. | - | ||||||||||||||||||
| 2581 | QTouchEvent touchEvent(QEvent::TouchCancel, | - | ||||||||||||||||||
| 2582 | e->device, | - | ||||||||||||||||||
| 2583 | e->modifiers); | - | ||||||||||||||||||
| 2584 | touchEvent.setTimestamp(e->timestamp); | - | ||||||||||||||||||
| 2585 | touchEvent.setWindow(w); | - | ||||||||||||||||||
| 2586 | QGuiApplication::sendSpontaneousEvent(w, &touchEvent); | - | ||||||||||||||||||
| 2587 | } never executed: end of block | 0 | ||||||||||||||||||
| 2588 | continue; never executed: continue; | 0 | ||||||||||||||||||
| 2589 | } | - | ||||||||||||||||||
| 2590 | - | |||||||||||||||||||
| 2591 | QTouchEvent touchEvent(eventType, | - | ||||||||||||||||||
| 2592 | e->device, | - | ||||||||||||||||||
| 2593 | e->modifiers, | - | ||||||||||||||||||
| 2594 | it.value().first, | - | ||||||||||||||||||
| 2595 | it.value().second); | - | ||||||||||||||||||
| 2596 | touchEvent.setTimestamp(e->timestamp); | - | ||||||||||||||||||
| 2597 | touchEvent.setWindow(w); | - | ||||||||||||||||||
| 2598 | - | |||||||||||||||||||
| 2599 | const int pointCount = touchEvent.touchPoints().count(); | - | ||||||||||||||||||
| 2600 | for (int i = 0; i < pointCount; ++i) {
| 0 | ||||||||||||||||||
| 2601 | QTouchEvent::TouchPoint &touchPoint = touchEvent._touchPoints[i]; | - | ||||||||||||||||||
| 2602 | - | |||||||||||||||||||
| 2603 | // preserve the sub-pixel resolution | - | ||||||||||||||||||
| 2604 | QRectF rect = touchPoint.screenRect(); | - | ||||||||||||||||||
| 2605 | const QPointF screenPos = rect.center(); | - | ||||||||||||||||||
| 2606 | const QPointF delta = screenPos - screenPos.toPoint(); | - | ||||||||||||||||||
| 2607 | - | |||||||||||||||||||
| 2608 | rect.moveCenter(w->mapFromGlobal(screenPos.toPoint()) + delta); | - | ||||||||||||||||||
| 2609 | touchPoint.d->rect = rect; | - | ||||||||||||||||||
| 2610 | if (touchPoint.state() == Qt::TouchPointPressed) {
| 0 | ||||||||||||||||||
| 2611 | touchPoint.d->startPos = w->mapFromGlobal(touchPoint.startScreenPos().toPoint()) + delta; | - | ||||||||||||||||||
| 2612 | touchPoint.d->lastPos = w->mapFromGlobal(touchPoint.lastScreenPos().toPoint()) + delta; | - | ||||||||||||||||||
| 2613 | } never executed: end of block | 0 | ||||||||||||||||||
| 2614 | } never executed: end of block | 0 | ||||||||||||||||||
| 2615 | - | |||||||||||||||||||
| 2616 | QGuiApplication::sendSpontaneousEvent(w, &touchEvent); | - | ||||||||||||||||||
| 2617 | if (!e->synthetic() && !touchEvent.isAccepted() && qApp->testAttribute(Qt::AA_SynthesizeMouseForUnhandledTouchEvents)) {
| 0 | ||||||||||||||||||
| 2618 | // exclude devices which generate their own mouse events | - | ||||||||||||||||||
| 2619 | if (!(touchEvent.device()->capabilities() & QTouchDevice::MouseEmulation)) {
| 0 | ||||||||||||||||||
| 2620 | Qt::MouseButtons b = eventType == QEvent::TouchEnd ? Qt::NoButton : Qt::LeftButton;
| 0 | ||||||||||||||||||
| 2621 | if (b == Qt::NoButton)
| 0 | ||||||||||||||||||
| 2622 | self->synthesizedMousePoints.clear(); never executed: self->synthesizedMousePoints.clear(); | 0 | ||||||||||||||||||
| 2623 | - | |||||||||||||||||||
| 2624 | const QList<QTouchEvent::TouchPoint> touchPoints&touchPoints = touchEvent.touchPoints(); | - | ||||||||||||||||||
| 2625 | if (eventType == QEvent::TouchBegin)
| 0 | ||||||||||||||||||
| 2626 | m_fakeMouseSourcePointId = touchPoints.first().id(); never executed: m_fakeMouseSourcePointId = touchPoints.first().id(); | 0 | ||||||||||||||||||
| 2627 | - | |||||||||||||||||||
| 2628 | for (int i = 0; i < touchPoints.count(); ++i) {
| 0 | ||||||||||||||||||
| 2629 | const QTouchEvent::TouchPoint &touchPoint = touchPoints.at(i); | - | ||||||||||||||||||
| 2630 | if (touchPoint.id() == m_fakeMouseSourcePointId) {
| 0 | ||||||||||||||||||
| 2631 | if (b != Qt::NoButton)
| 0 | ||||||||||||||||||
| 2632 | self->synthesizedMousePoints.insert(w, SynthesizedMouseData( never executed: self->synthesizedMousePoints.insert(w, SynthesizedMouseData( touchPoint.pos(), touchPoint.screenPos(), w)); | 0 | ||||||||||||||||||
| 2633 | touchPoint.pos(), touchPoint.screenPos(), w)); never executed: self->synthesizedMousePoints.insert(w, SynthesizedMouseData( touchPoint.pos(), touchPoint.screenPos(), w)); | 0 | ||||||||||||||||||
| 2634 | QWindowSystemInterfacePrivate::MouseEvent fake(w, e->timestamp, | - | ||||||||||||||||||
| 2635 | touchPoint.pos(), | - | ||||||||||||||||||
| 2636 | touchPoint.screenPos(), | - | ||||||||||||||||||
| 2637 | b | (buttons & ~Qt::LeftButton), | - | ||||||||||||||||||
| 2638 | e->modifiers, | - | ||||||||||||||||||
| 2639 | Qt::MouseEventSynthesizedByQt); | - | ||||||||||||||||||
| 2640 | fake.flags |= QWindowSystemInterfacePrivate::WindowSystemEvent::Synthetic; | - | ||||||||||||||||||
| 2641 | processMouseEvent(&fake); | - | ||||||||||||||||||
| 2642 | break; never executed: break; | 0 | ||||||||||||||||||
| 2643 | } | - | ||||||||||||||||||
| 2644 | } never executed: end of block | 0 | ||||||||||||||||||
| 2645 | } never executed: end of block | 0 | ||||||||||||||||||
| 2646 | } never executed: end of block | 0 | ||||||||||||||||||
| 2647 | } never executed: end of block | 0 | ||||||||||||||||||
| 2648 | - | |||||||||||||||||||
| 2649 | // Remove released points from the hash table only after the event is | - | ||||||||||||||||||
| 2650 | // delivered. When the receiver is a widget, QApplication will access | - | ||||||||||||||||||
| 2651 | // activeTouchPoints during delivery and therefore nothing can be removed | - | ||||||||||||||||||
| 2652 | // before sending the event. | - | ||||||||||||||||||
| 2653 | for (int i = 0; i < e->points.count(); ++i) {
| 0 | ||||||||||||||||||
| 2654 | QTouchEvent::TouchPoint touchPoint = e->points.at(i); | - | ||||||||||||||||||
| 2655 | if (touchPoint.state() == Qt::TouchPointReleased)
| 0 | ||||||||||||||||||
| 2656 | d->activeTouchPoints.remove(ActiveTouchPointsKey(e->device, touchPoint.id())); never executed: d->activeTouchPoints.remove(ActiveTouchPointsKey(e->device, touchPoint.id())); | 0 | ||||||||||||||||||
| 2657 | } never executed: end of block | 0 | ||||||||||||||||||
| 2658 | } never executed: end of block | 0 | ||||||||||||||||||
| 2659 | - | |||||||||||||||||||
| 2660 | void QGuiApplicationPrivate::reportScreenOrientationChange(QWindowSystemInterfacePrivate::ScreenOrientationEvent *e) | - | ||||||||||||||||||
| 2661 | { | - | ||||||||||||||||||
| 2662 | // This operation only makes sense after the QGuiApplication constructor runs | - | ||||||||||||||||||
| 2663 | if (QCoreApplication::startingUp()) | - | ||||||||||||||||||
| 2664 | return; | - | ||||||||||||||||||
| 2665 | - | |||||||||||||||||||
| 2666 | if (!e->screen) | - | ||||||||||||||||||
| 2667 | return; | - | ||||||||||||||||||
| 2668 | - | |||||||||||||||||||
| 2669 | QScreen *s = e->screen.data(); | - | ||||||||||||||||||
| 2670 | s->d_func()->orientation = e->orientation; | - | ||||||||||||||||||
| 2671 | - | |||||||||||||||||||
| 2672 | updateFilteredScreenOrientation(s); | - | ||||||||||||||||||
| 2673 | } | - | ||||||||||||||||||
| 2674 | - | |||||||||||||||||||
| 2675 | void QGuiApplicationPrivate::updateFilteredScreenOrientation(QScreen *s) | - | ||||||||||||||||||
| 2676 | { | - | ||||||||||||||||||
| 2677 | Qt::ScreenOrientation o = s->d_func()->orientation; | - | ||||||||||||||||||
| 2678 | if (o == Qt::PrimaryOrientation) | - | ||||||||||||||||||
| 2679 | o = s->primaryOrientation(); | - | ||||||||||||||||||
| 2680 | o = Qt::ScreenOrientation(o & s->orientationUpdateMask()); | - | ||||||||||||||||||
| 2681 | if (o == Qt::PrimaryOrientation) | - | ||||||||||||||||||
| 2682 | return; | - | ||||||||||||||||||
| 2683 | if (o == s->d_func()->filteredOrientation) | - | ||||||||||||||||||
| 2684 | return; | - | ||||||||||||||||||
| 2685 | s->d_func()->filteredOrientation = o; | - | ||||||||||||||||||
| 2686 | reportScreenOrientationChange(s); | - | ||||||||||||||||||
| 2687 | } | - | ||||||||||||||||||
| 2688 | - | |||||||||||||||||||
| 2689 | void QGuiApplicationPrivate::reportScreenOrientationChange(QScreen *s) | - | ||||||||||||||||||
| 2690 | { | - | ||||||||||||||||||
| 2691 | emit s->orientationChanged(s->orientation()); | - | ||||||||||||||||||
| 2692 | - | |||||||||||||||||||
| 2693 | QScreenOrientationChangeEvent event(s, s->orientation()); | - | ||||||||||||||||||
| 2694 | QCoreApplication::sendEvent(QCoreApplication::instance(), &event); | - | ||||||||||||||||||
| 2695 | } | - | ||||||||||||||||||
| 2696 | - | |||||||||||||||||||
| 2697 | void QGuiApplicationPrivate::reportGeometryChange(QWindowSystemInterfacePrivate::ScreenGeometryEvent *e) | - | ||||||||||||||||||
| 2698 | { | - | ||||||||||||||||||
| 2699 | // This operation only makes sense after the QGuiApplication constructor runs | - | ||||||||||||||||||
| 2700 | if (QCoreApplication::startingUp())
| 0 | ||||||||||||||||||
| 2701 | return; never executed: return; | 0 | ||||||||||||||||||
| 2702 | - | |||||||||||||||||||
| 2703 | if (!e->screen)
| 0 | ||||||||||||||||||
| 2704 | return; never executed: return; | 0 | ||||||||||||||||||
| 2705 | - | |||||||||||||||||||
| 2706 | QScreen *s = e->screen.data(); | - | ||||||||||||||||||
| 2707 | - | |||||||||||||||||||
| 2708 | bool geometryChanged = e->geometry != s->d_func()->geometry; | - | ||||||||||||||||||
| 2709 | s->d_func()->geometry = e->geometry; | - | ||||||||||||||||||
| 2710 | - | |||||||||||||||||||
| 2711 | bool availableGeometryChanged = e->availableGeometry != s->d_func()->availableGeometry; | - | ||||||||||||||||||
| 2712 | s->d_func()->availableGeometry = e->availableGeometry; | - | ||||||||||||||||||
| 2713 | - | |||||||||||||||||||
| 2714 | if (geometryChanged) {
| 0 | ||||||||||||||||||
| 2715 | Qt::ScreenOrientation primaryOrientation = s->primaryOrientation(); | - | ||||||||||||||||||
| 2716 | s->d_func()->updatePrimaryOrientation(); | - | ||||||||||||||||||
| 2717 | - | |||||||||||||||||||
| 2718 | emit s->geometryChanged(s->geometry()); | - | ||||||||||||||||||
| 2719 | emit s->physicalSizeChanged(s->physicalSize()); | - | ||||||||||||||||||
| 2720 | emit s->physicalDotsPerInchChanged(s->physicalDotsPerInch()); | - | ||||||||||||||||||
| 2721 | emit s->logicalDotsPerInchChanged(s->logicalDotsPerInch()); | - | ||||||||||||||||||
| 2722 | - | |||||||||||||||||||
| 2723 | if (s->primaryOrientation() != primaryOrientation)
| 0 | ||||||||||||||||||
| 2724 | emit s->primaryOrientationChanged(s->primaryOrientation()); never executed: s->primaryOrientationChanged(s->primaryOrientation()); | 0 | ||||||||||||||||||
| 2725 | - | |||||||||||||||||||
| 2726 | if (s->d_func()->orientation == Qt::PrimaryOrientation)
| 0 | ||||||||||||||||||
| 2727 | updateFilteredScreenOrientation(s); never executed: updateFilteredScreenOrientation(s); | 0 | ||||||||||||||||||
| 2728 | } never executed: end of block | 0 | ||||||||||||||||||
| 2729 | - | |||||||||||||||||||
| 2730 | if (availableGeometryChanged)
| 0 | ||||||||||||||||||
| 2731 | emit s->availableGeometryChanged(s->availableGeometry()); never executed: s->availableGeometryChanged(s->availableGeometry()); | 0 | ||||||||||||||||||
| 2732 | - | |||||||||||||||||||
| 2733 | if (geometryChanged || availableGeometryChanged) {
| 0 | ||||||||||||||||||
| 2734 | foreachconst auto siblings = s->virtualSiblings(); | - | ||||||||||||||||||
| 2735 | for (QScreen* sibling , s->virtualSiblings()): siblings) | - | ||||||||||||||||||
| 2736 | emit sibling->virtualGeometryChanged(sibling->virtualGeometry()); never executed: sibling->virtualGeometryChanged(sibling->virtualGeometry()); | 0 | ||||||||||||||||||
| 2737 | } never executed: end of block | 0 | ||||||||||||||||||
| 2738 | } never executed: end of block | 0 | ||||||||||||||||||
| 2739 | - | |||||||||||||||||||
| 2740 | void QGuiApplicationPrivate::reportLogicalDotsPerInchChange(QWindowSystemInterfacePrivate::ScreenLogicalDotsPerInchEvent *e) | - | ||||||||||||||||||
| 2741 | { | - | ||||||||||||||||||
| 2742 | // This operation only makes sense after the QGuiApplication constructor runs | - | ||||||||||||||||||
| 2743 | if (QCoreApplication::startingUp()) | - | ||||||||||||||||||
| 2744 | return; | - | ||||||||||||||||||
| 2745 | - | |||||||||||||||||||
| 2746 | if (!e->screen) | - | ||||||||||||||||||
| 2747 | return; | - | ||||||||||||||||||
| 2748 | - | |||||||||||||||||||
| 2749 | QScreen *s = e->screen.data(); | - | ||||||||||||||||||
| 2750 | s->d_func()->logicalDpi = QDpi(e->dpiX, e->dpiY); | - | ||||||||||||||||||
| 2751 | - | |||||||||||||||||||
| 2752 | emit s->logicalDotsPerInchChanged(s->logicalDotsPerInch()); | - | ||||||||||||||||||
| 2753 | } | - | ||||||||||||||||||
| 2754 | - | |||||||||||||||||||
| 2755 | void QGuiApplicationPrivate::reportRefreshRateChange(QWindowSystemInterfacePrivate::ScreenRefreshRateEvent *e) | - | ||||||||||||||||||
| 2756 | { | - | ||||||||||||||||||
| 2757 | // This operation only makes sense after the QGuiApplication constructor runs | - | ||||||||||||||||||
| 2758 | if (QCoreApplication::startingUp()) | - | ||||||||||||||||||
| 2759 | return; | - | ||||||||||||||||||
| 2760 | - | |||||||||||||||||||
| 2761 | if (!e->screen) | - | ||||||||||||||||||
| 2762 | return; | - | ||||||||||||||||||
| 2763 | - | |||||||||||||||||||
| 2764 | QScreen *s = e->screen.data(); | - | ||||||||||||||||||
| 2765 | qreal rate = e->rate; | - | ||||||||||||||||||
| 2766 | // safeguard ourselves against buggy platform behavior... | - | ||||||||||||||||||
| 2767 | if (rate < 1.0) | - | ||||||||||||||||||
| 2768 | rate = 60.0; | - | ||||||||||||||||||
| 2769 | if (!qFuzzyCompare(s->d_func()->refreshRate, rate)) { | - | ||||||||||||||||||
| 2770 | s->d_func()->refreshRate = rate; | - | ||||||||||||||||||
| 2771 | emit s->refreshRateChanged(s->refreshRate()); | - | ||||||||||||||||||
| 2772 | } | - | ||||||||||||||||||
| 2773 | } | - | ||||||||||||||||||
| 2774 | - | |||||||||||||||||||
| 2775 | void QGuiApplicationPrivate::processExposeEvent(QWindowSystemInterfacePrivate::ExposeEvent *e) | - | ||||||||||||||||||
| 2776 | { | - | ||||||||||||||||||
| 2777 | if (!e->exposed) | - | ||||||||||||||||||
| 2778 | return; | - | ||||||||||||||||||
| 2779 | - | |||||||||||||||||||
| 2780 | QWindow *window = e->exposed.data(); | - | ||||||||||||||||||
| 2781 | if (!window) | - | ||||||||||||||||||
| 2782 | return; | - | ||||||||||||||||||
| 2783 | QWindowPrivate *p = qt_window_private(window); | - | ||||||||||||||||||
| 2784 | - | |||||||||||||||||||
| 2785 | if (!p->receivedExpose) { | - | ||||||||||||||||||
| 2786 | if (p->resizeEventPending) { | - | ||||||||||||||||||
| 2787 | // as a convenience for plugins, send a resize event before the first expose event if they haven't done so | - | ||||||||||||||||||
| 2788 | // window->geometry() should have a valid size as soon as a handle exists. | - | ||||||||||||||||||
| 2789 | QResizeEvent e(window->geometry().size(), p->geometry.size()); | - | ||||||||||||||||||
| 2790 | QGuiApplication::sendSpontaneousEvent(window, &e); | - | ||||||||||||||||||
| 2791 | - | |||||||||||||||||||
| 2792 | p->resizeEventPending = false; | - | ||||||||||||||||||
| 2793 | } | - | ||||||||||||||||||
| 2794 | - | |||||||||||||||||||
| 2795 | p->receivedExpose = true; | - | ||||||||||||||||||
| 2796 | } | - | ||||||||||||||||||
| 2797 | - | |||||||||||||||||||
| 2798 | p->exposed = e->isExposed && window->screen(); | - | ||||||||||||||||||
| 2799 | - | |||||||||||||||||||
| 2800 | QExposeEvent exposeEvent(e->region); | - | ||||||||||||||||||
| 2801 | QCoreApplication::sendSpontaneousEvent(window, &exposeEvent); | - | ||||||||||||||||||
| 2802 | } | - | ||||||||||||||||||
| 2803 | - | |||||||||||||||||||
| 2804 | #ifndef QT_NO_DRAGANDDROP | - | ||||||||||||||||||
| 2805 | - | |||||||||||||||||||
| 2806 | QPlatformDragQtResponse QGuiApplicationPrivate::processDrag(QWindow *w, const QMimeData *dropData, const QPoint &p, Qt::DropActions supportedActions) | - | ||||||||||||||||||
| 2807 | { | - | ||||||||||||||||||
| 2808 | static QPointer<QWindow> currentDragWindow; | - | ||||||||||||||||||
| 2809 | static Qt::DropAction lastAcceptedDropAction = Qt::IgnoreAction; | - | ||||||||||||||||||
| 2810 | QPlatformDrag *platformDrag = platformIntegration()->drag(); | - | ||||||||||||||||||
| 2811 | if (!platformDrag) { | - | ||||||||||||||||||
| 2812 | lastAcceptedDropAction = Qt::IgnoreAction; | - | ||||||||||||||||||
| 2813 | return QPlatformDragQtResponse(false, lastAcceptedDropAction, QRect()); | - | ||||||||||||||||||
| 2814 | } | - | ||||||||||||||||||
| 2815 | - | |||||||||||||||||||
| 2816 | if (!dropData) { | - | ||||||||||||||||||
| 2817 | if (currentDragWindow.data() == w) | - | ||||||||||||||||||
| 2818 | currentDragWindow = 0; | - | ||||||||||||||||||
| 2819 | QDragLeaveEvent e; | - | ||||||||||||||||||
| 2820 | QGuiApplication::sendEvent(w, &e); | - | ||||||||||||||||||
| 2821 | lastAcceptedDropAction = Qt::IgnoreAction; | - | ||||||||||||||||||
| 2822 | return QPlatformDragQtResponse(false, lastAcceptedDropAction, QRect()); | - | ||||||||||||||||||
| 2823 | } | - | ||||||||||||||||||
| 2824 | QDragMoveEvent me(p, supportedActions, dropData, | - | ||||||||||||||||||
| 2825 | QGuiApplication::mouseButtons(), QGuiApplication::keyboardModifiers()); | - | ||||||||||||||||||
| 2826 | - | |||||||||||||||||||
| 2827 | if (w != currentDragWindow) { | - | ||||||||||||||||||
| 2828 | lastAcceptedDropAction = Qt::IgnoreAction; | - | ||||||||||||||||||
| 2829 | if (currentDragWindow) { | - | ||||||||||||||||||
| 2830 | QDragLeaveEvent e; | - | ||||||||||||||||||
| 2831 | QGuiApplication::sendEvent(currentDragWindow, &e); | - | ||||||||||||||||||
| 2832 | } | - | ||||||||||||||||||
| 2833 | currentDragWindow = w; | - | ||||||||||||||||||
| 2834 | QDragEnterEvent e(p, supportedActions, dropData, | - | ||||||||||||||||||
| 2835 | QGuiApplication::mouseButtons(), QGuiApplication::keyboardModifiers()); | - | ||||||||||||||||||
| 2836 | QGuiApplication::sendEvent(w, &e); | - | ||||||||||||||||||
| 2837 | if (e.isAccepted() && e.dropAction() != Qt::IgnoreAction) | - | ||||||||||||||||||
| 2838 | lastAcceptedDropAction = e.dropAction(); | - | ||||||||||||||||||
| 2839 | } | - | ||||||||||||||||||
| 2840 | - | |||||||||||||||||||
| 2841 | // Handling 'DragEnter' should suffice for the application. | - | ||||||||||||||||||
| 2842 | if (lastAcceptedDropAction != Qt::IgnoreAction | - | ||||||||||||||||||
| 2843 | && (supportedActions & lastAcceptedDropAction)) { | - | ||||||||||||||||||
| 2844 | me.setDropAction(lastAcceptedDropAction); | - | ||||||||||||||||||
| 2845 | me.accept(); | - | ||||||||||||||||||
| 2846 | } | - | ||||||||||||||||||
| 2847 | QGuiApplication::sendEvent(w, &me); | - | ||||||||||||||||||
| 2848 | lastAcceptedDropAction = me.isAccepted() ? | - | ||||||||||||||||||
| 2849 | me.dropAction() : Qt::IgnoreAction; | - | ||||||||||||||||||
| 2850 | return QPlatformDragQtResponse(me.isAccepted(), lastAcceptedDropAction, me.answerRect()); | - | ||||||||||||||||||
| 2851 | } | - | ||||||||||||||||||
| 2852 | - | |||||||||||||||||||
| 2853 | QPlatformDropQtResponse QGuiApplicationPrivate::processDrop(QWindow *w, const QMimeData *dropData, const QPoint &p, Qt::DropActions supportedActions) | - | ||||||||||||||||||
| 2854 | { | - | ||||||||||||||||||
| 2855 | QDropEvent de(p, supportedActions, dropData, | - | ||||||||||||||||||
| 2856 | QGuiApplication::mouseButtons(), QGuiApplication::keyboardModifiers()); | - | ||||||||||||||||||
| 2857 | QGuiApplication::sendEvent(w, &de); | - | ||||||||||||||||||
| 2858 | - | |||||||||||||||||||
| 2859 | Qt::DropAction acceptedAction = de.isAccepted() ? de.dropAction() : Qt::IgnoreAction; | - | ||||||||||||||||||
| 2860 | QPlatformDropQtResponse response(de.isAccepted(),acceptedAction); | - | ||||||||||||||||||
| 2861 | return response; | - | ||||||||||||||||||
| 2862 | } | - | ||||||||||||||||||
| 2863 | - | |||||||||||||||||||
| 2864 | #endif // QT_NO_DRAGANDDROP | - | ||||||||||||||||||
| 2865 | - | |||||||||||||||||||
| 2866 | #ifndef QT_NO_CLIPBOARD | - | ||||||||||||||||||
| 2867 | /*! | - | ||||||||||||||||||
| 2868 | Returns the object for interacting with the clipboard. | - | ||||||||||||||||||
| 2869 | */ | - | ||||||||||||||||||
| 2870 | QClipboard * QGuiApplication::clipboard() | - | ||||||||||||||||||
| 2871 | { | - | ||||||||||||||||||
| 2872 | if (QGuiApplicationPrivate::qt_clipboard == 0) { | - | ||||||||||||||||||
| 2873 | if (!qApp) { | - | ||||||||||||||||||
| 2874 | qWarning("QGuiApplication: Must construct a QGuiApplication before accessing a QClipboard"); | - | ||||||||||||||||||
| 2875 | return 0; | - | ||||||||||||||||||
| 2876 | } | - | ||||||||||||||||||
| 2877 | QGuiApplicationPrivate::qt_clipboard = new QClipboard(0); | - | ||||||||||||||||||
| 2878 | } | - | ||||||||||||||||||
| 2879 | return QGuiApplicationPrivate::qt_clipboard; | - | ||||||||||||||||||
| 2880 | } | - | ||||||||||||||||||
| 2881 | #endif | - | ||||||||||||||||||
| 2882 | - | |||||||||||||||||||
| 2883 | /*! | - | ||||||||||||||||||
| 2884 | \since 5.4 | - | ||||||||||||||||||
| 2885 | \fn void QGuiApplication::paletteChanged(const QPalette &palette) | - | ||||||||||||||||||
| 2886 | - | |||||||||||||||||||
| 2887 | This signal is emitted when the \a palette of the application changes. | - | ||||||||||||||||||
| 2888 | - | |||||||||||||||||||
| 2889 | \sa palette() | - | ||||||||||||||||||
| 2890 | */ | - | ||||||||||||||||||
| 2891 | - | |||||||||||||||||||
| 2892 | /*! | - | ||||||||||||||||||
| 2893 | Returns the default application palette. | - | ||||||||||||||||||
| 2894 | - | |||||||||||||||||||
| 2895 | \sa setPalette() | - | ||||||||||||||||||
| 2896 | */ | - | ||||||||||||||||||
| 2897 | - | |||||||||||||||||||
| 2898 | QPalette QGuiApplication::palette() | - | ||||||||||||||||||
| 2899 | { | - | ||||||||||||||||||
| 2900 | initPalette(); | - | ||||||||||||||||||
| 2901 | return *QGuiApplicationPrivate::app_pal; | - | ||||||||||||||||||
| 2902 | } | - | ||||||||||||||||||
| 2903 | - | |||||||||||||||||||
| 2904 | /*! | - | ||||||||||||||||||
| 2905 | Changes the default application palette to \a pal. | - | ||||||||||||||||||
| 2906 | - | |||||||||||||||||||
| 2907 | \sa palette() | - | ||||||||||||||||||
| 2908 | */ | - | ||||||||||||||||||
| 2909 | void QGuiApplication::setPalette(const QPalette &pal) | - | ||||||||||||||||||
| 2910 | { | - | ||||||||||||||||||
| 2911 | if (QGuiApplicationPrivate::app_pal && pal.isCopyOf(*QGuiApplicationPrivate::app_pal)) | - | ||||||||||||||||||
| 2912 | return; | - | ||||||||||||||||||
| 2913 | if (!QGuiApplicationPrivate::app_pal) | - | ||||||||||||||||||
| 2914 | QGuiApplicationPrivate::app_pal = new QPalette(pal); | - | ||||||||||||||||||
| 2915 | else | - | ||||||||||||||||||
| 2916 | *QGuiApplicationPrivate::app_pal = pal; | - | ||||||||||||||||||
| 2917 | applicationResourceFlags |= ApplicationPaletteExplicitlySet; | - | ||||||||||||||||||
| 2918 | QCoreApplication::setAttribute(Qt::AA_SetPalette); | - | ||||||||||||||||||
| 2919 | emit qGuiApp->paletteChanged(*QGuiApplicationPrivate::app_pal); | - | ||||||||||||||||||
| 2920 | } | - | ||||||||||||||||||
| 2921 | - | |||||||||||||||||||
| 2922 | void QGuiApplicationPrivate::applyWindowGeometrySpecificationTo(QWindow *window) | - | ||||||||||||||||||
| 2923 | { | - | ||||||||||||||||||
| 2924 | windowGeometrySpecification.applyTo(window); | - | ||||||||||||||||||
| 2925 | } | - | ||||||||||||||||||
| 2926 | - | |||||||||||||||||||
| 2927 | /*! | - | ||||||||||||||||||
| 2928 | Returns the default application font. | - | ||||||||||||||||||
| 2929 | - | |||||||||||||||||||
| 2930 | \sa setFont() | - | ||||||||||||||||||
| 2931 | */ | - | ||||||||||||||||||
| 2932 | QFont QGuiApplication::font() | - | ||||||||||||||||||
| 2933 | { | - | ||||||||||||||||||
| 2934 | Q_ASSERT_X(QGuiApplicationPrivate::self, "QGuiApplication::font()", "no QGuiApplication instance"); | - | ||||||||||||||||||
| 2935 | QMutexLocker locker(&applicationFontMutex); | - | ||||||||||||||||||
| 2936 | initFontUnlocked(); | - | ||||||||||||||||||
| 2937 | return *QGuiApplicationPrivate::app_font; | - | ||||||||||||||||||
| 2938 | } | - | ||||||||||||||||||
| 2939 | - | |||||||||||||||||||
| 2940 | /*! | - | ||||||||||||||||||
| 2941 | Changes the default application font to \a font. | - | ||||||||||||||||||
| 2942 | - | |||||||||||||||||||
| 2943 | \sa font() | - | ||||||||||||||||||
| 2944 | */ | - | ||||||||||||||||||
| 2945 | void QGuiApplication::setFont(const QFont &font) | - | ||||||||||||||||||
| 2946 | { | - | ||||||||||||||||||
| 2947 | QMutexLocker locker(&applicationFontMutex); | - | ||||||||||||||||||
| 2948 | if (!QGuiApplicationPrivate::app_font) | - | ||||||||||||||||||
| 2949 | QGuiApplicationPrivate::app_font = new QFont(font); | - | ||||||||||||||||||
| 2950 | else | - | ||||||||||||||||||
| 2951 | *QGuiApplicationPrivate::app_font = font; | - | ||||||||||||||||||
| 2952 | applicationResourceFlags |= ApplicationFontExplicitlySet; | - | ||||||||||||||||||
| 2953 | } | - | ||||||||||||||||||
| 2954 | - | |||||||||||||||||||
| 2955 | /*! | - | ||||||||||||||||||
| 2956 | \fn bool QGuiApplication::isRightToLeft() | - | ||||||||||||||||||
| 2957 | - | |||||||||||||||||||
| 2958 | Returns \c true if the application's layout direction is | - | ||||||||||||||||||
| 2959 | Qt::RightToLeft; otherwise returns \c false. | - | ||||||||||||||||||
| 2960 | - | |||||||||||||||||||
| 2961 | \sa layoutDirection(), isLeftToRight() | - | ||||||||||||||||||
| 2962 | */ | - | ||||||||||||||||||
| 2963 | - | |||||||||||||||||||
| 2964 | /*! | - | ||||||||||||||||||
| 2965 | \fn bool QGuiApplication::isLeftToRight() | - | ||||||||||||||||||
| 2966 | - | |||||||||||||||||||
| 2967 | Returns \c true if the application's layout direction is | - | ||||||||||||||||||
| 2968 | Qt::LeftToRight; otherwise returns \c false. | - | ||||||||||||||||||
| 2969 | - | |||||||||||||||||||
| 2970 | \sa layoutDirection(), isRightToLeft() | - | ||||||||||||||||||
| 2971 | */ | - | ||||||||||||||||||
| 2972 | - | |||||||||||||||||||
| 2973 | void QGuiApplicationPrivate::notifyLayoutDirectionChange() | - | ||||||||||||||||||
| 2974 | { | - | ||||||||||||||||||
| 2975 | const QWindowList list = QGuiApplication::topLevelWindows(); | - | ||||||||||||||||||
| 2976 | for (int i = 0; i < list.size(); ++i) { | - | ||||||||||||||||||
| 2977 | QEvent ev(QEvent::ApplicationLayoutDirectionChange); | - | ||||||||||||||||||
| 2978 | QCoreApplication::sendEvent(list.at(i), &ev); | - | ||||||||||||||||||
| 2979 | } | - | ||||||||||||||||||
| 2980 | } | - | ||||||||||||||||||
| 2981 | - | |||||||||||||||||||
| 2982 | void QGuiApplicationPrivate::notifyActiveWindowChange(QWindow *) | - | ||||||||||||||||||
| 2983 | { | - | ||||||||||||||||||
| 2984 | } | - | ||||||||||||||||||
| 2985 | - | |||||||||||||||||||
| 2986 | /*! | - | ||||||||||||||||||
| 2987 | \property QGuiApplication::windowIcon | - | ||||||||||||||||||
| 2988 | \brief the default window icon | - | ||||||||||||||||||
| 2989 | - | |||||||||||||||||||
| 2990 | \sa QWindow::setIcon(), {Setting the Application Icon} | - | ||||||||||||||||||
| 2991 | */ | - | ||||||||||||||||||
| 2992 | QIcon QGuiApplication::windowIcon() | - | ||||||||||||||||||
| 2993 | { | - | ||||||||||||||||||
| 2994 | return QGuiApplicationPrivate::app_icon ? *QGuiApplicationPrivate::app_icon : QIcon(); | - | ||||||||||||||||||
| 2995 | } | - | ||||||||||||||||||
| 2996 | - | |||||||||||||||||||
| 2997 | void QGuiApplication::setWindowIcon(const QIcon &icon) | - | ||||||||||||||||||
| 2998 | { | - | ||||||||||||||||||
| 2999 | if (!QGuiApplicationPrivate::app_icon) | - | ||||||||||||||||||
| 3000 | QGuiApplicationPrivate::app_icon = new QIcon(); | - | ||||||||||||||||||
| 3001 | *QGuiApplicationPrivate::app_icon = icon; | - | ||||||||||||||||||
| 3002 | if (QGuiApplicationPrivate::platform_integration | - | ||||||||||||||||||
| 3003 | && QGuiApplicationPrivate::platform_integration->hasCapability(QPlatformIntegration::ApplicationIcon)) | - | ||||||||||||||||||
| 3004 | QGuiApplicationPrivate::platform_integration->setApplicationIcon(icon); | - | ||||||||||||||||||
| 3005 | if (QGuiApplicationPrivate::is_app_running && !QGuiApplicationPrivate::is_app_closing) | - | ||||||||||||||||||
| 3006 | QGuiApplicationPrivate::self->notifyWindowIconChanged(); | - | ||||||||||||||||||
| 3007 | } | - | ||||||||||||||||||
| 3008 | - | |||||||||||||||||||
| 3009 | void QGuiApplicationPrivate::notifyWindowIconChanged() | - | ||||||||||||||||||
| 3010 | { | - | ||||||||||||||||||
| 3011 | QEvent ev(QEvent::ApplicationWindowIconChange); | - | ||||||||||||||||||
| 3012 | const QWindowList list = QGuiApplication::topLevelWindows(); | - | ||||||||||||||||||
| 3013 | for (int i = 0; i < list.size(); ++i) | - | ||||||||||||||||||
| 3014 | QCoreApplication::sendEvent(list.at(i), &ev); | - | ||||||||||||||||||
| 3015 | } | - | ||||||||||||||||||
| 3016 | - | |||||||||||||||||||
| 3017 | - | |||||||||||||||||||
| 3018 | - | |||||||||||||||||||
| 3019 | /*! | - | ||||||||||||||||||
| 3020 | \property QGuiApplication::quitOnLastWindowClosed | - | ||||||||||||||||||
| 3021 | - | |||||||||||||||||||
| 3022 | \brief whether the application implicitly quits when the last window is | - | ||||||||||||||||||
| 3023 | closed. | - | ||||||||||||||||||
| 3024 | - | |||||||||||||||||||
| 3025 | The default is \c true. | - | ||||||||||||||||||
| 3026 | - | |||||||||||||||||||
| 3027 | If this property is \c true, the applications quits when the last visible | - | ||||||||||||||||||
| 3028 | primary window (i.e. window with no parent) is closed. | - | ||||||||||||||||||
| 3029 | - | |||||||||||||||||||
| 3030 | \sa quit(), QWindow::close() | - | ||||||||||||||||||
| 3031 | */ | - | ||||||||||||||||||
| 3032 | - | |||||||||||||||||||
| 3033 | void QGuiApplication::setQuitOnLastWindowClosed(bool quit) | - | ||||||||||||||||||
| 3034 | { | - | ||||||||||||||||||
| 3035 | QCoreApplication::setQuitLockEnabled(quit); | - | ||||||||||||||||||
| 3036 | } | - | ||||||||||||||||||
| 3037 | - | |||||||||||||||||||
| 3038 | - | |||||||||||||||||||
| 3039 | - | |||||||||||||||||||
| 3040 | bool QGuiApplication::quitOnLastWindowClosed() | - | ||||||||||||||||||
| 3041 | { | - | ||||||||||||||||||
| 3042 | return QCoreApplication::isQuitLockEnabled(); | - | ||||||||||||||||||
| 3043 | } | - | ||||||||||||||||||
| 3044 | - | |||||||||||||||||||
| 3045 | - | |||||||||||||||||||
| 3046 | /*! | - | ||||||||||||||||||
| 3047 | \fn void QGuiApplication::lastWindowClosed() | - | ||||||||||||||||||
| 3048 | - | |||||||||||||||||||
| 3049 | This signal is emitted from exec() when the last visible | - | ||||||||||||||||||
| 3050 | primary window (i.e. window with no parent) is closed. | - | ||||||||||||||||||
| 3051 | - | |||||||||||||||||||
| 3052 | By default, QGuiApplication quits after this signal is emitted. This feature | - | ||||||||||||||||||
| 3053 | can be turned off by setting \l quitOnLastWindowClosed to \c false. | - | ||||||||||||||||||
| 3054 | - | |||||||||||||||||||
| 3055 | \sa QWindow::close(), QWindow::isTopLevel() | - | ||||||||||||||||||
| 3056 | */ | - | ||||||||||||||||||
| 3057 | - | |||||||||||||||||||
| 3058 | void QGuiApplicationPrivate::emitLastWindowClosed() | - | ||||||||||||||||||
| 3059 | { | - | ||||||||||||||||||
| 3060 | if (qGuiApp && qGuiApp->d_func()->in_exec) { | - | ||||||||||||||||||
| 3061 | emit qGuiApp->lastWindowClosed(); | - | ||||||||||||||||||
| 3062 | } | - | ||||||||||||||||||
| 3063 | } | - | ||||||||||||||||||
| 3064 | - | |||||||||||||||||||
| 3065 | bool QGuiApplicationPrivate::shouldQuit() | - | ||||||||||||||||||
| 3066 | { | - | ||||||||||||||||||
| 3067 | const QWindowList processedWindows; | - | ||||||||||||||||||
| 3068 | return shouldQuitInternal(processedWindows); | - | ||||||||||||||||||
| 3069 | } | - | ||||||||||||||||||
| 3070 | - | |||||||||||||||||||
| 3071 | bool QGuiApplicationPrivate::shouldQuitInternal(const QWindowList &processedWindows) | - | ||||||||||||||||||
| 3072 | { | - | ||||||||||||||||||
| 3073 | /* if there is no visible top-level window left, we allow the quit */ | - | ||||||||||||||||||
| 3074 | QWindowList list = QGuiApplication::topLevelWindows(); | - | ||||||||||||||||||
| 3075 | for (int i = 0; i < list.size(); ++i) { | - | ||||||||||||||||||
| 3076 | QWindow *w = list.at(i); | - | ||||||||||||||||||
| 3077 | if (processedWindows.contains(w)) | - | ||||||||||||||||||
| 3078 | continue; | - | ||||||||||||||||||
| 3079 | if (w->isVisible() && !w->transientParent()) | - | ||||||||||||||||||
| 3080 | return false; | - | ||||||||||||||||||
| 3081 | } | - | ||||||||||||||||||
| 3082 | return true; | - | ||||||||||||||||||
| 3083 | } | - | ||||||||||||||||||
| 3084 | - | |||||||||||||||||||
| 3085 | bool QGuiApplicationPrivate::tryCloseAllWindows() | - | ||||||||||||||||||
| 3086 | { | - | ||||||||||||||||||
| 3087 | return tryCloseRemainingWindows(QWindowList()); | - | ||||||||||||||||||
| 3088 | } | - | ||||||||||||||||||
| 3089 | - | |||||||||||||||||||
| 3090 | bool QGuiApplicationPrivate::tryCloseRemainingWindows(QWindowList processedWindows) | - | ||||||||||||||||||
| 3091 | { | - | ||||||||||||||||||
| 3092 | QWindowList list = QGuiApplication::topLevelWindows(); | - | ||||||||||||||||||
| 3093 | for (int i = 0; i < list.size(); ++i) { | - | ||||||||||||||||||
| 3094 | QWindow *w = list.at(i); | - | ||||||||||||||||||
| 3095 | if (w->isVisible() && !processedWindows.contains(w)) { | - | ||||||||||||||||||
| 3096 | if (!w->close()) | - | ||||||||||||||||||
| 3097 | return false; | - | ||||||||||||||||||
| 3098 | processedWindows.append(w); | - | ||||||||||||||||||
| 3099 | list = QGuiApplication::topLevelWindows(); | - | ||||||||||||||||||
| 3100 | i = -1; | - | ||||||||||||||||||
| 3101 | } | - | ||||||||||||||||||
| 3102 | } | - | ||||||||||||||||||
| 3103 | return true; | - | ||||||||||||||||||
| 3104 | } | - | ||||||||||||||||||
| 3105 | - | |||||||||||||||||||
| 3106 | /*! | - | ||||||||||||||||||
| 3107 | \since 5.2 | - | ||||||||||||||||||
| 3108 | \fn Qt::ApplicationState QGuiApplication::applicationState() | - | ||||||||||||||||||
| 3109 | - | |||||||||||||||||||
| 3110 | - | |||||||||||||||||||
| 3111 | Returns the current state of the application. | - | ||||||||||||||||||
| 3112 | - | |||||||||||||||||||
| 3113 | You can react to application state changes to perform actions such as | - | ||||||||||||||||||
| 3114 | stopping/resuming CPU-intensive tasks, freeing/loading resources or | - | ||||||||||||||||||
| 3115 | saving/restoring application data. | - | ||||||||||||||||||
| 3116 | */ | - | ||||||||||||||||||
| 3117 | - | |||||||||||||||||||
| 3118 | Qt::ApplicationState QGuiApplication::applicationState() | - | ||||||||||||||||||
| 3119 | { | - | ||||||||||||||||||
| 3120 | return QGuiApplicationPrivate::applicationState; | - | ||||||||||||||||||
| 3121 | } | - | ||||||||||||||||||
| 3122 | - | |||||||||||||||||||
| 3123 | /*! | - | ||||||||||||||||||
| 3124 | \since 5.2 | - | ||||||||||||||||||
| 3125 | \fn void QGuiApplication::applicationStateChanged(Qt::ApplicationState state) | - | ||||||||||||||||||
| 3126 | - | |||||||||||||||||||
| 3127 | This signal is emitted when the \a state of the application changes. | - | ||||||||||||||||||
| 3128 | - | |||||||||||||||||||
| 3129 | \sa applicationState() | - | ||||||||||||||||||
| 3130 | */ | - | ||||||||||||||||||
| 3131 | - | |||||||||||||||||||
| 3132 | void QGuiApplicationPrivate::setApplicationState(Qt::ApplicationState state, bool forcePropagate) | - | ||||||||||||||||||
| 3133 | { | - | ||||||||||||||||||
| 3134 | if ((applicationState == state) && !forcePropagate) | - | ||||||||||||||||||
| 3135 | return; | - | ||||||||||||||||||
| 3136 | - | |||||||||||||||||||
| 3137 | applicationState = state; | - | ||||||||||||||||||
| 3138 | - | |||||||||||||||||||
| 3139 | switch (state) { | - | ||||||||||||||||||
| 3140 | case Qt::ApplicationActive: { | - | ||||||||||||||||||
| 3141 | QEvent appActivate(QEvent::ApplicationActivate); | - | ||||||||||||||||||
| 3142 | QCoreApplication::sendSpontaneousEvent(qApp, &appActivate); | - | ||||||||||||||||||
| 3143 | break; } | - | ||||||||||||||||||
| 3144 | case Qt::ApplicationInactive: { | - | ||||||||||||||||||
| 3145 | QEvent appDeactivate(QEvent::ApplicationDeactivate); | - | ||||||||||||||||||
| 3146 | QCoreApplication::sendSpontaneousEvent(qApp, &appDeactivate); | - | ||||||||||||||||||
| 3147 | break; } | - | ||||||||||||||||||
| 3148 | default: | - | ||||||||||||||||||
| 3149 | break; | - | ||||||||||||||||||
| 3150 | } | - | ||||||||||||||||||
| 3151 | - | |||||||||||||||||||
| 3152 | QApplicationStateChangeEvent event(applicationState); | - | ||||||||||||||||||
| 3153 | QCoreApplication::sendSpontaneousEvent(qApp, &event); | - | ||||||||||||||||||
| 3154 | - | |||||||||||||||||||
| 3155 | emit qApp->applicationStateChanged(applicationState); | - | ||||||||||||||||||
| 3156 | } | - | ||||||||||||||||||
| 3157 | - | |||||||||||||||||||
| 3158 | #ifndef QT_NO_SESSIONMANAGER | - | ||||||||||||||||||
| 3159 | // ### Qt6: consider removing the feature or making it less intrusive | - | ||||||||||||||||||
| 3160 | /*! | - | ||||||||||||||||||
| 3161 | \since 5.6 | - | ||||||||||||||||||
| 3162 | - | |||||||||||||||||||
| 3163 | Returns whether QGuiApplication will use fallback session management. | - | ||||||||||||||||||
| 3164 | - | |||||||||||||||||||
| 3165 | The default is \c true. | - | ||||||||||||||||||
| 3166 | - | |||||||||||||||||||
| 3167 | If this is \c true and the session manager allows user interaction, | - | ||||||||||||||||||
| 3168 | QGuiApplication will try to close toplevel windows after | - | ||||||||||||||||||
| 3169 | commitDataRequest() has been emitted. If a window cannot be closed, session | - | ||||||||||||||||||
| 3170 | shutdown will be canceled and the application will keep running. | - | ||||||||||||||||||
| 3171 | - | |||||||||||||||||||
| 3172 | Fallback session management only benefits applications that have an | - | ||||||||||||||||||
| 3173 | "are you sure you want to close this window?" feature or other logic that | - | ||||||||||||||||||
| 3174 | prevents closing a toplevel window depending on certain conditions, and | - | ||||||||||||||||||
| 3175 | that do nothing to explicitly implement session management. In applications | - | ||||||||||||||||||
| 3176 | that \e do implement session management using the proper session management | - | ||||||||||||||||||
| 3177 | API, fallback session management interferes and may break session | - | ||||||||||||||||||
| 3178 | management logic. | - | ||||||||||||||||||
| 3179 | - | |||||||||||||||||||
| 3180 | \warning If all windows \e are closed due to fallback session management | - | ||||||||||||||||||
| 3181 | and quitOnLastWindowClosed() is \c true, the application will quit before | - | ||||||||||||||||||
| 3182 | it is explicitly instructed to quit through the platform's session | - | ||||||||||||||||||
| 3183 | management protocol. That violation of protocol may prevent the platform | - | ||||||||||||||||||
| 3184 | session manager from saving application state. | - | ||||||||||||||||||
| 3185 | - | |||||||||||||||||||
| 3186 | \sa setFallbackSessionManagementEnabled(), | - | ||||||||||||||||||
| 3187 | QSessionManager::allowsInteraction(), saveStateRequest(), | - | ||||||||||||||||||
| 3188 | commitDataRequest(), {Session Management} | - | ||||||||||||||||||
| 3189 | */ | - | ||||||||||||||||||
| 3190 | bool QGuiApplication::isFallbackSessionManagementEnabled() | - | ||||||||||||||||||
| 3191 | { | - | ||||||||||||||||||
| 3192 | return QGuiApplicationPrivate::is_fallback_session_management_enabled; | - | ||||||||||||||||||
| 3193 | } | - | ||||||||||||||||||
| 3194 | - | |||||||||||||||||||
| 3195 | /*! | - | ||||||||||||||||||
| 3196 | \since 5.6 | - | ||||||||||||||||||
| 3197 | - | |||||||||||||||||||
| 3198 | Sets whether QGuiApplication will use fallback session management to | - | ||||||||||||||||||
| 3199 | \a enabled. | - | ||||||||||||||||||
| 3200 | - | |||||||||||||||||||
| 3201 | \sa isFallbackSessionManagementEnabled() | - | ||||||||||||||||||
| 3202 | */ | - | ||||||||||||||||||
| 3203 | void QGuiApplication::setFallbackSessionManagementEnabled(bool enabled) | - | ||||||||||||||||||
| 3204 | { | - | ||||||||||||||||||
| 3205 | QGuiApplicationPrivate::is_fallback_session_management_enabled = enabled; | - | ||||||||||||||||||
| 3206 | } | - | ||||||||||||||||||
| 3207 | #endif // QT_NO_SESSIONMANAGER | - | ||||||||||||||||||
| 3208 | - | |||||||||||||||||||
| 3209 | /*! | - | ||||||||||||||||||
| 3210 | \since 4.2 | - | ||||||||||||||||||
| 3211 | \fn void QGuiApplication::commitDataRequest(QSessionManager &manager) | - | ||||||||||||||||||
| 3212 | - | |||||||||||||||||||
| 3213 | This signal deals with \l{Session Management}{session management}. It is | - | ||||||||||||||||||
| 3214 | emitted when the QSessionManager wants the application to commit all its | - | ||||||||||||||||||
| 3215 | data. | - | ||||||||||||||||||
| 3216 | - | |||||||||||||||||||
| 3217 | Usually this means saving all open files, after getting permission from | - | ||||||||||||||||||
| 3218 | the user. Furthermore you may want to provide a means by which the user | - | ||||||||||||||||||
| 3219 | can cancel the shutdown. | - | ||||||||||||||||||
| 3220 | - | |||||||||||||||||||
| 3221 | You should not exit the application within this signal. Instead, | - | ||||||||||||||||||
| 3222 | the session manager may or may not do this afterwards, depending on the | - | ||||||||||||||||||
| 3223 | context. | - | ||||||||||||||||||
| 3224 | - | |||||||||||||||||||
| 3225 | \warning Within this signal, no user interaction is possible, \e | - | ||||||||||||||||||
| 3226 | unless you ask the \a manager for explicit permission. See | - | ||||||||||||||||||
| 3227 | QSessionManager::allowsInteraction() and | - | ||||||||||||||||||
| 3228 | QSessionManager::allowsErrorInteraction() for details and example | - | ||||||||||||||||||
| 3229 | usage. | - | ||||||||||||||||||
| 3230 | - | |||||||||||||||||||
| 3231 | \note You should use Qt::DirectConnection when connecting to this signal. | - | ||||||||||||||||||
| 3232 | - | |||||||||||||||||||
| 3233 | \sa setFallbackSessionManagementEnabled(), isSessionRestored(), | - | ||||||||||||||||||
| 3234 | sessionId(), saveStateRequest(), {Session Management} | - | ||||||||||||||||||
| 3235 | */ | - | ||||||||||||||||||
| 3236 | - | |||||||||||||||||||
| 3237 | /*! | - | ||||||||||||||||||
| 3238 | \since 4.2 | - | ||||||||||||||||||
| 3239 | \fn void QGuiApplication::saveStateRequest(QSessionManager &manager) | - | ||||||||||||||||||
| 3240 | - | |||||||||||||||||||
| 3241 | This signal deals with \l{Session Management}{session management}. It is | - | ||||||||||||||||||
| 3242 | invoked when the \l{QSessionManager}{session manager} wants the application | - | ||||||||||||||||||
| 3243 | to preserve its state for a future session. | - | ||||||||||||||||||
| 3244 | - | |||||||||||||||||||
| 3245 | For example, a text editor would create a temporary file that includes the | - | ||||||||||||||||||
| 3246 | current contents of its edit buffers, the location of the cursor and other | - | ||||||||||||||||||
| 3247 | aspects of the current editing session. | - | ||||||||||||||||||
| 3248 | - | |||||||||||||||||||
| 3249 | You should never exit the application within this signal. Instead, the | - | ||||||||||||||||||
| 3250 | session manager may or may not do this afterwards, depending on the | - | ||||||||||||||||||
| 3251 | context. Futhermore, most session managers will very likely request a saved | - | ||||||||||||||||||
| 3252 | state immediately after the application has been started. This permits the | - | ||||||||||||||||||
| 3253 | session manager to learn about the application's restart policy. | - | ||||||||||||||||||
| 3254 | - | |||||||||||||||||||
| 3255 | \warning Within this signal, no user interaction is possible, \e | - | ||||||||||||||||||
| 3256 | unless you ask the \a manager for explicit permission. See | - | ||||||||||||||||||
| 3257 | QSessionManager::allowsInteraction() and | - | ||||||||||||||||||
| 3258 | QSessionManager::allowsErrorInteraction() for details. | - | ||||||||||||||||||
| 3259 | - | |||||||||||||||||||
| 3260 | \note You should use Qt::DirectConnection when connecting to this signal. | - | ||||||||||||||||||
| 3261 | - | |||||||||||||||||||
| 3262 | \sa isSessionRestored(), sessionId(), commitDataRequest(), {Session Management} | - | ||||||||||||||||||
| 3263 | */ | - | ||||||||||||||||||
| 3264 | - | |||||||||||||||||||
| 3265 | /*! | - | ||||||||||||||||||
| 3266 | \fn bool QGuiApplication::isSessionRestored() const | - | ||||||||||||||||||
| 3267 | - | |||||||||||||||||||
| 3268 | Returns \c true if the application has been restored from an earlier | - | ||||||||||||||||||
| 3269 | \l{Session Management}{session}; otherwise returns \c false. | - | ||||||||||||||||||
| 3270 | - | |||||||||||||||||||
| 3271 | \sa sessionId(), commitDataRequest(), saveStateRequest() | - | ||||||||||||||||||
| 3272 | */ | - | ||||||||||||||||||
| 3273 | - | |||||||||||||||||||
| 3274 | /*! | - | ||||||||||||||||||
| 3275 | \since 5.0 | - | ||||||||||||||||||
| 3276 | \fn bool QGuiApplication::isSavingSession() const | - | ||||||||||||||||||
| 3277 | - | |||||||||||||||||||
| 3278 | Returns \c true if the application is currently saving the | - | ||||||||||||||||||
| 3279 | \l{Session Management}{session}; otherwise returns \c false. | - | ||||||||||||||||||
| 3280 | - | |||||||||||||||||||
| 3281 | This is \c true when commitDataRequest() and saveStateRequest() are emitted, | - | ||||||||||||||||||
| 3282 | but also when the windows are closed afterwards by session management. | - | ||||||||||||||||||
| 3283 | - | |||||||||||||||||||
| 3284 | \sa sessionId(), commitDataRequest(), saveStateRequest() | - | ||||||||||||||||||
| 3285 | */ | - | ||||||||||||||||||
| 3286 | - | |||||||||||||||||||
| 3287 | /*! | - | ||||||||||||||||||
| 3288 | \fn QString QGuiApplication::sessionId() const | - | ||||||||||||||||||
| 3289 | - | |||||||||||||||||||
| 3290 | Returns the current \l{Session Management}{session's} identifier. | - | ||||||||||||||||||
| 3291 | - | |||||||||||||||||||
| 3292 | If the application has been restored from an earlier session, this | - | ||||||||||||||||||
| 3293 | identifier is the same as it was in that previous session. The session | - | ||||||||||||||||||
| 3294 | identifier is guaranteed to be unique both for different applications | - | ||||||||||||||||||
| 3295 | and for different instances of the same application. | - | ||||||||||||||||||
| 3296 | - | |||||||||||||||||||
| 3297 | \sa isSessionRestored(), sessionKey(), commitDataRequest(), saveStateRequest() | - | ||||||||||||||||||
| 3298 | */ | - | ||||||||||||||||||
| 3299 | - | |||||||||||||||||||
| 3300 | /*! | - | ||||||||||||||||||
| 3301 | \fn QString QGuiApplication::sessionKey() const | - | ||||||||||||||||||
| 3302 | - | |||||||||||||||||||
| 3303 | Returns the session key in the current \l{Session Management}{session}. | - | ||||||||||||||||||
| 3304 | - | |||||||||||||||||||
| 3305 | If the application has been restored from an earlier session, this key is | - | ||||||||||||||||||
| 3306 | the same as it was when the previous session ended. | - | ||||||||||||||||||
| 3307 | - | |||||||||||||||||||
| 3308 | The session key changes every time the session is saved. If the shutdown process | - | ||||||||||||||||||
| 3309 | is cancelled, another session key will be used when shutting down again. | - | ||||||||||||||||||
| 3310 | - | |||||||||||||||||||
| 3311 | \sa isSessionRestored(), sessionId(), commitDataRequest(), saveStateRequest() | - | ||||||||||||||||||
| 3312 | */ | - | ||||||||||||||||||
| 3313 | #ifndef QT_NO_SESSIONMANAGER | - | ||||||||||||||||||
| 3314 | bool QGuiApplication::isSessionRestored() const | - | ||||||||||||||||||
| 3315 | { | - | ||||||||||||||||||
| 3316 | Q_D(const QGuiApplication); | - | ||||||||||||||||||
| 3317 | return d->is_session_restored; | - | ||||||||||||||||||
| 3318 | } | - | ||||||||||||||||||
| 3319 | - | |||||||||||||||||||
| 3320 | QString QGuiApplication::sessionId() const | - | ||||||||||||||||||
| 3321 | { | - | ||||||||||||||||||
| 3322 | Q_D(const QGuiApplication); | - | ||||||||||||||||||
| 3323 | return d->session_manager->sessionId(); | - | ||||||||||||||||||
| 3324 | } | - | ||||||||||||||||||
| 3325 | - | |||||||||||||||||||
| 3326 | QString QGuiApplication::sessionKey() const | - | ||||||||||||||||||
| 3327 | { | - | ||||||||||||||||||
| 3328 | Q_D(const QGuiApplication); | - | ||||||||||||||||||
| 3329 | return d->session_manager->sessionKey(); | - | ||||||||||||||||||
| 3330 | } | - | ||||||||||||||||||
| 3331 | - | |||||||||||||||||||
| 3332 | bool QGuiApplication::isSavingSession() const | - | ||||||||||||||||||
| 3333 | { | - | ||||||||||||||||||
| 3334 | Q_D(const QGuiApplication); | - | ||||||||||||||||||
| 3335 | return d->is_saving_session; | - | ||||||||||||||||||
| 3336 | } | - | ||||||||||||||||||
| 3337 | - | |||||||||||||||||||
| 3338 | void QGuiApplicationPrivate::commitData() | - | ||||||||||||||||||
| 3339 | { | - | ||||||||||||||||||
| 3340 | Q_Q(QGuiApplication); | - | ||||||||||||||||||
| 3341 | is_saving_session = true; | - | ||||||||||||||||||
| 3342 | - | |||||||||||||||||||
| 3343 | emit q->commitDataRequest(*session_manager); | - | ||||||||||||||||||
| 3344 | if (is_fallback_session_management_enabled && session_manager->allowsInteraction() | - | ||||||||||||||||||
| 3345 | && !tryCloseAllWindows()) { | - | ||||||||||||||||||
| 3346 | session_manager->cancel(); | - | ||||||||||||||||||
| 3347 | } | - | ||||||||||||||||||
| 3348 | - | |||||||||||||||||||
| 3349 | is_saving_session = false; | - | ||||||||||||||||||
| 3350 | } | - | ||||||||||||||||||
| 3351 | - | |||||||||||||||||||
| 3352 | - | |||||||||||||||||||
| 3353 | void QGuiApplicationPrivate::saveState() | - | ||||||||||||||||||
| 3354 | { | - | ||||||||||||||||||
| 3355 | Q_Q(QGuiApplication); | - | ||||||||||||||||||
| 3356 | is_saving_session = true; | - | ||||||||||||||||||
| 3357 | emit q->saveStateRequest(*session_manager); | - | ||||||||||||||||||
| 3358 | is_saving_session = false; | - | ||||||||||||||||||
| 3359 | } | - | ||||||||||||||||||
| 3360 | #endif //QT_NO_SESSIONMANAGER | - | ||||||||||||||||||
| 3361 | - | |||||||||||||||||||
| 3362 | /*! | - | ||||||||||||||||||
| 3363 | \since 5.2 | - | ||||||||||||||||||
| 3364 | - | |||||||||||||||||||
| 3365 | Function that can be used to sync Qt state with the Window Systems state. | - | ||||||||||||||||||
| 3366 | - | |||||||||||||||||||
| 3367 | This function will first empty Qts events by calling QCoreApplication::processEvents(), | - | ||||||||||||||||||
| 3368 | then the platform plugin will sync up with the windowsystem, and finally Qts events | - | ||||||||||||||||||
| 3369 | will be delived by another call to QCoreApplication::processEvents(); | - | ||||||||||||||||||
| 3370 | - | |||||||||||||||||||
| 3371 | This function is timeconsuming and its use is discouraged. | - | ||||||||||||||||||
| 3372 | */ | - | ||||||||||||||||||
| 3373 | void QGuiApplication::sync() | - | ||||||||||||||||||
| 3374 | { | - | ||||||||||||||||||
| 3375 | QCoreApplication::processEvents(); | - | ||||||||||||||||||
| 3376 | if (QGuiApplicationPrivate::platform_integration | - | ||||||||||||||||||
| 3377 | && QGuiApplicationPrivate::platform_integration->hasCapability(QPlatformIntegration::SyncState)) { | - | ||||||||||||||||||
| 3378 | QGuiApplicationPrivate::platform_integration->sync(); | - | ||||||||||||||||||
| 3379 | QCoreApplication::processEvents(); | - | ||||||||||||||||||
| 3380 | QWindowSystemInterface::flushWindowSystemEvents(); | - | ||||||||||||||||||
| 3381 | } | - | ||||||||||||||||||
| 3382 | } | - | ||||||||||||||||||
| 3383 | - | |||||||||||||||||||
| 3384 | /*! | - | ||||||||||||||||||
| 3385 | \property QGuiApplication::layoutDirection | - | ||||||||||||||||||
| 3386 | \brief the default layout direction for this application | - | ||||||||||||||||||
| 3387 | - | |||||||||||||||||||
| 3388 | On system start-up, the default layout direction depends on the | - | ||||||||||||||||||
| 3389 | application's language. | - | ||||||||||||||||||
| 3390 | - | |||||||||||||||||||
| 3391 | The notifier signal was introduced in Qt 5.4. | - | ||||||||||||||||||
| 3392 | - | |||||||||||||||||||
| 3393 | \sa QWidget::layoutDirection, isLeftToRight(), isRightToLeft() | - | ||||||||||||||||||
| 3394 | */ | - | ||||||||||||||||||
| 3395 | - | |||||||||||||||||||
| 3396 | void QGuiApplication::setLayoutDirection(Qt::LayoutDirection direction) | - | ||||||||||||||||||
| 3397 | { | - | ||||||||||||||||||
| 3398 | if (layout_direction == direction || direction == Qt::LayoutDirectionAuto) | - | ||||||||||||||||||
| 3399 | return; | - | ||||||||||||||||||
| 3400 | - | |||||||||||||||||||
| 3401 | layout_direction = direction; | - | ||||||||||||||||||
| 3402 | - | |||||||||||||||||||
| 3403 | if (qGuiApp) { | - | ||||||||||||||||||
| 3404 | emit qGuiApp->layoutDirectionChanged(direction); | - | ||||||||||||||||||
| 3405 | QGuiApplicationPrivate::self->notifyLayoutDirectionChange(); | - | ||||||||||||||||||
| 3406 | } | - | ||||||||||||||||||
| 3407 | } | - | ||||||||||||||||||
| 3408 | - | |||||||||||||||||||
| 3409 | Qt::LayoutDirection QGuiApplication::layoutDirection() | - | ||||||||||||||||||
| 3410 | { | - | ||||||||||||||||||
| 3411 | // layout_direction is only ever Qt::LayoutDirectionAuto if setLayoutDirection | - | ||||||||||||||||||
| 3412 | // was never called, or called with Qt::LayoutDirectionAuto (which is a no-op). | - | ||||||||||||||||||
| 3413 | // In that case we return the default LeftToRight. | - | ||||||||||||||||||
| 3414 | return layout_direction == Qt::LayoutDirectionAuto ? Qt::LeftToRight : layout_direction; | - | ||||||||||||||||||
| 3415 | } | - | ||||||||||||||||||
| 3416 | - | |||||||||||||||||||
| 3417 | /*! | - | ||||||||||||||||||
| 3418 | \fn QCursor *QGuiApplication::overrideCursor() | - | ||||||||||||||||||
| 3419 | - | |||||||||||||||||||
| 3420 | Returns the active application override cursor. | - | ||||||||||||||||||
| 3421 | - | |||||||||||||||||||
| 3422 | This function returns 0 if no application cursor has been defined (i.e. the | - | ||||||||||||||||||
| 3423 | internal cursor stack is empty). | - | ||||||||||||||||||
| 3424 | - | |||||||||||||||||||
| 3425 | \sa setOverrideCursor(), restoreOverrideCursor() | - | ||||||||||||||||||
| 3426 | */ | - | ||||||||||||||||||
| 3427 | #ifndef QT_NO_CURSOR | - | ||||||||||||||||||
| 3428 | QCursor *QGuiApplication::overrideCursor() | - | ||||||||||||||||||
| 3429 | { | - | ||||||||||||||||||
| 3430 | CHECK_QAPP_INSTANCE(Q_NULLPTR) | - | ||||||||||||||||||
| 3431 | return qGuiApp->d_func()->cursor_list.isEmpty() ? 0 : &qGuiApp->d_func()->cursor_list.first(); | - | ||||||||||||||||||
| 3432 | } | - | ||||||||||||||||||
| 3433 | - | |||||||||||||||||||
| 3434 | /*! | - | ||||||||||||||||||
| 3435 | Changes the currently active application override cursor to \a cursor. | - | ||||||||||||||||||
| 3436 | - | |||||||||||||||||||
| 3437 | This function has no effect if setOverrideCursor() was not called. | - | ||||||||||||||||||
| 3438 | - | |||||||||||||||||||
| 3439 | \sa setOverrideCursor(), overrideCursor(), restoreOverrideCursor(), | - | ||||||||||||||||||
| 3440 | QWidget::setCursor() | - | ||||||||||||||||||
| 3441 | */ | - | ||||||||||||||||||
| 3442 | void QGuiApplication::changeOverrideCursor(const QCursor &cursor) | - | ||||||||||||||||||
| 3443 | { | - | ||||||||||||||||||
| 3444 | CHECK_QAPP_INSTANCE() | - | ||||||||||||||||||
| 3445 | if (qGuiApp->d_func()->cursor_list.isEmpty()) | - | ||||||||||||||||||
| 3446 | return; | - | ||||||||||||||||||
| 3447 | qGuiApp->d_func()->cursor_list.removeFirst(); | - | ||||||||||||||||||
| 3448 | setOverrideCursor(cursor); | - | ||||||||||||||||||
| 3449 | } | - | ||||||||||||||||||
| 3450 | #endif | - | ||||||||||||||||||
| 3451 | - | |||||||||||||||||||
| 3452 | - | |||||||||||||||||||
| 3453 | #ifndef QT_NO_CURSOR | - | ||||||||||||||||||
| 3454 | static inline void applyCursor(QWindow *w, QCursor c) | - | ||||||||||||||||||
| 3455 | { | - | ||||||||||||||||||
| 3456 | if (const QScreen *screen = w->screen()) | - | ||||||||||||||||||
| 3457 | if (QPlatformCursor *cursor = screen->handle()->cursor()) | - | ||||||||||||||||||
| 3458 | cursor->changeCursor(&c, w); | - | ||||||||||||||||||
| 3459 | } | - | ||||||||||||||||||
| 3460 | - | |||||||||||||||||||
| 3461 | static inline void unsetCursor(QWindow *w) | - | ||||||||||||||||||
| 3462 | { | - | ||||||||||||||||||
| 3463 | if (const QScreen *screen = w->screen()) | - | ||||||||||||||||||
| 3464 | if (QPlatformCursor *cursor = screen->handle()->cursor()) | - | ||||||||||||||||||
| 3465 | cursor->changeCursor(0, w); | - | ||||||||||||||||||
| 3466 | } | - | ||||||||||||||||||
| 3467 | - | |||||||||||||||||||
| 3468 | static inline void applyCursor(const QList<QWindow *> &l, const QCursor &c) | - | ||||||||||||||||||
| 3469 | { | - | ||||||||||||||||||
| 3470 | for (int i = 0; i < l.size(); ++i) { | - | ||||||||||||||||||
| 3471 | QWindow *w = l.at(i); | - | ||||||||||||||||||
| 3472 | if (w->handle() && w->type() != Qt::Desktop) | - | ||||||||||||||||||
| 3473 | applyCursor(w, c); | - | ||||||||||||||||||
| 3474 | } | - | ||||||||||||||||||
| 3475 | } | - | ||||||||||||||||||
| 3476 | - | |||||||||||||||||||
| 3477 | static inline void applyWindowCursor(const QList<QWindow *> &l) | - | ||||||||||||||||||
| 3478 | { | - | ||||||||||||||||||
| 3479 | for (int i = 0; i < l.size(); ++i) { | - | ||||||||||||||||||
| 3480 | QWindow *w = l.at(i); | - | ||||||||||||||||||
| 3481 | if (w->handle() && w->type() != Qt::Desktop) { | - | ||||||||||||||||||
| 3482 | if (qt_window_private(w)->hasCursor) { | - | ||||||||||||||||||
| 3483 | applyCursor(w, w->cursor()); | - | ||||||||||||||||||
| 3484 | } else { | - | ||||||||||||||||||
| 3485 | unsetCursor(w); | - | ||||||||||||||||||
| 3486 | } | - | ||||||||||||||||||
| 3487 | } | - | ||||||||||||||||||
| 3488 | } | - | ||||||||||||||||||
| 3489 | } | - | ||||||||||||||||||
| 3490 | - | |||||||||||||||||||
| 3491 | /*! | - | ||||||||||||||||||
| 3492 | \fn void QGuiApplication::setOverrideCursor(const QCursor &cursor) | - | ||||||||||||||||||
| 3493 | - | |||||||||||||||||||
| 3494 | Sets the application override cursor to \a cursor. | - | ||||||||||||||||||
| 3495 | - | |||||||||||||||||||
| 3496 | Application override cursors are intended for showing the user that the | - | ||||||||||||||||||
| 3497 | application is in a special state, for example during an operation that | - | ||||||||||||||||||
| 3498 | might take some time. | - | ||||||||||||||||||
| 3499 | - | |||||||||||||||||||
| 3500 | This cursor will be displayed in all the application's widgets until | - | ||||||||||||||||||
| 3501 | restoreOverrideCursor() or another setOverrideCursor() is called. | - | ||||||||||||||||||
| 3502 | - | |||||||||||||||||||
| 3503 | Application cursors are stored on an internal stack. setOverrideCursor() | - | ||||||||||||||||||
| 3504 | pushes the cursor onto the stack, and restoreOverrideCursor() pops the | - | ||||||||||||||||||
| 3505 | active cursor off the stack. changeOverrideCursor() changes the curently | - | ||||||||||||||||||
| 3506 | active application override cursor. | - | ||||||||||||||||||
| 3507 | - | |||||||||||||||||||
| 3508 | Every setOverrideCursor() must eventually be followed by a corresponding | - | ||||||||||||||||||
| 3509 | restoreOverrideCursor(), otherwise the stack will never be emptied. | - | ||||||||||||||||||
| 3510 | - | |||||||||||||||||||
| 3511 | Example: | - | ||||||||||||||||||
| 3512 | \snippet code/src_gui_kernel_qguiapplication_x11.cpp 0 | - | ||||||||||||||||||
| 3513 | - | |||||||||||||||||||
| 3514 | \sa overrideCursor(), restoreOverrideCursor(), changeOverrideCursor(), | - | ||||||||||||||||||
| 3515 | QWidget::setCursor() | - | ||||||||||||||||||
| 3516 | */ | - | ||||||||||||||||||
| 3517 | void QGuiApplication::setOverrideCursor(const QCursor &cursor) | - | ||||||||||||||||||
| 3518 | { | - | ||||||||||||||||||
| 3519 | CHECK_QAPP_INSTANCE() | - | ||||||||||||||||||
| 3520 | qGuiApp->d_func()->cursor_list.prepend(cursor); | - | ||||||||||||||||||
| 3521 | applyCursor(QGuiApplicationPrivate::window_list, cursor); | - | ||||||||||||||||||
| 3522 | } | - | ||||||||||||||||||
| 3523 | - | |||||||||||||||||||
| 3524 | /*! | - | ||||||||||||||||||
| 3525 | \fn void QGuiApplication::restoreOverrideCursor() | - | ||||||||||||||||||
| 3526 | - | |||||||||||||||||||
| 3527 | Undoes the last setOverrideCursor(). | - | ||||||||||||||||||
| 3528 | - | |||||||||||||||||||
| 3529 | If setOverrideCursor() has been called twice, calling | - | ||||||||||||||||||
| 3530 | restoreOverrideCursor() will activate the first cursor set. Calling this | - | ||||||||||||||||||
| 3531 | function a second time restores the original widgets' cursors. | - | ||||||||||||||||||
| 3532 | - | |||||||||||||||||||
| 3533 | \sa setOverrideCursor(), overrideCursor() | - | ||||||||||||||||||
| 3534 | */ | - | ||||||||||||||||||
| 3535 | void QGuiApplication::restoreOverrideCursor() | - | ||||||||||||||||||
| 3536 | { | - | ||||||||||||||||||
| 3537 | CHECK_QAPP_INSTANCE() | - | ||||||||||||||||||
| 3538 | if (qGuiApp->d_func()->cursor_list.isEmpty()) | - | ||||||||||||||||||
| 3539 | return; | - | ||||||||||||||||||
| 3540 | qGuiApp->d_func()->cursor_list.removeFirst(); | - | ||||||||||||||||||
| 3541 | if (qGuiApp->d_func()->cursor_list.size() > 0) { | - | ||||||||||||||||||
| 3542 | QCursor c(qGuiApp->d_func()->cursor_list.value(0)); | - | ||||||||||||||||||
| 3543 | applyCursor(QGuiApplicationPrivate::window_list, c); | - | ||||||||||||||||||
| 3544 | } else { | - | ||||||||||||||||||
| 3545 | applyWindowCursor(QGuiApplicationPrivate::window_list); | - | ||||||||||||||||||
| 3546 | } | - | ||||||||||||||||||
| 3547 | } | - | ||||||||||||||||||
| 3548 | #endif// QT_NO_CURSOR | - | ||||||||||||||||||
| 3549 | - | |||||||||||||||||||
| 3550 | /*! | - | ||||||||||||||||||
| 3551 | Returns the application's style hints. | - | ||||||||||||||||||
| 3552 | - | |||||||||||||||||||
| 3553 | The style hints encapsulate a set of platform dependent properties | - | ||||||||||||||||||
| 3554 | such as double click intervals, full width selection and others. | - | ||||||||||||||||||
| 3555 | - | |||||||||||||||||||
| 3556 | The hints can be used to integrate tighter with the underlying platform. | - | ||||||||||||||||||
| 3557 | - | |||||||||||||||||||
| 3558 | \sa QStyleHints | - | ||||||||||||||||||
| 3559 | */ | - | ||||||||||||||||||
| 3560 | QStyleHints *QGuiApplication::styleHints() | - | ||||||||||||||||||
| 3561 | { | - | ||||||||||||||||||
| 3562 | if (!QGuiApplicationPrivate::styleHints) | - | ||||||||||||||||||
| 3563 | QGuiApplicationPrivate::styleHints = new QStyleHints(); | - | ||||||||||||||||||
| 3564 | return QGuiApplicationPrivate::styleHints; | - | ||||||||||||||||||
| 3565 | } | - | ||||||||||||||||||
| 3566 | - | |||||||||||||||||||
| 3567 | /*! | - | ||||||||||||||||||
| 3568 | Sets whether Qt should use the system's standard colors, fonts, etc., to | - | ||||||||||||||||||
| 3569 | \a on. By default, this is \c true. | - | ||||||||||||||||||
| 3570 | - | |||||||||||||||||||
| 3571 | This function must be called before creating the QGuiApplication object, like | - | ||||||||||||||||||
| 3572 | this: | - | ||||||||||||||||||
| 3573 | - | |||||||||||||||||||
| 3574 | \snippet code/src_gui_kernel_qguiapplication.cpp 0 | - | ||||||||||||||||||
| 3575 | - | |||||||||||||||||||
| 3576 | \sa desktopSettingsAware() | - | ||||||||||||||||||
| 3577 | */ | - | ||||||||||||||||||
| 3578 | void QGuiApplication::setDesktopSettingsAware(bool on) | - | ||||||||||||||||||
| 3579 | { | - | ||||||||||||||||||
| 3580 | QGuiApplicationPrivate::obey_desktop_settings = on; | - | ||||||||||||||||||
| 3581 | } | - | ||||||||||||||||||
| 3582 | - | |||||||||||||||||||
| 3583 | /*! | - | ||||||||||||||||||
| 3584 | Returns \c true if Qt is set to use the system's standard colors, fonts, etc.; | - | ||||||||||||||||||
| 3585 | otherwise returns \c false. The default is \c true. | - | ||||||||||||||||||
| 3586 | - | |||||||||||||||||||
| 3587 | \sa setDesktopSettingsAware() | - | ||||||||||||||||||
| 3588 | */ | - | ||||||||||||||||||
| 3589 | bool QGuiApplication::desktopSettingsAware() | - | ||||||||||||||||||
| 3590 | { | - | ||||||||||||||||||
| 3591 | return QGuiApplicationPrivate::obey_desktop_settings; | - | ||||||||||||||||||
| 3592 | } | - | ||||||||||||||||||
| 3593 | - | |||||||||||||||||||
| 3594 | /*! | - | ||||||||||||||||||
| 3595 | returns the input method. | - | ||||||||||||||||||
| 3596 | - | |||||||||||||||||||
| 3597 | The input method returns properties about the state and position of | - | ||||||||||||||||||
| 3598 | the virtual keyboard. It also provides information about the position of the | - | ||||||||||||||||||
| 3599 | current focused input element. | - | ||||||||||||||||||
| 3600 | - | |||||||||||||||||||
| 3601 | \sa QInputMethod | - | ||||||||||||||||||
| 3602 | */ | - | ||||||||||||||||||
| 3603 | QInputMethod *QGuiApplication::inputMethod() | - | ||||||||||||||||||
| 3604 | { | - | ||||||||||||||||||
| 3605 | CHECK_QAPP_INSTANCE(Q_NULLPTR) | - | ||||||||||||||||||
| 3606 | if (!qGuiApp->d_func()->inputMethod) | - | ||||||||||||||||||
| 3607 | qGuiApp->d_func()->inputMethod = new QInputMethod(); | - | ||||||||||||||||||
| 3608 | return qGuiApp->d_func()->inputMethod; | - | ||||||||||||||||||
| 3609 | } | - | ||||||||||||||||||
| 3610 | - | |||||||||||||||||||
| 3611 | /*! | - | ||||||||||||||||||
| 3612 | \fn void QGuiApplication::fontDatabaseChanged() | - | ||||||||||||||||||
| 3613 | - | |||||||||||||||||||
| 3614 | This signal is emitted when application fonts are loaded or removed. | - | ||||||||||||||||||
| 3615 | - | |||||||||||||||||||
| 3616 | \sa QFontDatabase::addApplicationFont(), | - | ||||||||||||||||||
| 3617 | QFontDatabase::addApplicationFontFromData(), | - | ||||||||||||||||||
| 3618 | QFontDatabase::removeAllApplicationFonts(), | - | ||||||||||||||||||
| 3619 | QFontDatabase::removeApplicationFont() | - | ||||||||||||||||||
| 3620 | */ | - | ||||||||||||||||||
| 3621 | - | |||||||||||||||||||
| 3622 | QPixmap QGuiApplicationPrivate::getPixmapCursor(Qt::CursorShape cshape) | - | ||||||||||||||||||
| 3623 | { | - | ||||||||||||||||||
| 3624 | Q_UNUSED(cshape); | - | ||||||||||||||||||
| 3625 | return QPixmap(); | - | ||||||||||||||||||
| 3626 | } | - | ||||||||||||||||||
| 3627 | - | |||||||||||||||||||
| 3628 | void QGuiApplicationPrivate::notifyThemeChanged() | - | ||||||||||||||||||
| 3629 | { | - | ||||||||||||||||||
| 3630 | if (!(applicationResourceFlags & ApplicationPaletteExplicitlySet) && | - | ||||||||||||||||||
| 3631 | !QCoreApplication::testAttribute(Qt::AA_SetPalette)) { | - | ||||||||||||||||||
| 3632 | clearPalette(); | - | ||||||||||||||||||
| 3633 | initPalette(); | - | ||||||||||||||||||
| 3634 | } | - | ||||||||||||||||||
| 3635 | if (!(applicationResourceFlags & ApplicationFontExplicitlySet)) { | - | ||||||||||||||||||
| 3636 | QMutexLocker locker(&applicationFontMutex); | - | ||||||||||||||||||
| 3637 | clearFontUnlocked(); | - | ||||||||||||||||||
| 3638 | initFontUnlocked(); | - | ||||||||||||||||||
| 3639 | } | - | ||||||||||||||||||
| 3640 | } | - | ||||||||||||||||||
| 3641 | - | |||||||||||||||||||
| 3642 | #ifndef QT_NO_DRAGANDDROP | - | ||||||||||||||||||
| 3643 | void QGuiApplicationPrivate::notifyDragStarted(const QDrag *drag) | - | ||||||||||||||||||
| 3644 | { | - | ||||||||||||||||||
| 3645 | Q_UNUSED(drag) | - | ||||||||||||||||||
| 3646 | - | |||||||||||||||||||
| 3647 | } | - | ||||||||||||||||||
| 3648 | #endif | - | ||||||||||||||||||
| 3649 | - | |||||||||||||||||||
| 3650 | const QDrawHelperGammaTables *QGuiApplicationPrivate::gammaTables() | - | ||||||||||||||||||
| 3651 | { | - | ||||||||||||||||||
| 3652 | QDrawHelperGammaTables *result = m_gammaTables.load(); | - | ||||||||||||||||||
| 3653 | if (!result){ | - | ||||||||||||||||||
| 3654 | QDrawHelperGammaTables *tables = new QDrawHelperGammaTables(fontSmoothingGamma); | - | ||||||||||||||||||
| 3655 | if (!m_gammaTables.testAndSetRelease(0, tables)) | - | ||||||||||||||||||
| 3656 | delete tables; | - | ||||||||||||||||||
| 3657 | result = m_gammaTables.load(); | - | ||||||||||||||||||
| 3658 | } | - | ||||||||||||||||||
| 3659 | return result; | - | ||||||||||||||||||
| 3660 | } | - | ||||||||||||||||||
| 3661 | - | |||||||||||||||||||
| 3662 | void QGuiApplicationPrivate::_q_updateFocusObject(QObject *object) | - | ||||||||||||||||||
| 3663 | { | - | ||||||||||||||||||
| 3664 | Q_Q(QGuiApplication); | - | ||||||||||||||||||
| 3665 | - | |||||||||||||||||||
| 3666 | QPlatformInputContext *inputContext = platformIntegration()->inputContext(); | - | ||||||||||||||||||
| 3667 | bool enabled = false; | - | ||||||||||||||||||
| 3668 | if (object && inputContext) { | - | ||||||||||||||||||
| 3669 | QInputMethodQueryEvent query(Qt::ImEnabled | Qt::ImHints); | - | ||||||||||||||||||
| 3670 | QGuiApplication::sendEvent(object, &query); | - | ||||||||||||||||||
| 3671 | enabled = query.value(Qt::ImEnabled).toBool(); | - | ||||||||||||||||||
| 3672 | if (enabled) { | - | ||||||||||||||||||
| 3673 | static const bool supportsHiddenText = inputContext->hasCapability(QPlatformInputContext::HiddenTextCapability); | - | ||||||||||||||||||
| 3674 | const Qt::InputMethodHints hints = static_cast<Qt::InputMethodHints>(query.value(Qt::ImHints).toInt()); | - | ||||||||||||||||||
| 3675 | if ((hints & Qt::ImhHiddenText) && !supportsHiddenText) | - | ||||||||||||||||||
| 3676 | enabled = false; | - | ||||||||||||||||||
| 3677 | } | - | ||||||||||||||||||
| 3678 | } | - | ||||||||||||||||||
| 3679 | - | |||||||||||||||||||
| 3680 | QPlatformInputContextPrivate::setInputMethodAccepted(enabled); | - | ||||||||||||||||||
| 3681 | if (inputContext) | - | ||||||||||||||||||
| 3682 | inputContext->setFocusObject(object); | - | ||||||||||||||||||
| 3683 | emit q->focusObjectChanged(object); | - | ||||||||||||||||||
| 3684 | } | - | ||||||||||||||||||
| 3685 | - | |||||||||||||||||||
| 3686 | enum MouseMasks { | - | ||||||||||||||||||
| 3687 | MouseCapsMask = 0xFF, | - | ||||||||||||||||||
| 3688 | MouseSourceMaskDst = 0xFF00, | - | ||||||||||||||||||
| 3689 | MouseSourceMaskSrc = MouseCapsMask, | - | ||||||||||||||||||
| 3690 | MouseSourceShift = 8, | - | ||||||||||||||||||
| 3691 | MouseFlagsCapsMask = 0xFF0000, | - | ||||||||||||||||||
| 3692 | MouseFlagsShift = 16 | - | ||||||||||||||||||
| 3693 | }; | - | ||||||||||||||||||
| 3694 | - | |||||||||||||||||||
| 3695 | int QGuiApplicationPrivate::mouseEventCaps(QMouseEvent *event) | - | ||||||||||||||||||
| 3696 | { | - | ||||||||||||||||||
| 3697 | return event->caps & MouseCapsMask; | - | ||||||||||||||||||
| 3698 | } | - | ||||||||||||||||||
| 3699 | - | |||||||||||||||||||
| 3700 | QVector2D QGuiApplicationPrivate::mouseEventVelocity(QMouseEvent *event) | - | ||||||||||||||||||
| 3701 | { | - | ||||||||||||||||||
| 3702 | return event->velocity; | - | ||||||||||||||||||
| 3703 | } | - | ||||||||||||||||||
| 3704 | - | |||||||||||||||||||
| 3705 | void QGuiApplicationPrivate::setMouseEventCapsAndVelocity(QMouseEvent *event, int caps, const QVector2D &velocity) | - | ||||||||||||||||||
| 3706 | { | - | ||||||||||||||||||
| 3707 | Q_ASSERT(caps <= MouseCapsMask); | - | ||||||||||||||||||
| 3708 | event->caps &= ~MouseCapsMask; | - | ||||||||||||||||||
| 3709 | event->caps |= caps & MouseCapsMask; | - | ||||||||||||||||||
| 3710 | event->velocity = velocity; | - | ||||||||||||||||||
| 3711 | } | - | ||||||||||||||||||
| 3712 | - | |||||||||||||||||||
| 3713 | Qt::MouseEventSource QGuiApplicationPrivate::mouseEventSource(const QMouseEvent *event) | - | ||||||||||||||||||
| 3714 | { | - | ||||||||||||||||||
| 3715 | return Qt::MouseEventSource((event->caps & MouseSourceMaskDst) >> MouseSourceShift); | - | ||||||||||||||||||
| 3716 | } | - | ||||||||||||||||||
| 3717 | - | |||||||||||||||||||
| 3718 | void QGuiApplicationPrivate::setMouseEventSource(QMouseEvent *event, Qt::MouseEventSource source) | - | ||||||||||||||||||
| 3719 | { | - | ||||||||||||||||||
| 3720 | // Mouse event synthesization status is encoded in the caps field because | - | ||||||||||||||||||
| 3721 | // QTouchDevice::CapabilityFlag uses only 6 bits from it. | - | ||||||||||||||||||
| 3722 | int value = source; | - | ||||||||||||||||||
| 3723 | Q_ASSERT(value <= MouseSourceMaskSrc); | - | ||||||||||||||||||
| 3724 | event->caps &= ~MouseSourceMaskDst; | - | ||||||||||||||||||
| 3725 | event->caps |= (value & MouseSourceMaskSrc) << MouseSourceShift; | - | ||||||||||||||||||
| 3726 | } | - | ||||||||||||||||||
| 3727 | - | |||||||||||||||||||
| 3728 | Qt::MouseEventFlags QGuiApplicationPrivate::mouseEventFlags(const QMouseEvent *event) | - | ||||||||||||||||||
| 3729 | { | - | ||||||||||||||||||
| 3730 | return Qt::MouseEventFlags((event->caps & MouseFlagsCapsMask) >> MouseFlagsShift); | - | ||||||||||||||||||
| 3731 | } | - | ||||||||||||||||||
| 3732 | - | |||||||||||||||||||
| 3733 | void QGuiApplicationPrivate::setMouseEventFlags(QMouseEvent *event, Qt::MouseEventFlags flags) | - | ||||||||||||||||||
| 3734 | { | - | ||||||||||||||||||
| 3735 | // use the 0x00FF0000 byte from caps (containing up to 7 mouse event flags) | - | ||||||||||||||||||
| 3736 | unsigned int value = flags; | - | ||||||||||||||||||
| 3737 | Q_ASSERT(value <= Qt::MouseEventFlagMask); | - | ||||||||||||||||||
| 3738 | event->caps &= ~MouseFlagsCapsMask; | - | ||||||||||||||||||
| 3739 | event->caps |= (value & Qt::MouseEventFlagMask) << MouseFlagsShift; | - | ||||||||||||||||||
| 3740 | } | - | ||||||||||||||||||
| 3741 | - | |||||||||||||||||||
| 3742 | QInputDeviceManager *QGuiApplicationPrivate::inputDeviceManager() | - | ||||||||||||||||||
| 3743 | { | - | ||||||||||||||||||
| 3744 | Q_ASSERT(QGuiApplication::instance()); | - | ||||||||||||||||||
| 3745 | - | |||||||||||||||||||
| 3746 | if (!m_inputDeviceManager) | - | ||||||||||||||||||
| 3747 | m_inputDeviceManager = new QInputDeviceManager(QGuiApplication::instance()); | - | ||||||||||||||||||
| 3748 | - | |||||||||||||||||||
| 3749 | return m_inputDeviceManager; | - | ||||||||||||||||||
| 3750 | } | - | ||||||||||||||||||
| 3751 | - | |||||||||||||||||||
| 3752 | #include "moc_qguiapplication.cpp" | - | ||||||||||||||||||
| 3753 | - | |||||||||||||||||||
| 3754 | QT_END_NAMESPACE | - | ||||||||||||||||||
| Source code | Switch to Preprocessed file |