Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose registered games on the bus #155

merged 9 commits into from Jul 6, 2019


Copy link

@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:

  ListGames: Array of Tuples (ProcessId, ObjectPath)

  GameRegistered: ProcessId, ObjectPath
  GameUnregistered: ProcessId, ObjectPath

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

  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 Jul 2, 2019
First step to making GameModeClient useful outside of gamemode-
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.
Copy link
Contributor Author

@gicmo 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 added 2 commits Jul 4, 2019
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
Every time a game is (un)-registered and we emit the corresponding
signal, also emit the properties change signal for ClientCount.
@aejsmith aejsmith merged commit dab881b into FeralInteractive:master Jul 6, 2019
1 check passed
Copy link

@aejsmith 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 Jul 8, 2019
Copy link
Contributor Author

@gicmo gicmo commented Jul 8, 2019

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

Copy link

@aejsmith aejsmith commented Jul 13, 2019

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
None yet
None yet

Successfully merging this pull request may close these issues.

None yet

2 participants