weston: Port RDP backend to new output handling API
This is a complete port of the RDP backend that uses the recently added output handling API for output configuration. Output can be configured at runtime by passing the necessary configuration parameters, which can be filled in manually or obtained from the command line using previously added functionality. It is required that the scale and transform values are set using the previously added functionality. After everything has been set, output needs to be enabled manually using weston_output_enable(). v2: - Rename output_configure() to output_set_size() in plugin API and describe it. - Manually fetch parsed_options from wet_compositor. - Call rdp_output_disable() explicitly from rdp_output_destroy(). v3: - Disallow calling rdp_output_set_size more than once. - Manually assign a hardcoded name to an output as that's now mandatory. - Use weston_compositor_add_pending_output(). - Bump weston_rdp_backend_config version to 2. Reviewed-by: Quentin Glidic <sardemff7+git@sardemff7.net> Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk> Signed-off-by: Armin Krezović <krezovic.armin@gmail.com>
This commit is contained in:
committed by
Pekka Paalanen
parent
7fb17756fc
commit
8f1dca1369
+48
-4
@@ -1282,14 +1282,47 @@ load_headless_backend(struct weston_compositor *c,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
rdp_backend_output_configure(struct wl_listener *listener, void *data)
|
||||
{
|
||||
struct weston_output *output = data;
|
||||
struct wet_compositor *compositor = to_wet_compositor(output->compositor);
|
||||
struct wet_output_config *parsed_options = compositor->parsed_options;
|
||||
const struct weston_rdp_output_api *api = weston_rdp_output_get_api(output->compositor);
|
||||
int width = 640;
|
||||
int height = 480;
|
||||
|
||||
assert(parsed_options);
|
||||
|
||||
if (!api) {
|
||||
weston_log("Cannot use weston_rdp_output_api.\n");
|
||||
return;
|
||||
}
|
||||
|
||||
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_rdp_output_api.\n",
|
||||
output->name);
|
||||
return;
|
||||
}
|
||||
|
||||
weston_output_enable(output);
|
||||
}
|
||||
|
||||
static void
|
||||
weston_rdp_backend_config_init(struct weston_rdp_backend_config *config)
|
||||
{
|
||||
config->base.struct_version = WESTON_RDP_BACKEND_CONFIG_VERSION;
|
||||
config->base.struct_size = sizeof(struct weston_rdp_backend_config);
|
||||
|
||||
config->width = 640;
|
||||
config->height = 480;
|
||||
config->bind_address = NULL;
|
||||
config->port = 3389;
|
||||
config->rdp_key = NULL;
|
||||
@@ -1306,12 +1339,16 @@ load_rdp_backend(struct weston_compositor *c,
|
||||
struct weston_rdp_backend_config config = {{ 0, }};
|
||||
int ret = 0;
|
||||
|
||||
struct wet_output_config *parsed_options = wet_init_parsed_options(c);
|
||||
if (!parsed_options)
|
||||
return -1;
|
||||
|
||||
weston_rdp_backend_config_init(&config);
|
||||
|
||||
const struct weston_option rdp_options[] = {
|
||||
{ WESTON_OPTION_BOOLEAN, "env-socket", 0, &config.env_socket },
|
||||
{ WESTON_OPTION_INTEGER, "width", 0, &config.width },
|
||||
{ WESTON_OPTION_INTEGER, "height", 0, &config.height },
|
||||
{ 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 },
|
||||
{ WESTON_OPTION_BOOLEAN, "no-clients-resize", 0, &config.no_clients_resize },
|
||||
@@ -1325,10 +1362,17 @@ load_rdp_backend(struct weston_compositor *c,
|
||||
ret = weston_compositor_load_backend(c, WESTON_BACKEND_RDP,
|
||||
&config.base);
|
||||
|
||||
if (ret < 0)
|
||||
goto out;
|
||||
|
||||
wet_set_pending_output_handler(c, rdp_backend_output_configure);
|
||||
|
||||
out:
|
||||
free(config.bind_address);
|
||||
free(config.rdp_key);
|
||||
free(config.server_cert);
|
||||
free(config.server_key);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user