Game Mode🔗
org.freedesktop.portal.GameMode
Portal for accessing GameMode
Interface for accessing GameMode from within the sandbox. It
is analogous to the com.feralinteractive.GameMode interface
and will proxy requests there, but with additional permission
checking and PID mapping. The latter is necessary in the case
that the sandbox has PID namespace isolation enabled. See the man
page for pid_namespaces(7) for more details, but briefly, it
means that the sandbox has its own process ID namespace which
is separated from the one on the host. Thus there will be two
separate process IDs (PID) within two different namespaces
that both identify same process. One ID from the PID namespace
inside the sandbox and one ID from the host PID namespace.
Since org.freedesktop.portal.GameMode expects pids from the host
PID namespace but programs inside the sandbox can only know PID
from the sandbox namespace, process IDs need to be translated from
the portal to the host namespace. The portal will do that transparently
for all calls where this is necessary.
Note: org.freedesktop.portal.GameMode will monitor active clients, i.e. games and other programs that have successfully called RegisterGame(). In the event that a client terminates without a call to the UnregisterGame() method, GameMode will automatically un-register the client. This might happen with a (small) delay.
This documentation describes version 4 of this interface.
Properties🔗
Active🔗
Active readable b
Whether any pid on the system has enabled Game Mode.
version🔗
version readable u
Methods🔗
QueryStatus()🔗
QueryStatus (
IN pid i,
OUT result i
)
Query the GameMode status for a process.
If the caller is running inside a sandbox with PID namespace
isolation, the pid will be translated to the respective host PID.
See the general introduction for details.
The result will be one of:
0 if GameMode is inactive
1 if GameMode is active
2 if GameMode is active and
pidis registered-1 if the query failed inside GameMode
- pid
Process ID to query the GameMode status of
- result
The GameMode status for
pid
RegisterGame()🔗
RegisterGame (
IN pid i,
OUT result i
)
Register a game with GameMode and thus request GameMode to be activated.
If the caller is running inside a sandbox with PID namespace
isolation, the pid will be translated to the respective host PID.
See the general introduction for details.
If the GameMode has already been requested for pid before,
this call will fail, i.e. result will be -1.
The result will be one of:
0 if the game with
pidwas successfully registered-1 if the request was rejected by GameMode
- pid
Process ID of the game to register
- result
Status of the request: 0 for success, -1 indicates an error
UnregisterGame()🔗
UnregisterGame (
IN pid i,
OUT result i
)
Un-register a game from GameMode.
If the call is successful and there are no other games or clients registered, GameMode will be deactivated.
If the caller is running inside a sandbox with PID namespace
isolation, the pid will be translated to the respective host PID.
The result will be one of:
0 if the game with
pidwas successfully un-registered-1 if the request was rejected by GameMode
- pid
Process ID of the game to un-register
- result
Status of the request: 0 for success, -1 indicates an error
QueryStatusByPid()🔗
QueryStatusByPid (
IN target i,
IN requester i,
OUT result i
)
Query the GameMode status for a process.
Like QueryStatus() but requester
acting on behalf of target.
- target
Process ID to query the GameMode status of
- requester
Process ID of the process requesting the information
- result
The GameMode status for
target
RegisterGameByPid()🔗
RegisterGameByPid (
IN target i,
IN requester i,
OUT result i
)
Register a game with GameMode.
Like RegisterGame() but requester
acting on behalf of target.
- target
Process ID of the game to register
- requester
Process ID of the process requesting the registration
- result
Status of the request: 0 for success, -1 indicates an error
UnregisterGameByPid()🔗
UnregisterGameByPid (
IN target i,
IN requester i,
OUT result i
)
Un-register a game with GameMode.
Like UnregisterGame() but requester
acting on behalf of target.
- target
Process ID of the game to un-register
- requester
Process ID of the process requesting the un-registration
- result
Status of the request: 0 for success, -1 indicates an error
QueryStatusByPIDFd()🔗
QueryStatusByPIDFd (
IN target h,
IN requester h,
OUT result i
)
Query the GameMode status for a process.
Like QueryStatusByPid() but requester
and target are pidfds representing the processes.
- target
Pidfd to query the GameMode status of
- requester
Pidfd of the process requesting the information
- result
The GameMode status for
target
RegisterGameByPIDFd()🔗
RegisterGameByPIDFd (
IN target h,
IN requester h,
OUT result i
)
Register a game with GameMode.
Like RegisterGameByPid() but requester
and target are pidfds representing the processes.
- target
Pidfd of the game to register
- requester
Pidfd of the process requesting the registration
- result
Status of the request: 0 for success, -1 indicates an error
UnregisterGameByPIDFd()🔗
UnregisterGameByPIDFd (
IN target h,
IN requester h,
OUT result i
)
Un-register a game with GameMode.
Like UnregisterGameByPid() but requester
and target are pidfds representing the processes.
- target
Pidfd of the game to un-register
- requester
Pidfd of the process requesting the un-registration
- result
Status of the request: 0 for success, -1 indicates an error