@@ -6,7 +6,10 @@ use std::{
66 cell:: RefCell ,
77 collections:: VecDeque ,
88 rc:: Rc ,
9- sync:: atomic:: { AtomicBool , AtomicI32 , Ordering } ,
9+ sync:: {
10+ atomic:: { AtomicBool , AtomicI32 , Ordering } ,
11+ RwLock ,
12+ } ,
1013} ;
1114
1215use gtk:: {
@@ -63,11 +66,11 @@ pub struct Window {
6366 maximized : Rc < AtomicBool > ,
6467 is_always_on_top : Rc < AtomicBool > ,
6568 minimized : Rc < AtomicBool > ,
66- fullscreen : RefCell < Option < Fullscreen > > ,
67- inner_size_constraints : RefCell < WindowSizeConstraints > ,
69+ fullscreen : RwLock < Option < Fullscreen > > ,
70+ inner_size_constraints : RwLock < WindowSizeConstraints > ,
6871 /// Draw event Sender
6972 draw_tx : crossbeam_channel:: Sender < WindowId > ,
70- preferred_theme : RefCell < Option < Theme > > ,
73+ preferred_theme : RwLock < Option < Theme > > ,
7174 css_provider : CssProvider ,
7275}
7376
@@ -288,9 +291,9 @@ impl Window {
288291 maximized,
289292 minimized,
290293 is_always_on_top,
291- fullscreen : RefCell :: new ( attributes. fullscreen ) ,
292- inner_size_constraints : RefCell :: new ( attributes. inner_size_constraints ) ,
293- preferred_theme : RefCell :: new ( preferred_theme) ,
294+ fullscreen : RwLock :: new ( attributes. fullscreen ) ,
295+ inner_size_constraints : RwLock :: new ( attributes. inner_size_constraints ) ,
296+ preferred_theme : RwLock :: new ( preferred_theme) ,
294297 css_provider : CssProvider :: new ( ) ,
295298 } ;
296299
@@ -431,9 +434,9 @@ impl Window {
431434 maximized,
432435 minimized,
433436 is_always_on_top,
434- fullscreen : RefCell :: new ( None ) ,
435- inner_size_constraints : RefCell :: new ( WindowSizeConstraints :: default ( ) ) ,
436- preferred_theme : RefCell :: new ( None ) ,
437+ fullscreen : RwLock :: new ( None ) ,
438+ inner_size_constraints : RwLock :: new ( WindowSizeConstraints :: default ( ) ) ,
439+ preferred_theme : RwLock :: new ( None ) ,
437440 css_provider : CssProvider :: new ( ) ,
438441 } ;
439442
@@ -535,22 +538,22 @@ impl Window {
535538
536539 pub fn set_min_inner_size ( & self , size : Option < Size > ) {
537540 let ( width, height) = size. map ( crate :: extract_width_height) . unzip ( ) ;
538- let mut size_constraints = self . inner_size_constraints . borrow_mut ( ) ;
541+ let mut size_constraints = self . inner_size_constraints . write ( ) . unwrap ( ) ;
539542 size_constraints. min_width = width;
540543 size_constraints. min_height = height;
541544 self . set_size_constraints ( * size_constraints)
542545 }
543546
544547 pub fn set_max_inner_size ( & self , size : Option < Size > ) {
545548 let ( width, height) = size. map ( crate :: extract_width_height) . unzip ( ) ;
546- let mut size_constraints = self . inner_size_constraints . borrow_mut ( ) ;
549+ let mut size_constraints = self . inner_size_constraints . write ( ) . unwrap ( ) ;
547550 size_constraints. max_width = width;
548551 size_constraints. max_height = height;
549552 self . set_size_constraints ( * size_constraints)
550553 }
551554
552555 pub fn set_inner_size_constraints ( & self , constraints : WindowSizeConstraints ) {
553- * self . inner_size_constraints . borrow_mut ( ) = constraints;
556+ * self . inner_size_constraints . write ( ) . unwrap ( ) = constraints;
554557 self . set_size_constraints ( constraints)
555558 }
556559
@@ -698,7 +701,7 @@ impl Window {
698701 }
699702
700703 pub fn set_fullscreen ( & self , fullscreen : Option < Fullscreen > ) {
701- self . fullscreen . replace ( fullscreen. clone ( ) ) ;
704+ * self . fullscreen . write ( ) . unwrap ( ) = fullscreen. clone ( ) ;
702705 if let Err ( e) = self
703706 . window_requests_tx
704707 . send ( ( self . window_id , WindowRequest :: Fullscreen ( fullscreen) ) )
@@ -708,7 +711,7 @@ impl Window {
708711 }
709712
710713 pub fn fullscreen ( & self ) -> Option < Fullscreen > {
711- self . fullscreen . borrow ( ) . clone ( )
714+ self . fullscreen . read ( ) . unwrap ( ) . clone ( )
712715 }
713716
714717 pub fn set_decorations ( & self , decorations : bool ) {
@@ -1025,7 +1028,7 @@ impl Window {
10251028 }
10261029
10271030 pub fn theme ( & self ) -> Theme {
1028- if let Some ( theme) = * self . preferred_theme . borrow ( ) {
1031+ if let Some ( theme) = * self . preferred_theme . read ( ) . unwrap ( ) {
10291032 return theme;
10301033 }
10311034
@@ -1040,7 +1043,7 @@ impl Window {
10401043 }
10411044
10421045 pub fn set_theme ( & self , theme : Option < Theme > ) {
1043- * self . preferred_theme . borrow_mut ( ) = theme;
1046+ * self . preferred_theme . write ( ) . unwrap ( ) = theme;
10441047 if let Err ( e) = self
10451048 . window_requests_tx
10461049 . send ( ( WindowId :: dummy ( ) , WindowRequest :: SetTheme ( theme) ) )
0 commit comments