@@ -3,6 +3,7 @@ use std::sync::atomic::Ordering;
33use std:: sync:: { Arc , Mutex } ;
44
55use ahash:: AHashMap ;
6+ use libc:: dev_t;
67use sctk:: compositor:: { CompositorHandler , CompositorState } ;
78use sctk:: output:: { OutputHandler , OutputState } ;
89use sctk:: reexports:: calloop:: LoopHandle ;
@@ -40,6 +41,8 @@ use crate::WindowId;
4041/// Winit's Wayland state.
4142#[ derive( Debug ) ]
4243pub struct WinitState {
44+ globals : GlobalList ,
45+
4346 /// The WlRegistry.
4447 pub registry_state : RegistryState ,
4548
@@ -125,20 +128,27 @@ pub struct WinitState {
125128
126129 /// Whether the user initiated a wake up.
127130 pub proxy_wake_up : bool ,
131+
132+ pub extension_events : Vec < ExtensionEvents > ,
133+ }
134+
135+ #[ derive( Debug , Clone , Copy ) ]
136+ pub enum ExtensionEvents {
137+ LinuxMainDevice ( dev_t ) ,
128138}
129139
130140impl WinitState {
131141 pub fn new (
132- globals : & GlobalList ,
142+ globals : GlobalList ,
133143 queue_handle : & QueueHandle < Self > ,
134144 loop_handle : LoopHandle < ' static , WinitState > ,
135145 ) -> Result < Self , OsError > {
136- let registry_state = RegistryState :: new ( globals) ;
146+ let registry_state = RegistryState :: new ( & globals) ;
137147 let compositor_state =
138- CompositorState :: bind ( globals, queue_handle) . map_err ( |err| os_error ! ( err) ) ?;
148+ CompositorState :: bind ( & globals, queue_handle) . map_err ( |err| os_error ! ( err) ) ?;
139149 let subcompositor_state = match SubcompositorState :: bind (
140150 compositor_state. wl_compositor ( ) . clone ( ) ,
141- globals,
151+ & globals,
142152 queue_handle,
143153 ) {
144154 Ok ( c) => Some ( c) ,
@@ -148,26 +158,24 @@ impl WinitState {
148158 } ,
149159 } ;
150160
151- let output_state = OutputState :: new ( globals, queue_handle) ;
161+ let output_state = OutputState :: new ( & globals, queue_handle) ;
152162 let monitors = output_state. outputs ( ) . map ( MonitorHandle :: new) . collect ( ) ;
153163
154- let seat_state = SeatState :: new ( globals, queue_handle) ;
164+ let seat_state = SeatState :: new ( & globals, queue_handle) ;
155165
156166 let mut seats = AHashMap :: default ( ) ;
157167 for seat in seat_state. seats ( ) {
158168 seats. insert ( seat. id ( ) , WinitSeatState :: new ( ) ) ;
159169 }
160170
161171 let ( viewporter_state, fractional_scaling_manager) =
162- if let Ok ( fsm) = FractionalScalingManager :: new ( globals, queue_handle) {
163- ( ViewporterState :: new ( globals, queue_handle) . ok ( ) , Some ( fsm) )
172+ if let Ok ( fsm) = FractionalScalingManager :: new ( & globals, queue_handle) {
173+ ( ViewporterState :: new ( & globals, queue_handle) . ok ( ) , Some ( fsm) )
164174 } else {
165175 ( None , None )
166176 } ;
167177
168- let linux_dmabuf_manager = LinuxDmabufManager :: new ( globals, queue_handle) . ok ( ) ;
169-
170- let shm = Shm :: bind ( globals, queue_handle) . map_err ( |err| os_error ! ( err) ) ?;
178+ let shm = Shm :: bind ( & globals, queue_handle) . map_err ( |err| os_error ! ( err) ) ?;
171179 let image_pool = Arc :: new ( Mutex :: new ( SlotPool :: new ( 2 , & shm) . unwrap ( ) ) ) ;
172180
173181 Ok ( Self {
@@ -178,9 +186,9 @@ impl WinitState {
178186 seat_state,
179187 shm,
180188
181- xdg_shell : XdgShell :: bind ( globals, queue_handle) . map_err ( |err| os_error ! ( err) ) ?,
182- xdg_activation : XdgActivationState :: bind ( globals, queue_handle) . ok ( ) ,
183- xdg_toplevel_icon_manager : XdgToplevelIconManagerState :: bind ( globals, queue_handle)
189+ xdg_shell : XdgShell :: bind ( & globals, queue_handle) . map_err ( |err| os_error ! ( err) ) ?,
190+ xdg_activation : XdgActivationState :: bind ( & globals, queue_handle) . ok ( ) ,
191+ xdg_toplevel_icon_manager : XdgToplevelIconManagerState :: bind ( & globals, queue_handle)
184192 . ok ( ) ,
185193
186194 image_pool,
@@ -191,14 +199,14 @@ impl WinitState {
191199 window_events_sink : Default :: default ( ) ,
192200 viewporter_state,
193201 fractional_scaling_manager,
194- kwin_blur_manager : KWinBlurManager :: new ( globals , queue_handle ) . ok ( ) ,
195- linux_dmabuf_manager ,
202+ linux_dmabuf_manager : None ,
203+ kwin_blur_manager : KWinBlurManager :: new ( & globals , queue_handle ) . ok ( ) ,
196204
197205 seats,
198- text_input_state : TextInputState :: new ( globals, queue_handle) . ok ( ) ,
206+ text_input_state : TextInputState :: new ( & globals, queue_handle) . ok ( ) ,
199207
200- relative_pointer : RelativePointerState :: new ( globals, queue_handle) . ok ( ) ,
201- pointer_constraints : PointerConstraintsState :: new ( globals, queue_handle)
208+ relative_pointer : RelativePointerState :: new ( & globals, queue_handle) . ok ( ) ,
209+ pointer_constraints : PointerConstraintsState :: new ( & globals, queue_handle)
202210 . map ( Arc :: new)
203211 . ok ( ) ,
204212 pointer_surfaces : Default :: default ( ) ,
@@ -209,9 +217,16 @@ impl WinitState {
209217 // Make it true by default.
210218 dispatched_events : true ,
211219 proxy_wake_up : false ,
220+ extension_events : Vec :: new ( ) ,
221+ globals,
212222 } )
213223 }
214224
225+ pub fn register_linux_dmabuf ( & mut self , queue_handle : & QueueHandle < Self > ) {
226+ self . linux_dmabuf_manager = LinuxDmabufManager :: new ( & self . globals , queue_handle) . ok ( ) ;
227+ println ! ( "Registering!" ) ;
228+ }
229+
215230 pub fn scale_factor_changed (
216231 & mut self ,
217232 surface : & WlSurface ,
0 commit comments