diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp
index 61d52ff..3148775 100644
--- a/src/gui/kernel/qguiapplication.cpp
+++ b/src/gui/kernel/qguiapplication.cpp
@@ -427,13 +427,17 @@ QString QGuiApplication::applicationDisplayName()
 */
 QWindow *QGuiApplication::modalWindow()
 {
+
     if (QGuiApplicationPrivate::self->modalWindowList.isEmpty())
         return 0;
-    return QGuiApplicationPrivate::self->modalWindowList.first();
+    QWindow *w = QGuiApplicationPrivate::self->modalWindowList.first();
+   qDebug() << __FUNCTION__ << w;
+    return w;
 }
 
 void QGuiApplicationPrivate::updateBlockedStatus(QWindow *window)
 {
+    qDebug() << __FUNCTION__ << window;
     bool shouldBeBlocked = false;
     if ((window->windowType() & Qt::Popup) != Qt::Popup && !self->modalWindowList.isEmpty())
         shouldBeBlocked = self->isWindowBlocked(window);
@@ -442,12 +446,18 @@ void QGuiApplicationPrivate::updateBlockedStatus(QWindow *window)
         QEvent e(shouldBeBlocked ? QEvent::WindowBlocked : QEvent::WindowUnblocked);
 
         window->d_func()->blockedByModalWindow = shouldBeBlocked;
+       qDebug() << __FUNCTION__ << window << shouldBeBlocked;
         QGuiApplication::sendEvent(window, &e);
     }
 }
 
 void QGuiApplicationPrivate::showModalWindow(QWindow *modal)
 {
+    qDebug() << __FUNCTION__ << '>' << modal << modal->handle();
+    for (QWindow *w = modal->parent() ; w ; w = modal->parent() )
+        qDebug() << __FUNCTION__ << "parent" << w << w->handle();
+
+
     self->modalWindowList.prepend(modal);
 
     QEvent e(QEvent::WindowBlocked);
@@ -457,10 +467,12 @@ void QGuiApplicationPrivate::showModalWindow(QWindow *modal)
         if (!window->d_func()->blockedByModalWindow)
             updateBlockedStatus(window);
     }
+    qDebug() << __FUNCTION__ << '<' << modal << self->modalWindowList;
 }
 
 void QGuiApplicationPrivate::hideModalWindow(QWindow *window)
 {
+    qDebug() << __FUNCTION__ << '>' << window;
     self->modalWindowList.removeAll(window);
 
     QEvent e(QEvent::WindowUnblocked);
@@ -470,6 +482,7 @@ void QGuiApplicationPrivate::hideModalWindow(QWindow *window)
         if (window->d_func()->blockedByModalWindow)
             updateBlockedStatus(window);
     }
