xwayland: Move the libdecor resize to its own function

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 <ofourdan@redhat.com>
Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>
This commit is contained in:
Olivier Fourdan 2023-07-25 18:38:24 +02:00
parent cda004c2a9
commit e37539e1e2

View File

@ -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);