@@ -52,6 +52,27 @@ pub(crate) struct OutputInfo {
5252 pub image_ready : bool ,
5353}
5454
55+ impl Drop for OutputInfo {
56+ fn drop ( & mut self ) {
57+ log:: debug!( "Cleaning up OutputInfo resources" ) ;
58+
59+ // Release Wayland output object
60+ self . wl_output . release ( ) ;
61+
62+ // Clean up memory mapping first
63+ if let Some ( mmap) = self . image_mmap . take ( ) {
64+ drop ( mmap) ;
65+ }
66+
67+ // Clean up memory file descriptor
68+ if let Some ( memfd) = self . image_memfd . take ( ) {
69+ drop ( memfd) ;
70+ }
71+
72+ log:: debug!( "OutputInfo resources cleaned up" ) ;
73+ }
74+ }
75+
5576/// Global state for Wayland connection and screen capture.
5677///
5778/// This struct maintains the global state for the Wayland connection,
@@ -70,6 +91,23 @@ pub(crate) struct State {
7091 pub output_infos : Vec < OutputInfo > ,
7192}
7293
94+ impl Drop for State {
95+ fn drop ( & mut self ) {
96+ log:: debug!( "Cleaning up State resources" ) ;
97+
98+ // Wayland objects will be automatically cleaned up when dropped
99+ // No need to explicitly call release() on them
100+ self . wlr_screencopy_manager . take ( ) ;
101+ self . xdg_output_manager . take ( ) ;
102+ self . wl_shm . take ( ) ;
103+
104+ // OutputInfo objects will be cleaned up automatically through their Drop implementation
105+ self . output_infos . clear ( ) ;
106+
107+ log:: debug!( "State resources cleaned up" ) ;
108+ }
109+ }
110+
73111/// Handle Wayland registry events to discover available globals.
74112///
75113/// This implementation processes Wayland registry events to bind to the necessary
0 commit comments