mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-09-30 23:18:29 +00:00
Add SDL_HINT_APP_NAME and DBUS inhibition hint
See SDL bug #4703. This implements two new hints: - SDL_APP_NAME - SDL_SCREENSAVER_INHIBIT_ACTIVITY_NAME The former is the successor to SDL_HINT_AUDIO_DEVICE_APP_NAME, and acts as a generic "application name" used both by audio drivers and DBUS screensaver inhibition. If SDL_AUDIO_DEVICE_APP_NAME is set, it will still take priority over SDL_APP_NAME. The second allows the "activity name" used by org.freedesktop.ScreenSavver's Inhibit method, which are often shown in the UI as the reason the screensaver (and/or suspend/other power-managment features) are disabled.
This commit is contained in:

committed by
Ryan C. Gordon

parent
9fae8f7088
commit
a1ffeda0ed
@@ -1043,7 +1043,10 @@ PIPEWIRE_OpenDevice(_THIS, void *handle, const char *devname, int iscapture)
|
||||
/* Get the hints for the application name, stream name and role */
|
||||
app_name = SDL_GetHint(SDL_HINT_AUDIO_DEVICE_APP_NAME);
|
||||
if (!app_name || *app_name == '\0') {
|
||||
app_name = "SDL Application";
|
||||
app_name = SDL_GetHint(SDL_HINT_APP_NAME);
|
||||
if (!app_name || *app_name == '\0') {
|
||||
app_name = "SDL Application";
|
||||
}
|
||||
}
|
||||
|
||||
stream_name = SDL_GetHint(SDL_HINT_AUDIO_DEVICE_STREAM_NAME);
|
||||
|
@@ -246,7 +246,13 @@ static const char *
|
||||
getAppName(void)
|
||||
{
|
||||
const char *retval = SDL_GetHint(SDL_HINT_AUDIO_DEVICE_APP_NAME);
|
||||
if (!retval || !*retval) {
|
||||
if (retval && *retval) {
|
||||
return retval;
|
||||
}
|
||||
retval = SDL_GetHint(SDL_HINT_APP_NAME);
|
||||
if (retval && *retval) {
|
||||
return retval;
|
||||
} else {
|
||||
const char *verstr = PULSEAUDIO_pa_get_library_version();
|
||||
retval = "SDL Application"; /* the "oh well" default. */
|
||||
if (verstr != NULL) {
|
||||
|
@@ -19,6 +19,7 @@
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
#include "../../SDL_internal.h"
|
||||
#include "SDL_hints.h"
|
||||
#include "SDL_dbus.h"
|
||||
#include "SDL_atomic.h"
|
||||
|
||||
@@ -365,8 +366,15 @@ SDL_DBus_ScreensaverInhibit(SDL_bool inhibit)
|
||||
const char *interface = "org.freedesktop.ScreenSaver";
|
||||
|
||||
if (inhibit) {
|
||||
const char *app = "My SDL application";
|
||||
const char *reason = "Playing a game";
|
||||
const char *app = SDL_GetHint(SDL_HINT_APP_NAME);
|
||||
const char *reason = SDL_GetHint(SDL_HINT_SCREENSAVER_INHIBIT_ACTIVITY_NAME);
|
||||
if (!app || !app[0]) {
|
||||
app = "My SDL application";
|
||||
}
|
||||
if (!reason || !reason[0]) {
|
||||
reason = "Playing a game";
|
||||
}
|
||||
|
||||
if (!SDL_DBus_CallMethod(node, path, interface, "Inhibit",
|
||||
DBUS_TYPE_STRING, &app, DBUS_TYPE_STRING, &reason, DBUS_TYPE_INVALID,
|
||||
DBUS_TYPE_UINT32, &screensaver_cookie, DBUS_TYPE_INVALID)) {
|
||||
|
Reference in New Issue
Block a user