From 1a5b6722a8fa2b0b8b1167bb58de2f12765e28a1 Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Fri, 11 Jun 2021 18:41:34 +0200 Subject: [PATCH] output: use pending resolution when allocating swapchain This allows the swapchain to be created with the correct resolution during a mode change. --- types/wlr_output.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/types/wlr_output.c b/types/wlr_output.c index 2a054e7c..1b7a4c8f 100644 --- a/types/wlr_output.c +++ b/types/wlr_output.c @@ -477,9 +477,15 @@ static void output_state_clear_buffer(struct wlr_output_state *state) { static struct wlr_drm_format *output_pick_format(struct wlr_output *output, const struct wlr_drm_format_set *display_formats); +static void output_pending_resolution(struct wlr_output *output, int *width, + int *height); static bool output_create_swapchain(struct wlr_output *output) { - if (output->swapchain != NULL) { + int width, height; + output_pending_resolution(output, &width, &height); + + if (output->swapchain != NULL && output->swapchain->width == width && + output->swapchain->height == height) { return true; } @@ -508,14 +514,17 @@ static bool output_create_swapchain(struct wlr_output *output) { wlr_log(WLR_DEBUG, "Choosing primary buffer format 0x%"PRIX32" for output '%s'", format->format, output->name); - output->swapchain = wlr_swapchain_create(allocator, output->width, - output->height, format); + struct wlr_swapchain *swapchain = + wlr_swapchain_create(allocator, width, height, format); free(format); - if (output->swapchain == NULL) { + if (swapchain == NULL) { wlr_log(WLR_ERROR, "Failed to create output swapchain"); return false; } + wlr_swapchain_destroy(output->swapchain); + output->swapchain = swapchain; + return true; }