summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOlivier Fourdan <ofourdan@redhat.com>2023-11-27 13:39:26 +0100
committerOlivier Fourdan <ofourdan@redhat.com>2024-03-20 09:05:36 +0100
commit6a09cd2d20a6e6dfdb1efdbcbeb823ad99930a4d (patch)
tree62029297dfdb4de8e46c2e991acda0226b5462bb
parent8c54f90673370b75b75207aaf7f5752a9cd123f9 (diff)
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 <ofourdan@redhat.com> Reviewed-By: Kenny Levinsen <kl@kl.wtf> Acked-by: Peter Hutterer <peter.hutterer@who-t.net> Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1197>
-rw-r--r--hw/xwayland/xwayland-output.c12
-rw-r--r--hw/xwayland/xwayland-output.h4
2 files changed, 15 insertions, 1 deletions
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);