diff --git a/src/plugins/platforms/windows/qwindowswindow.cpp b/src/plugins/platforms/windows/qwindowswindow.cpp
index cac8ec5..108f136 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 {
@@ -1372,6 +1481,7 @@ QRect QWindowsWindow::normalGeometry() const
 
 void QWindowsWindow::setGeometry(const QRect &rectIn)
 {
+    qDebug() << __FUNCTION__ <<   m_data.hwnd << 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).
@@ -1445,6 +1555,7 @@ void QWindowsWindow::handleGeometryChange()
         return;
     const QRect previousGeometry = m_data.geometry;
     m_data.geometry = geometry_sys();
+    qDebug() << __FUNCTION__ <<   m_data.hwnd << m_data.geometry;
     QPlatformWindow::setGeometry(m_data.geometry);
     QWindowSystemInterface::handleGeometryChange(window(), m_data.geometry);
     // QTBUG-32121: OpenGL/normal windows (with exception of ANGLE) do not receive
@@ -1688,7 +1799,7 @@ void QWindowsWindow::setWindowState_sys(Qt::WindowState newState)
     const Qt::WindowState oldState = m_windowState;
     if (oldState == newState)
         return;
-    qCDebug(lcQpaWindows) << '>' << __FUNCTION__ << this << window()
+    qDebug() << '>' << __FUNCTION__ << this << window()
         << " from " << oldState << " to " << newState;
 
     const bool visible = isVisible();
@@ -1724,9 +1835,12 @@ void QWindowsWindow::setWindowState_sys(Qt::WindowState newState)
                     const QRect nf = normalFrameGeometry(m_data.hwnd);
                     if (nf.isValid())
                         m_savedFrameGeometry = nf;
+                        qDebug() << "assigned m_savedFrameGeometry from normalFrameGeometry" << m_savedFrameGeometry;
                 } else {
 #endif
+
                     m_savedFrameGeometry = frameGeometry_sys();
+                    qDebug() << "assigned m_savedFrameGeometry from frameGeometry_sys" << m_savedFrameGeometry;
 #ifndef Q_OS_WINCE
                 }
 #endif
@@ -1793,7 +1907,8 @@ void QWindowsWindow::setWindowState_sys(Qt::WindowState newState)
             ShowWindow(m_data.hwnd, (newState == Qt::WindowMinimized) ? SW_MINIMIZE :
                        (newState == Qt::WindowMaximized) ? SW_MAXIMIZE : SW_SHOWNORMAL);
     }
-    qCDebug(lcQpaWindows) << '<' << __FUNCTION__ << this << window() << newState;
+    qDebug() << '<' << __FUNCTION__ << this << window() << newState
+                          << "m_savedFrameGeometry=" <<m_savedFrameGeometry;
 }
 
 void QWindowsWindow::setStyle(unsigned s) const
