diff options
Diffstat (limited to 'src/gui/kernel/qguiapplication_p.h')
-rw-r--r-- | src/gui/kernel/qguiapplication_p.h | 148 |
1 files changed, 78 insertions, 70 deletions
diff --git a/src/gui/kernel/qguiapplication_p.h b/src/gui/kernel/qguiapplication_p.h index ea791326cd..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 @@ -53,11 +17,15 @@ #include <QtGui/private/qtguiglobal_p.h> #include <QtGui/qguiapplication.h> +#include <QtGui/qicon.h> +#include <QtCore/QHash> #include <QtCore/QPointF> -#include <QtCore/QSharedPointer> #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> @@ -66,7 +34,9 @@ # include "private/qshortcutmap_p.h" #endif -#include <qicon.h> +#include <QtCore/qpointer.h> + +#include <memory> QT_BEGIN_NAMESPACE @@ -89,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(); @@ -104,10 +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 maybeLastWindowClosed(); + bool lastWindowClosed() const; + static bool quitOnLastWindowClosed; static void captureGlobalModifierState(QEvent *e); static Qt::KeyboardModifiers modifier_buttons; @@ -143,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); @@ -187,11 +161,7 @@ public: Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers); #endif -#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) static bool processNativeEvent(QWindow *window, const QByteArray &eventType, void *message, qintptr *result); -#else - static bool processNativeEvent(QWindow *window, const QByteArray &eventType, void *message, long *result); -#endif static bool sendQWindowEventToQPlatformWindow(QWindow *window, QEvent *event); @@ -207,8 +177,6 @@ public: return alignment; } - static void emitLastWindowClosed(); - QPixmap getPixmapCursor(Qt::CursorShape cshape); void _q_updateFocusObject(QObject *object); @@ -224,16 +192,53 @@ 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; static Qt::HighDpiScaleFactorRoundingPolicy highDpiScaleFactorRoundingPolicy; - static bool highDpiScalingUpdated; static QPointer<QWindow> currentDragWindow; // TODO remove this: QPointingDevice can store what we need directly @@ -317,10 +322,9 @@ public: #endif static void updatePalette(); - QEvent *cloneEvent(QEvent *e) override; protected: - virtual void notifyThemeChanged(); + virtual void handleThemeChanged(); static bool setPalette(const QPalette &palette); virtual QPalette basePalette() const; @@ -336,10 +340,11 @@ private: friend class QDragManager; static QGuiApplicationPrivate *self; - static QPointingDevice *m_fakeTouchDevice; static int m_fakeMouseSourcePointId; - QSharedPointer<QColorTrcLut> m_a8ColorProfile; - QSharedPointer<QColorTrcLut> m_a32ColorProfile; +#ifdef Q_OS_WIN + std::shared_ptr<QColorTrcLut> m_a8ColorProfile; +#endif + std::shared_ptr<QColorTrcLut> m_a32ColorProfile; bool ownGlobalShareContext; @@ -350,17 +355,18 @@ private: static qreal m_maxDevicePixelRatio; }; -// ----------------- QPlatformInterface ----------------- +// ----------------- QNativeInterface ----------------- + +class QWindowsMimeConverter; -namespace QPlatformInterface::Private { +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 { - QT_DECLARE_PLATFORM_INTERFACE(QWindowsApplication) + QT_DECLARE_NATIVE_INTERFACE(QWindowsApplication, 1, QGuiApplication) enum WindowActivationBehavior { DefaultActivateWindow, @@ -388,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; @@ -412,14 +418,16 @@ 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 -} // QPlatformInterface::Private +} // QNativeInterface::Private #if defined(Q_OS_WIN) -Q_DECLARE_OPERATORS_FOR_FLAGS(QPlatformInterface::Private::QWindowsApplication::TouchWindowTouchTypes) -Q_DECLARE_OPERATORS_FOR_FLAGS(QPlatformInterface::Private::QWindowsApplication::DarkModeHandling) +Q_DECLARE_OPERATORS_FOR_FLAGS(QNativeInterface::Private::QWindowsApplication::TouchWindowTouchTypes) +Q_DECLARE_OPERATORS_FOR_FLAGS(QNativeInterface::Private::QWindowsApplication::DarkModeHandling) #endif QT_END_NAMESPACE |