Windows QPA: Add convenient overload to query window frame

To be used in a later commit.

As a drive-by, return early in the frameOnPrimaryScreen
overload to avoid calling GetWindowLong in cases we
don't need them.

Change-Id: Ia69f4acbbf3e044073f818f357e614d4c6680d21
Reviewed-by: André de la Rocha <andre.rocha@qt.io>
(cherry picked from commit 540745e599517a8c821d0bde2246a3407b95a4ee)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Yuhang Zhao 2022-02-07 18:01:15 +08:00 committed by Qt Cherry-pick Bot
parent 42c242f5fc
commit 5080988961
2 changed files with 11 additions and 0 deletions

View File

@ -931,6 +931,8 @@ QMargins QWindowsGeometryHint::frameOnPrimaryScreen(const QWindow *w, DWORD styl
QMargins QWindowsGeometryHint::frameOnPrimaryScreen(const QWindow *w, HWND hwnd)
{
if (!w->isTopLevel() || w->flags().testFlag(Qt::FramelessWindowHint))
return {};
return frameOnPrimaryScreen(w, DWORD(GetWindowLongPtr(hwnd, GWL_STYLE)),
DWORD(GetWindowLongPtr(hwnd, GWL_EXSTYLE)));
}
@ -970,6 +972,14 @@ QMargins QWindowsGeometryHint::frame(const QWindow *w, HWND hwnd, DWORD style, D
return frame(w, style, exStyle, dpi);
}
QMargins QWindowsGeometryHint::frame(const QWindow *w, HWND hwnd)
{
if (!w->isTopLevel() || w->flags().testFlag(Qt::FramelessWindowHint))
return {};
return frame(w, hwnd, DWORD(GetWindowLongPtrW(hwnd, GWL_STYLE)),
DWORD(GetWindowLongPtrW(hwnd, GWL_EXSTYLE)));
}
// For newly created windows.
QMargins QWindowsGeometryHint::frame(const QWindow *w, const QRect &geometry,
DWORD style, DWORD exStyle)

View File

@ -66,6 +66,7 @@ struct QWindowsGeometryHint
static QMargins frameOnPrimaryScreen(const QWindow *w, HWND hwnd);
static QMargins frame(const QWindow *w, DWORD style, DWORD exStyle, qreal dpi);
static QMargins frame(const QWindow *w, HWND hwnd, DWORD style, DWORD exStyle);
static QMargins frame(const QWindow *w, HWND hwnd);
static QMargins frame(const QWindow *w, const QRect &geometry,
DWORD style, DWORD exStyle);
static bool handleCalculateSize(const QMargins &customMargins, const MSG &msg, LRESULT *result);