diff --git a/src/plugins/platforms/windows/qwindowsintegration.cpp b/src/plugins/platforms/windows/qwindowsintegration.cpp
index bd2014b..1bc1b8b 100644
--- a/src/plugins/platforms/windows/qwindowsintegration.cpp
+++ b/src/plugins/platforms/windows/qwindowsintegration.cpp
@@ -302,7 +302,7 @@ QPlatformWindow *QWindowsIntegration::createPlatformWindow(QWindow *window) cons
         requested.customMargins = qvariant_cast<QMargins>(customMarginsV);
 
     QWindowsWindowData obtained = QWindowsWindowData::create(window, requested, window->title());
-    qCDebug(lcQpaWindows).nospace()
+    qDebug().nospace()
         << __FUNCTION__ << ' ' << window
         << "\n    Requested: " << requested.geometry << " frame incl.="
         << QWindowsGeometryHint::positionIncludesFrame(window)
diff --git a/src/plugins/platforms/windows/qwindowswindow.cpp b/src/plugins/platforms/windows/qwindowswindow.cpp
index cac8ec5..9de2389 100644
--- a/src/plugins/platforms/windows/qwindowswindow.cpp
+++ b/src/plugins/platforms/windows/qwindowswindow.cpp
@@ -637,12 +637,14 @@ QWindowsWindowData
     const QWindowCreationContextPtr context(new QWindowCreationContext(w, rect, data.customMargins, style, exStyle));
     QWindowsContext::instance()->setWindowCreationContext(context);
 
-    qCDebug(lcQpaWindows).nospace()
+
+    qDebug().nospace()
         << "CreateWindowEx: " << w << " class=" << windowClassName << " title=" << title
         << '\n' << *this << "\nrequested: " << rect << ": "
         << context->frameWidth << 'x' <<  context->frameHeight
         << '+' << context->frameX << '+' << context->frameY
-        << " custom margins: " << context->customMargins;
+        << " custom margins: " << context->customMargins
+        << "parentH=" << parentHandle;
 
     result.hwnd = CreateWindowEx(exStyle, classNameUtf16, titleUtf16,
                                  style,
@@ -974,6 +976,7 @@ QWindowsWindow::~QWindowsWindow()
 #endif // !Q_OS_WINCE
     destroyWindow();
     destroyIcon();
+    qDebug() << __FUNCTION__ << window();
 }
 
 void QWindowsWindow::fireExpose(const QRegion &region, bool force)
