Skip to content
Myr

wayland: fix crash when desktop scaling is enabled

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Single-pixel buffers must be scaled with a viewport. Before this patch, we didn't do that, unless we've seen fractional scaling being enabled by the compositor. We typically don't see this for the first frame, since compositor usually sends the fractional scaling factor *after* the window has been mapped. Despite this, it worked as long as there were no scaling enabled at all. With scaling enabled, we got: wl_surface#3: error 2: Buffer size (1x1) is not divisible by scale (2) warn: wayland.c:2634: disconnected from Wayland err: wayland.c:3093: failed to flush wayland socket: Protocol error (71) Fix by forcing the use of a viewport when committing single-pixel buffers.

authored by Daniel Eklöf · committed by Daniel Eklöf · parent 3ccfb60 · Browse files · 1 file+4 added−4 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+4 added−4 removed

  • other:+4 added−4 removed

1 file+4 added−4 removed

modified:wayland.c+4 added-4 removed
2433 unmodified lines
2434 .done = &frame_callback,2435};24362437static void2438commit_buffer(struct wayland *wayl, struct buffer *buf)2438commit_buffer(struct wayland *wayl, struct buffer *buf, bool force_viewport)2439{2440 const float scale = wayl->scale;2441 assert(scale >= 1);24422443 if (wayl->preferred_fractional_scale > 0) {2443 if (wayl->preferred_fractional_scale > 0 || force_viewport) {2444 LOG_DBG("scaling by a factor of %.2f using fractional scaling", scale);24452446 assert(wayl->viewport != NULL);2447
94 unmodified lines
2542 .height = wayl->height,2543 .wl_buf = single,2544 };25452546 commit_buffer(wayl, &buf);2546 commit_buffer(wayl, &buf, true);2547 wl_buffer_destroy(single);2548 goto done;2549 }2550
43 unmodified lines
25942595commit:2596 /* No pending frames - render immediately */2597 assert(!wayl->need_refresh);2598 commit_buffer(wayl, buf);2598 commit_buffer(wayl, buf, false);2599done:26002601 time_finish(2602 start_frame, NULL, "%sframe rendered",
556 unmodified lines