From 6a09cd2d20a6e6dfdb1efdbcbeb823ad99930a4d Mon Sep 17 00:00:00 2001 From: Olivier Fourdan Date: Mon, 27 Nov 2023 13:39:26 +0100 Subject: [PATCH] xwayland: Introduce output scale Add a scale factor to the Xwayland output and take the scale into account when computing the screen size. Signed-off-by: Olivier Fourdan Reviewed-By: Kenny Levinsen Acked-by: Peter Hutterer Part-of: --- hw/xwayland/xwayland-output.c | 12 +++++++++++- hw/xwayland/xwayland-output.h | 4 ++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/hw/xwayland/xwayland-output.c b/hw/xwayland/xwayland-output.c index 349af302b..23c9733d2 100644 --- a/hw/xwayland/xwayland-output.c +++ b/hw/xwayland/xwayland-output.c @@ -891,6 +891,7 @@ xwl_output_create(struct xwl_screen *xwl_screen, uint32_t id, xwl_output->server_output_id = id; wl_output_add_listener(xwl_output->output, &output_listener, xwl_output); + xwl_output->xscale = 1.0; xwl_output->xwl_screen = xwl_screen; @@ -1141,6 +1142,12 @@ mode_sort(const void *left, const void *right) return (*mode_b)->mode.width - (*mode_a)->mode.width; } +void +xwl_output_set_xscale(struct xwl_output *xwl_output, double xscale) +{ + xwl_output->xscale = xscale; +} + Bool xwl_randr_add_modes_fixed(struct xwl_output *xwl_output, int current_width, int current_height) @@ -1198,7 +1205,9 @@ xwl_output_set_mode_fixed(struct xwl_output *xwl_output, RRModePtr mode) xwl_output->mode_width = mode->mode.width; xwl_output->mode_height = mode->mode.height; - update_screen_size(xwl_screen, mode->mode.width, mode->mode.height); + update_screen_size(xwl_screen, + round((double) mode->mode.width * xwl_output->xscale), + round((double) mode->mode.height * xwl_output->xscale)); RRCrtcNotify(xwl_output->randr_crtc, mode, 0, 0, RR_Rotate_0, NULL, 1, &xwl_output->randr_output); @@ -1275,6 +1284,7 @@ xwl_screen_init_randr_fixed(struct xwl_screen *xwl_screen) xwl_output->xwl_screen = xwl_screen; xwl_screen->fixed_output = xwl_output; + xwl_output->xscale = 1.0; return TRUE; diff --git a/hw/xwayland/xwayland-output.h b/hw/xwayland/xwayland-output.h index 68889c59d..7923a7e1a 100644 --- a/hw/xwayland/xwayland-output.h +++ b/hw/xwayland/xwayland-output.h @@ -55,6 +55,7 @@ struct xwl_output { uint32_t server_output_id; int32_t x, y, width, height, refresh; int32_t mode_width, mode_height; + double xscale; /* Effective scale, can be fractional */ Rotation rotation; Bool wl_output_done; Bool xdg_output_done; @@ -78,6 +79,9 @@ Bool xwl_screen_init_output(struct xwl_screen *xwl_screen); Bool xwl_screen_init_randr_fixed(struct xwl_screen *xwl_screen); +void +xwl_output_set_xscale(struct xwl_output *xwl_output, double xscale); + Bool xwl_randr_add_modes_fixed(struct xwl_output *xwl_output, int current_width, int current_height);