1+ use std:: cell:: Cell ;
12use std:: error:: Error ;
23use std:: ffi:: c_void;
34use std:: os:: fd:: AsRawFd ;
@@ -101,11 +102,11 @@ struct WindowInner {
101102 window_id : XWindow ,
102103 window_info : WindowInfo ,
103104 visual_id : Visualid ,
104- mouse_cursor : MouseCursor ,
105+ mouse_cursor : Cell < MouseCursor > ,
105106
106107 frame_interval : Duration ,
107108 event_loop_running : bool ,
108- close_requested : bool ,
109+ close_requested : Cell < bool > ,
109110
110111 new_physical_size : Option < PhySize > ,
111112 parent_handle : Option < ParentHandle > ,
@@ -115,7 +116,7 @@ struct WindowInner {
115116}
116117
117118pub struct Window < ' a > {
118- inner : & ' a mut WindowInner ,
119+ inner : & ' a WindowInner ,
119120}
120121
121122// Hack to allow sending a RawWindowHandle between threads. Do not make public
@@ -284,11 +285,11 @@ impl<'a> Window<'a> {
284285 window_id,
285286 window_info,
286287 visual_id : visual_info. visual_id ,
287- mouse_cursor : MouseCursor :: default ( ) ,
288+ mouse_cursor : Cell :: new ( MouseCursor :: default ( ) ) ,
288289
289290 frame_interval : Duration :: from_millis ( 15 ) ,
290291 event_loop_running : false ,
291- close_requested : false ,
292+ close_requested : Cell :: new ( false ) ,
292293
293294 new_physical_size : None ,
294295 parent_handle,
@@ -312,8 +313,8 @@ impl<'a> Window<'a> {
312313 Ok ( ( ) )
313314 }
314315
315- pub fn set_mouse_cursor ( & mut self , mouse_cursor : MouseCursor ) {
316- if self . inner . mouse_cursor == mouse_cursor {
316+ pub fn set_mouse_cursor ( & self , mouse_cursor : MouseCursor ) {
317+ if self . inner . mouse_cursor . get ( ) == mouse_cursor {
317318 return ;
318319 }
319320
@@ -327,11 +328,11 @@ impl<'a> Window<'a> {
327328 let _ = self . inner . xcb_connection . conn . flush ( ) ;
328329 }
329330
330- self . inner . mouse_cursor = mouse_cursor;
331+ self . inner . mouse_cursor . set ( mouse_cursor) ;
331332 }
332333
333334 pub fn close ( & mut self ) {
334- self . inner . close_requested = true ;
335+ self . inner . close_requested . set ( true ) ;
335336 }
336337
337338 pub fn has_focus ( & mut self ) -> bool {
@@ -444,14 +445,14 @@ impl WindowInner {
444445 if let Some ( parent_handle) = & self . parent_handle {
445446 if parent_handle. parent_did_drop ( ) {
446447 self . handle_must_close ( handler) ;
447- self . close_requested = false ;
448+ self . close_requested . set ( false ) ;
448449 }
449450 }
450451
451452 // Check if the user has requested the window to close
452- if self . close_requested {
453+ if self . close_requested . get ( ) {
453454 self . handle_must_close ( handler) ;
454- self . close_requested = false ;
455+ self . close_requested . set ( false ) ;
455456 }
456457 }
457458
0 commit comments