diff --git a/.github/workflows/linting.yml b/.github/workflows/linting.yml index 71cea20713b..fd85b555c0c 100644 --- a/.github/workflows/linting.yml +++ b/.github/workflows/linting.yml @@ -44,4 +44,4 @@ jobs: run: sudo apt-get install appstream-util - name: Verify metainfo.xml - run: appstream-util validate-relax --nonet contrib/linux/dosbox-staging.metainfo.xml + run: appstream-util validate-relax --nonet contrib/linux/dosbox-staging.metainfo.xml.in diff --git a/.gitignore b/.gitignore index 0f250a7f8b2..ba636b03e6a 100644 --- a/.gitignore +++ b/.gitignore @@ -85,3 +85,5 @@ tools/unlock_the_magic_mpeg_ps.exe obj-*.-linux-gnu debian +contrib/linux/*.desktop +contrib/linux/*.metainfo.xml diff --git a/contrib/icons/meson.build b/contrib/icons/meson.build index 92feffc5f21..4c3280e20c2 100644 --- a/contrib/icons/meson.build +++ b/contrib/icons/meson.build @@ -19,7 +19,7 @@ png_files = { foreach name, size : png_files install_data( 'png' / name, - rename: 'dosbox-staging.png', + rename: appid + '.png', install_dir: icons_hicolor / size / 'apps', ) endforeach @@ -28,5 +28,6 @@ endforeach # install_data( 'svg' / 'dosbox-staging.svg', + rename: appid + '.svg', install_dir: icons_hicolor / 'scalable' / 'apps', ) diff --git a/contrib/linux/dosbox-staging.desktop b/contrib/linux/dosbox-staging.desktop.in similarity index 97% rename from contrib/linux/dosbox-staging.desktop rename to contrib/linux/dosbox-staging.desktop.in index 39d7615dfd4..e37a9505f68 100644 --- a/contrib/linux/dosbox-staging.desktop +++ b/contrib/linux/dosbox-staging.desktop.in @@ -56,9 +56,8 @@ GenericName[zh_CN]=DOS 模拟器 GenericName[zh_TW]=DOS 模擬器 Comment=DOS/x86 emulator focusing on ease of use Exec=dosbox -Icon=dosbox-staging +Icon=@app_id@ Type=Application Terminal=false Keywords=dos;gaming;game;games;emulator; Categories=Game;Emulator; -StartupWMClass=dosbox-staging diff --git a/contrib/linux/dosbox-staging.metainfo.xml b/contrib/linux/dosbox-staging.metainfo.xml.in similarity index 96% rename from contrib/linux/dosbox-staging.metainfo.xml rename to contrib/linux/dosbox-staging.metainfo.xml.in index 8cbafb99bfc..ccc03528109 100644 --- a/contrib/linux/dosbox-staging.metainfo.xml +++ b/contrib/linux/dosbox-staging.metainfo.xml.in @@ -1,7 +1,7 @@ - io.github.dosbox-staging + @app_id@ CC0-1.0 GPL-2.0-or-later DOSBox Staging @@ -65,7 +65,7 @@ console gamepad - dosbox-staging.desktop + @app_id@.desktop The DOSBox Staging Team dreamer.tan@gmail.com https://www.dosbox-staging.org/ diff --git a/contrib/linux/install-icons.sh b/contrib/linux/install-icons.sh index c7368571060..e740d22e147 100755 --- a/contrib/linux/install-icons.sh +++ b/contrib/linux/install-icons.sh @@ -25,10 +25,11 @@ usage() { install_icons() { cp -r icons $DEST_PATH - cp desktop/dosbox-staging.desktop $DEST_PATH/applications + cp desktop/dosbox-staging.desktop.in $DEST_PATH/applications/dosbox-staging.desktop ## Replace executable location in the .desktop file sed -i 's\Exec=dosbox\Exec='$(realpath dosbox)'\g' $DEST_PATH/applications/dosbox-staging.desktop + sed -i 's\@app_id@\dosbox-staging\g' $DEST_PATH/applications/dosbox-staging.desktop } remove_icons() { diff --git a/contrib/linux/meson.build b/contrib/linux/meson.build index 1ecd7010466..5d05e95fc91 100644 --- a/contrib/linux/meson.build +++ b/contrib/linux/meson.build @@ -1,3 +1,16 @@ -install_data('dosbox-staging.desktop', install_dir: data_dir / 'applications') +resource_data = configuration_data() +resource_data.set('app_id', appid) -install_data('dosbox-staging.metainfo.xml', install_dir: data_dir / 'metainfo') +configure_file( + input: 'dosbox-staging.desktop.in', + output: appid + '.desktop', + configuration: resource_data, + install_dir: data_dir / 'applications', +) + +configure_file( + input: 'dosbox-staging.metainfo.xml.in', + output: appid + '.metainfo.xml', + configuration: resource_data, + install_dir: data_dir / 'metainfo', +) diff --git a/include/dosbox.h b/include/dosbox.h index ed4e72f6fca..807756c28ba 100644 --- a/include/dosbox.h +++ b/include/dosbox.h @@ -37,7 +37,6 @@ // Copyright string #define DOSBOX_COPYRIGHT "(C) " DOSBOX_TEAM - int sdl_main(int argc, char *argv[]); // The shutdown_requested bool is a conditional break in the parse-loop and diff --git a/meson.build b/meson.build index 74052c37945..4ca17255d62 100644 --- a/meson.build +++ b/meson.build @@ -55,6 +55,7 @@ install_data( ) install_data('AUTHORS', 'README', 'THANKS', install_dir: doc_dir) +appid = get_option('app_id') subdir('contrib/linux') subdir('contrib/icons') subdir('contrib/resources') @@ -418,6 +419,7 @@ git_hash = run_command( conf_data = configuration_data() conf_data.set('version', meson.project_version()) conf_data.set('project_name', meson.project_name()) +conf_data.set('app_id', appid) conf_data.set('git_hash', git_hash) conf_data.set_quoted( 'CUSTOM_DATADIR', diff --git a/meson_options.txt b/meson_options.txt index 926a76eb305..1fa7ddd14e3 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -1,3 +1,12 @@ +# Fully qualified application ID for the emulator +# See https://dbus.freedesktop.org/doc/dbus-specification.html#message-protocol-names for details +option( + 'app_id', + type: 'string', + value: 'org.dosbox-staging.Dosbox-staging', + description: 'Fully qualified application ID for dosbox-staging. This is primarily used on Linux', +) + option( 'use_sdl2_net', type: 'boolean', diff --git a/scripts/create-package.sh b/scripts/create-package.sh index 29376a5f40c..b645347a3cc 100755 --- a/scripts/create-package.sh +++ b/scripts/create-package.sh @@ -147,7 +147,9 @@ pkg_linux() ldd "${build_dir}/dosbox" || true install -DT "${build_dir}/dosbox" "${pkg_dir}/dosbox" - install -DT contrib/linux/dosbox-staging.desktop "${pkg_dir}/desktop/dosbox-staging.desktop" + install -DT contrib/linux/dosbox-staging.desktop.in "${pkg_dir}/desktop/dosbox-staging.desktop" + sed -i 's\@app_id@\dosbox-staging\g' "${pkg_dir}/desktop/dosbox-staging.desktop" + install -DT contrib/linux/install-icons.sh "${pkg_dir}/install-icons.sh" DESTDIR="$(realpath "$pkg_dir")" make -C contrib/icons/ install datadir= diff --git a/src/config.h.in b/src/config.h.in index ca74bfe293a..7c4311f5885 100644 --- a/src/config.h.in +++ b/src/config.h.in @@ -30,6 +30,10 @@ // Git hash of the build #define BUILD_GIT_HASH "@git_hash@" +// Fully qualified application ID for the emulator +// See https://dbus.freedesktop.org/doc/dbus-specification.html#message-protocol-names for details +#define DOSBOX_APP_ID "@app_id@" + /* Operating System */ diff --git a/src/gui/sdlmain.cpp b/src/gui/sdlmain.cpp index f148dc83cba..0f9a89e61ad 100644 --- a/src/gui/sdlmain.cpp +++ b/src/gui/sdlmain.cpp @@ -88,6 +88,10 @@ #define APIENTRYP APIENTRY * #endif +#if SDL_VERSION_ATLEAST(3, 0, 0) +#define SDL_HINT_APP_ID DOSBOX_APP_ID +#endif + /* Don't guard these with GL_VERSION_2_0 - Apple defines it but not these typedefs. * If they're already defined they should match these definitions, so no conflicts. */ @@ -4616,13 +4620,16 @@ static int erase_mapper_file() return 0; } +#if !(SDL_VERSION_ATLEAST(3, 0, 0)) static void override_wm_class() { #if !defined(WIN32) constexpr int overwrite = 0; // don't overwrite - setenv("SDL_VIDEO_X11_WMCLASS", DOSBOX_PROJECT_NAME, overwrite); + setenv("SDL_VIDEO_X11_WMCLASS", DOSBOX_APP_ID, overwrite); + setenv("SDL_VIDEO_WAYLAND_WMCLASS", DOSBOX_APP_ID, overwrite); #endif } +#endif int sdl_main(int argc, char* argv[]) { @@ -4669,8 +4676,10 @@ int sdl_main(int argc, char* argv[]) } } + #if !(SDL_VERSION_ATLEAST(3, 0, 0)) // Before SDL2 video subsystem is initialised override_wm_class(); + #endif // Create or determine the location of the config directory // (e.g., in portable mode, the config directory is the