@@ -1291,7 +1294,14 @@ void QWindowsWindow::hide_sys() const
 
 void QWindowsWindow::setParent(const QPlatformWindow *newParent)
 {
-    qCDebug(lcQpaWindows) << __FUNCTION__ << window() << newParent;
+    {
+        QDebug d  = qDebug();
+        d << __FUNCTION__ << window();
+        if (newParent)
+            d << newParent->window();
+        else
+            d << '0';
+    }
 
     if (m_data.hwnd)
         setParent_sys(newParent);
@@ -1469,11 +1479,12 @@ void QWindowsWindow::setGeometry_sys(const QRect &rect) const
     const QMargins margins = frameMargins();
     const QRect frameGeometry = rect + margins;
 
-    qCDebug(lcQpaWindows) << '>' << __FUNCTION__ << window()
+    /*
+    qDebug() << '>' << __FUNCTION__ << window()
         << "\n from " << geometry_sys() << " frame: "
         << margins << " to " <<rect
         << " new frame: " << frameGeometry;
-
+*/
     bool result = false;
 #ifndef Q_OS_WINCE
     WINDOWPLACEMENT windowPlacement;
@@ -1866,6 +1877,7 @@ bool QWindowsWindow::handleGeometryChangingMessage(MSG *message, const QWindow *
     const QRect correctedFrameGeometry = correctedGeometryF.toRect() + margins;
     if (correctedFrameGeometry == suggestedFrameGeometry)
         return false;
+qDebug() << __FUNCTION__ << suggestedFrameGeometry << correctedFrameGeometry;
     windowPos->x = correctedFrameGeometry.left();
     windowPos->y = correctedFrameGeometry.top();
     windowPos->cx = correctedFrameGeometry.width();
diff --git a/src/widgets/widgets/qdockwidget.cpp b/src/widgets/widgets/qdockwidget.cpp
index 67eb466..c6a6be3 100644
--- a/src/widgets/widgets/qdockwidget.cpp
+++ b/src/widgets/widgets/qdockwidget.cpp
@@ -723,6 +723,7 @@ void QDockWidgetPrivate::initDrag(const QPoint &pos, bool nca)
         return;
 
     QMainWindowLayout *layout = qt_mainwindow_layout_from_dock(q);
+qDebug() << __FUNCTION__ << layout <<"nca="  << nca;
     Q_ASSERT(layout != 0);
     if (layout->pluggingWidget != 0) // the main window is animating a docking operation
         return;
@@ -753,6 +754,8 @@ void QDockWidgetPrivate::startDrag(bool group)
     Q_ASSERT(layout != 0);
 
     state->widgetItem = layout->unplug(q, group);
+qDebug() << __FUNCTION__ << this << "group="     << group << layout
+         << "\nstate->widgetItem=" <<state->widgetItem;
     if (state->widgetItem == 0) {
         /* I have a QMainWindow parent, but I was never inserted with
             QMainWindow::addDockWidget, so the QMainWindowLayout has no
@@ -977,8 +980,11 @@ void QDockWidgetPrivate::nonClientAreaMouseEvent(QMouseEvent *event)
         case QEvent::NonClientAreaMouseButtonPress:
             if (!titleRect.contains(event->globalPos()))
                 break;
+            qDebug() << __FUNCTION__ << "parent=" << parent;
             if (state != 0)
                 break;
+            if (q->isWindow())
+                break;
             if (qobject_cast<QMainWindow*>(parent) == 0 && qobject_cast<QDockWidgetGroupWindow*>(parent) == 0)
                 break;
             if (isAnimating())
@@ -992,6 +998,7 @@ void QDockWidgetPrivate::nonClientAreaMouseEvent(QMouseEvent *event)
         case QEvent::NonClientAreaMouseMove:
             if (state == 0 || !state->dragging)
                 break;
+            qDebug() << __FUNCTION__ <<"move";
 
 #ifndef Q_OS_MAC
             if (state->nca) {
@@ -1042,9 +1049,10 @@ void QDockWidgetPrivate::moveEvent(QMoveEvent *event)
 void QDockWidgetPrivate::unplug(const QRect &rect)
 {
     Q_Q(QDockWidget);
+    qDebug() << __FUNCTION__ << this << rect;
     QRect r = rect;
     r.moveTopLeft(q->mapToGlobal(QPoint(0, 0)));
-    QDockWidgetLayout *dwLayout = qobject_cast<QDockWidgetLayout*>(layout);
+    QDockWidgetLayout *dwLayout = qobject_cast<QDockWidgetLayout*>(layout);    
     if (dwLayout->nativeWindowDeco(true))
         r.adjust(0, dwLayout->titleHeight(), 0, 0);
     setWindowState(true, true, r);
@@ -1053,11 +1061,15 @@ void QDockWidgetPrivate::unplug(const QRect &rect)
 void QDockWidgetPrivate::plug(const QRect &rect)
 {
     setWindowState(false, false, rect);
+    qDebug() << __FUNCTION__ <<  q_func();
 }
 
 void QDockWidgetPrivate::setWindowState(bool floating, bool unplug, const QRect &rect)
 {
+
     Q_Q(QDockWidget);
+    qDebug() << __FUNCTION__ <<  "floating=" << floating << "unplug=" << unplug
+             << rect << "parent=" << parent;
 
     if (!floating && parent) {
         QMainWindowLayout *mwlayout = qt_mainwindow_layout_from_dock(q);
@@ -1089,6 +1101,8 @@ void QDockWidgetPrivate::setWindowState(bool floating, bool unplug, const QRect
 
     if (unplug)
         flags |= Qt::X11BypassWindowManagerHint;
+    qDebug() << __FUNCTION__ <<  "wasFloating=" << wasFloating
+             << flags;
 
     q->setWindowFlags(flags);
 
diff --git a/src/widgets/widgets/qmainwindowlayout.cpp b/src/widgets/widgets/qmainwindowlayout.cpp
index 54e956c..c2b0e5f 100644
--- a/src/widgets/widgets/qmainwindowlayout.cpp
+++ b/src/widgets/widgets/qmainwindowlayout.cpp
@@ -2251,14 +2251,17 @@ void QMainWindowLayout::setCentralWidget(QWidget *widget)
  */
 QLayoutItem *QMainWindowLayout::unplug(QWidget *widget, bool group)
 {
+    qDebug() << __FUNCTION__ << widget << group;
 #if !defined(QT_NO_DOCKWIDGET) && !defined(QT_NO_TABBAR)
     QDockWidgetGroupWindow *floatingParent = qobject_cast<QDockWidgetGroupWindow *>(widget->parentWidget());
     if (group && floatingParent && !widget->isWindow()) {
+        qDebug() << __FUNCTION__ << "dragging";
         // We are just dragging a floating window as it, not need to do anything, we just have to
         // look up the corresponding QWidgetItem* if it exists
         QList<int> tabbedWindowPath = layoutState.indexOf(widget->parentWidget());
         return tabbedWindowPath.isEmpty() ? 0 : layoutState.item(tabbedWindowPath);
     } else if (floatingParent) {
+        qDebug() << __FUNCTION__ << "floatingParent";
         // We are unplugging a dock widget from a floating window.
         if (QDockWidget *dw = qobject_cast<QDockWidget*>(widget)) {
             dw->d_func()->unplug(widget->geometry());
