Skip to content

Commit 1220d4e

Browse files
committed
Fix format used for cursor capture
1 parent aed95c1 commit 1220d4e

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/wayland/cursor_stream.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ impl futures::stream::Stream for CursorStream {
6767
width,
6868
height,
6969
width * 4,
70-
wl_shm::Format::Abgr8888,
70+
wl_shm::Format::Argb8888,
7171
);
7272
*buffer = Some((width, height, fd, wl_buffer));
7373
*state = State::WaitingForFormats; // XXX, well, not waiting
@@ -81,7 +81,12 @@ impl futures::stream::Stream for CursorStream {
8181
let (width, height, fd, _) = &buffer.as_ref().unwrap();
8282
// XXX unwrap
8383
let mmap = unsafe { memmap2::Mmap::map(fd).unwrap() };
84-
let image = image::RgbaImage::from_vec(*width, *height, mmap.to_vec());
84+
let mut bytes = mmap.to_vec();
85+
// Swap BGRA to RGBA
86+
for pixel in bytes.chunks_mut(4) {
87+
pixel.swap(2, 0);
88+
}
89+
let image = image::RgbaImage::from_vec(*width, *height, bytes);
8590
return Poll::Ready(image);
8691
}
8792
// XXX Ignore error

0 commit comments

Comments
 (0)