From: Debian Qt/KDE Maintainers Date: Thu, 25 Jul 2024 12:43:37 +0000 (+0300) Subject: don't fallback to X11 tray backend on non-X11 X-Git-Tag: archive/raspbian/5.15.13+dfsg-4+rpi1^2~12 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=d7369fd2307da3056f69e8b670c0dd65273ddc29;p=qtbase-opensource-src.git don't fallback to X11 tray backend on non-X11 Origin: upstream, https://code.qt.io/cgit/qt/qtbase.git/commit/?id=f6cd286e6609cfbf Last-Update: 2024-07-24 This allows to have system tray support on the fly on Wayland at least where only QDBusTrayIcon is possible and no need to fallback to QSystemTrayIconSys Gbp-Pq: Name dont_fallback_to_x11_tray_on_non_x11.diff --- diff --git a/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp b/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp index 1d2c67d62..5dbbcc5ef 100644 --- a/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp +++ b/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp @@ -101,17 +101,19 @@ static const char defaultFixedFontNameC[] = "monospace"; enum { defaultSystemFontSize = 9 }; #if !defined(QT_NO_DBUS) && !defined(QT_NO_SYSTEMTRAYICON) -static bool isDBusTrayAvailable() { - static bool dbusTrayAvailable = false; - static bool dbusTrayAvailableKnown = false; - if (!dbusTrayAvailableKnown) { +static bool shouldUseDBusTray() { + // There's no other tray implementation to fallback to on non-X11 + // and QDBusTrayIcon can register the icon on the fly after creation + static bool result = QGuiApplication::platformName() != QLatin1String("xcb"); + static bool resultKnown = result; + if (!resultKnown) { QDBusMenuConnection conn; if (conn.isWatcherRegistered()) - dbusTrayAvailable = true; - dbusTrayAvailableKnown = true; - qCDebug(qLcTray) << "D-Bus tray available:" << dbusTrayAvailable; + result = true; + resultKnown = true; + qCDebug(qLcTray) << "D-Bus tray available:" << result; } - return dbusTrayAvailable; + return result; } #endif @@ -204,7 +206,7 @@ QPlatformMenuBar *QGenericUnixTheme::createPlatformMenuBar() const #if !defined(QT_NO_DBUS) && !defined(QT_NO_SYSTEMTRAYICON) QPlatformSystemTrayIcon *QGenericUnixTheme::createPlatformSystemTrayIcon() const { - if (isDBusTrayAvailable()) + if (shouldUseDBusTray()) return new QDBusTrayIcon(); return nullptr; } @@ -683,7 +685,7 @@ QPlatformMenuBar *QKdeTheme::createPlatformMenuBar() const #if !defined(QT_NO_DBUS) && !defined(QT_NO_SYSTEMTRAYICON) QPlatformSystemTrayIcon *QKdeTheme::createPlatformSystemTrayIcon() const { - if (isDBusTrayAvailable()) + if (shouldUseDBusTray()) return new QDBusTrayIcon(); return nullptr; } @@ -803,7 +805,7 @@ QPlatformMenuBar *QGnomeTheme::createPlatformMenuBar() const #if !defined(QT_NO_DBUS) && !defined(QT_NO_SYSTEMTRAYICON) QPlatformSystemTrayIcon *QGnomeTheme::createPlatformSystemTrayIcon() const { - if (isDBusTrayAvailable()) + if (shouldUseDBusTray()) return new QDBusTrayIcon(); return nullptr; }