diff options
Diffstat (limited to 'src/gui/kernel')
26 files changed, 329 insertions, 70 deletions
diff --git a/src/gui/kernel/qcursor.cpp b/src/gui/kernel/qcursor.cpp index b7035d47c4..8ae9085d9f 100644 --- a/src/gui/kernel/qcursor.cpp +++ b/src/gui/kernel/qcursor.cpp @@ -471,6 +471,54 @@ QCursor::QCursor(Qt::CursorShape shape) setShape(shape); } +/*! + \fn bool operator==(const QCursor &lhs, const QCursor &rhs) + \relates QCursor + \since 5.10 + + Equality operator. Returns \c true if \a lhs and \a rhs + have the same \l{QCursor::}{shape()} and, in the case of + \l{Qt::BitmapCursor}{bitmap cursors}, the same \l{QCursor::}{hotSpot()} + and either the same \l{QCursor::}{pixmap()} or the same + \l{QCursor::}{bitmap()} and \l{QCursor::}{mask()}. + + \note When comparing bitmap cursors, this function only + compares the bitmaps' \l{QPixmap::cacheKey()}{cache keys}, + not each pixel. + + \sa operator!=(const QCursor &lhs, const QCursor &rhs) +*/ +bool operator==(const QCursor &lhs, const QCursor &rhs) Q_DECL_NOTHROW +{ + if (lhs.d == rhs.d) + return true; // Copy or same shape + + // Check pixmaps or bitmaps cache keys. Notice that having BitmapCursor + // shape implies either non-null pixmap or non-null bitmap and mask + if (lhs.shape() == Qt::BitmapCursor && rhs.shape() == Qt::BitmapCursor + && lhs.hotSpot() == rhs.hotSpot()) { + if (!lhs.d->pixmap.isNull()) + return lhs.d->pixmap.cacheKey() == rhs.d->pixmap.cacheKey(); + + if (!rhs.d->pixmap.isNull()) + return false; + + return lhs.d->bm->cacheKey() == rhs.d->bm->cacheKey() + && lhs.d->bmm->cacheKey() == rhs.d->bmm->cacheKey(); + } + + return false; +} + +/*! + \fn bool operator!=(const QCursor &lhs, const QCursor &rhs) + \relates QCursor + \since 5.10 + + Inequality operator. Returns the equivalent of !(\a lhs == \a rhs). + + \sa operator==(const QCursor &lhs, const QCursor &rhs) +*/ /*! Returns the cursor shape identifier. The return value is one of diff --git a/src/gui/kernel/qcursor.h b/src/gui/kernel/qcursor.h index c7e9188e5b..ccce3d84ef 100644 --- a/src/gui/kernel/qcursor.h +++ b/src/gui/kernel/qcursor.h @@ -112,10 +112,14 @@ public: inline static void setPos(QScreen *screen, const QPoint &p) { setPos(screen, p.x(), p.y()); } private: + friend Q_GUI_EXPORT bool operator==(const QCursor &lhs, const QCursor &rhs) Q_DECL_NOTHROW; QCursorData *d; }; Q_DECLARE_SHARED_NOT_MOVABLE_UNTIL_QT6(QCursor) +Q_GUI_EXPORT bool operator==(const QCursor &lhs, const QCursor &rhs) Q_DECL_NOTHROW; +inline bool operator!=(const QCursor &lhs, const QCursor &rhs) Q_DECL_NOTHROW { return !(lhs == rhs); } + /***************************************************************************** QCursor stream functions *****************************************************************************/ diff --git a/src/gui/kernel/qdnd.cpp b/src/gui/kernel/qdnd.cpp index a59612474b..3af7f5c181 100644 --- a/src/gui/kernel/qdnd.cpp +++ b/src/gui/kernel/qdnd.cpp @@ -71,14 +71,11 @@ QDragManager *QDragManager::m_instance = 0; QDragManager::QDragManager() - : QObject(qApp), m_platformDropData(0), m_currentDropTarget(0), + : QObject(qApp), m_currentDropTarget(0), m_platformDrag(QGuiApplicationPrivate::platformIntegration()->drag()), m_object(0) { Q_ASSERT(!m_instance); - - if (m_platformDrag) - m_platformDropData = m_platformDrag->platformDropData(); } diff --git a/src/gui/kernel/qdnd_p.h b/src/gui/kernel/qdnd_p.h index 6f2ec46252..eaf6c74fd4 100644 --- a/src/gui/kernel/qdnd_p.h +++ b/src/gui/kernel/qdnd_p.h @@ -134,7 +134,6 @@ public: QObject *source() const; private: - QMimeData *m_platformDropData; QObject *m_currentDropTarget; QPlatformDrag *m_platformDrag; QDrag *m_object; diff --git a/src/gui/kernel/qkeysequence.cpp b/src/gui/kernel/qkeysequence.cpp index a6bc7d4d9c..1a106be98b 100644 --- a/src/gui/kernel/qkeysequence.cpp +++ b/src/gui/kernel/qkeysequence.cpp @@ -56,7 +56,6 @@ #if defined(Q_OS_MACX) #include <QtCore/private/qcore_mac_p.h> -#include <Carbon/Carbon.h> #endif #include <algorithm> @@ -70,6 +69,13 @@ struct MacSpecialKey { ushort macSymbol; }; +// Unicode code points for the glyphs associated with these keys +// Defined by Carbon headers but not anywhere in Cocoa +static const int kShiftUnicode = 0x21E7; +static const int kControlUnicode = 0x2303; +static const int kOptionUnicode = 0x2325; +static const int kCommandUnicode = 0x2318; + static const int NumEntries = 21; static const MacSpecialKey entries[NumEntries] = { { Qt::Key_Escape, 0x238B }, diff --git a/src/gui/kernel/qplatformdrag.h b/src/gui/kernel/qplatformdrag.h index 560f984a5b..54e6a667fe 100644 --- a/src/gui/kernel/qplatformdrag.h +++ b/src/gui/kernel/qplatformdrag.h @@ -95,7 +95,6 @@ public: virtual ~QPlatformDrag(); QDrag *currentDrag() const; - virtual QMimeData *platformDropData() = 0; virtual Qt::DropAction drag(QDrag *m_drag) = 0; virtual void cancelDrag(); diff --git a/src/gui/kernel/qplatformintegration.cpp b/src/gui/kernel/qplatformintegration.cpp index fe1861e08b..873ec3a33b 100644 --- a/src/gui/kernel/qplatformintegration.cpp +++ b/src/gui/kernel/qplatformintegration.cpp @@ -237,6 +237,10 @@ QPlatformServices *QPlatformIntegration::services() const is required to have this capability. \value ApplicationIcon The platform supports setting the application icon. (since 5.5) + + \value TopStackedNativeChildWindows The platform supports native child windows via + QWindowContainer without having to punch a transparent hole in the + backingstore. (since 5.10) */ /*! @@ -260,7 +264,8 @@ QPlatformServices *QPlatformIntegration::services() const bool QPlatformIntegration::hasCapability(Capability cap) const { - return cap == NonFullScreenWindows || cap == NativeWidgets || cap == WindowManagement; + return cap == NonFullScreenWindows || cap == NativeWidgets || cap == WindowManagement + || cap == TopStackedNativeChildWindows; } QPlatformPixmap *QPlatformIntegration::createPlatformPixmap(QPlatformPixmap::PixelType type) const @@ -387,6 +392,8 @@ QVariant QPlatformIntegration::styleHint(StyleHint hint) const return false; case ShowIsMaximized: return false; + case ShowShortcutsInContextMenus: + return QPlatformTheme::defaultThemeHint(QPlatformTheme::ShowShortcutsInContextMenus); case PasswordMaskDelay: return QPlatformTheme::defaultThemeHint(QPlatformTheme::PasswordMaskDelay); case PasswordMaskCharacter: @@ -622,4 +629,26 @@ void QPlatformIntegration::setApplicationIcon(const QIcon &icon) const Q_UNUSED(icon); } +#if QT_CONFIG(vulkan) + +/*! + Factory function for QPlatformVulkanInstance. The \a instance parameter is a + pointer to the instance for which a platform-specific backend needs to be + created. + + Returns a pointer to a QPlatformOpenGLContext instance or \c NULL if the context could + not be created. + + \sa QVulkanInstance + \since 5.10 +*/ +QPlatformVulkanInstance *QPlatformIntegration::createPlatformVulkanInstance(QVulkanInstance *instance) const +{ + Q_UNUSED(instance); + qWarning("This plugin does not support createPlatformVulkanInstance"); + return nullptr; +} + +#endif // QT_CONFIG(vulkan) + QT_END_NAMESPACE diff --git a/src/gui/kernel/qplatformintegration.h b/src/gui/kernel/qplatformintegration.h index 0449e0b4c8..eeaa7574f7 100644 --- a/src/gui/kernel/qplatformintegration.h +++ b/src/gui/kernel/qplatformintegration.h @@ -78,6 +78,8 @@ class QPlatformSessionManager; class QKeyEvent; class QPlatformOffscreenSurface; class QOffscreenSurface; +class QPlatformVulkanInstance; +class QVulkanInstance; class Q_GUI_EXPORT QPlatformIntegration { @@ -99,7 +101,8 @@ public: RasterGLSurface, AllGLFunctionsQueryable, ApplicationIcon, - SwitchableWidgetComposition + SwitchableWidgetComposition, + TopStackedNativeChildWindows }; virtual ~QPlatformIntegration() { } @@ -160,6 +163,7 @@ public: ItemViewActivateItemOnSingleClick, UiEffects, WheelScrollLines, + ShowShortcutsInContextMenus, }; virtual QVariant styleHint(StyleHint hint) const; @@ -188,6 +192,10 @@ public: virtual void beep() const; +#if QT_CONFIG(vulkan) + virtual QPlatformVulkanInstance *createPlatformVulkanInstance(QVulkanInstance *instance) const; +#endif + protected: void screenAdded(QPlatformScreen *screen, bool isPrimary = false); void destroyScreen(QPlatformScreen *screen); diff --git a/src/gui/kernel/qplatformtheme.cpp b/src/gui/kernel/qplatformtheme.cpp index 878f656f2e..ebf65eda12 100644 --- a/src/gui/kernel/qplatformtheme.cpp +++ b/src/gui/kernel/qplatformtheme.cpp @@ -161,6 +161,8 @@ QT_BEGIN_NAMESPACE The default value is double the MouseDoubleClickDistance, or 10 logical pixels if that is not specified. + \value ShowShortcutsInContextMenus (bool) Whether to display shortcut key sequences in context menus. + \sa themeHint(), QStyle::pixelMetric() */ @@ -516,6 +518,8 @@ QVariant QPlatformTheme::defaultThemeHint(ThemeHint hint) return QVariant(QStringList()); case QPlatformTheme::StyleNames: return QVariant(QStringList()); + case QPlatformTheme::ShowShortcutsInContextMenus: + return QVariant(false); case TextCursorWidth: return QVariant(1); case DropShadow: diff --git a/src/gui/kernel/qplatformtheme.h b/src/gui/kernel/qplatformtheme.h index 2ba2f8669f..f4ff418db6 100644 --- a/src/gui/kernel/qplatformtheme.h +++ b/src/gui/kernel/qplatformtheme.h @@ -115,7 +115,8 @@ public: MousePressAndHoldInterval, MouseDoubleClickDistance, WheelScrollLines, - TouchDoubleTapDistance + TouchDoubleTapDistance, + ShowShortcutsInContextMenus }; enum DialogType { diff --git a/src/gui/kernel/qplatformwindow.cpp b/src/gui/kernel/qplatformwindow.cpp index 5062bd1e77..dda7cc94fe 100644 --- a/src/gui/kernel/qplatformwindow.cpp +++ b/src/gui/kernel/qplatformwindow.cpp @@ -261,7 +261,7 @@ QPoint QPlatformWindow::mapFromGlobal(const QPoint &pos) const Qt::WindowActive can be ignored. */ -void QPlatformWindow::setWindowState(Qt::WindowState) +void QPlatformWindow::setWindowState(Qt::WindowStates) { } diff --git a/src/gui/kernel/qplatformwindow.h b/src/gui/kernel/qplatformwindow.h index 8af8791bb4..eead96f2d1 100644 --- a/src/gui/kernel/qplatformwindow.h +++ b/src/gui/kernel/qplatformwindow.h @@ -89,7 +89,7 @@ public: virtual void setVisible(bool visible); virtual void setWindowFlags(Qt::WindowFlags flags); - virtual void setWindowState(Qt::WindowState state); + virtual void setWindowState(Qt::WindowStates state); virtual WId winId() const; virtual void setParent(const QPlatformWindow *window); diff --git a/src/gui/kernel/qsimpledrag.cpp b/src/gui/kernel/qsimpledrag.cpp index fc62273325..481971f21a 100644 --- a/src/gui/kernel/qsimpledrag.cpp +++ b/src/gui/kernel/qsimpledrag.cpp @@ -353,13 +353,6 @@ QSimpleDrag::QSimpleDrag() : m_current_window(0) { } -QMimeData *QSimpleDrag::platformDropData() -{ - if (drag()) - return drag()->mimeData(); - return 0; -} - void QSimpleDrag::startDrag() { QBasicDrag::startDrag(); diff --git a/src/gui/kernel/qsimpledrag_p.h b/src/gui/kernel/qsimpledrag_p.h index 0b8a0bc703..45c13e43b2 100644 --- a/src/gui/kernel/qsimpledrag_p.h +++ b/src/gui/kernel/qsimpledrag_p.h @@ -125,7 +125,6 @@ class Q_GUI_EXPORT QSimpleDrag : public QBasicDrag { public: QSimpleDrag(); - virtual QMimeData *platformDropData() Q_DECL_OVERRIDE; protected: virtual void startDrag() Q_DECL_OVERRIDE; diff --git a/src/gui/kernel/qstylehints.cpp b/src/gui/kernel/qstylehints.cpp index 85c0768e35..0850228ee5 100644 --- a/src/gui/kernel/qstylehints.cpp +++ b/src/gui/kernel/qstylehints.cpp @@ -365,6 +365,17 @@ bool QStyleHints::showIsMaximized() const } /*! + \property QStyleHints::showShortcutsInContextMenus + \since 5.10 + \brief \c true if the platform normally shows shortcut key sequences in + context menus, otherwise \c false. +*/ +bool QStyleHints::showShortcutsInContextMenus() const +{ + return themeableHint(QPlatformTheme::ShowShortcutsInContextMenus, QPlatformIntegration::ShowShortcutsInContextMenus).toBool(); +} + +/*! \property QStyleHints::passwordMaskDelay \brief the time, in milliseconds, a typed letter is displayed unshrouded in a text input field in password mode. diff --git a/src/gui/kernel/qstylehints.h b/src/gui/kernel/qstylehints.h index b9bf428edd..3230149247 100644 --- a/src/gui/kernel/qstylehints.h +++ b/src/gui/kernel/qstylehints.h @@ -90,6 +90,7 @@ public: int cursorFlashTime() const; bool showIsFullScreen() const; bool showIsMaximized() const; + bool showShortcutsInContextMenus() const; int passwordMaskDelay() const; QChar passwordMaskCharacter() const; qreal fontSmoothingGamma() const; diff --git a/src/gui/kernel/qsurface.cpp b/src/gui/kernel/qsurface.cpp index 3cdd11de8c..63651ee822 100644 --- a/src/gui/kernel/qsurface.cpp +++ b/src/gui/kernel/qsurface.cpp @@ -78,6 +78,8 @@ QT_BEGIN_NAMESPACE requires the use of private API. \value OpenVGSurface The surface is an OpenVG compatible surface and can be used in conjunction with OpenVG contexts. + \value VulkanSurface The surface is a Vulkan compatible surface and can be used + in conjunction with the Vulkan graphics API. */ diff --git a/src/gui/kernel/qsurface.h b/src/gui/kernel/qsurface.h index a96b7a6422..7e09449d12 100644 --- a/src/gui/kernel/qsurface.h +++ b/src/gui/kernel/qsurface.h @@ -66,6 +66,7 @@ public: OpenGLSurface, RasterGLSurface, OpenVGSurface, + VulkanSurface }; virtual ~QSurface(); diff --git a/src/gui/kernel/qsurfaceformat.cpp b/src/gui/kernel/qsurfaceformat.cpp index 000d727380..574310f554 100644 --- a/src/gui/kernel/qsurfaceformat.cpp +++ b/src/gui/kernel/qsurfaceformat.cpp @@ -73,6 +73,7 @@ public: , major(2) , minor(0) , swapInterval(1) // default to vsync + , colorSpace(QSurfaceFormat::DefaultColorSpace) { } @@ -91,7 +92,8 @@ public: profile(other->profile), major(other->major), minor(other->minor), - swapInterval(other->swapInterval) + swapInterval(other->swapInterval), + colorSpace(other->colorSpace) { } @@ -110,6 +112,7 @@ public: int major; int minor; int swapInterval; + QSurfaceFormat::ColorSpace colorSpace; }; /*! @@ -124,6 +127,12 @@ public: contains surface configuration parameters such as OpenGL profile and version for rendering, whether or not to enable stereo buffers, and swap behaviour. + + \note When troubleshooting context or window format issues, it can be + helpful to enable the logging category \c{qt.qpa.gl}. Depending on the + platform, this may print useful debug information when it comes to OpenGL + initialization and the native visual or framebuffer configurations which + QSurfaceFormat gets mapped to. */ /*! @@ -199,6 +208,22 @@ public: */ /*! + \enum QSurfaceFormat::ColorSpace + + This enum is used to specify the preferred color space, controlling if the + window's associated default framebuffer is able to do updates and blending + in a given encoding instead of the standard linear operations. + + \value DefaultColorSpace The default, unspecified color space. + + \value sRGBColorSpace When \c{GL_ARB_framebuffer_sRGB} or + \c{GL_EXT_framebuffer_sRGB} is supported by the platform and this value is + set, the window will be created with an sRGB-capable default + framebuffer. Note that some platforms may return windows with a sRGB-capable + default framebuffer even when not requested explicitly. + */ + +/*! Constructs a default initialized QSurfaceFormat. \note By default OpenGL 2.0 is requested since this provides the highest @@ -736,6 +761,47 @@ int QSurfaceFormat::swapInterval() const return d->swapInterval; } +/*! + Sets the preferred \a colorSpace. + + For example, this allows requesting windows with default framebuffers that + are sRGB-capable on platforms that support it. + + \note When the requested color space is not supported by the platform, the + request is ignored. Query the QSurfaceFormat after window creation to verify + if the color space request could be honored or not. + + \note This setting controls if the default framebuffer of the window is + capable of updates and blending in a given color space. It does not change + applications' output by itself. The applications' rendering code will still + have to opt in via the appropriate OpenGL calls to enable updates and + blending to be performed in the given color space instead of using the + standard linear operations. + + \since 5.10 + + \sa colorSpace() + */ +void QSurfaceFormat::setColorSpace(ColorSpace colorSpace) +{ + if (d->colorSpace != colorSpace) { + detach(); + d->colorSpace = colorSpace; + } +} + +/*! + \return the color space. + + \since 5.10 + + \sa setColorSpace() +*/ +QSurfaceFormat::ColorSpace QSurfaceFormat::colorSpace() const +{ + return d->colorSpace; +} + Q_GLOBAL_STATIC(QSurfaceFormat, qt_default_surface_format) /*! @@ -841,6 +907,7 @@ QDebug operator<<(QDebug dbg, const QSurfaceFormat &f) << ", samples " << d->numSamples << ", swapBehavior " << d->swapBehavior << ", swapInterval " << d->swapInterval + << ", colorSpace " << d->colorSpace << ", profile " << d->profile << ')'; diff --git a/src/gui/kernel/qsurfaceformat.h b/src/gui/kernel/qsurfaceformat.h index 246163609e..ed63eb8bbf 100644 --- a/src/gui/kernel/qsurfaceformat.h +++ b/src/gui/kernel/qsurfaceformat.h @@ -85,6 +85,12 @@ public: }; Q_ENUM(OpenGLContextProfile) + enum ColorSpace { + DefaultColorSpace, + sRGBColorSpace + }; + Q_ENUM(ColorSpace) + QSurfaceFormat(); /*implicit*/ QSurfaceFormat(FormatOptions options); QSurfaceFormat(const QSurfaceFormat &other); @@ -145,6 +151,9 @@ public: int swapInterval() const; void setSwapInterval(int interval); + ColorSpace colorSpace() const; + void setColorSpace(ColorSpace colorSpace); + static void setDefaultFormat(const QSurfaceFormat &format); static QSurfaceFormat defaultFormat(); diff --git a/src/gui/kernel/qwindow.cpp b/src/gui/kernel/qwindow.cpp index d44bfabc04..3f5f71002b 100644 --- a/src/gui/kernel/qwindow.cpp +++ b/src/gui/kernel/qwindow.cpp @@ -116,7 +116,7 @@ QT_BEGIN_NAMESPACE application, isExposed() will simply return the same value as isVisible(). QWindow::Visibility queried through visibility() is a convenience API - combining the functions of visible() and windowState(). + combining the functions of visible() and windowStates(). \section1 Rendering @@ -323,27 +323,16 @@ void QWindowPrivate::updateVisibility() QWindow::Visibility old = visibility; - if (visible) { - switch (windowState) { - case Qt::WindowMinimized: - visibility = QWindow::Minimized; - break; - case Qt::WindowMaximized: - visibility = QWindow::Maximized; - break; - case Qt::WindowFullScreen: - visibility = QWindow::FullScreen; - break; - case Qt::WindowNoState: - visibility = QWindow::Windowed; - break; - default: - Q_ASSERT(false); - break; - } - } else { + if (!visible) visibility = QWindow::Hidden; - } + else if (windowState & Qt::WindowMinimized) + visibility = QWindow::Minimized; + else if (windowState & Qt::WindowFullScreen) + visibility = QWindow::FullScreen; + else if (windowState & Qt::WindowMaximized) + visibility = QWindow::Maximized; + else + visibility = QWindow::Windowed; if (visibility != old) emit q->visibilityChanged(visibility); @@ -1216,6 +1205,17 @@ qreal QWindow::devicePixelRatio() const return d->platformWindow->devicePixelRatio() * QHighDpiScaling::factor(this); } +Qt::WindowState QWindowPrivate::effectiveState(Qt::WindowStates state) +{ + if (state & Qt::WindowMinimized) + return Qt::WindowMinimized; + else if (state & Qt::WindowFullScreen) + return Qt::WindowFullScreen; + else if (state & Qt::WindowMaximized) + return Qt::WindowMaximized; + return Qt::WindowNoState; +} + /*! \brief set the screen-occupation state of the window @@ -1224,31 +1224,69 @@ qreal QWindow::devicePixelRatio() const The enum value Qt::WindowActive is not an accepted parameter. - \sa showNormal(), showFullScreen(), showMinimized(), showMaximized() + \sa showNormal(), showFullScreen(), showMinimized(), showMaximized(), setWindowStates() */ void QWindow::setWindowState(Qt::WindowState state) { - if (state == Qt::WindowActive) { - qWarning("QWindow::setWindowState does not accept Qt::WindowActive"); - return; - } + setWindowStates(state); +} +/*! + \brief set the screen-occupation state of the window + \since 5.10 + + The window \a state represents whether the window appears in the + windowing system as maximized, minimized and/or fullscreen. + + The window can be in a combination of several states. For example, if + the window is both minimized and maximized, the window will appear + minimized, but clicking on the task bar entry will restore it to the + maximized state. + + The enum value Qt::WindowActive should not be set. + + \sa showNormal(), showFullScreen(), showMinimized(), showMaximized() + */ +void QWindow::setWindowStates(Qt::WindowStates state) +{ Q_D(QWindow); + if (state & Qt::WindowActive) { + qWarning("QWindow::setWindowStates does not accept Qt::WindowActive"); + state &= ~Qt::WindowActive; + } + if (d->platformWindow) d->platformWindow->setWindowState(state); d->windowState = state; - emit windowStateChanged(d->windowState); + emit windowStateChanged(QWindowPrivate::effectiveState(d->windowState)); d->updateVisibility(); } /*! \brief the screen-occupation state of the window - \sa setWindowState() + \sa setWindowState(), windowStates() */ Qt::WindowState QWindow::windowState() const { Q_D(const QWindow); + return QWindowPrivate::effectiveState(d->windowState); +} + +/*! + \brief the screen-occupation state of the window + \since 5.10 + + The window can be in a combination of several states. For example, if + the window is both minimized and maximized, the window will appear + minimized, but clicking on the task bar entry will restore it to + the maximized state. + + \sa setWindowStates() +*/ +Qt::WindowStates QWindow::windowStates() const +{ + Q_D(const QWindow); return d->windowState; } @@ -1256,7 +1294,7 @@ Qt::WindowState QWindow::windowState() const \fn QWindow::windowStateChanged(Qt::WindowState windowState) This signal is emitted when the \a windowState changes, either - by being set explicitly with setWindowState(), or automatically when + by being set explicitly with setWindowStates(), or automatically when the user clicks one of the titlebar buttons or by other means. */ @@ -1997,42 +2035,42 @@ void QWindow::hide() /*! Shows the window as minimized. - Equivalent to calling setWindowState(Qt::WindowMinimized) and then + Equivalent to calling setWindowStates(Qt::WindowMinimized) and then setVisible(true). - \sa setWindowState(), setVisible() + \sa setWindowStates(), setVisible() */ void QWindow::showMinimized() { - setWindowState(Qt::WindowMinimized); + setWindowStates(Qt::WindowMinimized); setVisible(true); } /*! Shows the window as maximized. - Equivalent to calling setWindowState(Qt::WindowMaximized) and then + Equivalent to calling setWindowStates(Qt::WindowMaximized) and then setVisible(true). - \sa setWindowState(), setVisible() + \sa setWindowStates(), setVisible() */ void QWindow::showMaximized() { - setWindowState(Qt::WindowMaximized); + setWindowStates(Qt::WindowMaximized); setVisible(true); } /*! Shows the window as fullscreen. - Equivalent to calling setWindowState(Qt::WindowFullScreen) and then + Equivalent to calling setWindowStates(Qt::WindowFullScreen) and then setVisible(true). - \sa setWindowState(), setVisible() + \sa setWindowStates(), setVisible() */ void QWindow::showFullScreen() { - setWindowState(Qt::WindowFullScreen); + setWindowStates(Qt::WindowFullScreen); setVisible(true); #if !defined Q_OS_QNX // On QNX this window will be activated anyway from libscreen // activating it here before libscreen activates it causes problems @@ -2043,14 +2081,14 @@ void QWindow::showFullScreen() /*! Shows the window as normal, i.e. neither maximized, minimized, nor fullscreen. - Equivalent to calling setWindowState(Qt::WindowNoState) and then + Equivalent to calling setWindowStates(Qt::WindowNoState) and then setVisible(true). - \sa setWindowState(), setVisible() + \sa setWindowStates(), setVisible() */ void QWindow::showNormal() { - setWindowState(Qt::WindowNoState); + setWindowStates(Qt::WindowNoState); setVisible(true); } @@ -2246,7 +2284,7 @@ bool QWindow::event(QEvent *ev) case QEvent::WindowStateChange: { Q_D(QWindow); - emit windowStateChanged(d->windowState); + emit windowStateChanged(QWindowPrivate::effectiveState(d->windowState)); d->updateVisibility(); break; } @@ -2762,6 +2800,30 @@ QDebug operator<<(QDebug debug, const QWindow *window) } #endif // !QT_NO_DEBUG_STREAM +#if QT_CONFIG(vulkan) + +/*! + Associates this window with the specified Vulkan \a instance. + + \a instance must stay valid as long as this QWindow instance exists. + */ +void QWindow::setVulkanInstance(QVulkanInstance *instance) +{ + Q_D(QWindow); + d->vulkanInstance = instance; +} + +/*! + \return the associrated Vulkan instance or \c null if there is none. + */ +QVulkanInstance *QWindow::vulkanInstance() const +{ + Q_D(const QWindow); + return d->vulkanInstance; +} + +#endif // QT_CONFIG(vulkan) + QT_END_NAMESPACE #include "moc_qwindow.cpp" diff --git a/src/gui/kernel/qwindow.h b/src/gui/kernel/qwindow.h index 2883749d2e..529589e67b 100644 --- a/src/gui/kernel/qwindow.h +++ b/src/gui/kernel/qwindow.h @@ -88,6 +88,9 @@ class QWindowContainer; #ifndef QT_NO_DEBUG_STREAM class QDebug; #endif +#if QT_CONFIG(vulkan) +class QVulkanInstance; +#endif class Q_GUI_EXPORT QWindow : public QObject, public QSurface { @@ -189,7 +192,9 @@ public: qreal devicePixelRatio() const; Qt::WindowState windowState() const; + Qt::WindowStates windowStates() const; void setWindowState(Qt::WindowState state); + void setWindowStates(Qt::WindowStates states); void setTransientParent(QWindow *parent); QWindow *transientParent() const; @@ -267,6 +272,11 @@ public: static QWindow *fromWinId(WId id); +#if QT_CONFIG(vulkan) + void setVulkanInstance(QVulkanInstance *instance); + QVulkanInstance *vulkanInstance() const; +#endif + public Q_SLOTS: Q_REVISION(1) void requestActivate(); diff --git a/src/gui/kernel/qwindow_p.h b/src/gui/kernel/qwindow_p.h index dd282a671d..cffe5b4125 100644 --- a/src/gui/kernel/qwindow_p.h +++ b/src/gui/kernel/qwindow_p.h @@ -105,6 +105,9 @@ public: , hasCursor(false) #endif , compositing(false) +#if QT_CONFIG(vulkan) + , vulkanInstance(nullptr) +#endif { isWindow = true; } @@ -151,6 +154,8 @@ public: static QWindowPrivate *get(QWindow *window) { return window->d_func(); } + static Qt::WindowState effectiveState(Qt::WindowStates); + QWindow::SurfaceType surfaceType; Qt::WindowFlags windowFlags; QWindow *parentWindow; @@ -163,7 +168,7 @@ public: QString windowFilePath; QIcon windowIcon; QRect geometry; - Qt::WindowState windowState; + Qt::WindowStates windowState; QWindow::Visibility visibility; bool resizeEventPending; bool receivedExpose; @@ -194,6 +199,10 @@ public: bool compositing; QElapsedTimer lastComposeTime; + +#if QT_CONFIG(vulkan) + QVulkanInstance *vulkanInstance; +#endif }; diff --git a/src/gui/kernel/qwindowsysteminterface.cpp b/src/gui/kernel/qwindowsysteminterface.cpp index 7ad4f57198..f3486acbc3 100644 --- a/src/gui/kernel/qwindowsysteminterface.cpp +++ b/src/gui/kernel/qwindowsysteminterface.cpp @@ -241,14 +241,14 @@ QT_DEFINE_QPA_EVENT_HANDLER(void, handleWindowActivated, QWindow *window, Qt::Fo QWindowSystemInterfacePrivate::handleWindowSystemEvent<Delivery>(e); } -QT_DEFINE_QPA_EVENT_HANDLER(void, handleWindowStateChanged, QWindow *window, Qt::WindowState newState, int oldState) +QT_DEFINE_QPA_EVENT_HANDLER(void, handleWindowStateChanged, QWindow *window, Qt::WindowStates newState, int oldState) { Q_ASSERT(window); if (oldState < Qt::WindowNoState) oldState = window->windowState(); QWindowSystemInterfacePrivate::WindowStateChangedEvent *e = - new QWindowSystemInterfacePrivate::WindowStateChangedEvent(window, newState, Qt::WindowState(oldState)); + new QWindowSystemInterfacePrivate::WindowStateChangedEvent(window, newState, Qt::WindowStates(oldState)); QWindowSystemInterfacePrivate::handleWindowSystemEvent<Delivery>(e); } diff --git a/src/gui/kernel/qwindowsysteminterface.h b/src/gui/kernel/qwindowsysteminterface.h index 253584314c..c9e34527cd 100644 --- a/src/gui/kernel/qwindowsysteminterface.h +++ b/src/gui/kernel/qwindowsysteminterface.h @@ -176,7 +176,7 @@ public: static void handleWindowActivated(QWindow *window, Qt::FocusReason r = Qt::OtherFocusReason); template<typename Delivery = QWindowSystemInterface::DefaultDelivery> - static void handleWindowStateChanged(QWindow *window, Qt::WindowState newState, int oldState = -1); + static void handleWindowStateChanged(QWindow *window, Qt::WindowStates newState, int oldState = -1); static void handleWindowScreenChanged(QWindow *window, QScreen *newScreen); static void handleApplicationStateChanged(Qt::ApplicationState newState, bool forcePropagate = false); diff --git a/src/gui/kernel/qwindowsysteminterface_p.h b/src/gui/kernel/qwindowsysteminterface_p.h index 1bcc79552d..4ee85b98a1 100644 --- a/src/gui/kernel/qwindowsysteminterface_p.h +++ b/src/gui/kernel/qwindowsysteminterface_p.h @@ -168,13 +168,13 @@ public: class WindowStateChangedEvent : public WindowSystemEvent { public: - WindowStateChangedEvent(QWindow *_window, Qt::WindowState _newState, Qt::WindowState _oldState) + WindowStateChangedEvent(QWindow *_window, Qt::WindowStates _newState, Qt::WindowStates _oldState) : WindowSystemEvent(WindowStateChanged), window(_window), newState(_newState), oldState(_oldState) { } QPointer<QWindow> window; - Qt::WindowState newState; - Qt::WindowState oldState; + Qt::WindowStates newState; + Qt::WindowStates oldState; }; class WindowScreenChangedEvent : public WindowSystemEvent { |