Don't fallback to X11 tray backend on non-X11
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 Fixes: QTBUG-114439 Task-number: QTBUG-94871 Pick-to: 6.5 Change-Id: Ic927cde585ef02f9b9ef03f3b6338f35072bef70 Reviewed-by: Dmitry Shachnev <mitya57@gmail.com> Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io> (cherry picked from commit f6cd286e6609cfbfda50bc74e96e115f3f8ec0ea) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
1752308123
commit
c1daaf5217
@ -78,17 +78,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() != "xcb"_L1;
|
||||
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
|
||||
|
||||
@ -476,7 +478,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;
|
||||
}
|
||||
@ -1247,7 +1249,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;
|
||||
}
|
||||
@ -1442,7 +1444,7 @@ Qt::ColorScheme QGnomeTheme::colorScheme() const
|
||||
#if !defined(QT_NO_DBUS) && !defined(QT_NO_SYSTEMTRAYICON)
|
||||
QPlatformSystemTrayIcon *QGnomeTheme::createPlatformSystemTrayIcon() const
|
||||
{
|
||||
if (isDBusTrayAvailable())
|
||||
if (shouldUseDBusTray())
|
||||
return new QDBusTrayIcon();
|
||||
return nullptr;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user