From bffb18ea66efa16889f7a545abbb7a8d92376e09 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gerg=C5=91=20S=C3=A1lyi?= Date: Sun, 15 Jun 2025 21:16:14 +0200 Subject: [PATCH] Fix Wayland protocol error invalid stride on wl_shm with bgr888 format Align wl_shm buffer stride to both 4 and 3, so to 12, fixes: https://github.com/gergo-salyi/multibg-wayland/issues/17 --- src/wayland.rs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/wayland.rs b/src/wayland.rs index 4c3d1d4..ccaf02a 100644 --- a/src/wayland.rs +++ b/src/wayland.rs @@ -968,10 +968,13 @@ fn load_wallpapers( let shm_stride = match shm_format { wl_shm::Format::Xrgb8888 => width as usize * 4, wl_shm::Format::Bgr888 => { - // Align buffer stride to both 4 and pixel format - // block size. Not being aligned to 4 caused - // https://github.com/gergo-salyi/multibg-wayland/issues/6 - (width as usize * 3).next_multiple_of(4) + // Align buffer stride: + // - once to 4, because not being aligned to 4 caused + // https://github.com/gergo-salyi/multibg-wayland/issues/6 + // - and to 3, because not being aligned to 3 caused + // https://github.com/gergo-salyi/multibg-wayland/issues/17 + // So align stride to 4 * 3 = 12 + (width as usize * 3).next_multiple_of(12) }, _ => unreachable!(), };