diff options
Diffstat (limited to 'src/gui/kernel/qguiapplication_p.h')
-rw-r--r-- | src/gui/kernel/qguiapplication_p.h | 118 |
1 files changed, 64 insertions, 54 deletions
diff --git a/src/gui/kernel/qguiapplication_p.h b/src/gui/kernel/qguiapplication_p.h index 3450c6e36b..cca79534fc 100644 --- a/src/gui/kernel/qguiapplication_p.h +++ b/src/gui/kernel/qguiapplication_p.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtGui module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef QGUIAPPLICATION_P_H #define QGUIAPPLICATION_P_H @@ -55,10 +19,13 @@ #include <QtGui/qguiapplication.h> #include <QtGui/qicon.h> +#include <QtCore/QHash> #include <QtCore/QPointF> #include <QtCore/private/qcoreapplication_p.h> #include <QtCore/qnativeinterface.h> +#include <QtCore/private/qnativeinterface_p.h> +#include <QtCore/private/qnumeric_p.h> #include <QtCore/private/qthread_p.h> #include <qpa/qwindowsysteminterface.h> @@ -67,6 +34,8 @@ # include "private/qshortcutmap_p.h" #endif +#include <QtCore/qpointer.h> + #include <memory> QT_BEGIN_NAMESPACE @@ -90,7 +59,7 @@ class Q_GUI_EXPORT QGuiApplicationPrivate : public QCoreApplicationPrivate { Q_DECLARE_PUBLIC(QGuiApplication) public: - QGuiApplicationPrivate(int &argc, char **argv, int flags); + QGuiApplicationPrivate(int &argc, char **argv); ~QGuiApplicationPrivate(); void init(); @@ -105,11 +74,12 @@ public: #if QT_CONFIG(commandlineparser) void addQtOptions(QList<QCommandLineOption> *options) override; #endif - virtual bool shouldQuit() override; + bool canQuitAutomatically() override; void quit() override; - bool shouldQuitInternal(const QWindowList &processedWindows); - void maybeQuitOnLastWindowClosed(QWindow *closedWindow); + void maybeLastWindowClosed(); + bool lastWindowClosed() const; + static bool quitOnLastWindowClosed; static void captureGlobalModifierState(QEvent *e); static Qt::KeyboardModifiers modifier_buttons; @@ -145,9 +115,11 @@ public: static void processEnterEvent(QWindowSystemInterfacePrivate::EnterEvent *e); static void processLeaveEvent(QWindowSystemInterfacePrivate::LeaveEvent *e); - static void processActivatedEvent(QWindowSystemInterfacePrivate::ActivatedWindowEvent *e); + static void processFocusWindowEvent(QWindowSystemInterfacePrivate::FocusWindowEvent *e); + static void processWindowStateChangedEvent(QWindowSystemInterfacePrivate::WindowStateChangedEvent *e); static void processWindowScreenChangedEvent(QWindowSystemInterfacePrivate::WindowScreenChangedEvent *e); + static void processWindowDevicePixelRatioChangedEvent(QWindowSystemInterfacePrivate::WindowDevicePixelRatioChangedEvent *e); static void processSafeAreaMarginsChangedEvent(QWindowSystemInterfacePrivate::SafeAreaMarginsChangedEvent *e); @@ -205,8 +177,6 @@ public: return alignment; } - static void emitLastWindowClosed(); - QPixmap getPixmapCursor(Qt::CursorShape cshape); void _q_updateFocusObject(QObject *object); @@ -222,12 +192,49 @@ public: static void showModalWindow(QWindow *window); static void hideModalWindow(QWindow *window); static void updateBlockedStatus(QWindow *window); - virtual bool isWindowBlocked(QWindow *window, QWindow **blockingWindow = nullptr) const; + + virtual Qt::WindowModality defaultModality() const; + virtual bool windowNeverBlocked(QWindow *window) const; + bool isWindowBlocked(QWindow *window, QWindow **blockingWindow = nullptr) const; virtual bool popupActive() { return false; } virtual bool closeAllPopups() { return false; } static Qt::MouseButton mousePressButton; - static QPointF lastCursorPosition; + static struct QLastCursorPosition { + constexpr inline QLastCursorPosition() noexcept : thePoint(qt_inf(), qt_inf()) {} + constexpr inline Q_IMPLICIT QLastCursorPosition(QPointF p) noexcept : thePoint(p) {} + constexpr inline Q_IMPLICIT operator QPointF() const noexcept { return thePoint; } + constexpr inline qreal x() const noexcept{ return thePoint.x(); } + constexpr inline qreal y() const noexcept{ return thePoint.y(); } + Q_GUI_EXPORT QPoint toPoint() const noexcept; + + constexpr void reset() noexcept { *this = QLastCursorPosition{}; } + + // QGuiApplicationPrivate::lastCursorPosition is used for mouse-move detection + // but even QPointF's qFuzzCompare on doubles is too precise, and causes move-noise + // e.g. on macOS (see QTBUG-111170). So we specialize the equality operators here + // to use single-point precision. + friend constexpr bool operator==(const QLastCursorPosition &p1, const QPointF &p2) noexcept + { + return qFuzzyCompare(float(p1.x()), float(p2.x())) + && qFuzzyCompare(float(p1.y()), float(p2.y())); + } + friend constexpr bool operator!=(const QLastCursorPosition &p1, const QPointF &p2) noexcept + { + return !(p1 == p2); + } + friend constexpr bool operator==(const QPointF &p1, const QLastCursorPosition &p2) noexcept + { + return p2 == p1; + } + friend constexpr bool operator!=(const QPointF &p1, const QLastCursorPosition &p2) noexcept + { + return !(p2 == p1); + } + + private: + QPointF thePoint; + } lastCursorPosition; static QWindow *currentMouseWindow; static QWindow *currentMousePressWindow; static Qt::ApplicationState applicationState; @@ -317,7 +324,7 @@ public: static void updatePalette(); protected: - virtual void notifyThemeChanged(); + virtual void handleThemeChanged(); static bool setPalette(const QPalette &palette); virtual QPalette basePalette() const; @@ -350,11 +357,12 @@ private: // ----------------- QNativeInterface ----------------- +class QWindowsMimeConverter; + namespace QNativeInterface::Private { -#if defined(Q_OS_WIN) || defined(Q_CLANG_QDOC) +#if defined(Q_OS_WIN) || defined(Q_QDOC) -class QWindowsMime; struct Q_GUI_EXPORT QWindowsApplication { @@ -386,18 +394,18 @@ struct Q_GUI_EXPORT QWindowsApplication virtual WindowActivationBehavior windowActivationBehavior() const = 0; virtual void setWindowActivationBehavior(WindowActivationBehavior behavior) = 0; + virtual void setHasBorderInFullScreenDefault(bool border) = 0; + virtual bool isTabletMode() const = 0; virtual bool isWinTabEnabled() const = 0; virtual bool setWinTabEnabled(bool enabled) = 0; - virtual bool isDarkMode() const = 0; - virtual DarkModeHandling darkModeHandling() const = 0; virtual void setDarkModeHandling(DarkModeHandling handling) = 0; - virtual void registerMime(QWindowsMime *mime) = 0; - virtual void unregisterMime(QWindowsMime *mime) = 0; + virtual void registerMime(QWindowsMimeConverter *mime) = 0; + virtual void unregisterMime(QWindowsMimeConverter *mime) = 0; virtual int registerMimeType(const QString &mime) = 0; @@ -410,6 +418,8 @@ struct Q_GUI_EXPORT QWindowsApplication virtual QVariant gpu() const = 0; // internal, used by qtdiag virtual QVariant gpuList() const = 0; + + virtual void populateLightSystemPalette(QPalette &pal) const = 0; }; #endif // Q_OS_WIN |