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 };
|
enum { defaultSystemFontSize = 9 };
|
||||||
|
|
||||||
#if !defined(QT_NO_DBUS) && !defined(QT_NO_SYSTEMTRAYICON)
|
#if !defined(QT_NO_DBUS) && !defined(QT_NO_SYSTEMTRAYICON)
|
||||||
static bool isDBusTrayAvailable() {
|
static bool shouldUseDBusTray() {
|
||||||
static bool dbusTrayAvailable = false;
|
// There's no other tray implementation to fallback to on non-X11
|
||||||
static bool dbusTrayAvailableKnown = false;
|
// and QDBusTrayIcon can register the icon on the fly after creation
|
||||||
if (!dbusTrayAvailableKnown) {
|
static bool result = QGuiApplication::platformName() != "xcb"_L1;
|
||||||
|
static bool resultKnown = result;
|
||||||
|
if (!resultKnown) {
|
||||||
QDBusMenuConnection conn;
|
QDBusMenuConnection conn;
|
||||||
if (conn.isWatcherRegistered())
|
if (conn.isWatcherRegistered())
|
||||||
dbusTrayAvailable = true;
|
result = true;
|
||||||
dbusTrayAvailableKnown = true;
|
resultKnown = true;
|
||||||
qCDebug(qLcTray) << "D-Bus tray available:" << dbusTrayAvailable;
|
qCDebug(qLcTray) << "D-Bus tray available:" << result;
|
||||||
}
|
}
|
||||||
return dbusTrayAvailable;
|
return result;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -476,7 +478,7 @@ QPlatformMenuBar *QGenericUnixTheme::createPlatformMenuBar() const
|
|||||||
#if !defined(QT_NO_DBUS) && !defined(QT_NO_SYSTEMTRAYICON)
|
#if !defined(QT_NO_DBUS) && !defined(QT_NO_SYSTEMTRAYICON)
|
||||||
QPlatformSystemTrayIcon *QGenericUnixTheme::createPlatformSystemTrayIcon() const
|
QPlatformSystemTrayIcon *QGenericUnixTheme::createPlatformSystemTrayIcon() const
|
||||||
{
|
{
|
||||||
if (isDBusTrayAvailable())
|
if (shouldUseDBusTray())
|
||||||
return new QDBusTrayIcon();
|
return new QDBusTrayIcon();
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
@ -1247,7 +1249,7 @@ QPlatformMenuBar *QKdeTheme::createPlatformMenuBar() const
|
|||||||
#if !defined(QT_NO_DBUS) && !defined(QT_NO_SYSTEMTRAYICON)
|
#if !defined(QT_NO_DBUS) && !defined(QT_NO_SYSTEMTRAYICON)
|
||||||
QPlatformSystemTrayIcon *QKdeTheme::createPlatformSystemTrayIcon() const
|
QPlatformSystemTrayIcon *QKdeTheme::createPlatformSystemTrayIcon() const
|
||||||
{
|
{
|
||||||
if (isDBusTrayAvailable())
|
if (shouldUseDBusTray())
|
||||||
return new QDBusTrayIcon();
|
return new QDBusTrayIcon();
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
@ -1442,7 +1444,7 @@ Qt::ColorScheme QGnomeTheme::colorScheme() const
|
|||||||
#if !defined(QT_NO_DBUS) && !defined(QT_NO_SYSTEMTRAYICON)
|
#if !defined(QT_NO_DBUS) && !defined(QT_NO_SYSTEMTRAYICON)
|
||||||
QPlatformSystemTrayIcon *QGnomeTheme::createPlatformSystemTrayIcon() const
|
QPlatformSystemTrayIcon *QGnomeTheme::createPlatformSystemTrayIcon() const
|
||||||
{
|
{
|
||||||
if (isDBusTrayAvailable())
|
if (shouldUseDBusTray())
|
||||||
return new QDBusTrayIcon();
|
return new QDBusTrayIcon();
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user