diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index 3212880ab..4825d88fe 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -228,4 +228,15 @@ function(add_core_resources target) endif() install(DIRECTORY "$/resources" DESTINATION "${CMAKE_INSTALL_BINDIR}") endif() + + # Linux platforms need a copy of the .desktop and icon file because Wayland stupidity. + # See QtHost::EarlyProcessStartup() for where this is used and why. We still need to set it when running + # as a Flatpak, but thankfully we don't need the extra copy. + if((LINUX OR BSD) AND (NOT DEFINED ENV{container})) + message(STATUS "Copying desktop file to resources directory.") + set(PACKAGING_SOURCE_DIR "${CMAKE_SOURCE_DIR}/scripts/packaging") + foreach(path "org.duckstation.DuckStation.desktop" "org.duckstation.DuckStation.png") + add_resources(${target} "${PACKAGING_SOURCE_DIR}/${path}" "${PACKAGING_SOURCE_DIR}") + endforeach() + endif() endfunction() diff --git a/src/duckstation-qt/qthost.cpp b/src/duckstation-qt/qthost.cpp index 2c1f7e8b7..704765ae2 100644 --- a/src/duckstation-qt/qthost.cpp +++ b/src/duckstation-qt/qthost.cpp @@ -180,6 +180,25 @@ bool QtHost::EarlyProcessStartup() // TODO: Re-evaluate this on Qt 6.9. if (QtHost::IsRunningOnWayland()) QGuiApplication::setAttribute(Qt::AA_DontCreateNativeWidgetSiblings, true); + + // We also need to manually set the path to the .desktop file, because Wayland's stupidity doesn't allow + // applications to set window icons, because GNOME circlejerkers think their iconless windows are superior. + // Even the Qt side of this is weird, thankfully we can give it an absolute path, just without the extension. + // To make matters even worse, setting the full path here doesn't work for Flatpaks... or anything outside of + // KDE. Setting the application name alone does for flatpak. What a clusterfuck of a platform for basic tasks + // that operating systems have done for decades. + if (getenv("container")) + { + // Flatpak. + QGuiApplication::setDesktopFileName(QStringLiteral("org.duckstation.DuckStation")); + } + else if (const char* current_desktop = getenv("XDG_CURRENT_DESKTOP"); + current_desktop && std::strstr(current_desktop, "KDE")) + { + // AppImage or local build. + QGuiApplication::setDesktopFileName( + QString::fromStdString(Path::Combine(EmuFolders::Resources, "org.duckstation.DuckStation"))); + } #endif // Config-based RAIntegration switch must happen before the main window is displayed.