From 4262e0198957d1c1523f266beb7e79dc3d27f852 Mon Sep 17 00:00:00 2001 From: Manuel Stoeckl Date: Mon, 29 Apr 2024 11:37:08 -0400 Subject: Fix fractional scale detection The fractional scale protocol does not guarantee that a preferred fractional scale value is provided before the surface is mapped. Therefore, use the (integral) output scale value until a fractional scale is available. Also: wl_output.scale is not guaranteed to be sent if the initial output scale is 1 (although Sway always sends it). Set the default output scale value. --- main.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/main.c b/main.c index f15669e..fc6725e 100644 --- a/main.c +++ b/main.c @@ -159,7 +159,7 @@ static void get_buffer_size(const struct swaybg_output *output, output->state->viewporter) { *buffer_width = 1; *buffer_height = 1; - } else if (output->fract_scale && output->state->viewporter) { + } else if (output->pref_fract_scale && output->state->viewporter) { // rounding mode is 'round half up' *buffer_width = (output->width * output->pref_fract_scale + FRACT_DENOM / 2) / FRACT_DENOM; @@ -419,6 +419,7 @@ static void handle_global(void *data, struct wl_registry *registry, } else if (strcmp(interface, wl_output_interface.name) == 0) { struct swaybg_output *output = calloc(1, sizeof(struct swaybg_output)); output->state = state; + output->scale = 1; output->wl_name = name; output->wl_output = wl_registry_bind(registry, name, &wl_output_interface, 4); -- cgit v1.2.3