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.
This commit is contained in:
Jente Hidskes
2017-05-15 09:48:07 +02:00
committed by Peter Hutterer
parent 178b08cd0a
commit 2722e008e0
2 changed files with 10 additions and 0 deletions

View File

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

View File

@@ -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,
};