@@ -5,6 +5,7 @@ use std::rc::Rc;
55use crate :: egl:: EGLState ;
66use crate :: wallpaper:: Wallpaper ;
77use crate :: wallpaper_renderer:: WPRenderer ;
8+ use crossbeam:: channel:: Sender ;
89use fps_counter:: FPSCounter ;
910use gl:: COLOR_BUFFER_BIT ;
1011use khronos_egl:: ATTRIB_NONE ;
@@ -41,7 +42,7 @@ pub struct RenderingContext {
4142}
4243
4344impl RenderingContext {
44- pub fn new ( ) -> Self {
45+ pub fn new ( new_output_tx : Sender < OutputInfo > ) -> Self {
4546 let connection = Rc :: new ( Connection :: connect_to_env ( ) . unwrap ( ) ) ;
4647 let egl_state = Rc :: new ( EGLState :: new ( connection. clone ( ) ) ) ;
4748 let ( globals, event_queue) : ( GlobalList , EventQueue < WLState > ) =
@@ -53,6 +54,7 @@ impl RenderingContext {
5354 egl_state. clone ( ) ,
5455 & globals,
5556 queue_handle,
57+ new_output_tx,
5658 ) ;
5759
5860 tracing:: info!( "Created WL state" ) ;
@@ -134,6 +136,7 @@ pub struct WLState {
134136 layer_shell : LayerShell ,
135137
136138 pub layers : HashMap < String , SimpleLayer > ,
139+ new_output_tx : Sender < OutputInfo > ,
137140}
138141
139142impl WLState {
@@ -142,6 +145,7 @@ impl WLState {
142145 egl_state : Rc < EGLState > ,
143146 globals : & GlobalList ,
144147 queue_handle : QueueHandle < Self > ,
148+ new_output_tx : Sender < OutputInfo > ,
145149 ) -> Self {
146150 Self {
147151 connection,
@@ -156,6 +160,7 @@ impl WLState {
156160 queue_handle,
157161
158162 layers : HashMap :: new ( ) ,
163+ new_output_tx,
159164 }
160165 }
161166
@@ -226,15 +231,6 @@ impl WLState {
226231 }
227232}
228233
229- impl Drop for SimpleLayer {
230- fn drop ( & mut self ) {
231- self . egl_state
232- . egl
233- . destroy_surface ( self . egl_state . egl_display , self . egl_window_surface )
234- . expect ( "Couldn't destroy surface" ) ;
235- }
236- }
237-
238234pub struct OutputsList ( HashMap < WlOutput , OutputInfo > ) ;
239235
240236impl OutputsList {
@@ -290,6 +286,15 @@ pub struct SimpleLayer {
290286 fps_counter : FPSCounter ,
291287}
292288
289+ impl Drop for SimpleLayer {
290+ fn drop ( & mut self ) {
291+ self . egl_state
292+ . egl
293+ . destroy_surface ( self . egl_state . egl_display , self . egl_window_surface )
294+ . expect ( "Couldn't destroy surface" ) ;
295+ }
296+ }
297+
293298impl CompositorHandler for WLState {
294299 fn scale_factor_changed (
295300 & mut self ,
@@ -349,7 +354,16 @@ impl OutputHandler for WLState {
349354 & mut self . output_state
350355 }
351356
352- fn new_output ( & mut self , _conn : & Connection , _qh : & QueueHandle < Self > , _output : WlOutput ) { }
357+ fn new_output ( & mut self , _conn : & Connection , _qh : & QueueHandle < Self > , output : WlOutput ) {
358+ match self . output_state . info ( & output) {
359+ Some ( infos) => {
360+ self . new_output_tx
361+ . send ( infos)
362+ . expect ( "Error sending new output event" ) ;
363+ }
364+ None => tracing:: error!( "Could not retrieve new output info" ) ,
365+ }
366+ }
353367
354368 fn update_output ( & mut self , _conn : & Connection , _qh : & QueueHandle < Self > , _output : WlOutput ) {
355369 // TODO resize wallpaper if output size or scale has changed
0 commit comments