Qt 6.x
The Qt SDK
Loading...
Searching...
No Matches
qwindowswindow.cpp File Reference
#include <QtCore/qt_windows.h>
#include "qwindowswindow.h"
#include "qwindowscontext.h"
#include "qwindowsscreen.h"
#include "qwindowsintegration.h"
#include "qwindowsmenu.h"
#include "qwindowsnativeinterface.h"
#include "qwindowsopenglcontext.h"
#include "qwindowsopengltester.h"
#include <QtGui/qguiapplication.h>
#include <QtGui/qscreen.h>
#include <QtGui/qwindow.h>
#include <QtGui/qregion.h>
#include <QtGui/qopenglcontext.h>
#include <private/qwindow_p.h>
#include <private/qguiapplication_p.h>
#include <private/qhighdpiscaling_p.h>
#include <qpa/qwindowsysteminterface.h>
#include <QtCore/qdebug.h>
#include <QtCore/qlibraryinfo.h>
#include <dwmapi.h>
#include <shellscalingapi.h>
+ Include dependency graph for qwindowswindow.cpp:

Go to the source code of this file.

Classes

class  WindowCreationData
 Window creation code. More...
 

Macros

#define GWL_HWNDPARENT   (-8)
 

Typedefs

using QWindowCreationContextPtr = QSharedPointer< QWindowCreationContext >
 

Enumerations

enum  { defaultWindowWidth = 160 , defaultWindowHeight = 160 }
 
enum  : WORD { DwmwaUseImmersiveDarkMode = 20 , DwmwaUseImmersiveDarkModeBefore20h1 = 19 }
 

Functions

Q_GUI_EXPORT HICON qt_pixmapToWinHICON (const QPixmap &)
 
static QByteArray debugWinStyle (DWORD style)
 
static QByteArray debugWinExStyle (DWORD exStyle)
 
static QByteArray debugWinSwpPos (UINT flags)
 
static QByteArray debugWindowPlacementFlags (const UINT flags)
 
static QByteArray debugShowWindowCmd (const UINT cmd)
 
static QSize qSizeOfRect (const RECT &rect)
 
static QRect qrectFromRECT (const RECT &rect)
 
static RECT RECTfromQRect (const QRect &rect)
 
QDebug operator<< (QDebug d, const RECT &r)
 
QDebug operator<< (QDebug d, const POINT &p)
 
QDebug operator<< (QDebug d, const WINDOWPOS &wp)
 
QDebug operator<< (QDebug d, const NCCALCSIZE_PARAMS &p)
 
QDebug operator<< (QDebug d, const MINMAXINFO &i)
 
QDebug operator<< (QDebug d, const WINDOWPLACEMENT &wp)
 
QDebug operator<< (QDebug d, const GUID &guid)
 
static void formatBriefRectangle (QDebug &d, const QRect &r)
 
static void formatBriefMargins (QDebug &d, const QMargins &m)
 
static QPoint windowPlacementOffset (HWND hwnd, const QPoint &point)
 
static QRect frameGeometry (HWND hwnd, bool topLevel)
 
static QWindow::Visibility windowVisibility_sys (HWND hwnd)
 
static bool windowIsAccelerated (const QWindow *w)
 
static bool applyBlurBehindWindow (HWND hwnd)
 
static bool shouldShowMaximizeButton (const QWindow *w, Qt::WindowFlags flags)
 
static void setWindowOpacity (HWND hwnd, Qt::WindowFlags flags, bool hasAlpha, bool accelerated, qreal level)
 
static void updateGLWindowSettings (const QWindow *w, HWND hwnd, Qt::WindowFlags flags, qreal opacity)
 
static int getResizeBorderThickness (const UINT dpi)
 
static QMargins invisibleMargins (QPoint screenPoint)
 Calculates the dimensions of the invisible borders within the window frames which only exist on Windows 10 and onwards.
 
static QMargins invisibleMargins (const HWND hwnd)
 
