Attribute the contributions made by members of the community, but avoid
unweildy and inconsistent copyright notices at the top of each file.
Existing contributor copyright notices have been left as-is.
Rename the pkg-config entry for libgamemodeauto, to it make it more that this will link against a library, compared to what the `gamemode` pkg-config does. This also removes the manual addition of the libdl dependency, this is done by Meson automatically.
Signed-off-by: Stephan Lachnit <stephanlachnit@protonmail.com>
This makes it more clear that libgamemode and libgamemodeauto are indeed libraries. Also, the misleading name `libgamemode_dep` has been renamed to `gamemode_dep`, which now also includes the dependency on libdl. The misleading `libgamemode_includes` variable name has also been changed.
Signed-off-by: Stephan Lachnit <stephanlachnit@protonmail.com>
Try to make API requests using the new pidfd based APIs. If getting
the pidfds fails or if the remote (daemon) does not support the new
pidfd based D-Bus API, transparently fall back to the old API.
Switch the dbus implementation for the client from systemd to
libdbus. The main reason is that, in flatpaks systemd is not easily
available. No phenomenological change for users of the library,
hopefully.
When we detect that we are running inside a flatpak, talk to the
flatpak portal D-Bus service instead of the session daemon. This
is necessary because flatpak uses pid namespace isolation (see
man pid_namespaces(7)) and thus the pid needs to be translated
from the flatpak pid namespace to the host namespace. This
translation is happening inside the GameMode xdg-desktop-portal.
On each gamemode_request call a new connection to d-bus is opened
but the reference was never release thus leaking the connection
and associated memory.
Games built against a new gamemode_client.h will fail to work with older
GameMode installations without this change. There are no ABI changes right
now so just attempt to load the old unversioned path if loading the
versioned one fails.
In order to be safe for future ABI changes and to fulfill packaging
requirements for e.g. Fedora, provide libtool like versioning for
both libraries, i.e. libgamemode and libgamemodeauto.
To ease development, create a gamemode.pc and a gamemode-auto.pc
file, that other projects can use integrate with gamemode. The
former if they want to integrate at the source level and the latter
if the automatic integration is preferred.
This allows the client to query the daemon about the status of gamemode.
Returns the following:
0 if gamemode is inactive
1 if gamemode is active
2 if gamemode is active and this client is registered
-1 if the query failed
Passing -s to gamemoded will simply query and print the current status.
Allows for more comprehensive testing when using 'gamemoded -r' as well as more reactionary program behaviour
* Minor C cleanup
- some symbols can be made static:
1. set_gov_state
2. everything in gamemode_client.h
- daemonize() can also take a const char*, since the name is only
passed to printf() or syslog()
- prevent shadowing of variables
- use explicit (void) as parameter-list more consistently
- use some more const.
Move cast to more appropriate place and document that execv() behaves
as if args where of type const *char and we trust on that.
- example: Just use main(void), which is also an acceptable ISO-C decl
- example: Use stderr for errors
* Fix -Wold-style-declaration issue
The systemd bus headers aren't setting a POSIX compliance level so we
define the catch-all to ensure the build doesn't error out, as seen with
issue #3. This is due to the reliance of `siginfo_t`, which requires a
minimum POSIX level of `199309L` when using glibc.
Signed-off-by: Ikey Doherty <ikey@solus-project.com>