Skip to content

Commit

Permalink
use RefCell on Linux
Browse files Browse the repository at this point in the history
  • Loading branch information
amrbashir committed Sep 19, 2024
1 parent 1b4b5b4 commit e595125
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/platform_impl/linux/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ use gtk::{
glib::{self, translate::ToGlibPtr},
};
use gtk::{prelude::*, Settings};
use parking_lot::Mutex;

use crate::{
dpi::{LogicalPosition, LogicalSize, PhysicalPosition, PhysicalSize, Position, Size},
Expand Down Expand Up @@ -66,7 +65,7 @@ pub struct Window {
inner_size_constraints: RefCell<WindowSizeConstraints>,
/// Draw event Sender
draw_tx: crossbeam_channel::Sender<WindowId>,
preferred_theme: Mutex<Option<Theme>>,
preferred_theme: RefCell<Option<Theme>>,
}

impl Window {
Expand Down Expand Up @@ -307,7 +306,7 @@ impl Window {
minimized,
fullscreen: RefCell::new(attributes.fullscreen),
inner_size_constraints: RefCell::new(attributes.inner_size_constraints),
preferred_theme: Mutex::new(preferred_theme),
preferred_theme: RefCell::new(preferred_theme),
};

win.set_skip_taskbar(pl_attribs.skip_taskbar);
Expand Down Expand Up @@ -386,7 +385,7 @@ impl Window {
minimized,
fullscreen: RefCell::new(None),
inner_size_constraints: RefCell::new(WindowSizeConstraints::default()),
preferred_theme: Mutex::new(None),
preferred_theme: RefCell::new(None),
};

Ok(win)
Expand Down Expand Up @@ -942,7 +941,7 @@ impl Window {
}

pub fn theme(&self) -> Theme {
if let Some(theme) = *self.preferred_theme.lock() {
if let Some(theme) = *self.preferred_theme.borrow() {
return theme;
}

Expand All @@ -957,7 +956,7 @@ impl Window {
}

pub fn set_theme(&self, theme: Option<Theme>) {
*self.preferred_theme.lock() = theme;
*self.preferred_theme.borrow_mut() = theme;
if let Err(e) = self
.window_requests_tx
.send((WindowId::dummy(), WindowRequest::SetTheme(theme)))
Expand Down

0 comments on commit e595125

Please sign in to comment.