diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp
index 834449f..3c06478 100644
--- a/src/gui/kernel/qguiapplication.cpp
+++ b/src/gui/kernel/qguiapplication.cpp
@@ -2104,9 +2104,11 @@ void QGuiApplicationPrivate::processActivatedEvent(QWindowSystemInterfacePrivate
 
 void QGuiApplicationPrivate::processWindowStateChangedEvent(QWindowSystemInterfacePrivate::WindowStateChangedEvent *wse)
 {
+
     if (QWindow *window  = wse->window.data()) {
         QWindowStateChangeEvent e(window->windowState());
         window->d_func()->windowState = wse->newState;
+        qDebug() << __FUNCTION__ << wse << window;
         QGuiApplication::sendSpontaneousEvent(window, &e);
     }
 }
@@ -2146,6 +2148,7 @@ void QGuiApplicationPrivate::processGeometryChangeEvent(QWindowSystemInterfacePr
     QWindow *window = e->tlw.data();
     if (!window)
         return;
+    qDebug() << __FUNCTION__ << e << window;
 
     QRect newRect = e->newGeometry;
     QRect oldRect = e->oldGeometry.isNull() ? window->d_func()->geometry : e->oldGeometry;
diff --git a/src/gui/kernel/qwindowsysteminterface.cpp b/src/gui/kernel/qwindowsysteminterface.cpp
index cae9760..ac1f84d 100644
--- a/src/gui/kernel/qwindowsysteminterface.cpp
+++ b/src/gui/kernel/qwindowsysteminterface.cpp
@@ -119,6 +119,7 @@ void QWindowSystemInterface::handleWindowStateChanged(QWindow *tlw, Qt::WindowSt
 {
     QWindowSystemInterfacePrivate::WindowStateChangedEvent *e =
         new QWindowSystemInterfacePrivate::WindowStateChangedEvent(tlw, newState);
+    qDebug() << __FUNCTION__ << e << tlw->objectName() << newState;
     QWindowSystemInterfacePrivate::handleWindowSystemEvent(e);
 }
 
@@ -143,6 +144,7 @@ void QWindowSystemInterface::handleApplicationStateChanged(Qt::ApplicationState
 void QWindowSystemInterface::handleGeometryChange(QWindow *tlw, const QRect &newRect, const QRect &oldRect)
 {
     QWindowSystemInterfacePrivate::GeometryChangeEvent *e = new QWindowSystemInterfacePrivate::GeometryChangeEvent(tlw, QHighDpi::fromNativePixels(newRect, tlw), QHighDpi::fromNativePixels(oldRect, tlw));
+    qDebug() << __FUNCTION__ << e << tlw->objectName() <<  oldRect << "->" << newRect;
     QWindowSystemInterfacePrivate::handleWindowSystemEvent(e);
 }
 
diff --git a/src/plugins/platforms/windows/qwindowswindow.cpp b/src/plugins/platforms/windows/qwindowswindow.cpp
index 9c6cb53..26bd77e 100644
--- a/src/plugins/platforms/windows/qwindowswindow.cpp
+++ b/src/plugins/platforms/windows/qwindowswindow.cpp
@@ -55,6 +55,115 @@
 
 #include <QtCore/QDebug>
 
+// -------------------------- Diagnostics start
+
+QT_BEGIN_NAMESPACE
+
+static QByteArray debugWinStyle(DWORD style);
+static QByteArray debugWinExStyle(DWORD exStyle);
+
+QT_END_NAMESPACE
+
+static void formatSwpFlags(QDebug &d, UINT uFlags)
+{
+    if (uFlags & SWP_NOSIZE)
+        d << " SWP_NOSIZE";
+    if (uFlags & SWP_NOMOVE)
+        d << " SWP_NOMOVE";
+    if (uFlags & SWP_NOZORDER)
+        d << " SWP_NOZORDER";
+    if (uFlags & SWP_NOREDRAW)
+        d << " SWP_NOREDRAW";
+    if (uFlags & SWP_NOACTIVATE)
+        d << " SWP_NOACTIVATE";
+    if (uFlags & SWP_FRAMECHANGED)
+        d << " SWP_FRAMECHANGED";
+    if (uFlags & SWP_SHOWWINDOW)
+        d << " SWP_SHOWWINDOW";
+    if (uFlags & SWP_HIDEWINDOW)
+        d << " SWP_HIDEWINDOW";
+}
+
+static BOOL _setWindowPos(HWND hWnd, HWND hWndInsertAfter, int X,
+                            int Y, int cx,  int cy, UINT uFlags)
+{
+    {
+        QDebug d = qDebug();
+        d << ">SetWindowPos(" << hWnd << "hWndInsertAfter="
+             << hWndInsertAfter;
+        switch (quintptr(hWndInsertAfter)) {
+        case HWND_TOP:
+            d << "HWND_TOP";
+            break;
+        case HWND_BOTTOM:
+            d << "HWND_BOTTOM";
+            break;
+        case HWND_TOPMOST:
+            d << "HWND_TOPMOST";
+            break;
+        case HWND_NOTOPMOST:
+            d << "HWND_NOTOPMOST";
+            break;
+        }
+        d <<  X << Y << cx <<  cy << "uFlags=" << showbase << hex << uFlags << noshowbase << dec;
+       formatSwpFlags(d, uFlags);
+        d << ')';
+    }
+    const BOOL r = SetWindowPos(hWnd, hWndInsertAfter, X, Y, cx,  cy, uFlags);
+    const DWORD err = GetLastError();
+    qDebug() << "<SetWindowPos() returned" << r;
+    if (!r)
+        qErrnoWarning(err, "SetWindowPos, err=%lu", err);
+    return r;
+}
+
+const char * showWindowMacros[] = {
+   "SW_HIDE", "SW_SHOWNORMAL", "SW_SHOWMINIMIZED", "SW_SHOWMAXIMIZED",
+    "SW_SHOWNOACTIVATE", "SW_SHOW", "SW_MINIMIZE ", "SW_SHOWMINNOACTIVE",
+    "SW_SHOWNA", "SW_RESTORE", "SW_SHOWDEFAULT", "SW_FORCEMINIMIZE" };
+
+static BOOL _showWindow(HWND h, int s)
+{
+    qDebug() << ">ShowWindow(" << h << s << showWindowMacros[s] << ')';
+    const bool r = ShowWindow(h, s);
+    qDebug() << "<ShowWindow() returned (previously visible)" << r;
+    return r;
+}
+
+LONG_PTR _setWindowLongPtr(HWND hWnd, int i, LONG_PTR v)
+{
+    {
+        QDebug d = qDebug();
+        d << ">SetWindowLongPtrW(" << hWnd << ", idx=" << i << ", "
+          << hex << showbase << v << dec << noshowbase;
+        switch (i) {
+        case GWL_STYLE:
+            d << "GWL_STYLE: " << debugWinStyle(v);
+            break;
+        case GWL_EXSTYLE:
+            d << "GWL_EXSTYLE: " << debugWinExStyle(v);
+            break;
+        default:
+            break;
+        }
+        d << ')';
+    }
+    SetLastError(0);
+    const LONG_PTR r = SetWindowLongPtrW(hWnd, i, v);
+    qDebug() << "<SetWindowLongPtrW() returned" << hex << showbase << r << dec << noshowbase;
+    const DWORD err = GetLastError();
+    if (!r && err)
+        qErrnoWarning("SetWindowLongPtrW");
+    return r;
+}
+
+#define ShowWindow _showWindow
+#define SetWindowPos _setWindowPos
+#undef SetWindowLongPtr
+#define SetWindowLongPtr _setWindowLongPtr
+
+// -------------------------- Diagnostics end
+
 QT_BEGIN_NAMESPACE
 
 enum {
@@ -1391,6 +1500,7 @@ QRect QWindowsWindow::normalGeometry() const
 
 void QWindowsWindow::setGeometry(const QRect &rectIn)
 {
+    qDebug() << __FUNCTION__ << '>' << rectIn;
     QRect rect = rectIn;
     // This means it is a call from QWindow::setFramePosition() and
     // the coordinates include the frame (size is still the contents rectangle).
@@ -1425,6 +1535,7 @@ void QWindowsWindow::setGeometry(const QRect &rectIn)
     } else {
         QPlatformWindow::setGeometry(rect);
     }
+    qDebug() << __FUNCTION__ << '<';
 }
 
 void QWindowsWindow::handleMoved()
@@ -1441,17 +1552,23 @@ void QWindowsWindow::handleResized(int wParam)
     case SIZE_MAXSHOW:
         return;
     case SIZE_MINIMIZED:
+        qDebug() << __FUNCTION__ << "SIZE_MINIMIZED";
         handleWindowStateChange(Qt::WindowMinimized);
         return;
     case SIZE_MAXIMIZED:
+        qDebug() << __FUNCTION__ << "SIZE_MAXIMIZED";
         handleWindowStateChange(Qt::WindowMaximized);
         handleGeometryChange();
         break;
     case SIZE_RESTORED:
-        if (isFullScreen_sys())
+        if (isFullScreen_sys()) {
+            qDebug() << __FUNCTION__ << "Full";
             handleWindowStateChange(Qt::WindowFullScreen);
-        else if (m_windowState != Qt::WindowNoState && !testFlag(MaximizeToFullScreen))
+
+        } else if (m_windowState != Qt::WindowNoState && !testFlag(MaximizeToFullScreen)) {
+            qDebug() << __FUNCTION__ << "nostate";
             handleWindowStateChange(Qt::WindowNoState);
+        }
         handleGeometryChange();
         break;
     }
@@ -1460,8 +1577,11 @@ void QWindowsWindow::handleResized(int wParam)
 void QWindowsWindow::handleGeometryChange()
 {
     //Prevent recursive resizes for Windows CE
-    if (testFlag(WithinSetStyle))
+    qDebug(">handleGeometryChange()");
+    if (testFlag(WithinSetStyle)) {
+        qDebug("<handleGeometryChange(): WithinSetStyle return");
         return;
+    }
     const QRect previousGeometry = m_data.geometry;
     m_data.geometry = geometry_sys();
     QPlatformWindow::setGeometry(m_data.geometry);
@@ -1479,10 +1599,14 @@ void QWindowsWindow::handleGeometryChange()
         if (newScreen != screen())
             QWindowSystemInterface::handleWindowScreenChanged(window(), newScreen->screen());
     }
-    if (testFlag(SynchronousGeometryChangeEvent))
+    if (testFlag(SynchronousGeometryChangeEvent)) {
+        qDebug(">flush()");
         QWindowSystemInterface::flushWindowSystemEvents();
+        qDebug("<flush()");
+    }
 
     qCDebug(lcQpaEvents) << __FUNCTION__ << this << window() << m_data.geometry;
+    qDebug("<handleGeometryChange()");
 }
 
 void QWindowsWindow::setGeometry_sys(const QRect &rect) const
@@ -1636,7 +1760,7 @@ QWindowsWindowData QWindowsWindow::setWindowFlags_sys(Qt::WindowFlags wt,
 
 void QWindowsWindow::handleWindowStateChange(Qt::WindowState state)
 {
-    qCDebug(lcQpaWindows) << __FUNCTION__ << this << window()
+    qDebug() << __FUNCTION__ << this << window()
                  << "\n    from " << m_windowState << " to " << state;
     setFlag(FrameDirty);
     m_windowState = state;
@@ -1677,10 +1801,12 @@ void QWindowsWindow::handleWindowStateChange(Qt::WindowState state)
 
 void QWindowsWindow::setWindowState(Qt::WindowState state)
 {
+    qDebug() << __FUNCTION__ << '>' << state;
     if (m_data.hwnd) {
         setWindowState_sys(state);
         m_windowState = state;
     }
+    qDebug() << __FUNCTION__ << '<';
 }
 
 bool QWindowsWindow::isFullScreen_sys() const
