diff --git a/src/core/framelesshelper_win.cpp b/src/core/framelesshelper_win.cpp index 735fa709..241da8d8 100644 --- a/src/core/framelesshelper_win.cpp +++ b/src/core/framelesshelper_win.cpp @@ -503,6 +503,10 @@ static inline void cleanupFallbackWindow() } g_win32Helper()->data[parentWindowId].fallbackTitleBarWindowId = fallbackTitleBarWindowId; g_win32Helper()->fallbackTitleBarToParentWindowMapping.insert(fallbackTitleBarWindowId, parentWindowId); + // ### Why do we need an extra resize here? + QTimer::singleShot(0, qApp, [parentWindowId, fallbackTitleBarWindowId, hide](){ + std::ignore = resizeFallbackTitleBarWindow(parentWindowId, fallbackTitleBarWindowId, hide); + }); return true; } @@ -529,13 +533,10 @@ void FramelessHelperWin::addWindow(FramelessParamsConst params) qApp->installNativeEventFilter(g_win32Helper()->nativeEventFilter.get()); } DEBUG.noquote() << "The DPI of window" << hwnd2str(windowId) << "is" << data.dpi; + // Remove the bad window styles added by Qt (it's not that "bad" though). + Utils::maybeFixupQtInternals(windowId); #if 0 params->setWindowFlags(params->getWindowFlags() | Qt::FramelessWindowHint); - // We need some delay here, otherwise the window styles will be overwritten by - // QPA itself. But don't use QThread::sleep(), it doesn't help in our case. - QTimer::singleShot(0, qApp, [windowId](){ - Utils::maybeFixupQtInternals(windowId); - }); #else // Qt maintains a frame margin internally, we need to update it accordingly // otherwise we'll get lots of warning messages when we change the window diff --git a/src/core/utils_win.cpp b/src/core/utils_win.cpp index 36a9466a..5b7be2e8 100644 --- a/src/core/utils_win.cpp +++ b/src/core/utils_win.cpp @@ -1284,6 +1284,7 @@ void Utils::maybeFixupQtInternals(const WId windowId) } bool shouldUpdateFrame = false; const auto hwnd = reinterpret_cast(windowId); +#if 0 SetLastError(ERROR_SUCCESS); const auto classStyle = static_cast(GetClassLongPtrW(hwnd, GCL_STYLE)); if (classStyle != 0) { @@ -1304,6 +1305,7 @@ void Utils::maybeFixupQtInternals(const WId windowId) } else { WARNING << getSystemErrorMessage(kGetClassLongPtrW); } +#endif SetLastError(ERROR_SUCCESS); const auto windowStyle = static_cast(GetWindowLongPtrW(hwnd, GWL_STYLE)); if (windowStyle == 0) { @@ -2506,7 +2508,7 @@ bool Utils::isValidWindow(const WId windowId, const bool checkVisible, const boo return false; } const LONG_PTR exStyles = ::GetWindowLongPtrW(hwnd, GWL_EXSTYLE); - if (exStyles & WS_EX_TOOLWINDOW) { + if ((exStyles != 0) && (exStyles & WS_EX_TOOLWINDOW)) { return false; } RECT rect = { 0, 0, 0, 0 };