From 3ff013b47baac1ac421a2148c39cd0c8f2eb811e Mon Sep 17 00:00:00 2001 From: moWerk Date: Thu, 14 May 2026 13:42:20 +0200 Subject: [PATCH] Fix Application_p zero size on Qt6 Wayland by syncing to window geometry - In Qt5, the Wayland platform set the root QQuickItem dimensions synchronously before QML evaluation, so anchors.fill: parent on Application_p correctly resolved to the screen size at startup - In Qt6, the Wayland xdg_toplevel configure handshake is asynchronous and the QQuickWindow geometry arrives after QML component completion, leaving Application_p at 0x0 until a layout pass occurs - This caused LayerStack to calculate sub-page x positions as depth * 0 = 0 at push() time, stacking all pages at the origin with no slide animation, and the FlatMesh tutorial off-screen positions to resolve to 0 instead of the screen width - Fix: override itemChange in Application_p to detect ItemSceneChange and immediately call setWidth/setHeight from the QQuickWindow dimensions, then stay connected to widthChanged and heightChanged for any subsequent resize - The initial ItemSceneChange fires before the window is sized (0x0), so the guard w->width() > 0 skips that first call; the widthChanged signal fires moments later with the correct 321x321 geometry and the size is applied then - Diagnosed via Component.onCompleted logging in asteroid-settings confirming Application width reported as 0 at startup, and itemChange qDebug output confirming the two-phase size arrival sequence on sparrow - Confirmed on sparrow (catfish TicWatch Pro 2020): LayerStack sub-pages now animate in correctly with the slide transition --- src/controls/src/application_p.cpp | 17 +++++++++++++++++ src/controls/src/application_p.h | 3 +++ 2 files changed, 20 insertions(+) diff --git a/src/controls/src/application_p.cpp b/src/controls/src/application_p.cpp index b329c82..0fb191b 100644 --- a/src/controls/src/application_p.cpp +++ b/src/controls/src/application_p.cpp @@ -51,3 +51,20 @@ bool Application_p::overridesSystemGestures() { return m_overridesSystemGestures; } + +void Application_p::itemChange(ItemChange change, const ItemChangeData &data) +{ + QQuickItem::itemChange(change, data); + if (change == ItemSceneChange && data.window) { + auto syncSize = [this]() { + QQuickWindow *w = window(); + if (w && w->width() > 0) { + setWidth(w->width()); + setHeight(w->height()); + } + }; + syncSize(); + connect(data.window, &QQuickWindow::widthChanged, this, syncSize); + connect(data.window, &QQuickWindow::heightChanged, this, syncSize); + } +} diff --git a/src/controls/src/application_p.h b/src/controls/src/application_p.h index 414db5a..1cfede6 100644 --- a/src/controls/src/application_p.h +++ b/src/controls/src/application_p.h @@ -47,6 +47,9 @@ class Application_p : public QQuickItem private: bool m_overridesSystemGestures; +protected: + void itemChange(ItemChange change, const ItemChangeData &data) override; + signals: void overridesSystemGesturesChanged(); };