QDebug operator<< (QDebug debug, const WindowCreationData &d)
 
static void fixTopLevelWindowFlags (Qt::WindowFlags &flags)
 
static QScreenscreenForDeviceName (const QWindow *w, const QString &name)
 
static QPoint calcPosition (const QWindow *w, const QWindowCreationContextPtr &context, const QMargins &invMargins)
 
static bool shouldApplyDarkFrame (const QWindow *w)
 
static QSize toNativeSizeConstrained (QSize dip, const QScreen *s)
 
static bool testShowWithoutActivating (const QWindow *window)
 
static void setMinimizedGeometry (HWND hwnd, const QRect &r)
 
static void setRestoreMaximizedFlag (HWND hwnd, bool set=true)
 
static QRect normalFrameGeometry (HWND hwnd)
 
static QString msgUnableToSetGeometry (const QWindowsWindow *platformWindow, const QRect &requestedRect, const QRect &obtainedRect, const QMargins &fullMargins, const QMargins &customMargins)
 
static bool equalDpi (const QDpi &d1, const QDpi &d2)
 
static bool isSoftwareGl ()
 
static HRGN createRectRegion (const QRect &r)
 
static void addRectToWinRegion (const QRect &rect, HRGN *winRegion)
 
static HRGN qRegionToWinRegion (const QRegion &region)
 
static DWORD edgesToWinOrientation (Qt::Edges edges)
 
static CursorHandlePtr defaultCursor (const QWindow *w)
 
static bool applyNewCursor (const QWindow *w)
 
static HICON createHIcon (const QIcon &icon, int xSize, int ySize)
 
static bool queryDarkBorder (HWND hwnd)
 

Macro Definition Documentation

◆ GWL_HWNDPARENT

#define GWL_HWNDPARENT   (-8)

Definition at line 1790 of file qwindowswindow.cpp.

Typedef Documentation

◆ QWindowCreationContextPtr

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
defaultWindowWidth 
defaultWindowHeight 

Definition at line 50 of file qwindowswindow.cpp.

◆ anonymous enum

anonymous enum : WORD
Enumerator
DwmwaUseImmersiveDarkMode 
DwmwaUseImmersiveDarkModeBefore20h1 

Definition at line 3271 of file qwindowswindow.cpp.

Function Documentation

◆ addRectToWinRegion()

static void addRectToWinRegion ( const QRect rect,
HRGN *  winRegion 
)
inlinestatic

Definition at line 2847 of file qwindowswindow.cpp.

References createRectRegion(), and rect.

Referenced by qRegionToWinRegion().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ applyBlurBehindWindow()

static bool applyBlurBehindWindow ( HWND  hwnd)
static

Definition at line 444 of file qwindowswindow.cpp.

Referenced by QWindowsWindow::handleCompositionSettingsChanged(), and updateGLWindowSettings().

+ Here is the caller graph for this function:

◆ applyNewCursor()

static bool applyNewCursor ( const QWindow w)
inlinestatic

Definition at line 3116 of file qwindowswindow.cpp.

References QWindowsWindow::cursor(), QWindowsContext::instance(), CursorHandle::isNull(), QWindowsWindow::windowsWindowOf(), and QWindowsContext::windowUnderMouse().

Referenced by QWindowsWindow::setCursor().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ calcPosition()

static QPoint calcPosition ( const QWindow w,
const QWindowCreationContextPtr context,
const QMargins invMargins 
)
static

Definition at line 659 of file qwindowswindow.cpp.

References QPlatformScreen::availableGeometry(), QMargins::bottom(), QRect::center(), QRect::contains(), context, QWindowsWindow::forcedScreenForGLWindow(), QScreen::handle(), QRect::height(), QMargins::left(), QRect::left(), qMax(), QMargins::right(), screen, QMargins::top(), QRect::top(), QScreen::virtualSiblings(), QRect::width(), Qt::Window, QPoint::x(), and QPoint::y().

