diff --git a/src/controls/qquickmenupopupwindow.cpp b/src/controls/qquickmenupopupwindow.cpp
index 8d821d8..438ab2c 100644
--- a/src/controls/qquickmenupopupwindow.cpp
+++ b/src/controls/qquickmenupopupwindow.cpp
@@ -80,11 +80,15 @@ void QQuickMenuPopupWindow::setItemAt(QQuickItem *menuItem)
 
 void QQuickMenuPopupWindow::setParentWindow(QWindow *effectiveParentWindow, QQuickWindow *parentWindow)
 {
+    qDebug() << __FUNCTION__ << effectiveParentWindow << parentWindow;
     while (effectiveParentWindow && effectiveParentWindow->parent())
         effectiveParentWindow = effectiveParentWindow->parent();
     if (transientParent() != effectiveParentWindow)
         setTransientParent(effectiveParentWindow);
     m_logicalParentWindow = parentWindow;
+    qDebug() << __FUNCTION__ << "m_logicalParentWindow=" << m_logicalParentWindow
+             << "effectiveParentWindow=" << effectiveParentWindow;
+
     if (parentWindow) {
         if (QQuickMenuPopupWindow *pw = qobject_cast<QQuickMenuPopupWindow *>(parentWindow)) {
             connect(pw, SIGNAL(popupDismissed()), this, SLOT(dismissPopup()));
@@ -104,10 +108,12 @@ void QQuickMenuPopupWindow::setToBeDeletedLater()
 void QQuickMenuPopupWindow::setGeometry(int posx, int posy, int w, int h)
 {
     QWindow *pw = transientParent();
+    qDebug() << __FUNCTION__ << this <<  posx << posy << w << h;
     if (!pw && parentItem())
         pw = parentItem()->window();
     if (!pw)
         pw = this;
+    qDebug() << __FUNCTION__ << "pw=" << this;
     QRect g = pw->screen()->geometry();
 
     if (posx + w > g.right()) {
@@ -124,6 +130,7 @@ void QQuickMenuPopupWindow::setGeometry(int posx, int posy, int w, int h)
 
     posy = qBound(g.top(), posy, g.bottom() - h);
 
+    qDebug() << __FUNCTION__ << " QQuickWindow::setGeometry(" <<   posx << posy << w << h;
     QQuickWindow::setGeometry(posx, posy, w, h);
     emit geometryChanged();
 }
@@ -138,6 +145,7 @@ void QQuickMenuPopupWindow::updateSize()
     qreal y = m_initialPos.y();
     if (qGuiApp->layoutDirection() == Qt::RightToLeft)
         x -= contentItem->width();
+    qDebug() << __FUNCTION__ << x << y << "from=m_initialPos" << m_initialPos;
     setGeometry(x, y, contentItem->width(), contentItem->height());
 }
 
@@ -155,8 +163,11 @@ void QQuickMenuPopupWindow::exposeEvent(QExposeEvent *e)
     m_initialPos = position();
     if (m_logicalParentWindow && m_logicalParentWindow->parent()) {
         // This must be a QQuickWindow embedded via createWindowContainer.
+        qDebug() << __FUNCTION__ << "m_initialPos offset from" << m_logicalParentWindow
+                 << m_logicalParentWindow->geometry().topLeft();
         m_initialPos += m_logicalParentWindow->geometry().topLeft();
     }
+    qDebug() << __FUNCTION__ << "m_initialPos" << m_initialPos;
     QQuickPopupWindow::exposeEvent(e);
 
     if (isExposed())
diff --git a/src/controls/qquickpopupwindow.cpp b/src/controls/qquickpopupwindow.cpp
index cfab5bd..eb90b0d 100644
--- a/src/controls/qquickpopupwindow.cpp
+++ b/src/controls/qquickpopupwindow.cpp
@@ -59,19 +59,34 @@ void QQuickPopupWindow::applicationStateChanged(Qt::ApplicationState state)
         dismissPopup();
 }
 
+void QQuickPopupWindow::moveEvent(QMoveEvent *me)
+{
+    qDebug() << me;
+    QQuickWindow::moveEvent(me);
+}
+
 void QQuickPopupWindow::show()
 {
     qreal posx = x();
     qreal posy = y();
+    qDebug() << __FUNCTION__ << this << isTopLevel() << posx << posy
+                << "par=" << parent() << "tp=" << transientParent()
+                << "m_parentItem=" << m_parentItem << "m_contentItem=" << m_contentItem;
     // transientParent may not be a QQuickWindow when embedding into widgets
     if (QWindow *tp = transientParent()) {
         if (m_parentItem) {
-            QPointF pos = m_parentItem->mapToItem(m_parentItem->window()->contentItem(), QPointF(posx, posy));
-            pos += tp->mapFromGlobal(m_parentItem->window()->mapToGlobal(QPoint()));
+            qDebug() << "tp=" << tp << "m_parentItem->window()=" << m_parentItem->window();
+            QPointF pos = m_parentItem->mapToItem(m_parentItem->window()->contentItem(), QPointF(posx, posy));            
+            qDebug() << "pos=" << pos;
+            QPoint o1 = m_parentItem->window()->mapToGlobal(QPoint());
+            qDebug() << "o1=" << o1;
+            pos += tp->mapFromGlobal(o1);
+            qDebug() << "pos=" << pos << " ( + tp->mapFromGlobal(o1) )";
             posx = pos.x();
             posy = pos.y();
         }
         QPoint tlwOffset = tp->mapToGlobal(QPoint());
+        qDebug() << "tlwOffset=" << tlwOffset;
         posx += tlwOffset.x();
         posy += tlwOffset.y();
     } else if (m_parentItem && m_parentItem->window()) {
@@ -88,14 +103,17 @@ void QQuickPopupWindow::show()
         posy += offset.y() + parentWindowOffset.y();
     }
 
+    qDebug() << posx << posy;
     if (m_contentItem) {
         qreal initialWidth = qMax(qreal(1), m_contentItem->width());
         qreal initialHeight = qMax(qreal(1), m_contentItem->height());
+        qDebug() << "setGeometry" << posx << posy << initialWidth << initialHeight;
         setGeometry(posx, posy, initialWidth, initialHeight);
     } else {
+        qDebug() << "setPosition" << posx << posy;
         setPosition(posx, posy);
     }
-    emit geometryChanged();
+   emit geometryChanged();
 
     if (!qobject_cast<QQuickPopupWindow *>(transientParent())) { // No need for parent menu windows
         if (QQuickWindow *w = qobject_cast<QQuickWindow *>(transientParent())) {
@@ -113,13 +131,16 @@ void QQuickPopupWindow::show()
 
 void QQuickPopupWindow::setParentItem(QQuickItem *item)
 {
+    qDebug() << __FUNCTION__ << item << item->window();
     m_parentItem = item;
     if (m_parentItem)
         setTransientParent(m_parentItem->window());
+    qDebug() << '<' << __FUNCTION__ ;
 }
 
 void QQuickPopupWindow::setPopupContentItem(QQuickItem *contentItem)
 {
+    qDebug() << __FUNCTION__ << contentItem;
     if (!contentItem)
         return;
 
@@ -131,6 +152,7 @@ void QQuickPopupWindow::setPopupContentItem(QQuickItem *contentItem)
 
 void QQuickPopupWindow::updateSize()
 {
+    qDebug() << __FUNCTION__ << x() << y();
     setGeometry(x(), y(), popupContentItem()->width(), popupContentItem()->height());
     emit geometryChanged();
 }
diff --git a/src/controls/qquickpopupwindow_p.h b/src/controls/qquickpopupwindow_p.h
index 830ba38..04300df 100644
--- a/src/controls/qquickpopupwindow_p.h
+++ b/src/controls/qquickpopupwindow_p.h
@@ -68,6 +68,7 @@ Q_SIGNALS:
     void geometryChanged();
 
 protected:
+    void moveEvent(QMoveEvent *me) Q_DECL_OVERRIDE;
     void mousePressEvent(QMouseEvent *) Q_DECL_OVERRIDE;
     void mouseReleaseEvent(QMouseEvent *) Q_DECL_OVERRIDE;
     void mouseMoveEvent(QMouseEvent *) Q_DECL_OVERRIDE;
