diff options
author | Yuhang Zhao <2546789017@qq.com> | 2022-02-07 18:01:15 +0800 |
---|---|---|
committer | Yuhang Zhao <2546789017@qq.com> | 2022-03-01 13:08:03 +0800 |
commit | 540745e599517a8c821d0bde2246a3407b95a4ee (patch) | |
tree | 1b9c70ef2f40398a8a3e26424e0c3e1fa48d18f5 | |
parent | 77d0ad6657997b24e760f9a510676c08fc952eca (diff) |
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.
Pick-to: 6.3 6.2
Change-Id: Ia69f4acbbf3e044073f818f357e614d4c6680d21
Reviewed-by: André de la Rocha <andre.rocha@qt.io>
-rw-r--r-- | src/plugins/platforms/windows/qwindowswindow.cpp | 10 | ||||
-rw-r--r-- | src/plugins/platforms/windows/qwindowswindow.h | 1 |
2 files changed, 11 insertions, 0 deletions
diff --git a/src/plugins/platforms/windows/qwindowswindow.cpp b/src/plugins/platforms/windows/qwindowswindow.cpp index d28a3ee675..2a91b466f9 100644 --- a/src/plugins/platforms/windows/qwindowswindow.cpp +++ b/src/plugins/platforms/windows/qwindowswindow.cpp @@ -1065,6 +1065,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))); } @@ -1101,6 +1103,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) diff --git a/src/plugins/platforms/windows/qwindowswindow.h b/src/plugins/platforms/windows/qwindowswindow.h index 915254dbd8..d18e617c7a 100644 --- a/src/plugins/platforms/windows/qwindowswindow.h +++ b/src/plugins/platforms/windows/qwindowswindow.h @@ -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); |