Fix QWindow disappear bug of Qt Quick.

Restoring window styles to default will break Qt Quick applications.
The QWindow will disappear once we do it.

Qt Widgets applications are not affected.

Don't know why currently.

Disable it by default because it's not something we must do.

Signed-off-by: Yuhang Zhao <2546789017@qq.com>
This commit is contained in:
Yuhang Zhao 2020-05-11 22:05:43 +08:00
parent 48ff3280b1
commit 2df22bdb64
2 changed files with 22 additions and 15 deletions

View File

@ -932,20 +932,26 @@ bool WinNativeEventFilter::nativeEventFilter(const QByteArray &eventType,
if (!data->initialized) {
// Avoid initializing a same window twice.
data->initialized = TRUE;
// Don't restore the window styles to default when you are
// developing Qt Quick applications because the QWindow
// will disappear once you do it. However, Qt Widgets applications
// are not affected. Don't know why currently.
if (data->windowData.restoreDefaultWindowStyles) {
// Restore default window style.
// WS_OVERLAPPEDWINDOW = WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU |
// WS_THICKFRAME | WS_MINIMIZEBOX | WS_MAXIMIZEBOX
// Apply the WS_OVERLAPPEDWINDOW window style to restore the window
// to a normal native Win32 window.
// Don't apply the Qt::FramelessWindowHint flag, it will add the
// WS_POPUP window style to the window, which will turn the window
// into a popup window, losing all the functions a normal window
// should have.
// WS_OVERLAPPEDWINDOW = WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU
// | WS_THICKFRAME | WS_MINIMIZEBOX | WS_MAXIMIZEBOX
// Apply the WS_OVERLAPPEDWINDOW window style to restore the
// window to a normal native Win32 window.
// Don't apply the Qt::FramelessWindowHint flag, it will add
// the WS_POPUP window style to the window, which will turn
// the window into a popup window, losing all the functions
// a normal window should have.
// WS_CLIPCHILDREN | WS_CLIPSIBLINGS: work-around strange bugs.
m_lpSetWindowLongPtrW(msg->hwnd, GWL_STYLE,
WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN |
WS_CLIPSIBLINGS);
if (!data->windowData.notLayeredWindow) {
}
if (!data->windowData.doNotEnableLayeredWindow) {
// Turn our window into a layered window to get better
// performance and hopefully, to get rid of some strange bugs at
// the same time. But this will break the Arcylic effect

View File

@ -54,7 +54,8 @@ class WinNativeEventFilter : public QAbstractNativeEventFilter {
public:
using WINDOWDATA = struct _WINDOWDATA {
BOOL fixedSize = FALSE, mouseTransparent = FALSE,
notLayeredWindow = FALSE;
restoreDefaultWindowStyles = FALSE,
doNotEnableLayeredWindow = FALSE;
int borderWidth = -1, borderHeight = -1, titleBarHeight = -1;
QVector<QRect> ignoreAreas = {}, draggableAreas = {};
QVector<QPointer<QObject>> ignoreObjects = {}, draggableObjects = {};