resolution: add signal for active resolution changes

This implements a signal that is fired whenever the active resolution
changes. For now the signal is only fired when the resolution changes
through the setter, ratbagd_resolution_set_resolution, as profile changes may
not always be hooked up in the hardware.

Reference #8.
This commit is contained in:
Jente Hidskes
2017-05-15 10:07:01 +02:00
committed by Peter Hutterer
parent 2722e008e0
commit b1feabaf64
2 changed files with 11 additions and 0 deletions

View File

@@ -66,6 +66,8 @@ The **org.freedesktop.ratbag1.Resolution** interface provides:
- Methods:
- SetResolution(uint, uint) -> x/y resolution to assign
- SetReportRate(uint) -> uint for the report rate to assign
- Signals:
- ActiveResolutionChanged -> active resolution changed, carries index of the currently active resolution
The **org.freedesktop.ratbag1.Button** interface provides:
- Properties:

View File

@@ -86,6 +86,14 @@ static int ratbagd_resolution_set_resolution(sd_bus_message *m,
resolution->xres = xres;
resolution->yres = yres;
}
(void) sd_bus_emit_signal(sd_bus_message_get_bus(m),
"/org/freedesktop/ratbag1",
"/org.freedesktop.ratbag1.Resolution",
"ActiveResolutionChanged",
"u",
resolution->index);
return sd_bus_reply_method_return(m, "u", r);
}
@@ -133,6 +141,7 @@ const sd_bus_vtable ratbagd_resolution_vtable[] = {
SD_BUS_PROPERTY("ReportRate", "u", NULL, offsetof(struct ratbagd_resolution, rate), SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),
SD_BUS_METHOD("SetReportRate", "u", "u", ratbagd_resolution_set_report_rate, SD_BUS_VTABLE_UNPRIVILEGED),
SD_BUS_METHOD("SetResolution", "uu", "u", ratbagd_resolution_set_resolution, SD_BUS_VTABLE_UNPRIVILEGED),
SD_BUS_SIGNAL("ActiveResolutionChanged", "u", 0),
SD_BUS_VTABLE_END,
};