diff --git a/src/controls/qquickmenupopupwindow.cpp b/src/controls/qquickmenupopupwindow.cpp
index 937a5ea5..783678a7 100644
--- a/src/controls/qquickmenupopupwindow.cpp
+++ b/src/controls/qquickmenupopupwindow.cpp
@@ -139,6 +139,7 @@ void QQuickMenuPopupWindow1::updateSize()
 
     qreal x = m_initialPos.x();
     qreal y = m_initialPos.y();
+    qDebug() << __FUNCTION__ << m_initialPos;
     if (qGuiApp->layoutDirection() == Qt::RightToLeft)
         x -= contentItem->width();
     setGeometry(x, y, contentItem->width(), contentItem->height());
@@ -147,7 +148,9 @@ void QQuickMenuPopupWindow1::updateSize()
 void QQuickMenuPopupWindow1::updatePosition()
 {
     QPointF newPos = position() + m_oldItemPos - m_itemAt->position();
+
     m_initialPos += m_oldItemPos - m_itemAt->position();
+    qDebug() << __FUNCTION__ << m_initialPos<< "newPos=" << newPos;
     setGeometry(newPos.x(), newPos.y(), width(), height());
 }
 
@@ -163,9 +166,13 @@ void QQuickMenuPopupWindow1::exposeEvent(QExposeEvent *e)
     // the popup will reposition at the last moment, so its
     // initial position must be captured for updateSize().
     m_initialPos = position();
+    qDebug() << __FUNCTION__ << "assigned" << m_initialPos << "from position()" <<
+                flags();
     if (m_logicalParentWindow && m_logicalParentWindow->parent()) {
         // This must be a QQuickWindow embedded via createWindowContainer.
-        m_initialPos += m_logicalParentWindow->geometry().topLeft();
+        QPoint off = m_logicalParentWindow->geometry().topLeft();
+        qDebug() << __FUNCTION__ << "offset" << off << "from m_logicalParentWindow=" << m_logicalParentWindow;
+        m_initialPos += off;
     }
     QQuickPopupWindow1::exposeEvent(e);
 
diff --git a/src/controls/qquickpopupwindow.cpp b/src/controls/qquickpopupwindow.cpp
index 9a6519ed..746cacf0 100644
--- a/src/controls/qquickpopupwindow.cpp
+++ b/src/controls/qquickpopupwindow.cpp
@@ -66,17 +66,31 @@ void QQuickPopupWindow1::show()
 {
     qreal posx = x();
     qreal posy = y();
+    qDebug() << __FUNCTION__ << posx << posy;
     // transientParent may not be a QQuickWindow when embedding into widgets
     if (QWindow *tp = transientParent()) {
+         qDebug() << __FUNCTION__ << "transientParent()" << transientParent();
         if (m_parentItem) {
-            QPointF pos = m_parentItem->mapToItem(m_parentItem->window()->contentItem(), QPointF(posx, posy));
+            QQuickWindow *pwi = m_parentItem->window();
+            QQuickItem *ci = pwi->contentItem();
+            QPointF pos = m_parentItem->mapToItem(ci, QPointF(posx, posy));
             posx = pos.x();
             posy = pos.y();
+            qDebug() << "m_parentItem=" << m_parentItem
+                     << "m_parentItem/window=" << pwi << ",vis=" << pwi->isVisible()
+                     << ",tl=" << pwi->isTopLevel() << ",geom=" << pwi->geometry()
+                     << ",surface type=" << pwi->surfaceType() << ",surface class="  << pwi->surfaceClass()
+                     << "m_parentItem/window/contentItem=" << ci
+                     << "assigning" << posx << posy << "from"
+                     << m_parentItem->window();
         }
+        qDebug() << __FUNCTION__ << posx << posy << "Determining tlwOffset";
         QPoint tlwOffset = tp->mapToGlobal(QPoint());
         posx += tlwOffset.x();
         posy += tlwOffset.y();
+        qDebug() << __FUNCTION__ << "tlwOffset=" << tlwOffset <<  "->" << posx << posy;
     } else if (m_parentItem && m_parentItem->window()) {
+        qDebug() << __FUNCTION__ << "m_parentItem/window=" << m_parentItem->window();
         QPoint offset;
         QQuickWindow *quickWindow = m_parentItem->window();
         QWindow *renderWindow = QQuickRenderControl::renderWindowFor(quickWindow, &offset);
diff --git a/tests/manual/viewinqwidget/viewinqwidget.pro b/tests/manual/viewinqwidget/viewinqwidget.pro
index bb7cb282..36446684 100644
--- a/tests/manual/viewinqwidget/viewinqwidget.pro
+++ b/tests/manual/viewinqwidget/viewinqwidget.pro
@@ -3,3 +3,4 @@ TARGET = viewinqwidget
 SOURCES += $$PWD/main.cpp
 DEFINES += SRCDIR=\\\"$$PWD/\\\"
 OTHER_FILES += main.qml
+CONFIG+=console
