From 2a25e816240ba4afa3de140b7d2daa0e3f977ff0 Mon Sep 17 00:00:00 2001 From: Ian Douglas Scott Date: Tue, 16 Jan 2024 09:09:28 -0800 Subject: [PATCH] client: Fix endianness in `simple_window` example Haven't tested on a big-endian system, but this should be correct. It seems redundant to use bitshifts only to convert with `to_*_bytes`, so just use an array. Fixes https://github.com/Smithay/wayland-rs/issues/385. --- wayland-client/examples/simple_window.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/wayland-client/examples/simple_window.rs b/wayland-client/examples/simple_window.rs index 0adaee1432b..d5269e8e7d3 100644 --- a/wayland-client/examples/simple_window.rs +++ b/wayland-client/examples/simple_window.rs @@ -124,9 +124,7 @@ fn draw(tmp: &mut File, (buf_x, buf_y): (u32, u32)) { let r = min(((buf_x - x) * 0xFF) / buf_x, ((buf_y - y) * 0xFF) / buf_y); let g = min((x * 0xFF) / buf_x, ((buf_y - y) * 0xFF) / buf_y); let b = min(((buf_x - x) * 0xFF) / buf_x, (y * 0xFF) / buf_y); - - let color = (a << 24) + (r << 16) + (g << 8) + b; - buf.write_all(&color.to_ne_bytes()).unwrap(); + buf.write_all(&[b as u8, g as u8, r as u8, a as u8]).unwrap(); } } buf.flush().unwrap();