From ab03760bfe5bcd944c134a50b029cff06fed0521 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gerg=C5=91=20S=C3=A1lyi?= Date: Fri, 25 Apr 2025 20:03:27 +0200 Subject: [PATCH] Disable tracking of wl_buffer release events --- src/wayland.rs | 92 +++++++++++++++++++++++++------------------------- 1 file changed, 46 insertions(+), 46 deletions(-) diff --git a/src/wayland.rs b/src/wayland.rs index 6542270..b2e6d39 100644 --- a/src/wayland.rs +++ b/src/wayland.rs @@ -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 { debug!("Wallpaper for output {} workspace {} is not ready yet", self.output_name, workspace_name); @@ -130,7 +130,7 @@ impl BackgroundLayer { // Attach and commit to new workspace background self.layer.attach(Some(wl_buffer), 0, 0); - wallpaper_borrow.active_count += 1; + // wallpaper_borrow.active_count += 1; // Damage the entire surface self.layer.wl_surface().damage_buffer(0, 0, self.width, self.height); @@ -152,7 +152,7 @@ struct WorkspaceBackground { struct Wallpaper { wl_buffer: Option, - active_count: usize, + // active_count: usize, memory: Memory, canon_path: PathBuf, canon_modified: u128, @@ -161,10 +161,10 @@ struct Wallpaper { impl Drop for Wallpaper { fn drop(&mut self) { if let Some(wl_buffer) = &self.wl_buffer { - if self.active_count != 0 { - debug!("Destroying a {} times active wl_buffer of \ - wallpaper {:?}", self.active_count, self.canon_path); - } + // if self.active_count != 0 { + // debug!("Destroying a {} times active wl_buffer of \ + // wallpaper {:?}", self.active_count, self.canon_path); + // } wl_buffer.destroy(); } } @@ -347,25 +347,25 @@ impl DmabufHandler for State { &mut self, _conn: &Connection, _qh: &QueueHandle, - buffer: &WlBuffer + _buffer: &WlBuffer ) { - for bg in self.background_layers.iter_mut() - .flat_map(|bg_layer| &mut bg_layer.workspace_backgrounds) - { - let mut wallpaper = bg.wallpaper.borrow_mut(); - if wallpaper.wl_buffer.as_ref() == Some(buffer) { - if let Some(new_count) = wallpaper.active_count.checked_sub(1) { - debug!("Compositor released the DMA-BUF wl_buffer of {:?}", - wallpaper.canon_path); - wallpaper.active_count = new_count; - } else { - error!("Unexpected release event for the DMA-BUF \ - wl_buffer of {:?}", wallpaper.canon_path); - } - return - } - } - warn!("Release event for already destroyed DMA-BUF wl_buffer"); + // for bg in self.background_layers.iter_mut() + // .flat_map(|bg_layer| &mut bg_layer.workspace_backgrounds) + // { + // let mut wallpaper = bg.wallpaper.borrow_mut(); + // if wallpaper.wl_buffer.as_ref() == Some(buffer) { + // if let Some(new_count) = wallpaper.active_count.checked_sub(1) { + // debug!("Compositor released the DMA-BUF wl_buffer of {:?}", + // wallpaper.canon_path); + // wallpaper.active_count = new_count; + // } else { + // error!("Unexpected release event for the DMA-BUF \ + // wl_buffer of {:?}", wallpaper.canon_path); + // } + // return + // } + // } + // warn!("Release event for already destroyed DMA-BUF wl_buffer"); } } @@ -810,30 +810,30 @@ impl Dispatch for State { impl Dispatch for State { fn event( - state: &mut Self, - proxy: &WlBuffer, + _state: &mut Self, + _proxy: &WlBuffer, _event: ::Event, _data: &(), _conn: &Connection, _qhandle: &QueueHandle, ) { - for bg in state.background_layers.iter_mut() - .flat_map(|bg_layer| &mut bg_layer.workspace_backgrounds) - { - let mut wallpaper = bg.wallpaper.borrow_mut(); - if wallpaper.wl_buffer.as_ref() == Some(proxy) { - if let Some(new_count) = wallpaper.active_count.checked_sub(1) { - debug!("Compositor released the wl_shm wl_buffer of {:?}", - wallpaper.canon_path); - wallpaper.active_count = new_count; - } else { - error!("Unexpected release event for the wl_shm \ - wl_buffer of {:?}", wallpaper.canon_path); - } - return - } - } - warn!("Release event for already destroyed wl_shm wl_buffer"); + // for bg in state.background_layers.iter_mut() + // .flat_map(|bg_layer| &mut bg_layer.workspace_backgrounds) + // { + // let mut wallpaper = bg.wallpaper.borrow_mut(); + // if wallpaper.wl_buffer.as_ref() == Some(proxy) { + // if let Some(new_count) = wallpaper.active_count.checked_sub(1) { + // debug!("Compositor released the wl_shm wl_buffer of {:?}", + // wallpaper.canon_path); + // wallpaper.active_count = new_count; + // } else { + // error!("Unexpected release event for the wl_shm \ + // wl_buffer of {:?}", wallpaper.canon_path); + // } + // return + // } + // } + // warn!("Release event for already destroyed wl_shm wl_buffer"); } } @@ -1097,7 +1097,7 @@ fn load_wallpapers( workspace_name: wallpaper_file.workspace, wallpaper: Rc::new(RefCell::new(Wallpaper { wl_buffer: Some(wl_buffer), - active_count: 0, + // active_count: 0, memory: Memory::WlShm { pool: shm_pool }, canon_path: wallpaper_file.canon_path, canon_modified: wallpaper_file.canon_modified, @@ -1237,7 +1237,7 @@ fn wallpaper_dmabuf( ); Rc::new(RefCell::new(Wallpaper { wl_buffer: None, - active_count: 0, + // active_count: 0, memory: Memory::Dmabuf { gpu_memory, params: Some(params) }, canon_path, canon_modified,