diff options
author | Simon Ser <contact@emersion.fr> | 2021-06-11 18:41:34 +0200 |
---|---|---|
committer | Simon Ser <contact@emersion.fr> | 2021-07-28 22:52:35 +0200 |
commit | 1a5b6722a8fa2b0b8b1167bb58de2f12765e28a1 (patch) | |
tree | 45e676d3bfae1c2200890535e983e954b26a227c | |
parent | d6f0fc251e675d85e1d8e6f23165b0ba0b503b83 (diff) |
output: use pending resolution when allocating swapchain
This allows the swapchain to be created with the correct resolution
during a mode change.
-rw-r--r-- | types/wlr_output.c | 17 |
1 files 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; } |