Add utility function to detect if SDL is inside a sandbox

Refactor the previous sandbox check in a standalone function that also
includes Snap support.

Signed-off-by: Ludovico de Nittis <ludovico.denittis@collabora.com>
This commit is contained in:
Ludovico de Nittis 2022-08-26 12:28:33 +02:00 committed by Sam Lantinga
parent a3ce700ded
commit e8cb4da71f
8 changed files with 100 additions and 16 deletions

View file

@ -77,6 +77,7 @@
#include "../../core/linux/SDL_evdev_capabilities.h"
#include "../../core/linux/SDL_udev.h"
#include "../../core/linux/SDL_sandbox.h"
#if 0
#define DEBUG_INPUT_EVENTS 1
@ -756,12 +757,7 @@ LINUX_JoystickInit(void)
SDL_LogDebug(SDL_LOG_CATEGORY_INPUT,
"udev disabled by SDL_JOYSTICK_DISABLE_UDEV");
enumeration_method = ENUMERATION_FALLBACK;
} else if (access("/.flatpak-info", F_OK) == 0
|| access("/run/host/container-manager", F_OK) == 0) {
/* Explicitly check `/.flatpak-info` because, for old versions of
* Flatpak, this was the only available way to tell if we were in
* a Flatpak container. */
} else if (SDL_DetectSandbox() != SDL_SANDBOX_NONE) {
SDL_LogDebug(SDL_LOG_CATEGORY_INPUT,
"Container detected, disabling udev integration");
enumeration_method = ENUMERATION_FALLBACK;