Referenced by WindowCreationData::create().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ createHIcon()

static HICON createHIcon ( const QIcon icon,
int  xSize,
int  ySize 
)
static

Definition at line 3237 of file qwindowswindow.cpp.

References QIcon::actualSize(), icon, QIcon::isNull(), QPixmap::isNull(), QIcon::pixmap(), and qt_pixmapToWinHICON().

Referenced by QWindowsWindow::setWindowIcon().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ createRectRegion()

static HRGN createRectRegion ( const QRect r)
inlinestatic

Definition at line 2842 of file qwindowswindow.cpp.

Referenced by addRectToWinRegion(), and qRegionToWinRegion().

+ Here is the caller graph for this function:

◆ debugShowWindowCmd()

static QByteArray debugShowWindowCmd ( const UINT  cmd)
inlinestatic

Definition at line 219 of file qwindowswindow.cpp.

References QByteArray::number().

Referenced by operator<<().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ debugWindowPlacementFlags()

static QByteArray debugWindowPlacementFlags ( const UINT  flags)
inlinestatic

Definition at line 206 of file qwindowswindow.cpp.

References QByteArray::number().

Referenced by operator<<().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ debugWinExStyle()

static QByteArray debugWinExStyle ( DWORD  exStyle)
static

Definition at line 112 of file qwindowswindow.cpp.

References QByteArray::number().

Referenced by WindowCreationData::applyWindowFlags(), operator<<(), and QWindowsWindow::setExStyle().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ debugWinStyle()

static QByteArray debugWinStyle ( DWORD  style)
static

Definition at line 57 of file qwindowswindow.cpp.

References QByteArray::number().

Referenced by WindowCreationData::applyWindowFlags(), operator<<(), QWindowsForeignWindow::setParent(), and QWindowsWindow::setStyle().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ debugWinSwpPos()

static QByteArray debugWinSwpPos ( UINT  flags)
static

Definition at line 169 of file qwindowswindow.cpp.

References QByteArray::number().

Referenced by operator<<().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ defaultCursor()

static CursorHandlePtr defaultCursor ( const QWindow w)
inlinestatic

Definition at line 3104 of file qwindowswindow.cpp.

References Qt::ArrowCursor, QWindowsCursor::createCursorFromShape(), cursor, QScreen::handle(), and screen.

Referenced by QWindowsWindow::applyCursor().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ edgesToWinOrientation()

static DWORD edgesToWinOrientation ( Qt::Edges  edges)
inlinestatic

Definition at line 3007 of file qwindowswindow.cpp.

References Qt::BottomEdge, Qt::LeftEdge, Qt::RightEdge, and Qt::TopEdge.

Referenced by QWindowsWindow::startSystemResize().

+ Here is the caller graph for this function:

◆ equalDpi()

static bool equalDpi ( const QDpi d1,
const QDpi d2 
)
inlinestatic

Definition at line 2272 of file qwindowswindow.cpp.

References d1, d2, and qFuzzyCompare().

Referenced by QWindowsWindow::checkForScreenChanged().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fixTopLevelWindowFlags()

static void fixTopLevelWindowFlags ( Qt::WindowFlags &  flags)
inlinestatic

Definition at line 621 of file qwindowswindow.cpp.

References Qt::Dialog, Qt::FramelessWindowHint, Qt::SplashScreen, Qt::Tool, Qt::Window, Qt::WindowCloseButtonHint, Qt::WindowMaximizeButtonHint, Qt::WindowMinimizeButtonHint, Qt::WindowSystemMenuHint, Qt::WindowTitleHint, and Qt::WindowType_Mask.

Referenced by WindowCreationData::fromWindow().

+ Here is the caller graph for this function:

◆ formatBriefMargins()

static void formatBriefMargins ( QDebug d,
const QMargins m 
)
static

Definition at line 358 of file qwindowswindow.cpp.

References d.

Referenced by msgUnableToSetGeometry().

