forked from github_mirror/framelesshelper
win: fix a rare bug
Signed-off-by: Yuhang Zhao <2546789017@qq.com>
This commit is contained in:
parent
32d29e39f6
commit
378f59f462
|
@ -1452,29 +1452,31 @@ void Utils::maybeFixupQtInternals(const WId windowId)
|
|||
} else {
|
||||
WARNING << getSystemErrorMessage(kGetClassLongPtrW);
|
||||
}
|
||||
SetLastError(ERROR_SUCCESS);
|
||||
const auto windowStyle = static_cast<DWORD>(GetWindowLongPtrW(hwnd, GWL_STYLE));
|
||||
if (windowStyle != 0) {
|
||||
// Qt by default adds the "WS_POPUP" flag to all Win32 windows it created and maintained,
|
||||
// which is not a good thing (although it won't cause any obvious issues in most cases
|
||||
// either), because popup windows have some different behavior with normal overlapped
|
||||
// windows, for example, it will affect DWM's default policy. And Qt will also lack some
|
||||
// necessary window styles in some cases (caused by misconfigured setWindowFlag(s) calls)
|
||||
// and this will also break the normal functionalities for our windows, so we do the
|
||||
// correction here unconditionally.
|
||||
static constexpr const DWORD badWindowStyle = WS_POPUP;
|
||||
static constexpr const DWORD goodWindowStyle =
|
||||
(WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME);
|
||||
if ((windowStyle & badWindowStyle) || !(windowStyle & goodWindowStyle)) {
|
||||
SetLastError(ERROR_SUCCESS);
|
||||
if (SetWindowLongPtrW(hwnd, GWL_STYLE, ((windowStyle & ~badWindowStyle) | goodWindowStyle)) == 0) {
|
||||
WARNING << getSystemErrorMessage(kSetWindowLongPtrW);
|
||||
} else {
|
||||
shouldUpdateFrame = true;
|
||||
if (!FramelessConfig::instance()->isSet(Option::UseCrossPlatformQtImplementation)) {
|
||||
SetLastError(ERROR_SUCCESS);
|
||||
const auto windowStyle = static_cast<DWORD>(GetWindowLongPtrW(hwnd, GWL_STYLE));
|
||||
if (windowStyle != 0) {
|
||||
// Qt by default adds the "WS_POPUP" flag to all Win32 windows it created and maintained,
|
||||
// which is not a good thing (although it won't cause any obvious issues in most cases
|
||||
// either), because popup windows have some different behavior with normal overlapped
|
||||
// windows, for example, it will affect DWM's default policy. And Qt will also lack some
|
||||
// necessary window styles in some cases (caused by misconfigured setWindowFlag(s) calls)
|
||||
// and this will also break the normal functionalities for our windows, so we do the
|
||||
// correction here unconditionally.
|
||||
static constexpr const DWORD badWindowStyle = WS_POPUP;
|
||||
static constexpr const DWORD goodWindowStyle =
|
||||
(WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME);
|
||||
if ((windowStyle & badWindowStyle) || !(windowStyle & goodWindowStyle)) {
|
||||
SetLastError(ERROR_SUCCESS);
|
||||
if (SetWindowLongPtrW(hwnd, GWL_STYLE, ((windowStyle & ~badWindowStyle) | goodWindowStyle)) == 0) {
|
||||
WARNING << getSystemErrorMessage(kSetWindowLongPtrW);
|
||||
} else {
|
||||
shouldUpdateFrame = true;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
WARNING << getSystemErrorMessage(kGetWindowLongPtrW);
|
||||
}
|
||||
} else {
|
||||
WARNING << getSystemErrorMessage(kGetWindowLongPtrW);
|
||||
}
|
||||
if (shouldUpdateFrame) {
|
||||
triggerFrameChange(windowId);
|
||||
|
|
Loading…
Reference in New Issue