From d1df848d94a6f0daa9dab044a9aa83920f2300a7 Mon Sep 17 00:00:00 2001 From: Philipp Zabel Date: Thu, 5 Oct 2023 11:39:23 +0200 Subject: [PATCH] compositor, backend-vnc: Allow to disable output resizing In some use cases the VNC client should not be allowed to resize the VNC output. Add a boolean option "resizeable" in the VNC [output] section to control this. Signed-off-by: Philipp Zabel --- compositor/main.c | 5 ++++- include/libweston/backend-vnc.h | 4 ++-- libweston/backend-vnc/vnc.c | 12 ++++++++++-- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/compositor/main.c b/compositor/main.c index af6ec272..80c0ade9 100644 --- a/compositor/main.c +++ b/compositor/main.c @@ -3444,6 +3444,7 @@ vnc_backend_output_configure(struct weston_output *output) struct weston_config_section *section; int width; int height; + bool resizeable; assert(parsed_options); @@ -3457,10 +3458,12 @@ vnc_backend_output_configure(struct weston_output *output) parse_simple_mode(output, section, &width, &height, &defaults, compositor->parsed_options); + weston_config_section_get_bool(section, "resizeable", &resizeable, true); + weston_output_set_scale(output, 1); weston_output_set_transform(output, WL_OUTPUT_TRANSFORM_NORMAL); - if (api->output_set_size(output, width, height) < 0) { + if (api->output_set_size(output, width, height, resizeable) < 0) { weston_log("Cannot configure output \"%s\" using weston_vnc_output_api.\n", output->name); return -1; diff --git a/include/libweston/backend-vnc.h b/include/libweston/backend-vnc.h index c8c29984..13f61dde 100644 --- a/include/libweston/backend-vnc.h +++ b/include/libweston/backend-vnc.h @@ -33,7 +33,7 @@ extern "C" { #include #include -#define WESTON_VNC_OUTPUT_API_NAME "weston_vnc_output_api_v1" +#define WESTON_VNC_OUTPUT_API_NAME "weston_vnc_output_api_v2" #define VNC_DEFAULT_FREQ 60 struct weston_vnc_output_api { @@ -42,7 +42,7 @@ struct weston_vnc_output_api { * Returns 0 on success, -1 on failure. */ int (*output_set_size)(struct weston_output *output, - int width, int height); + int width, int height, bool resizeable); }; static inline const struct weston_vnc_output_api * diff --git a/libweston/backend-vnc/vnc.c b/libweston/backend-vnc/vnc.c index c391ea69..b3869eb0 100644 --- a/libweston/backend-vnc/vnc.c +++ b/libweston/backend-vnc/vnc.c @@ -92,6 +92,8 @@ struct vnc_output { struct nvnc_fb_pool *fb_pool; struct wl_list peers; + + bool resizeable; }; struct vnc_peer { @@ -400,13 +402,16 @@ vnc_handle_desktop_layout_event(struct nvnc_client *client, vnc_log_desktop_layout(peer->backend, layout); + if (!output->resizeable) + return false; + new_mode.width = width; new_mode.height = height; new_mode.refresh = peer->backend->vnc_monitor_refresh_rate; weston_output_mode_set_native(&output->base, &new_mode, 1); - return false; + return true; } static void @@ -1140,7 +1145,8 @@ vnc_switch_mode(struct weston_output *base, struct weston_mode *target_mode) } static int -vnc_output_set_size(struct weston_output *base, int width, int height) +vnc_output_set_size(struct weston_output *base, int width, int height, + bool resizeable) { struct vnc_output *output = to_vnc_output(base); struct vnc_backend *backend = output->backend; @@ -1164,6 +1170,8 @@ vnc_output_set_size(struct weston_output *base, int width, int height) output->base.set_dpms = NULL; output->base.switch_mode = vnc_switch_mode; + output->resizeable = resizeable; + return 0; }