+ Here is the caller graph for this function:

◆ formatBriefRectangle()

static void formatBriefRectangle ( QDebug d,
const QRect r 
)
static

Definition at line 353 of file qwindowswindow.cpp.

References d, Qt::forcesign(), and Qt::noforcesign().

Referenced by msgUnableToSetGeometry().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ frameGeometry()

static QRect frameGeometry ( HWND  hwnd,
bool  topLevel 
)
inlinestatic

Definition at line 379 of file qwindowswindow.cpp.

References parent, qrectFromRECT(), rect, screenToClient(), and windowPlacementOffset().

Referenced by WindowCreationData::create(), QWindowsBaseWindow::frameGeometry_sys(), operator<<(), QWindowsBaseWindow::setGeometry_sys(), and QPlatformWindow::windowFrameGeometry().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getResizeBorderThickness()

static int getResizeBorderThickness ( const UINT  dpi)
inlinestatic

Definition at line 517 of file qwindowswindow.cpp.

Referenced by invisibleMargins(), and invisibleMargins().

+ Here is the caller graph for this function:

◆ invisibleMargins() [1/2]

static QMargins invisibleMargins ( const HWND  hwnd)
inlinestatic

Definition at line 545 of file qwindowswindow.cpp.

References getResizeBorderThickness().

+ Here is the call graph for this function:

◆ invisibleMargins() [2/2]

static QMargins invisibleMargins ( QPoint  screenPoint)
static

Calculates the dimensions of the invisible borders within the window frames which only exist on Windows 10 and onwards.

Definition at line 531 of file qwindowswindow.cpp.

References getResizeBorderThickness(), QPoint::x(), and QPoint::y().

Referenced by WindowCreationData::create(), QWindowsWindow::frameMargins(), QWindowsWindow::handleNonClientHitTest(), and QWindowsWindow::handleResized().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isSoftwareGl()

static bool isSoftwareGl ( )
inlinestatic

Definition at line 2403 of file qwindowswindow.cpp.

References QOpenGLContext::LibGL, QWindowsOpengl32DLL::moduleIsNotOpengl32(), QOpenGLStaticContext::opengl32, and QOpenGLContext::openGLModuleType().

Referenced by QWindowsWindow::handleWmPaint().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ msgUnableToSetGeometry()

static QString msgUnableToSetGeometry ( const QWindowsWindow platformWindow,
const QRect requestedRect,
const QRect obtainedRect,
const QMargins fullMargins,
const QMargins customMargins 
)
static

Definition at line 2077 of file qwindowswindow.cpp.

References debug, formatBriefMargins(), formatBriefRectangle(), QWindowsWindow::getSizeHints(), QMargins::isNull(), QWINDOWSIZE_MAX, window(), and QPlatformWindow::window().

Referenced by QWindowsWindow::setGeometry().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ normalFrameGeometry()

static QRect normalFrameGeometry ( HWND  hwnd)
static

Definition at line 2054 of file qwindowswindow.cpp.

References qrectFromRECT(), and windowPlacementOffset().

Referenced by QWindowsWindow::normalGeometry(), and QWindowsWindow::updateRestoreGeometry().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ operator<<() [1/8]

QDebug operator<< ( QDebug  d,
const GUID &  guid 
)

Definition at line 335 of file qwindowswindow.cpp.

References d, Qt::hex(), i, qSetFieldWidth(), qSetPadChar(), and Qt::uppercasedigits().

+ Here is the call graph for this function:

◆ operator<<() [2/8]

QDebug operator<< ( QDebug  d,
const MINMAXINFO &  i 
)

Definition at line 312 of file qwindowswindow.cpp.

References d, and i.

◆ operator<<() [3/8]

QDebug operator<< ( QDebug  d,
const NCCALCSIZE_PARAMS &  p 
)

Definition at line 303 of file qwindowswindow.cpp.

References d.

◆ operator<<() [4/8]

