@@ -26,11 +26,13 @@ use smithay_client_toolkit::{
2626} ;
2727use tokio:: time:: sleep;
2828
29+ pub type Outputs = Vec < ( WlOutput , Option < OutputInfo > ) > ;
30+
2931#[ derive( Debug , Default ) ]
3032pub struct State {
3133 pub socket_path : PathBuf ,
3234 pid_path : PathBuf ,
33- outputs : HashMap < WlOutput , Option < OutputInfo > > ,
35+ outputs : Outputs ,
3436 /// If false, we have to wait for new Outputs before opening a window
3537 outputs_ready : bool ,
3638 pub windows : HashMap < Id , Window > ,
@@ -115,7 +117,7 @@ impl State {
115117 wayland:: OutputEvent :: Created ( info_maybe) => {
116118 let first_output = self . outputs . is_empty ( ) ;
117119 log:: debug!( "got new output: {info_maybe:#?}" ) ;
118- self . outputs . insert ( wl_output, info_maybe) ;
120+ self . outputs . push ( ( wl_output, info_maybe) ) ;
119121 if !self . outputs_ready && first_output {
120122 return Task :: future ( async {
121123 sleep ( Duration :: from_millis ( 500 ) ) . await ;
@@ -124,10 +126,17 @@ impl State {
124126 }
125127 }
126128 wayland:: OutputEvent :: InfoUpdate ( info) => {
127- self . outputs . insert ( wl_output, Some ( info) ) ;
129+ if let Some ( ( _, info_maybe) ) =
130+ self . outputs . iter_mut ( ) . find ( |( wlo, _) | wlo == & wl_output)
131+ {
132+ * info_maybe = Some ( info) ;
133+ }
128134 }
129135 wayland:: OutputEvent :: Removed => {
130- self . outputs . remove ( & wl_output) ;
136+ let pos = self . outputs . iter ( ) . position ( |( wlo, _) | wlo == & wl_output) ;
137+ if let Some ( pos) = pos {
138+ self . outputs . remove ( pos) ;
139+ }
131140 }
132141 } ,
133142 OutputsReady => {
@@ -163,7 +172,7 @@ impl State {
163172 WindowRequest :: Open ( opts) => {
164173 info ! ( "Opening new window" ) ;
165174 let naive_id;
166- ( task, naive_id) = self . open_window ( opts) ;
175+ ( task, naive_id) = self . open_window ( * opts) ;
167176 IpcResponse :: Window {
168177 id : vec ! [ naive_id] ,
169178 event : WindowResponse :: Opened ,
@@ -281,7 +290,7 @@ impl State {
281290 )
282291 }
283292
284- pub fn view ( & self , id : Id ) -> Element {
293+ pub fn view ( & self , id : Id ) -> Element < ' _ > {
285294 match self . windows . get ( & id) {
286295 Some ( window) => window. view ( & self . registry ) ,
287296 None => "Invalid window ID" . into ( ) ,
0 commit comments