summaryrefslogtreecommitdiff
path: root/main.c
diff options
context:
space:
mode:
authorManuel Stoeckl <code@mstoeckl.com>2024-04-29 11:37:08 -0400
committerSimon Ser <contact@emersion.fr>2024-04-29 17:47:54 +0200
commit4262e0198957d1c1523f266beb7e79dc3d27f852 (patch)
tree32a0d8a6ad38c16d07459caeae6d1424d827755a /main.c
parentade567683ab84b814af07d1d5e2d19e69424a5da (diff)
downloadswaybg-4262e0198957d1c1523f266beb7e79dc3d27f852.tar.gz
swaybg-4262e0198957d1c1523f266beb7e79dc3d27f852.tar.bz2
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.
Diffstat (limited to 'main.c')
-rw-r--r--main.c3
1 files changed, 2 insertions, 1 deletions
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);