From 1805383d9eb17ef8ac159366c684ac85b3d53731 Mon Sep 17 00:00:00 2001 From: Roman Gilg Date: Mon, 10 Aug 2020 18:58:56 +0200 Subject: [PATCH] xwayland: simplify output_get_new_size function We can just read out the xdg_output field of the provided xwl_output to check if a rotation is necessary or not. This makes the function easier to understand. Additionally some documentation is added. Signed-off-by: Roman Gilg --- hw/xwayland/xwayland-output.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/hw/xwayland/xwayland-output.c b/hw/xwayland/xwayland-output.c index f94aa0d35..eb2b7235c 100644 --- a/hw/xwayland/xwayland-output.c +++ b/hw/xwayland/xwayland-output.c @@ -125,14 +125,19 @@ output_handle_mode(void *data, struct wl_output *wl_output, uint32_t flags, xwl_output->refresh = refresh; } +/** + * Decides on the maximum expanse of an output in logical space (i.e. in the + * Wayland compositor plane) respective to some fix width and height values. The + * function sets the provided values to these maxima on return. + */ static inline void -output_get_new_size(struct xwl_output *xwl_output, - Bool need_rotate, - int *height, int *width) +output_get_new_size(struct xwl_output *xwl_output, int *height, int *width) { int output_width, output_height; - if (!need_rotate || (xwl_output->rotation & (RR_Rotate_0 | RR_Rotate_180))) { + /* When we have xdg-output support the stored size is already rotated. */ + if (xwl_output->xdg_output + || (xwl_output->rotation & (RR_Rotate_0 | RR_Rotate_180))) { output_width = xwl_output->width; output_height = xwl_output->height; } else { @@ -535,14 +540,14 @@ apply_output_change(struct xwl_output *xwl_output) if (it == xwl_output) has_this_output = 1; - output_get_new_size(it, need_rotate, &height, &width); + output_get_new_size(it, &height, &width); } if (!has_this_output) { xorg_list_append(&xwl_output->link, &xwl_screen->output_list); /* we did not check this output for new screen size, do it now */ - output_get_new_size(xwl_output, need_rotate, &height, &width); + output_get_new_size(xwl_output, &height, &width); --xwl_screen->expecting_event; } @@ -704,12 +709,11 @@ xwl_output_remove(struct xwl_output *xwl_output) struct xwl_output *it; struct xwl_screen *xwl_screen = xwl_output->xwl_screen; int width = 0, height = 0; - Bool need_rotate = (xwl_output->xdg_output == NULL); xorg_list_del(&xwl_output->link); xorg_list_for_each_entry(it, &xwl_screen->output_list, link) - output_get_new_size(it, need_rotate, &height, &width); + output_get_new_size(it, &height, &width); update_screen_size(xwl_output, width, height); RRCrtcDestroy(xwl_output->randr_crtc);