Skip to content

Conversation

@gicmo
Copy link
Contributor

@gicmo gicmo commented Jul 2, 2019

For the Shell extension (or a little separate tool) as well as future integration with GNOME Usage I wanted to get the list of currently registered games from gamemoded. For this I added to the com.feralinteractive.GameMode interface:

methods:
  ListGames: Array of Tuples (ProcessId, ObjectPath)

signals:
  GameRegistered: ProcessId, ObjectPath
  GameUnregistered: ProcessId, ObjectPath

As well as a new com.feralinteractive.GameMode.Game interface:

properties:
  ProcessId: int
  Executable: string

This should make it possible for a client to track all currently registered games (start listening to the signals, list the current active ones and track changes via the signals).

In order to expose the individual games, I opted for expose the GameModeClient struct (as an opaque struct with getters). To be able to do this I added reference counting to it, so it can outlive being reaped by the reaper. Since the object is de-facto immutable this should be sufficient.

gicmo added 7 commits July 2, 2019 17:45
First step to making GameModeClient useful outside of gamemode-
context.c.
This is so it can out-live its membership in the client list, e.g.
when it is passed outside of gamemode-context.c and the reaper
comes along and reaps a client in the background but we still are
using the struct outside.
So it can be used outside ouf gamemode-context.c.
Now that GameModeClient is reference counted, the counterpart to
game_mode_client_unref is also needed.
Add getters for all two properties of GameModeCLient: the process
id and the executable path.
Return an array of pid_t elements containing the process ids of
all registered clients. Memory ownership is transferred to the
client and must be freed.
Like game_mode_context_has_client, but will add a reference to
the client, if a match was found.
@gicmo gicmo force-pushed the client_objects branch from 2907666 to 54ff404 Compare July 2, 2019 17:06
@gicmo
Copy link
Contributor Author

gicmo commented Jul 3, 2019

Just realized I have some inconsistencies between pids on the bus as unsigned u vs pids as signed i. Will fix.

@gicmo gicmo force-pushed the client_objects branch from 54ff404 to 2bd5ce8 Compare July 4, 2019 12:56
gicmo added 2 commits July 4, 2019 16:04
For each registered game, export an object on the bus under the
path "/com/feralinteractive/GameMode/Games/<pid>" with an dbus
interface of ""com.feralinteractive.GameMode.Game". The interface
currently provides to properties, ProcessId and Executable.
Additionally add the ListGames method and the GameRegistered,
GameUnregistered signals to the com.feralinteractive.GameMode
interface.
Every time a game is (un)-registered and we emit the corresponding
signal, also emit the properties change signal for ClientCount.
@gicmo gicmo force-pushed the client_objects branch from 2bd5ce8 to dab881b Compare July 4, 2019 14:04
@aejsmith aejsmith merged commit dab881b into FeralInteractive:master Jul 6, 2019
@aejsmith
Copy link
Contributor

aejsmith commented Jul 6, 2019

All looks good to me, merged. Thanks!

I did one follow up change (12cf304) just to reduce some duplication of the game path prefix string.

@gicmo gicmo deleted the client_objects branch July 8, 2019 09:43
@gicmo
Copy link
Contributor Author

gicmo commented Jul 8, 2019

Thanks! The follow-up change makes total sense. Btw, any plans for a 1.4 release? ;)

@aejsmith
Copy link
Contributor

Don't have any specific plans for a new release currently, but since there's a reasonable amount of new stuff I'll see if we can do one soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants