Disable tracking of wl_buffer release events

This commit is contained in:
Gergő Sályi 2025-04-25 20:03:27 +02:00
parent 377e742ce0
commit ab03760bfe

View file

@ -120,7 +120,7 @@ impl BackgroundLayer {
} }
} }
let mut wallpaper_borrow = wallpaper.borrow_mut(); let wallpaper_borrow = wallpaper.borrow();
let Some(wl_buffer) = wallpaper_borrow.wl_buffer.as_ref() else { let Some(wl_buffer) = wallpaper_borrow.wl_buffer.as_ref() else {
debug!("Wallpaper for output {} workspace {} is not ready yet", debug!("Wallpaper for output {} workspace {} is not ready yet",
self.output_name, workspace_name); self.output_name, workspace_name);
@ -130,7 +130,7 @@ impl BackgroundLayer {
// Attach and commit to new workspace background // Attach and commit to new workspace background
self.layer.attach(Some(wl_buffer), 0, 0); self.layer.attach(Some(wl_buffer), 0, 0);
wallpaper_borrow.active_count += 1; // wallpaper_borrow.active_count += 1;
// Damage the entire surface // Damage the entire surface
self.layer.wl_surface().damage_buffer(0, 0, self.width, self.height); self.layer.wl_surface().damage_buffer(0, 0, self.width, self.height);
@ -152,7 +152,7 @@ struct WorkspaceBackground {
struct Wallpaper { struct Wallpaper {
wl_buffer: Option<WlBuffer>, wl_buffer: Option<WlBuffer>,
active_count: usize, // active_count: usize,
memory: Memory, memory: Memory,
canon_path: PathBuf, canon_path: PathBuf,
canon_modified: u128, canon_modified: u128,
@ -161,10 +161,10 @@ struct Wallpaper {
impl Drop for Wallpaper { impl Drop for Wallpaper {
fn drop(&mut self) { fn drop(&mut self) {
if let Some(wl_buffer) = &self.wl_buffer { if let Some(wl_buffer) = &self.wl_buffer {
if self.active_count != 0 { // if self.active_count != 0 {
debug!("Destroying a {} times active wl_buffer of \ // debug!("Destroying a {} times active wl_buffer of \
wallpaper {:?}", self.active_count, self.canon_path); // wallpaper {:?}", self.active_count, self.canon_path);
} // }
wl_buffer.destroy(); wl_buffer.destroy();
} }
} }
@ -347,25 +347,25 @@ impl DmabufHandler for State {
&mut self, &mut self,
_conn: &Connection, _conn: &Connection,
_qh: &QueueHandle<Self>, _qh: &QueueHandle<Self>,
buffer: &WlBuffer _buffer: &WlBuffer
) { ) {
for bg in self.background_layers.iter_mut() // for bg in self.background_layers.iter_mut()
.flat_map(|bg_layer| &mut bg_layer.workspace_backgrounds) // .flat_map(|bg_layer| &mut bg_layer.workspace_backgrounds)
{ // {
let mut wallpaper = bg.wallpaper.borrow_mut(); // let mut wallpaper = bg.wallpaper.borrow_mut();
if wallpaper.wl_buffer.as_ref() == Some(buffer) { // if wallpaper.wl_buffer.as_ref() == Some(buffer) {
if let Some(new_count) = wallpaper.active_count.checked_sub(1) { // if let Some(new_count) = wallpaper.active_count.checked_sub(1) {
debug!("Compositor released the DMA-BUF wl_buffer of {:?}", // debug!("Compositor released the DMA-BUF wl_buffer of {:?}",
wallpaper.canon_path); // wallpaper.canon_path);
wallpaper.active_count = new_count; // wallpaper.active_count = new_count;
} else { // } else {
error!("Unexpected release event for the DMA-BUF \ // error!("Unexpected release event for the DMA-BUF \
wl_buffer of {:?}", wallpaper.canon_path); // wl_buffer of {:?}", wallpaper.canon_path);
} // }
return // return
} // }
} // }
warn!("Release event for already destroyed DMA-BUF wl_buffer"); // warn!("Release event for already destroyed DMA-BUF wl_buffer");
} }
} }
@ -810,30 +810,30 @@ impl Dispatch<WpViewport, ()> for State {
impl Dispatch<WlBuffer, ()> for State { impl Dispatch<WlBuffer, ()> for State {
fn event( fn event(
state: &mut Self, _state: &mut Self,
proxy: &WlBuffer, _proxy: &WlBuffer,
_event: <WlBuffer as Proxy>::Event, _event: <WlBuffer as Proxy>::Event,
_data: &(), _data: &(),
_conn: &Connection, _conn: &Connection,
_qhandle: &QueueHandle<Self>, _qhandle: &QueueHandle<Self>,
) { ) {
for bg in state.background_layers.iter_mut() // for bg in state.background_layers.iter_mut()
.flat_map(|bg_layer| &mut bg_layer.workspace_backgrounds) // .flat_map(|bg_layer| &mut bg_layer.workspace_backgrounds)
{ // {
let mut wallpaper = bg.wallpaper.borrow_mut(); // let mut wallpaper = bg.wallpaper.borrow_mut();
if wallpaper.wl_buffer.as_ref() == Some(proxy) { // if wallpaper.wl_buffer.as_ref() == Some(proxy) {
if let Some(new_count) = wallpaper.active_count.checked_sub(1) { // if let Some(new_count) = wallpaper.active_count.checked_sub(1) {
debug!("Compositor released the wl_shm wl_buffer of {:?}", // debug!("Compositor released the wl_shm wl_buffer of {:?}",
wallpaper.canon_path); // wallpaper.canon_path);
wallpaper.active_count = new_count; // wallpaper.active_count = new_count;
} else { // } else {
error!("Unexpected release event for the wl_shm \ // error!("Unexpected release event for the wl_shm \
wl_buffer of {:?}", wallpaper.canon_path); // wl_buffer of {:?}", wallpaper.canon_path);
} // }
return // return
} // }
} // }
warn!("Release event for already destroyed wl_shm wl_buffer"); // warn!("Release event for already destroyed wl_shm wl_buffer");
} }
} }
@ -1097,7 +1097,7 @@ fn load_wallpapers(
workspace_name: wallpaper_file.workspace, workspace_name: wallpaper_file.workspace,
wallpaper: Rc::new(RefCell::new(Wallpaper { wallpaper: Rc::new(RefCell::new(Wallpaper {
wl_buffer: Some(wl_buffer), wl_buffer: Some(wl_buffer),
active_count: 0, // active_count: 0,
memory: Memory::WlShm { pool: shm_pool }, memory: Memory::WlShm { pool: shm_pool },
canon_path: wallpaper_file.canon_path, canon_path: wallpaper_file.canon_path,
canon_modified: wallpaper_file.canon_modified, canon_modified: wallpaper_file.canon_modified,
@ -1237,7 +1237,7 @@ fn wallpaper_dmabuf(
); );
Rc::new(RefCell::new(Wallpaper { Rc::new(RefCell::new(Wallpaper {
wl_buffer: None, wl_buffer: None,
active_count: 0, // active_count: 0,
memory: Memory::Dmabuf { gpu_memory, params: Some(params) }, memory: Memory::Dmabuf { gpu_memory, params: Some(params) },
canon_path, canon_path,
canon_modified, canon_modified,