From 8a9ea279fa5e96327794ad943ebd96be31cca433 Mon Sep 17 00:00:00 2001 From: Stefan Eichenberger Date: Wed, 16 Nov 2022 17:42:02 +0100 Subject: qt5: examples: cinematicexperience: Fix a crash with no screen When there is no screen attached the Qt application fails to start. The message when the application crashes is: xdg_wm_base@17: error 4: xdg_surface geometry (500 x 500) is larger than the configured fullscreen state (0 x 0) The Wayland connection experienced a fatal error: Protocol error This leads to a kernel messages each time the application tries to start. With BSP5 the application just tries to restart every time the applications exits but doesn't spam the kernel log. The reason why this changed is this new feature: https://code.qt.io/cgit/qt/qtwayland.git/commit/?h=5.15&id=d58008c4310f99d0faebcfb2fd9aa9296b813ecf The change of this commit fixes the application so that it properly works with no screen attached and doesn't crash at all. Related-to: ELB-4884 Signed-off-by: Stefan Eichenberger (cherry picked from commit 2ca50c7c93e69cd02028ec5a204b84632d996703) Signed-off-by: Max Krummenacher --- .../cinematicexperience/fix-fullscreen-mode.patch | 43 ++++++++++++++++++++++ .../examples/cinematicexperience_1.0.bbappend | 3 ++ 2 files changed, 46 insertions(+) create mode 100644 qt5-layer/recipes-qt/examples/cinematicexperience/fix-fullscreen-mode.patch create mode 100644 qt5-layer/recipes-qt/examples/cinematicexperience_1.0.bbappend diff --git a/qt5-layer/recipes-qt/examples/cinematicexperience/fix-fullscreen-mode.patch b/qt5-layer/recipes-qt/examples/cinematicexperience/fix-fullscreen-mode.patch new file mode 100644 index 0000000..a7a6846 --- /dev/null +++ b/qt5-layer/recipes-qt/examples/cinematicexperience/fix-fullscreen-mode.patch @@ -0,0 +1,43 @@ +--- main.cpp.orig 2022-11-16 15:25:11.221100107 +0100 ++++ main.cpp 2022-11-18 09:30:01.084064039 +0100 +@@ -1,5 +1,22 @@ + #include + #include ++#include ++ ++void setFullscreen(QQuickView *view, const QScreen *screen) ++{ ++ QSize screenSize = screen->size(); ++ /* If we set fullscreen and screen size is 0,0 the application crashes. ++ * Therefore, we only set fullscreen mode when the screen size is big enough. ++ * We have to set visible false before we change the window state, else it ++ * won't update correctly and we might have a title bar */ ++ if ((screenSize.height() > 1) && (screenSize.width() > 1)) { ++ view->setVisible(false); ++ view->setWindowStates(Qt::WindowFullScreen); ++ } ++ ++ /* We always need to set visible to true, else the window will not show up */ ++ view->setVisible(true); ++} + + int main(int argc, char* argv[]) + { +@@ -10,9 +27,15 @@ + + const QString lowerArgument = QString::fromLatin1(argv[1]).toLower(); + if (lowerArgument == QLatin1String("--fullscreen")) { +- view.showFullScreen(); +- } else { ++ QObject::connect(&view, &QQuickView::screenChanged, &app, [&view](QScreen *screen) { ++ setFullscreen(&view, screen); ++ }, Qt::DirectConnection); ++ ++ setFullscreen(&view, view.screen()); ++ } ++ else { + view.show(); + } ++ + return app.exec(); + } diff --git a/qt5-layer/recipes-qt/examples/cinematicexperience_1.0.bbappend b/qt5-layer/recipes-qt/examples/cinematicexperience_1.0.bbappend new file mode 100644 index 0000000..e4d42f4 --- /dev/null +++ b/qt5-layer/recipes-qt/examples/cinematicexperience_1.0.bbappend @@ -0,0 +1,3 @@ +FILESEXTRAPATHS:prepend := "${THISDIR}/${PN}:" + +SRC_URI:append = " file://fix-fullscreen-mode.patch" -- cgit v1.2.3