QDebug operator<< ( QDebug  d,
const POINT &  p 
)

Definition at line 284 of file qwindowswindow.cpp.

References d.

◆ operator<<() [5/8]

QDebug operator<< ( QDebug  d,
const RECT &  r 
)

Definition at line 274 of file qwindowswindow.cpp.

References d.

◆ operator<<() [6/8]

QDebug operator<< ( QDebug  d,
const WINDOWPLACEMENT &  wp 
)

Definition at line 323 of file qwindowswindow.cpp.

References d, debugShowWindowCmd(), and debugWindowPlacementFlags().

+ Here is the call graph for this function:

◆ operator<<() [7/8]

QDebug operator<< ( QDebug  d,
const WINDOWPOS &  wp 
)

Definition at line 292 of file qwindowswindow.cpp.

References d, and debugWinSwpPos().

+ Here is the call graph for this function:

◆ operator<<() [8/8]

QDebug operator<< ( QDebug  debug,
const WindowCreationData d 
)

Definition at line 603 of file qwindowswindow.cpp.

References d, debug, debugWinExStyle(), and debugWinStyle().

+ Here is the call graph for this function:

◆ qrectFromRECT()

static QRect qrectFromRECT ( const RECT &  rect)
inlinestatic

Definition at line 259 of file qwindowswindow.cpp.

References qSizeOfRect(), and rect.

Referenced by frameGeometry(), QWindowsWindow::handleWmPaint(), and normalFrameGeometry().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ qRegionToWinRegion()

static HRGN qRegionToWinRegion ( const QRegion region)
static

Definition at line 2859 of file qwindowswindow.cpp.

References addRectToWinRegion(), QRegion::begin(), createRectRegion(), QRegion::end(), and it.

Referenced by QWindowsWindow::setMask().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ qSizeOfRect()

static QSize qSizeOfRect ( const RECT &  rect)
inlinestatic

Definition at line 254 of file qwindowswindow.cpp.

References rect.

Referenced by qrectFromRECT().

+ Here is the caller graph for this function:

◆ qt_pixmapToWinHICON()

Q_GUI_EXPORT HICON qt_pixmapToWinHICON ( const QPixmap p)

Definition at line 536 of file qpixmap_win.cpp.

References QImage::convertToFormat(), QImage::Format_Mono, QPixmap::isNull(), QPixmap::mask(), and QPixmap::toImage().

Referenced by createHIcon(), and QWindowsSystemTrayIcon::showMessage().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ queryDarkBorder()

static bool queryDarkBorder ( HWND  hwnd)
static

Definition at line 3276 of file qwindowswindow.cpp.

References DwmwaUseImmersiveDarkMode, DwmwaUseImmersiveDarkModeBefore20h1, ok, and qCWarning.

Referenced by QWindowsWindow::setDarkBorder().

+ Here is the caller graph for this function:

◆ RECTfromQRect()

static RECT RECTfromQRect ( const QRect rect)
inlinestatic

Definition at line 264 of file qwindowswindow.cpp.

References rect.

Referenced by QWindowsWindow::moveTransientChildren(), QWindowsBaseWindow::setGeometry_sys(), and setMinimizedGeometry().

+ Here is the caller graph for this function:

◆ screenForDeviceName()

static QScreen * screenForDeviceName ( const QWindow w,
const QString name 
)
static

Definition at line 641 of file qwindowswindow.cpp.

References QString::data(), QScreen::handle(), QGuiApplication::primaryScreen, screen, and QScreen::virtualSiblings().

Referenced by QWindowsWindow::forcedScreenForGLWindow().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setMinimizedGeometry()

static void setMinimizedGeometry ( HWND  hwnd,
const QRect r 
)
static

Definition at line 1821 of file qwindowswindow.cpp.

References RECTfromQRect().

+ Here is the call graph for this function:

◆ setRestoreMaximizedFlag()

static void setRestoreMaximizedFlag ( HWND  hwnd,
bool  set = true 
)
static

