From ab9b67b140f94e0d8bc7320bbbb35c8dbd8296d2 Mon Sep 17 00:00:00 2001 From: Pier Luigi Fiorini Date: Sat, 29 Aug 2015 18:17:00 +0200 Subject: [PATCH] Set appId according to QGuiApplication::desktopFileName() Since qtbase 61ad604ad41607be97efea5a18cd4d9fb7ddca73, QGuiApplication has got a new property: desktopFileName. Applications can now specify the desktop file name. In that case we have a reliable information: use it for the appId removing the ".desktop" suffix. Otherwise, just use the logic we previously established. Change-Id: I03c89009620b33bc68ee97ed414cfee1c1794632 Reviewed-by: Paul Olav Tvete --- .../platforms/wayland/qwaylandwindow.cpp | 41 ++++++++++++------- 1 file changed, 26 insertions(+), 15 deletions(-) diff --git a/src/plugins/platforms/wayland/qwaylandwindow.cpp b/src/plugins/platforms/wayland/qwaylandwindow.cpp index 5c06f66dbd2..097320c5bed 100644 --- a/src/plugins/platforms/wayland/qwaylandwindow.cpp +++ b/src/plugins/platforms/wayland/qwaylandwindow.cpp @@ -50,6 +50,7 @@ #include #include +#include #include #include @@ -131,22 +132,32 @@ void QWaylandWindow::initWindow() mShellSurface->setTitle(window()->title()); // The appId is the desktop entry identifier that should follow the - // reverse DNS convention (see http://standards.freedesktop.org/desktop-entry-spec/latest/ar01s02.html), - // use the application domain if available, otherwise the executable base name. - // According to xdg-shell the appId is only the name, without the .desktop suffix. - QFileInfo fi = QCoreApplication::instance()->applicationFilePath(); - QStringList domainName = - QCoreApplication::instance()->organizationDomain().split(QLatin1Char('.'), - QString::SkipEmptyParts); - - if (domainName.isEmpty()) { - mShellSurface->setAppId(fi.baseName()); + // reverse DNS convention (see http://standards.freedesktop.org/desktop-entry-spec/latest/ar01s02.html). + // According to xdg-shell the appId is only the name, without + // the .desktop suffix. + // + // If the application specifies the desktop file name use that + // removing the ".desktop" suffix, otherwise fall back to the + // executable name and prepend the reversed organization domain + // when available. + if (!QGuiApplication::desktopFileName().isEmpty()) { + QString name = QGuiApplication::desktopFileName(); + mShellSurface->setAppId(name.replace(QRegularExpression(QLatin1String("\\.desktop$")), QString())); } else { - QString appId; - for (int i = 0; i < domainName.count(); ++i) - appId.prepend(QLatin1Char('.')).prepend(domainName.at(i)); - appId.append(fi.baseName()); - mShellSurface->setAppId(appId); + QFileInfo fi = QCoreApplication::instance()->applicationFilePath(); + QStringList domainName = + QCoreApplication::instance()->organizationDomain().split(QLatin1Char('.'), + QString::SkipEmptyParts); + + if (domainName.isEmpty()) { + mShellSurface->setAppId(fi.baseName()); + } else { + QString appId; + for (int i = 0; i < domainName.count(); ++i) + appId.prepend(QLatin1Char('.')).prepend(domainName.at(i)); + appId.append(fi.baseName()); + mShellSurface->setAppId(appId); + } } }