From f9827edfb6b1fcb67401e484d58ce660f554694d Mon Sep 17 00:00:00 2001 From: Christian Kellner Date: Tue, 2 Jul 2019 17:42:37 +0200 Subject: [PATCH] daemon: emit client count change automatically Every time a game is (un)-registered and we emit the corresponding signal, also emit the properties change signal for ClientCount. --- daemon/gamemode-context.c | 2 -- daemon/gamemode-dbus.c | 15 ++++++--------- daemon/gamemode.h | 1 - 3 files changed, 6 insertions(+), 12 deletions(-) diff --git a/daemon/gamemode-context.c b/daemon/gamemode-context.c index 1e840ce..6e23116 100644 --- a/daemon/gamemode-context.c +++ b/daemon/gamemode-context.c @@ -487,7 +487,6 @@ int game_mode_context_register(GameModeContext *self, pid_t client, pid_t reques pthread_rwlock_unlock(&self->rwlock); game_mode_client_registered(client); - game_mode_client_count_changed(); return 0; @@ -586,7 +585,6 @@ int game_mode_context_unregister(GameModeContext *self, pid_t client, pid_t requ /* Unlock now we're done applying optimisations */ pthread_rwlock_unlock(&self->rwlock); - game_mode_client_count_changed(); game_mode_client_unregistered(client); return 0; diff --git a/daemon/gamemode-dbus.c b/daemon/gamemode-dbus.c index 8c5fb69..c6ab8e0 100644 --- a/daemon/gamemode-dbus.c +++ b/daemon/gamemode-dbus.c @@ -203,15 +203,6 @@ static int property_get_client_count(sd_bus *local_bus, const char *path, const return sd_bus_message_append_basic(reply, 'i', &count); } -void game_mode_client_count_changed(void) -{ - (void)sd_bus_emit_properties_changed(bus, - "/com/feralinteractive/GameMode", - "com.feralinteractive.GameMode", - "ClientCount", - NULL); -} - /** * Handles the Refresh Config request */ @@ -293,6 +284,12 @@ static void game_mode_client_send_game_signal(pid_t pid, bool new_game) path); if (ret < 0) fprintf(stderr, "failed to emit signal: %s", strerror(-ret)); + + (void)sd_bus_emit_properties_changed(bus, + "/com/feralinteractive/GameMode", + "com.feralinteractive.GameMode", + "ClientCount", + NULL); } /* Emit GameRegistered signal */ diff --git a/daemon/gamemode.h b/daemon/gamemode.h index 4dffc93..27151fa 100644 --- a/daemon/gamemode.h +++ b/daemon/gamemode.h @@ -197,6 +197,5 @@ int game_mode_get_gpu(GameModeGPUInfo *info); */ void game_mode_context_loop(GameModeContext *context) __attribute__((noreturn)); int game_mode_inhibit_screensaver(bool inhibit); -void game_mode_client_count_changed(void); void game_mode_client_registered(pid_t); void game_mode_client_unregistered(pid_t);