Re-added SDL_HINT_APP_ID and SDL_HINT_APP_NAME

This commit is contained in:
Sam Lantinga 2024-07-28 14:45:38 -07:00 committed by Ryan C. Gordon
parent 94827e0acd
commit 61a88077a7
4 changed files with 46 additions and 8 deletions

View File

@ -782,12 +782,11 @@ The following hints have been removed:
* SDL_HINT_WINDOWS_DISABLE_THREAD_NAMING - SDL now properly handles the 0x406D1388 Exception if no debugger intercepts it, preventing its propagation.
* SDL_HINT_WINDOWS_NO_CLOSE_ON_ALT_F4 - replaced with SDL_HINT_WINDOWS_CLOSE_ON_ALT_F4, defaulting to SDL_TRUE
* SDL_HINT_XINPUT_USE_OLD_JOYSTICK_MAPPING
* SDL_HINT_APP_NAME - replaced by either using the appname param to SDL_SetAppMetadata() or setting SDL_PROP_APP_METADATA_NAME_STRING with SDL_SetAppMetadataProperty().
* SDL_HINT_AUDIO_DEVICE_APP_NAME - replaced by either using the appname param to SDL_SetAppMetadata() or using SDL_PROP_APP_METADATA_NAME_STRING in SDL_SetAppMetadataWithProperties()
* SDL_HINT_AUDIO_DEVICE_APP_NAME - replaced by either using the appname param to SDL_SetAppMetadata() or setting SDL_PROP_APP_METADATA_NAME_STRING with SDL_SetAppMetadataProperty()
* Renamed hints SDL_HINT_VIDEODRIVER and SDL_HINT_AUDIODRIVER to SDL_HINT_VIDEO_DRIVER and SDL_HINT_AUDIO_DRIVER
* Renamed environment variables SDL_VIDEODRIVER and SDL_AUDIODRIVER to SDL_VIDEO_DRIVER and SDL_AUDIO_DRIVER
* The environment variables SDL_VIDEO_X11_WMCLASS and SDL_VIDEO_WAYLAND_WMCLASS have been removed and replaced with app metadata (either use the appindentifier param to SDL_SetAppMetadata() or set SDL_PROP_APP_METADATA_IDENTIFIER_STRING with SDL_SetAppMetadataProperty()).
* The environment variables SDL_VIDEO_X11_WMCLASS and SDL_VIDEO_WAYLAND_WMCLASS have been removed and replaced by either using the appindentifier param to SDL_SetAppMetadata() or setting SDL_PROP_APP_METADATA_IDENTIFIER_STRING with SDL_SetAppMetadataProperty()
The following hints have been renamed:
* SDL_HINT_ALLOW_TOPMOST => SDL_HINT_WINDOW_ALLOW_TOPMOST

View File

@ -125,6 +125,38 @@ extern "C" {
*/
#define SDL_HINT_ANDROID_TRAP_BACK_BUTTON "SDL_ANDROID_TRAP_BACK_BUTTON"
/**
* A variable setting the app ID string.
*
* This string is used by desktop compositors to identify and group windows
* together, as well as match applications with associated desktop settings
* and icons.
*
* This will override SDL_PROP_APP_METADATA_IDENTIFIER_STRING, if set by the application.
*
* This hint should be set before SDL is initialized.
*
* \since This hint is available since SDL 3.0.0.
*/
#define SDL_HINT_APP_ID "SDL_APP_ID"
/**
* A variable setting the application name.
*
* This hint lets you specify the application name sent to the OS when
* required. For example, this will often appear in volume control applets for
* audio streams, and in lists of applications which are inhibiting the
* screensaver. You should use a string that describes your program ("My Game
* 2: The Revenge")
*
* This will override SDL_PROP_APP_METADATA_NAME_STRING, if set by the application.
*
* This hint should be set before SDL is initialized.
*
* \since This hint is available since SDL 3.0.0.
*/
#define SDL_HINT_APP_NAME "SDL_APP_NAME"
/**
* A variable controlling whether controllers used with the Apple TV generate
* UI events.

View File

@ -246,8 +246,7 @@ extern SDL_DECLSPEC int SDLCALL SDL_SetAppMetadata(const char *appname, const ch
* These are the supported properties:
*
* - `SDL_PROP_APP_METADATA_NAME_STRING`: The human-readable name of the
* application, like "My Game 2: Bad Guy's Revenge!". This defaults to "SDL
* Application".
* application, like "My Game 2: Bad Guy's Revenge!". This will show up anywhere the OS shows the name of the application separately from window titles, such as volume control applets, etc. This defaults to "SDL Application".
* - SDL_PROP_APP_METADATA_VERSION_STRING`: The version of the app that is
* running; there are no rules on format, so "1.0.3beta2" and "April 22nd,
* 2024" and a git hash are all valid options. This has no default.
@ -255,7 +254,8 @@ extern SDL_DECLSPEC int SDLCALL SDL_SetAppMetadata(const char *appname, const ch
* identifies this app. This must be in reverse-domain format, like
* "com.example.mygame2". This string is used by desktop compositors to
* identify and group windows together, as well as match applications with
* associated desktop settings and icons. This has no default.
* associated desktop settings and icons. If you plan to package your application in a container such as Flatpak, the
* app ID should match the name of your Flatpak container as well. This has no default.
* - SDL_PROP_APP_METADATA_CREATOR_STRING`: The human-readable name of the
* creator/developer/maker of this app, like "MojoWorkshop, LLC"
* - SDL_PROP_APP_METADATA_COPYRIGHT_STRING`: The human-readable copyright

View File

@ -151,8 +151,15 @@ const char *SDL_GetAppMetadataProperty(const char *name)
return NULL;
}
const SDL_PropertiesID props = SDL_GetGlobalProperties();
const char *value = SDL_GetStringProperty(props, name, NULL);
const char *value = NULL;
if (SDL_strcmp(name, SDL_PROP_APP_METADATA_NAME_STRING) == 0) {
value = SDL_GetHint(SDL_HINT_APP_NAME);
} else if (SDL_strcmp(name, SDL_PROP_APP_METADATA_IDENTIFIER_STRING) == 0) {
value = SDL_GetHint(SDL_HINT_APP_ID);
}
if (!value || !*value) {
value = SDL_GetStringProperty(SDL_GetGlobalProperties(), name, NULL);
}
if (!value || !*value) {
if (SDL_strcmp(name, SDL_PROP_APP_METADATA_NAME_STRING) == 0) {
value = "SDL Application";