diff --git a/src/client/qwaylandwindow.cpp b/src/client/qwaylandwindow.cpp index 1127a07d..715d08ef 100644 --- a/src/client/qwaylandwindow.cpp +++ b/src/client/qwaylandwindow.cpp @@ -132,10 +132,16 @@ void QWaylandWindow::initWindow() if (shouldCreateSubSurface()) { Q_ASSERT(!mSubSurfaceWindow); + // find the most topmost parent that has actualy been initialised auto *parent = static_cast(QPlatformWindow::parent()); - if (parent->wlSurface()) { - if (::wl_subsurface *subsurface = mDisplay->createSubSurface(this, parent)) - mSubSurfaceWindow = new QWaylandSubSurface(this, parent, subsurface); + while (parent) { + if (parent->wlSurface() && (parent->mShellSurface || parent->mSubSurfaceWindow)) { + qDebug() << "Creating subsurface" << window() << " to " << parent->window(); + if (::wl_subsurface *subsurface = mDisplay->createSubSurface(this, parent)) + mSubSurfaceWindow = new QWaylandSubSurface(this, parent, subsurface); + break; + } + parent = static_cast(parent->QPlatformWindow::parent()); } } else if (shouldCreateShellSurface()) { Q_ASSERT(!mShellSurface); @@ -336,8 +342,16 @@ void QWaylandWindow::setGeometry_helper(const QRect &rect) qBound(window()->minimumHeight(), rect.height(), window()->maximumHeight()))); if (mSubSurfaceWindow) { - QMargins m = QPlatformWindow::parent()->frameMargins(); - mSubSurfaceWindow->set_position(rect.x() + m.left(), rect.y() + m.top()); + auto parent = QPlatformWindow::parent(); + QPoint offset; + while (parent && parent != mSubSurfaceWindow->parent()) { + offset += parent->geometry().topLeft(); + qDebug() << "Adding offset" << offset << "from " << parent->window(); + parent = parent->parent(); + qDebug() << parent->window(); + } + QMargins m = mSubSurfaceWindow->parent()->frameMargins(); + mSubSurfaceWindow->set_position(offset.x() + rect.x() + m.left(), offset.y() + rect.y() + m.top()); mSubSurfaceWindow->parent()->window()->requestUpdate(); } }