.. _org.freedesktop.portal.GameMode:

===============================
 Game Mode
===============================

-----------
Description
-----------

.. _org.freedesktop.portal.GameMode Description:

Portal for accessing GameMode

Interface for accessing GameMode from within the sandbox. It
is analogous to the com.feralinteractive.GameMode interface
and will proxy request there, but with additional permission
checking and pid mapping. The latter is necessary in the case
that 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
`org.freedesktop.portal.GameMode.RegisterGame`_.
In the event that a client terminates without a call to the
`org.freedesktop.portal.GameMode.UnregisterGame`_ method, GameMode will
automatically un-register the client. This might happen with a (small)
delay.

This documentation describes version 4 of this interface.



.. _org.freedesktop.portal.GameMode Properties:

----------
Properties
----------

.. _org.freedesktop.portal.GameMode:Active:

org.freedesktop.portal.GameMode:Active
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

::

    Active readable b


Whether any pid on the system has enabled Game Mode.




.. _org.freedesktop.portal.GameMode:version:

org.freedesktop.portal.GameMode:version
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

::

    version readable u




.. _org.freedesktop.portal.GameMode Methods:

-------
Methods
-------

.. _org.freedesktop.portal.GameMode.QueryStatus:

org.freedesktop.portal.GameMode.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 ``pid`` is registered
- `-1` if the query failed inside GameMode



pid
  Process id to query the GameMode status of

result
  The GameMode status for ``pid``



.. _org.freedesktop.portal.GameMode.RegisterGame:

org.freedesktop.portal.GameMode.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 ``pid`` was 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



.. _org.freedesktop.portal.GameMode.UnregisterGame:

org.freedesktop.portal.GameMode.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 ``pid`` was 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



.. _org.freedesktop.portal.GameMode.QueryStatusByPid:

org.freedesktop.portal.GameMode.QueryStatusByPid
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

::

    QueryStatusByPid (
      IN target i,
      IN requester i,
      OUT result i
    )



Query the GameMode status for a process.

Like `org.freedesktop.portal.GameMode.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``



.. _org.freedesktop.portal.GameMode.RegisterGameByPid:

org.freedesktop.portal.GameMode.RegisterGameByPid
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

::

    RegisterGameByPid (
      IN target i,
      IN requester i,
      OUT result i
    )



Register a game with GameMode.

Like `org.freedesktop.portal.GameMode.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



.. _org.freedesktop.portal.GameMode.UnregisterGameByPid:

org.freedesktop.portal.GameMode.UnregisterGameByPid
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

::

    UnregisterGameByPid (
      IN target i,
      IN requester i,
      OUT result i
    )



Un-register a game with GameMode.

Like `org.freedesktop.portal.GameMode.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



.. _org.freedesktop.portal.GameMode.QueryStatusByPIDFd:

org.freedesktop.portal.GameMode.QueryStatusByPIDFd
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

::

    QueryStatusByPIDFd (
      IN target h,
      IN requester h,
      OUT result i
    )



Query the GameMode status for a process.

Like `org.freedesktop.portal.GameMode.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``



.. _org.freedesktop.portal.GameMode.RegisterGameByPIDFd:

org.freedesktop.portal.GameMode.RegisterGameByPIDFd
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

::

    RegisterGameByPIDFd (
      IN target h,
      IN requester h,
      OUT result i
    )



Register a game with GameMode.

Like `org.freedesktop.portal.GameMode.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



.. _org.freedesktop.portal.GameMode.UnregisterGameByPIDFd:

org.freedesktop.portal.GameMode.UnregisterGameByPIDFd
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

::

    UnregisterGameByPIDFd (
      IN target h,
      IN requester h,
      OUT result i
    )



Un-register a game with GameMode.

Like `org.freedesktop.portal.GameMode.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


