From e37539e1e2d38127fc7ae600da543b0ac341ec14 Mon Sep 17 00:00:00 2001 From: Olivier Fourdan Date: Tue, 25 Jul 2023 18:38:24 +0200 Subject: [PATCH] xwayland: Move the libdecor resize to its own function MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This moves the code which updates the XRandR modes and sets the root window size to its own function. This preparation work for the next commit, no functional change. Signed-off-by: Olivier Fourdan Reviewed-by: Michel Dänzer --- hw/xwayland/xwayland-window.c | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/hw/xwayland/xwayland-window.c b/hw/xwayland/xwayland-window.c index 85d917161..72c832e4e 100644 --- a/hw/xwayland/xwayland-window.c +++ b/hw/xwayland/xwayland-window.c @@ -616,6 +616,21 @@ xwl_window_update_libdecor_size(struct xwl_window *xwl_window, int width, int he } } +static void +xwl_window_libdecor_resize(struct xwl_window *xwl_window, int width, int height) +{ + struct xwl_screen *xwl_screen = xwl_window->xwl_screen; + struct xwl_output *xwl_output; + RRModePtr mode; + + xwl_output = xwl_screen_get_fixed_or_first_output(xwl_screen); + if (!xwl_randr_add_modes_fixed(xwl_output, width, height)) + return; + + mode = xwl_output_find_mode(xwl_output, width, height); + xwl_output_set_mode_fixed(xwl_output, mode); +} + static void handle_libdecor_configure(struct libdecor_frame *frame, struct libdecor_configuration *configuration, @@ -623,9 +638,7 @@ handle_libdecor_configure(struct libdecor_frame *frame, { struct xwl_window *xwl_window = data; struct xwl_screen *xwl_screen = xwl_window->xwl_screen; - struct xwl_output *xwl_output; struct libdecor_state *state; - RRModePtr mode; int width, height; if (!libdecor_configuration_get_content_size(configuration, frame, &width, &height)) { @@ -633,13 +646,8 @@ handle_libdecor_configure(struct libdecor_frame *frame, height = xwl_screen->height; } - if (xwl_screen->width != width || xwl_screen->height != height) { - xwl_output = xwl_screen_get_fixed_or_first_output(xwl_screen); - if (xwl_randr_add_modes_fixed(xwl_output, width, height)) { - mode = xwl_output_find_mode(xwl_output, width, height); - xwl_output_set_mode_fixed(xwl_output, mode); - } - } + if (xwl_screen->width != width || xwl_screen->height != height) + xwl_window_libdecor_resize(xwl_window, width, height); state = libdecor_state_new(xwl_screen->width, xwl_screen->height); libdecor_frame_commit(frame, state, configuration);