From c83b3cc51411237aa2071de5303ae5719d926032 Mon Sep 17 00:00:00 2001 From: columbarius Date: Mon, 22 Aug 2022 23:15:02 +0200 Subject: [PATCH] screenshot: Announce version property --- include/screenshot_common.h | 6 ++++++ include/xdpw.h | 2 ++ src/core/main.c | 8 +++++++- src/screenshot/screenshot.c | 5 ++++- 4 files changed, 19 insertions(+), 2 deletions(-) create mode 100644 include/screenshot_common.h diff --git a/include/screenshot_common.h b/include/screenshot_common.h new file mode 100644 index 0000000..e02863a --- /dev/null +++ b/include/screenshot_common.h @@ -0,0 +1,6 @@ +#ifndef SCREENSHOT_COMMON_H +#define SCREENSHOT_COMMON_H + +#define XDP_SHOT_PROTO_VER 2 + +#endif diff --git a/include/xdpw.h b/include/xdpw.h index 105877d..5ae4167 100644 --- a/include/xdpw.h +++ b/include/xdpw.h @@ -11,6 +11,7 @@ #endif #include "screencast_common.h" +#include "screenshot_common.h" #include "config.h" struct xdpw_state { @@ -22,6 +23,7 @@ struct xdpw_state { uint32_t screencast_source_types; // bitfield of enum source_types uint32_t screencast_cursor_modes; // bitfield of enum cursor_modes uint32_t screencast_version; + uint32_t screenshot_version; struct xdpw_config *config; int timer_poll_fd; struct wl_list timers; diff --git a/src/core/main.c b/src/core/main.c index 7746ad8..935a3d7 100644 --- a/src/core/main.c +++ b/src/core/main.c @@ -119,12 +119,18 @@ int main(int argc, char *argv[]) { .screencast_source_types = MONITOR, .screencast_cursor_modes = HIDDEN | EMBEDDED, .screencast_version = XDP_CAST_PROTO_VER, + .screenshot_version = XDP_SHOT_PROTO_VER, .config = &config, }; wl_list_init(&state.xdpw_sessions); - xdpw_screenshot_init(&state); + ret = xdpw_screenshot_init(&state); + if (ret < 0) { + logprint(ERROR, "xdpw: failed to initialize screenshot"); + goto error; + } + ret = xdpw_screencast_init(&state); if (ret < 0) { logprint(ERROR, "xdpw: failed to initialize screencast"); diff --git a/src/screenshot/screenshot.c b/src/screenshot/screenshot.c index 9df0ea7..48c4c00 100644 --- a/src/screenshot/screenshot.c +++ b/src/screenshot/screenshot.c @@ -286,6 +286,9 @@ static const sd_bus_vtable screenshot_vtable[] = { SD_BUS_VTABLE_START(0), SD_BUS_METHOD("Screenshot", "ossa{sv}", "ua{sv}", method_screenshot, SD_BUS_VTABLE_UNPRIVILEGED), SD_BUS_METHOD("PickColor", "ossa{sv}", "ua{sv}", method_pick_color, SD_BUS_VTABLE_UNPRIVILEGED), + SD_BUS_PROPERTY("version", "u", NULL, + offsetof(struct xdpw_state, screenshot_version), + SD_BUS_VTABLE_PROPERTY_CONST), SD_BUS_VTABLE_END }; @@ -293,5 +296,5 @@ int xdpw_screenshot_init(struct xdpw_state *state) { // TODO: cleanup sd_bus_slot *slot = NULL; return sd_bus_add_object_vtable(state->bus, &slot, object_path, interface_name, - screenshot_vtable, NULL); + screenshot_vtable, state); }