Definition at line 1832 of file qwindowswindow.cpp.

References set.

◆ setWindowOpacity()

static void setWindowOpacity ( HWND  hwnd,
Qt::WindowFlags  flags,
bool  hasAlpha,
bool  accelerated,
qreal  level 
)
static

Definition at line 490 of file qwindowswindow.cpp.

References Qt::FramelessWindowHint, hasAlpha(), qRound(), and QWindowsWindow::setWindowLayered().

Referenced by QWindowsWindow::setOpacity(), and updateGLWindowSettings().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ shouldApplyDarkFrame()

static bool shouldApplyDarkFrame ( const QWindow w)
inlinestatic

Definition at line 844 of file qwindowswindow.cpp.

References QPalette::color(), Qt::FramelessWindowHint, QWindowPrivate::get(), QWindowsIntegration::instance(), QColor::lightness(), testFlag(), QPalette::Window, and QPalette::WindowText.

Referenced by WindowCreationData::create(), and QWindowsWindow::setDarkBorder().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ shouldShowMaximizeButton()

static bool shouldShowMaximizeButton ( const QWindow w,
Qt::WindowFlags  flags 
)
static

Definition at line 461 of file qwindowswindow.cpp.

References Qt::CustomizeWindowHint, Qt::MSWindowsFixedSizeDialogHint, QWINDOWSIZE_MAX, and Qt::WindowMaximizeButtonHint.

Referenced by WindowCreationData::fromWindow().

+ Here is the caller graph for this function:

◆ testShowWithoutActivating()

static bool testShowWithoutActivating ( const QWindow window)
inlinestatic

Definition at line 1814 of file qwindowswindow.cpp.

References QVariant::isValid(), QVariant::toBool(), and window().

+ Here is the call graph for this function:

◆ toNativeSizeConstrained()

static QSize toNativeSizeConstrained ( QSize  dip,
const QScreen s 
)
static

Definition at line 1001 of file qwindowswindow.cpp.

References QHighDpiScaling::factor(), QSize::height(), QHighDpiScaling::isActive(), qFuzzyCompare(), qRound(), QWINDOWSIZE_MAX, QSize::setHeight(), QSize::setWidth(), and QSize::width().

Referenced by QWindowsGeometryHint::frameSizeConstraints().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ updateGLWindowSettings()

static void updateGLWindowSettings ( const QWindow w,
HWND  hwnd,
Qt::WindowFlags  flags,
qreal  opacity 
)
inlinestatic

Definition at line 506 of file qwindowswindow.cpp.

References applyBlurBehindWindow(), hasAlpha(), setWindowOpacity(), and windowIsAccelerated().

Referenced by QWindowsWindow::aboutToMakeCurrent(), and WindowCreationData::initialize().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ windowIsAccelerated()

static bool windowIsAccelerated ( const QWindow w)
inlinestatic

Definition at line 428 of file qwindowswindow.cpp.

References QWindowPrivate::compositing, QSurface::Direct3DSurface, QSurface::OpenGLSurface, qt_window_private(), QSurface::RasterGLSurface, and QSurface::VulkanSurface.

Referenced by updateGLWindowSettings().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ windowPlacementOffset()

static QPoint windowPlacementOffset ( HWND  hwnd,
const QPoint point 
)
static

Definition at line 365 of file qwindowswindow.cpp.

References QScreen::availableGeometry, QList< T >::constFirst(), QScreen::geometry, QWindowsContext::instance(), screen, QWindowsScreenManager::screenAtDp(), QWindowsContext::screenManager(), QWindowsScreenManager::screens(), QList< T >::size(), and QRect::topLeft().

Referenced by frameGeometry(), normalFrameGeometry(), and QWindowsBaseWindow::setGeometry_sys().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ windowVisibility_sys()

static QWindow::Visibility windowVisibility_sys ( HWND  hwnd)
static

Definition at line 407 of file qwindowswindow.cpp.