diff options
author | Roman Gilg <subdiff@gmail.com> | 2020-08-10 18:58:56 +0200 |
---|---|---|
committer | Olivier Fourdan <fourdan@gmail.com> | 2020-09-01 13:13:57 +0000 |
commit | 1805383d9eb17ef8ac159366c684ac85b3d53731 (patch) | |
tree | aa00c99e38c3dcc71d3fa541c8ed6b1bf8212913 | |
parent | 919f1f46fc67dae93b2b3f278fcbfc77af34ec58 (diff) |
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 <subdiff@gmail.com>
-rw-r--r-- | hw/xwayland/xwayland-output.c | 20 |
1 files 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); |