From b1feabaf64265f1f3a027e7b966c4decd0c9d052 Mon Sep 17 00:00:00 2001 From: Jente Hidskes Date: Mon, 15 May 2017 10:07:01 +0200 Subject: [PATCH] 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. --- README.md | 2 ++ src/ratbagd-resolution.c | 9 +++++++++ 2 files changed, 11 insertions(+) diff --git a/README.md b/README.md index 4b6fba78..8a03a435 100644 --- a/README.md +++ b/README.md @@ -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: diff --git a/src/ratbagd-resolution.c b/src/ratbagd-resolution.c index 7af846c1..cc8b9c51 100644 --- a/src/ratbagd-resolution.c +++ b/src/ratbagd-resolution.c @@ -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, };