Skip to content

Commit 3949027

Browse files
committed
Linux: remove ".desktop" suffix when setting WM_CLASS
This fixes a warning printed with Qt6. I read the Qt5 source code of this a while back and saw that the suffix is also stripped there.
1 parent 5009c8d commit 3949027

1 file changed

Lines changed: 8 additions & 7 deletions

File tree

linux.cpp

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ namespace Sys {
3232

3333
namespace {
3434

35-
const QString DESKTOP_FILE_NAME = "net.unvanquished.Unvanquished.desktop";
35+
const char DESKTOP_URI[] = "net.unvanquished.Unvanquished";
3636

3737
// Use QProcess::splitCommand in Qt 5.15+
3838
QStringList splitArgs(const QString& command) {
@@ -158,14 +158,15 @@ bool installShortcuts()
158158
qDebug() << "Created directory for desktop files" << desktopDirString;
159159
}
160160

161-
QFile desktopFile(":resources/" + DESKTOP_FILE_NAME);
161+
QString desktopFileName = QString(DESKTOP_URI) + ".desktop";
162+
QFile desktopFile(":resources/" + desktopFileName);
162163
if (!desktopFile.open(QIODevice::ReadOnly | QIODevice::Text)) {
163-
qDebug() << "missing resource" << DESKTOP_FILE_NAME;
164+
qDebug() << "missing resource" << desktopFileName;
164165
return false;
165166
}
166167
QString desktopStr = QString(desktopFile.readAll().data()).arg(settings.installPath());
167168
{
168-
QFile outputFile(desktopDir.filePath(DESKTOP_FILE_NAME));
169+
QFile outputFile(desktopDir.filePath(desktopFileName));
169170
if (!outputFile.open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Truncate)) {
170171
qDebug() << "error opening" << outputFile.fileName();
171172
return false;
@@ -179,7 +180,7 @@ bool installShortcuts()
179180

180181
int ret = QProcess::execute("xdg-mime",
181182
{QString("default"),
182-
desktopDir.filePath(DESKTOP_FILE_NAME),
183+
desktopDir.filePath(desktopFileName),
183184
QString("x-scheme-handler/unv")});
184185
qDebug() << "xdg-mime returned" << ret;
185186
ret = QProcess::execute("update-desktop-database", {desktopDirString});
@@ -293,9 +294,9 @@ void initApplicationName()
293294
QCoreApplication::setApplicationName("updater");
294295

295296
// WM_CLASS for X backend
296-
qputenv("RESOURCE_NAME", "net.unvanquished.Unvanquished");
297+
qputenv("RESOURCE_NAME", DESKTOP_URI);
297298
// equivalent for Wayland backend
298-
QGuiApplication::setDesktopFileName(DESKTOP_FILE_NAME);
299+
QGuiApplication::setDesktopFileName(DESKTOP_URI);
299300
}
300301

301302
// Settings are stored in ~/.config/unvanquished/updater.conf

0 commit comments

Comments
 (0)