+    qDebug() << __FUNCTION__ << '<' << window;
 }
 
 /*
@@ -479,12 +492,14 @@ void QGuiApplicationPrivate::hideModalWindow(QWindow *window)
 */
 bool QGuiApplicationPrivate::isWindowBlocked(QWindow *window, QWindow **blockingWindow) const
 {
+    qDebug() << __FUNCTION__ << '>' << window;
     QWindow *unused = 0;
     if (!blockingWindow)
         blockingWindow = &unused;
 
     if (modalWindowList.isEmpty()) {
         *blockingWindow = 0;
+        qDebug() << __FUNCTION__ << "r1false";
         return false;
     }
 
@@ -497,6 +512,7 @@ bool QGuiApplicationPrivate::isWindowBlocked(QWindow *window, QWindow **blocking
             while (w) {
                 if (w == modalWindow) {
                     *blockingWindow = 0;
+                    qDebug() << __FUNCTION__ << "r2false";
                     return false;
                 }
                 QWindow *p = w->parent();
@@ -512,6 +528,7 @@ bool QGuiApplicationPrivate::isWindowBlocked(QWindow *window, QWindow **blocking
         {
             if (modalWindow != window) {
                 *blockingWindow = modalWindow;
+                qDebug() << __FUNCTION__ << modalWindow << "r3 true";
                 return true;
             }
             break;
@@ -524,6 +541,7 @@ bool QGuiApplicationPrivate::isWindowBlocked(QWindow *window, QWindow **blocking
                 do {
                     if (m == w) {
                         *blockingWindow = m;
+                        qDebug() << __FUNCTION__ << m << "r4 true";
                         return true;
                     }
                     QWindow *p = m->parent();
@@ -544,6 +562,7 @@ bool QGuiApplicationPrivate::isWindowBlocked(QWindow *window, QWindow **blocking
         }
     }
     *blockingWindow = 0;
+    qDebug() << __FUNCTION__ << "r6 false";
     return false;
 }
 
@@ -1188,6 +1207,7 @@ void QGuiApplicationPrivate::processWindowSystemEvent(QWindowSystemInterfacePriv
 void QGuiApplicationPrivate::processMouseEvent(QWindowSystemInterfacePrivate::MouseEvent *e)
 {
     QEvent::Type type;
+    qDebug() << __FUNCTION__ << '>' << e->window;
     // move first
     Qt::MouseButtons stateChange = e->buttons ^ buttons;
     const bool frameStrut = e->type == QWindowSystemInterfacePrivate::FrameStrutMouse;
@@ -1248,10 +1268,11 @@ void QGuiApplicationPrivate::processMouseEvent(QWindowSystemInterfacePrivate::Mo
             type = frameStrut ? QEvent::NonClientAreaMouseButtonRelease : QEvent::MouseButtonRelease;
         }
     }
-
+    qDebug() << __FUNCTION__ << "receiver" << window;
     if (!window)
         return;
 
+    qDebug() << __FUNCTION__ << "receiver BLOCKED" << window->d_func()->blockedByModalWindow;
     if (window->d_func()->blockedByModalWindow) {
         // a modal window is blocking this window, don't allow mouse events through
         return;
diff --git a/src/gui/kernel/qwindow.cpp b/src/gui/kernel/qwindow.cpp
index 2dc62d6..9d07639 100644
--- a/src/gui/kernel/qwindow.cpp
+++ b/src/gui/kernel/qwindow.cpp
@@ -362,6 +362,7 @@ QWindow *QWindow::parent() const
 
 void QWindow::setParent(QWindow *parent)
 {
+    qDebug() << __FUNCTION__ << this << parent;
     Q_D(QWindow);
 
     QObject::setParent(parent);
@@ -811,7 +812,7 @@ void QWindow::setTransientParent(QWindow *parent)
 {
     Q_D(QWindow);
     d->transientParent = parent;
-
+    qDebug() << __FUNCTION__ << this << parent;
     QGuiApplicationPrivate::updateBlockedStatus(this);
 }
 
@@ -1217,6 +1218,7 @@ bool QWindow::setMouseGrabEnabled(bool grab)
     Q_D(QWindow);
     if (d->platformWindow)
         return d->platformWindow->setMouseGrabEnabled(grab);
+    qDebug() << __FUNCTION__ << this << grab;
     return false;
 }
 
diff --git a/src/gui/kernel/qwindowsysteminterface.cpp b/src/gui/kernel/qwindowsysteminterface.cpp
index 23c23ba..411480e 100644
--- a/src/gui/kernel/qwindowsysteminterface.cpp
+++ b/src/gui/kernel/qwindowsysteminterface.cpp
@@ -76,6 +76,7 @@ extern QPointer<QWindow> qt_last_mouse_receiver;
 
 void QWindowSystemInterface::handleEnterEvent(QWindow *tlw)
 {
+    qDebug() << __FUNCTION__ << tlw;
     if (tlw) {
         QWindowSystemInterfacePrivate::EnterEvent *e = new QWindowSystemInterfacePrivate::EnterEvent(tlw);
         QWindowSystemInterfacePrivate::queueWindowSystemEvent(e);
@@ -84,6 +85,7 @@ void QWindowSystemInterface::handleEnterEvent(QWindow *tlw)
 
 void QWindowSystemInterface::handleLeaveEvent(QWindow *tlw)
 {
+    qDebug() << __FUNCTION__ << tlw;
     QWindowSystemInterfacePrivate::LeaveEvent *e = new QWindowSystemInterfacePrivate::LeaveEvent(tlw);
     QWindowSystemInterfacePrivate::queueWindowSystemEvent(e);
 }
@@ -143,6 +145,7 @@ void QWindowSystemInterface::handleMouseEvent(QWindow *w, const QPointF & local,
 
 void QWindowSystemInterface::handleMouseEvent(QWindow *w, ulong timestamp, const QPointF & local, const QPointF & global, Qt::MouseButtons b, Qt::KeyboardModifiers mods)
 {
+    qDebug() << __FUNCTION__ <<w;
     QWindowSystemInterfacePrivate::MouseEvent * e =
             new QWindowSystemInterfacePrivate::MouseEvent(w, timestamp, local, global, b, mods);
     QWindowSystemInterfacePrivate::queueWindowSystemEvent(e);
diff --git a/src/plugins/platforms/xcb/qxcbwindow.cpp b/src/plugins/platforms/xcb/qxcbwindow.cpp
index e1e8c9e..0649b6e 100644
--- a/src/plugins/platforms/xcb/qxcbwindow.cpp
+++ b/src/plugins/platforms/xcb/qxcbwindow.cpp
@@ -549,7 +549,9 @@ void QXcbWindow::show()
 
         // update WM_TRANSIENT_FOR
         if (window()->transientParent() && isTransient(window())) {
+
             QXcbWindow *transientXcbParent = static_cast<QXcbWindow *>(window()->transientParent()->handle());
+            qDebug() <<    __FUNCTION__ << "transient"<<  window() <<         window()->transientParent();
             if (transientXcbParent) {
                 // ICCCM 4.1.2.6
                 xcb_window_t parentWindow = transientXcbParent->xcb_window();
@@ -760,7 +762,8 @@ Qt::WindowFlags QXcbWindow::setWindowFlags(Qt::WindowFlags flags)
 
     setNetWmWindowFlags(flags);
     setMotifWindowFlags(flags);
-
+    qDebug() << __FUNCTION__ << "mouse" << (flags & Qt::WindowTransparentForInput) <<
+                "focus" << (flags & Qt::WindowDoesNotAcceptFocus);
     setTransparentForMouseEvents(flags & Qt::WindowTransparentForInput);
     updateDoesNotAcceptFocus(flags & Qt::WindowDoesNotAcceptFocus);
 
@@ -1656,6 +1659,11 @@ bool QXcbWindow::setKeyboardGrabEnabled(bool grab)
 
 bool QXcbWindow::setMouseGrabEnabled(bool grab)
 {
+    qDebug() << __FUNCTION__ << this << window() << grab;
+    if (grab) {
+        qDebug() << "GRAB";
+
+    }
     if (!grab) {
         xcb_ungrab_pointer(xcb_connection(), XCB_TIME_CURRENT_TIME);
         return true;
diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp
index 9d1b9c9..90c7f22 100644
--- a/src/widgets/kernel/qapplication.cpp
+++ b/src/widgets/kernel/qapplication.cpp
@@ -746,7 +746,9 @@ QWidget *QApplication::activePopupWidget()
 QWidget *QApplication::activeModalWidget()
 {
     QWidgetWindow *widgetWindow = qobject_cast<QWidgetWindow *>(modalWindow());
-    return widgetWindow ? widgetWindow->widget() : 0;
+    QWidget *m = widgetWindow ? widgetWindow->widget() : 0;
+    qDebug() << __FUNCTION__ << m << " mouse grabber: " << QWidget::mouseGrabber();
+    return m;
 }
 
 /*!
diff --git a/src/widgets/kernel/qwidget_qpa.cpp b/src/widgets/kernel/qwidget_qpa.cpp
index a1a414e..3126466 100644
--- a/src/widgets/kernel/qwidget_qpa.cpp
+++ b/src/widgets/kernel/qwidget_qpa.cpp
@@ -356,6 +356,7 @@ static QWidget *keyboardGrb = 0;
 
 void QWidget::grabMouse()
 {
+    qDebug() << __FUNCTION__ << this;
     if (qt_mouseGrb)
         qt_mouseGrb->releaseMouse();
 
