From 2722e008e040491e8fef09ab9444ec70160b8b36 Mon Sep 17 00:00:00 2001 From: Jente Hidskes Date: Mon, 15 May 2017 09:48:07 +0200 Subject: [PATCH] profile: add signal for active profile changes This implements a signal that is fired whenever the active profile changes. For now the signal is only fired when the profile changes through the setter, ratbagd_profile_set_active, as profile changes may not always be hooked up in the hardware. Fixes #7. --- README.md | 2 ++ src/ratbagd-profile.c | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/README.md b/README.md index 52f8f139..4b6fba78 100644 --- a/README.md +++ b/README.md @@ -53,6 +53,8 @@ The **org.freedesktop.ratbag1.Profile** interface provides: - Methods: - SetActive(void) -> set this profile to be the active profile - GetResolutionByIndex(uint) -> returns the object path for the given index +- Signals: + - ActiveProfileChanged -> active profile changed, carries index of the currently active profile The **org.freedesktop.ratbag1.Resolution** interface provides: - Properties: diff --git a/src/ratbagd-profile.c b/src/ratbagd-profile.c index b945afb5..e36e94b9 100644 --- a/src/ratbagd-profile.c +++ b/src/ratbagd-profile.c @@ -245,6 +245,13 @@ static int ratbagd_profile_set_active(sd_bus_message *m, if (r < 0) return r; + (void) sd_bus_emit_signal(sd_bus_message_get_bus(m), + "/org/freedesktop/ratbag1", + "/org.freedesktop.ratbag1.Profile", + "ActiveProfileChanged", + "u", + profile->index); + return sd_bus_reply_method_return(m, "u", ratbag_profile_set_active(profile->lib_profile)); } @@ -279,6 +286,7 @@ const sd_bus_vtable ratbagd_profile_vtable[] = { SD_BUS_PROPERTY("DefaultResolution", "u", ratbagd_profile_get_default_resolution, 0, 0), SD_BUS_METHOD("SetActive", "", "u", ratbagd_profile_set_active, SD_BUS_VTABLE_UNPRIVILEGED), SD_BUS_METHOD("GetResolutionByIndex", "u", "o", ratbagd_profile_get_resolution_by_index, SD_BUS_VTABLE_UNPRIVILEGED), + SD_BUS_SIGNAL("ActiveProfileChanged", "u", 0), SD_BUS_VTABLE_END, };