frontend: Use simple_heads_changes for head enablement

Similarly to all the other back-ends do the same for the RDP one.

With this change the remote output will be placed, similar to the
VNC/PipeWire on the right side from the native one, when both backends
are loaded.

But ultimately this patch is about having all backends share the same
code path.

Fixes: #820
Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
This commit is contained in:
Marius Vlad 2024-03-06 17:56:00 +02:00 committed by Marius Vlad
parent 060f010c35
commit e70d9d47fc
1 changed files with 41 additions and 70 deletions

View File

@ -3393,24 +3393,25 @@ weston_rdp_backend_config_init(struct weston_rdp_backend_config *config)
config->refresh_rate = RDP_DEFAULT_FREQ;
}
static void
rdp_handle_layout(struct weston_compositor *ec, struct wet_backend *wb)
static int
rdp_backend_output_configure(struct weston_output *output)
{
struct wet_compositor *wc = to_wet_compositor(ec);
struct wet_output_config *parsed_options = wc->parsed_options;
const struct weston_rdp_output_api *api = weston_rdp_output_get_api(ec);
struct wet_compositor *compositor = to_wet_compositor(output->compositor);
const struct weston_rdp_output_api *api =
weston_rdp_output_get_api(compositor->compositor);
struct wet_output_config *parsed_options = compositor->parsed_options;
struct weston_rdp_monitor config;
struct weston_head *head = NULL;
int width;
int height;
struct weston_head *head = NULL;
int scale = 1;
while ((head = wet_backend_iterate_heads(wc, wb, head))) {
struct weston_coord_global pos;
struct weston_output *output = head->output;
struct weston_mode new_mode = {};
assert(output);
head = weston_output_get_first_head(output);
if (!head) {
weston_log("RDP backend: Failed to get proper head for output %s\n", output->name);
return -1;
}
api->head_get_monitor(head, &config);
@ -3432,46 +3433,15 @@ rdp_handle_layout(struct weston_compositor *ec, struct wet_backend *wb)
new_mode.width = width;
new_mode.height = height;
api->output_set_mode(output, &new_mode);
weston_output_set_scale(output, scale);
weston_output_set_transform(output,
WL_OUTPUT_TRANSFORM_NORMAL);
pos.c = weston_coord(config.x, config.y);
weston_output_move(output, pos);
}
}
weston_output_set_transform(output, WL_OUTPUT_TRANSFORM_NORMAL);
static void
rdp_heads_changed(struct wl_listener *listener, void *arg)
{
struct weston_compositor *compositor = arg;
struct wet_compositor *wet = to_wet_compositor(compositor);
struct wet_backend *wb = container_of(listener, struct wet_backend,
heads_changed_listener);
struct weston_head *head = NULL;
weston_log("rdp_backend_output_configure.. Done\n");
while ((head = wet_backend_iterate_heads(wet, wb, head))) {
if (head->output)
continue;
struct weston_output *out;
out = weston_compositor_create_output(compositor,
head, head->name);
wet_head_tracker_create(wet, head);
weston_output_attach_head(out, head);
}
rdp_handle_layout(compositor, wb);
while ((head = wet_backend_iterate_heads(wet, wb, head))) {
if (!head->output->enabled)
weston_output_enable(head->output);
weston_head_reset_device_changed(head);
}
return 0;
}
static int
@ -3521,7 +3491,8 @@ load_rdp_backend(struct weston_compositor *c,
&config.server_key, config.server_key);
wb = wet_compositor_load_backend(c, WESTON_BACKEND_RDP, &config.base,
rdp_heads_changed, NULL);
simple_heads_changed,
rdp_backend_output_configure);
free(config.bind_address);
free(config.rdp_key);