1
+ use std:: cell:: Cell ;
1
2
use std:: error:: Error ;
2
3
use std:: ffi:: c_void;
3
4
use std:: os:: fd:: AsRawFd ;
@@ -101,11 +102,11 @@ struct WindowInner {
101
102
window_id : XWindow ,
102
103
window_info : WindowInfo ,
103
104
visual_id : Visualid ,
104
- mouse_cursor : MouseCursor ,
105
+ mouse_cursor : Cell < MouseCursor > ,
105
106
106
107
frame_interval : Duration ,
107
108
event_loop_running : bool ,
108
- close_requested : bool ,
109
+ close_requested : Cell < bool > ,
109
110
110
111
new_physical_size : Option < PhySize > ,
111
112
parent_handle : Option < ParentHandle > ,
@@ -115,7 +116,7 @@ struct WindowInner {
115
116
}
116
117
117
118
pub struct Window < ' a > {
118
- inner : & ' a mut WindowInner ,
119
+ inner : & ' a WindowInner ,
119
120
}
120
121
121
122
// Hack to allow sending a RawWindowHandle between threads. Do not make public
@@ -284,11 +285,11 @@ impl<'a> Window<'a> {
284
285
window_id,
285
286
window_info,
286
287
visual_id : visual_info. visual_id ,
287
- mouse_cursor : MouseCursor :: default ( ) ,
288
+ mouse_cursor : Cell :: new ( MouseCursor :: default ( ) ) ,
288
289
289
290
frame_interval : Duration :: from_millis ( 15 ) ,
290
291
event_loop_running : false ,
291
- close_requested : false ,
292
+ close_requested : Cell :: new ( false ) ,
292
293
293
294
new_physical_size : None ,
294
295
parent_handle,
@@ -312,8 +313,8 @@ impl<'a> Window<'a> {
312
313
Ok ( ( ) )
313
314
}
314
315
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 {
317
318
return ;
318
319
}
319
320
@@ -327,11 +328,11 @@ impl<'a> Window<'a> {
327
328
let _ = self . inner . xcb_connection . conn . flush ( ) ;
328
329
}
329
330
330
- self . inner . mouse_cursor = mouse_cursor;
331
+ self . inner . mouse_cursor . set ( mouse_cursor) ;
331
332
}
332
333
333
334
pub fn close ( & mut self ) {
334
- self . inner . close_requested = true ;
335
+ self . inner . close_requested . set ( true ) ;
335
336
}
336
337
337
338
pub fn has_focus ( & mut self ) -> bool {
@@ -444,14 +445,14 @@ impl WindowInner {
444
445
if let Some ( parent_handle) = & self . parent_handle {
445
446
if parent_handle. parent_did_drop ( ) {
446
447
self . handle_must_close ( handler) ;
447
- self . close_requested = false ;
448
+ self . close_requested . set ( false ) ;
448
449
}
449
450
}
450
451
451
452
// Check if the user has requested the window to close
452
- if self . close_requested {
453
+ if self . close_requested . get ( ) {
453
454
self . handle_must_close ( handler) ;
454
- self . close_requested = false ;
455
+ self . close_requested . set ( false ) ;
455
456
}
456
457
}
457
458
0 commit comments