forge
Explore
Log in

Don't you dare go Hollow

Fix screencopy buffers when buffer-size != shm-pool-size (#4566)

Browse files at this commit

9e72e4917ca31baf4010496bf7f4aaf78d34d236UnverifiedStephanParent: a787723
* screencopy: allow buffer-size != shm-pool-size

* screencopy: add helper for advertised buffer stride
src/protocols/screencopy.rsmodified+7 -4
@@ -29,6 +29,10 @@ use crate::utils::{get_credentials_for_client, get_monotonic_time, CastSessionId
29 29
30 const VERSION: u32 = 3;30 const VERSION: u32 = 3;
31 31
32+fn screencopy_shm_buffer_stride(size: Size<i32, Physical>) -> i32 {
33+ size.w * 4
34+}
35+
32 /// Inactivity timeout for considering a screencopy cast as stopped.36 /// Inactivity timeout for considering a screencopy cast as stopped.
33 ///37 ///
34 /// xdg-desktop-portal-wlr keeps the screencopy manager alive across casts, so there's no way to38 /// xdg-desktop-portal-wlr keeps the screencopy manager alive across casts, so there's no way to
@@ -416,7 +420,7 @@ where
416 Format::Xrgb8888,420 Format::Xrgb8888,
417 buffer_size.w as u32,421 buffer_size.w as u32,
418 buffer_size.h as u32,422 buffer_size.h as u32,
419- buffer_size.w as u32 * 4,423+ screencopy_shm_buffer_stride(buffer_size) as u32,
420 );424 );
421 425
422 if frame.version() >= 3 {426 if frame.version() >= 3 {
@@ -550,12 +554,11 @@ where
550 );554 );
551 return;555 return;
552 }556 }
553- } else if shm::with_buffer_contents(&buffer, |_, shm_len, buffer_data| {557+ } else if shm::with_buffer_contents(&buffer, |_, _, buffer_data| {
554 buffer_data.format == Format::Xrgb8888558 buffer_data.format == Format::Xrgb8888
555 && buffer_data.width == size.w559 && buffer_data.width == size.w
556 && buffer_data.height == size.h560 && buffer_data.height == size.h
557- && buffer_data.stride == size.w * 4561+ && buffer_data.stride == screencopy_shm_buffer_stride(size)
558- && shm_len == buffer_data.stride as usize * buffer_data.height as usize
559 })562 })
560 .unwrap_or(false)563 .unwrap_or(false)
561 {564 {