From f9cd2235c374630fae8f45246ef11e255a97c023 Mon Sep 17 00:00:00 2001 From: Jan Grulich Date: Tue, 4 Jan 2022 13:58:18 +0100 Subject: [PATCH] Do not use wayland platform plugin on GNOME wayland sessions by default This restores to the original behavior we had with Qt 6.2.0, we switched to wayland by default in GNOME in Qt 6.2.1, which changed behavior in a bugfix release. Revert "Use wayland platform plugin on GNOME wayland sessions by default" This reverts commit 75c6f11a36335ac1dcc3d352883910b3d7461232. Change-Id: Ie5fee31e59e946c255489789df44528ca794bf5c Reviewed-by: Eskil Abrahamsen Blomfeldt --- src/gui/kernel/qguiapplication.cpp | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp index dff86d0edf4..bad15cf1da9 100644 --- a/src/gui/kernel/qguiapplication.cpp +++ b/src/gui/kernel/qguiapplication.cpp @@ -1402,9 +1402,16 @@ void QGuiApplicationPrivate::createPlatformIntegration() } const bool defaultIsWayland = !defaultIsXcb && platformPluginBase.startsWith("wayland"); + bool isGnome = false; const QByteArray waylandPlatformName = defaultIsWayland ? platformName : "wayland"; if (hasWaylandDisplay || isWaylandSessionType) { - preferredPlatformOrder.prepend(waylandPlatformName); + const QByteArray currentDesktop = qgetenv("XDG_CURRENT_DESKTOP").toLower(); + const QByteArray sessionDesktop = qgetenv("XDG_SESSION_DESKTOP").toLower(); + isGnome = currentDesktop.contains("gnome") || sessionDesktop.contains("gnome"); + if (isGnome) + preferredPlatformOrder.append(waylandPlatformName); + else + preferredPlatformOrder.prepend(waylandPlatformName); if (defaultIsWayland) platformName.clear(); @@ -1472,7 +1479,14 @@ void QGuiApplicationPrivate::createPlatformIntegration() argc = j; } +#if defined(Q_OS_UNIX) && !defined(Q_OS_DARWIN) + if ((hasWaylandDisplay || isWaylandSessionType) && isGnome && !platformExplicitlySelected) { + qInfo() << "Warning: Ignoring WAYLAND_DISPLAY on Gnome." + << "Use QT_QPA_PLATFORM=wayland to run on Wayland anyway."; + } +#else Q_UNUSED(platformExplicitlySelected); +#endif init_platform(QLatin1String(platformName), platformPluginPath, platformThemeName, argc, argv);