diff options
author | Stefan Agner <stefan@agner.ch> | 2019-09-22 19:40:04 +0200 |
---|---|---|
committer | Philipp Zabel <philipp.zabel@gmail.com> | 2022-10-18 07:31:42 +0200 |
commit | 12f766531002d0086c8cd2ea62a1605db934304a (patch) | |
tree | 3a5adcd9f8a3c8672a1035120acd806b131c6b6a /compositor | |
parent | 9e5922744db905278b6d1c573ca766c302b2401e (diff) |
backend-vnc: add VNC support using Neat VNC library
This adds basic VNC protocol support using the Neat VNC library
(https://github.com/any1/neatvnc). Neat VNC depends on the AML main
loop library. The backend makes use of AML's integrated epoll backend
and connects AML via file descriptor with the Wayland event loop.
This implementation does not support authentication and hardcodes the
pixel format currently.
Co-authored-by: Philipp Zabel <p.zabel@pengutronix.de>
Co-authored-by: Rouven Czerwinski <r.czerwinski@pengutronix.de>
Signed-off-by: Stefan Agner <stefan@agner.ch>
[r.czerwinski@pengutronix.de:
- use new (as of 0.5.0) Neat VNC buffer API, with a buffer pool]
Signed-off-by: Rouven Czerwinski <r.czerwinski@pengutronix.de>
[p.zabel@pengutronix.de:
- transform repaint damage to output coordinates
- transform pointer coordinates into global space
- check that outputs and heads are in fact ours, see aab722bb1785..060ef82d9360
- track damage across multiple frame buffers
- choose pixel format by drm_fourcc, see 8b6c3fe0ad4b
- enable ctrl and alt modifiers
- fix frame timing to achieve a constant repaint rate
- pass initial size explicitly, see f4559b076008
- use resize_output with pixman-renderer, see 55d08f9634e8..84b5d0eb4bee
- allow configuring the refresh rate]
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Diffstat (limited to 'compositor')
-rw-r--r-- | compositor/main.c | 99 |
1 files changed, 99 insertions, 0 deletions
diff --git a/compositor/main.c b/compositor/main.c index 7dcfa7ab..5689458b 100644 --- a/compositor/main.c +++ b/compositor/main.c @@ -61,6 +61,7 @@ #include <libweston/backend-drm.h> #include <libweston/backend-headless.h> #include <libweston/backend-rdp.h> +#include <libweston/backend-vnc.h> #include <libweston/backend-x11.h> #include <libweston/backend-wayland.h> #include <libweston/windowed-output-api.h> @@ -653,6 +654,9 @@ usage(int error_code) #if defined(BUILD_RDP_COMPOSITOR) "\t\t\t\trdp-backend.so\n" #endif +#if defined(BUILD_VNC_COMPOSITOR) + "\t\t\t\tvnc-backend.so\n" +#endif #if defined(BUILD_WAYLAND_COMPOSITOR) "\t\t\t\twayland-backend.so\n" #endif @@ -719,6 +723,15 @@ usage(int error_code) "\n"); #endif +#if defined(BUILD_VNC_COMPOSITOR) + fprintf(out, + "Options for vnc-backend.so:\n\n" + " --width=WIDTH\t\tWidth of desktop\n" + " --height=HEIGHT\tHeight of desktop\n" + " --port=PORT\t\tThe port to listen on\n" + "\n"); +#endif + #if defined(BUILD_WAYLAND_COMPOSITOR) fprintf(out, "Options for wayland-backend.so:\n\n" @@ -3099,6 +3112,90 @@ load_rdp_backend(struct weston_compositor *c, } static int +vnc_backend_output_configure(struct weston_output *output) +{ + struct wet_compositor *compositor = to_wet_compositor(output->compositor); + struct wet_output_config *parsed_options = compositor->parsed_options; + const struct weston_vnc_output_api *api = weston_vnc_output_get_api(output->compositor); + int width = 640; + int height = 480; + + assert(parsed_options); + + if (!api) { + weston_log("Cannot use weston_vnc_output_api.\n"); + return -1; + } + + if (parsed_options->width) + width = parsed_options->width; + + if (parsed_options->height) + height = parsed_options->height; + + weston_output_set_scale(output, 1); + weston_output_set_transform(output, WL_OUTPUT_TRANSFORM_NORMAL); + + if (api->output_set_size(output, width, height) < 0) { + weston_log("Cannot configure output \"%s\" using weston_vnc_output_api.\n", + output->name); + return -1; + } + weston_log("vnc_backend_output_configure.. Done\n"); + + return 0; +} + + +static void +weston_vnc_backend_config_init(struct weston_vnc_backend_config *config) +{ + config->base.struct_version = WESTON_VNC_BACKEND_CONFIG_VERSION; + config->base.struct_size = sizeof(struct weston_vnc_backend_config); + + config->bind_address = NULL; + config->port = 5900; + config->refresh_rate = VNC_DEFAULT_FREQ; +} + +static int +load_vnc_backend(struct weston_compositor *c, + int *argc, char *argv[], struct weston_config *wc) +{ + struct weston_vnc_backend_config config = {{ 0, }}; + struct weston_config_section *section; + int ret = 0; + + struct wet_output_config *parsed_options = wet_init_parsed_options(c); + if (!parsed_options) + return -1; + + weston_vnc_backend_config_init(&config); + + const struct weston_option vnc_options[] = { + { WESTON_OPTION_INTEGER, "width", 0, &parsed_options->width }, + { WESTON_OPTION_INTEGER, "height", 0, &parsed_options->height }, + { WESTON_OPTION_STRING, "address", 0, &config.bind_address }, + { WESTON_OPTION_INTEGER, "port", 0, &config.port }, + }; + + parse_options(vnc_options, ARRAY_LENGTH(vnc_options), argc, argv); + + wet_set_simple_head_configurator(c, vnc_backend_output_configure); + section = weston_config_get_section(wc, "vnc", NULL, NULL); + weston_config_section_get_int(section, "refresh-rate", + &config.refresh_rate, + VNC_DEFAULT_FREQ); + + ret = weston_compositor_load_backend(c, WESTON_BACKEND_VNC, + &config.base); + + free(config.bind_address); + + return ret; +} + +static int x11_backend_output_configure(struct weston_output *output) { struct wet_output_config defaults = { @@ -3343,6 +3440,8 @@ load_backend(struct weston_compositor *compositor, const char *backend, return load_headless_backend(compositor, argc, argv, config); else if (strstr(backend, "rdp-backend.so")) return load_rdp_backend(compositor, argc, argv, config); + else if (strstr(backend, "vnc-backend.so")) + return load_vnc_backend(compositor, argc, argv, config); else if (strstr(backend, "drm-backend.so")) return load_drm_backend(compositor, argc, argv, config); else if (strstr(backend, "x11-backend.so")) |