frontend: Disable client resize for RDP remote outputs

Similar to the VNC backend do the same for the RDP backed, as this would
allow to get a matching output, in dimensions, to the one we are
mirroring.

This also re-works a bit the no-clients-resize to be more inline with
VNC one.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
This commit is contained in:
Marius Vlad 2024-04-02 15:20:45 +03:00 committed by Derek Foreman
parent f43342cf78
commit 75280d2e40
4 changed files with 31 additions and 11 deletions

View File

@ -777,7 +777,7 @@ usage(int error_code)
" --external-listener-fd=FD\tUse socket as listener connection\n"
" --address=ADDR\tThe address to bind\n"
" --port=PORT\t\tThe port to listen on\n"
" --no-clients-resize\tThe RDP peers will be forced to the size of the desktop\n"
" --no-resizeable\tThe RDP peers will be forced to the size of the desktop\n"
" --rdp4-key=FILE\tThe file containing the key for RDP4 encryption\n"
" --rdp-tls-cert=FILE\tThe file containing the certificate for TLS encryption\n"
" --rdp-tls-key=FILE\tThe file containing the private key for TLS encryption\n"
@ -3660,7 +3660,7 @@ weston_rdp_backend_config_init(struct weston_rdp_backend_config *config)
config->server_key = NULL;
config->env_socket = 0;
config->external_listener_fd = -1;
config->no_clients_resize = 0;
config->resizeable = true;
config->force_no_compression = 0;
config->remotefx_codec = true;
config->refresh_rate = RDP_DEFAULT_FREQ;
@ -3711,6 +3711,11 @@ rdp_backend_output_configure(struct weston_output *output)
new_mode.width = width;
new_mode.height = height;
if (output->mirror_of) {
api->disable_output_resize(output);
weston_log("Use of mirror_of disables resizing for output %s\n", output->name);
}
api->output_set_mode(output, &new_mode);
wet_output_set_scale(output, section, scale, 0);
@ -3731,6 +3736,7 @@ load_rdp_backend(struct weston_compositor *c,
struct wet_backend *wb;
bool no_remotefx_codec = false;
struct wet_output_config *parsed_options = wet_init_parsed_options(c);
bool no_resizeable = false;
if (!parsed_options)
return -1;
@ -3744,7 +3750,7 @@ load_rdp_backend(struct weston_compositor *c,
{ 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 },
{ WESTON_OPTION_BOOLEAN, "no-resizeable", false, &no_resizeable },
{ WESTON_OPTION_STRING, "rdp4-key", 0, &config.rdp_key },
{ WESTON_OPTION_STRING, "rdp-tls-cert", 0, &config.server_cert },
{ WESTON_OPTION_STRING, "rdp-tls-key", 0, &config.server_key },
@ -3755,6 +3761,7 @@ load_rdp_backend(struct weston_compositor *c,
parse_options(rdp_options, ARRAY_LENGTH(rdp_options), argc, argv);
config.remotefx_codec = !no_remotefx_codec;
config.resizeable = !no_resizeable;
config.renderer = renderer;
section = weston_config_get_section(wc, "rdp", NULL, NULL);

View File

@ -53,6 +53,9 @@ struct weston_rdp_output_api {
/** Set mode for an output */
void (*output_set_mode)(struct weston_output *base,
struct weston_mode *mode);
/** disable output resize */
void (*disable_output_resize)(struct weston_output *output);
};
static inline const struct weston_rdp_output_api *
@ -81,7 +84,7 @@ struct weston_rdp_backend_config {
char *server_cert;
char *server_key;
int env_socket;
int no_clients_resize;
bool resizeable;
int force_no_compression;
bool remotefx_codec;
int external_listener_fd;

View File

@ -328,6 +328,15 @@ finish_frame_handler(void *data)
return 1;
}
static void
rdp_output_disable_resize(struct weston_output *base)
{
struct rdp_output *rdpOutput = container_of(base, struct rdp_output, base);
struct rdp_backend *b = rdpOutput->backend;
b->resizeable = false;
}
static void
rdp_output_set_mode(struct weston_output *base, struct weston_mode *mode)
{
@ -1091,7 +1100,7 @@ xf_peer_activate(freerdp_peer* client)
* We still need the xf_peer_adjust_monitor_layout() call to make sure
* we've set up scaling appropriately.
*/
if (b->no_clients_resize) {
if (!b->resizeable) {
struct weston_mode *mode = output->base.current_mode;
if (mode->width != (int)settings->DesktopWidth ||
@ -1620,7 +1629,7 @@ xf_peer_adjust_monitor_layout(freerdp_peer *client)
fallback = true;
}
if (b->no_clients_resize)
if (!b->resizeable)
fallback = true;
if (settings->MonitorCount > RDP_MAX_MONITOR) {
@ -1658,7 +1667,7 @@ xf_peer_adjust_monitor_layout(freerdp_peer *client)
monitors[0].attributes.deviceScaleFactor = settings->DeviceScaleFactor;
monitors[0].orig_screen = 0;
if (b->no_clients_resize) {
if (!b->resizeable) {
/* If we're not allowing clients to resize us, set these
* to 0 so the front end knows it needs to make something
* up.
@ -1726,7 +1735,7 @@ rdp_peer_init(freerdp_peer *client, struct rdp_backend *b)
client->PostConnect = xf_peer_post_connect;
client->Activate = xf_peer_activate;
if (!b->no_clients_resize) {
if (b->resizeable) {
settings->SupportMonitorLayoutPdu = TRUE;
client->AdjustMonitorsLayout = xf_peer_adjust_monitor_layout;
}
@ -1805,6 +1814,7 @@ rdp_incoming_peer(freerdp_listener *instance, freerdp_peer *client)
static const struct weston_rdp_output_api api = {
rdp_head_get_monitor,
rdp_output_set_mode,
rdp_output_disable_resize,
};
static const uint32_t rdp_formats[] = {
@ -1830,7 +1840,7 @@ rdp_backend_create(struct weston_compositor *compositor,
b->base.destroy = rdp_destroy;
b->base.create_output = rdp_output_create;
b->rdp_key = config->rdp_key ? strdup(config->rdp_key) : NULL;
b->no_clients_resize = config->no_clients_resize;
b->resizeable = config->resizeable;
b->force_no_compression = config->force_no_compression;
b->remotefx_codec = config->remotefx_codec;
b->audio_in_setup = config->audio_in_setup;
@ -2003,7 +2013,7 @@ config_init_to_defaults(struct weston_rdp_backend_config *config)
config->server_cert = NULL;
config->server_key = NULL;
config->env_socket = 0;
config->no_clients_resize = 0;
config->resizeable = true;
config->force_no_compression = 0;
config->remotefx_codec = true;
config->external_listener_fd = -1;

View File

@ -86,7 +86,7 @@ struct rdp_backend {
char *server_key;
char *rdp_key;
int tls_enabled;
int no_clients_resize;
int resizeable;
int force_no_compression;
bool remotefx_codec;
int external_listener_fd;