Skip to content

Commit 505e36d

Browse files
committed
Make CosmicWindowInternal/CosmicStackInternal not Clone
`IcedElement` uses `Arc` internally (and compares with `Arc::ptr_eq`). So these structs are never cloned, and probably shouldn't be.
1 parent 6e41646 commit 505e36d

File tree

2 files changed

+35
-36
lines changed

2 files changed

+35
-36
lines changed

src/shell/element/stack.rs

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ use std::{
6464
fmt,
6565
hash::Hash,
6666
sync::{
67-
Arc, LazyLock, Mutex,
67+
LazyLock, Mutex,
6868
atomic::{AtomicBool, AtomicU8, AtomicUsize, Ordering},
6969
},
7070
};
@@ -91,21 +91,21 @@ impl fmt::Debug for CosmicStack {
9191
}
9292
}
9393

94-
#[derive(Debug, Clone)]
94+
#[derive(Debug)]
9595
pub struct CosmicStackInternal {
96-
windows: Arc<Mutex<Vec<CosmicSurface>>>,
97-
active: Arc<AtomicUsize>,
98-
activated: Arc<AtomicBool>,
99-
group_focused: Arc<AtomicBool>,
100-
previous_index: Arc<Mutex<Option<(Serial, usize)>>>,
101-
scroll_to_focus: Arc<AtomicBool>,
102-
previous_keyboard: Arc<AtomicUsize>,
103-
pointer_entered: Arc<AtomicU8>,
104-
reenter: Arc<AtomicBool>,
105-
potential_drag: Arc<Mutex<Option<usize>>>,
106-
override_alive: Arc<AtomicBool>,
107-
geometry: Arc<Mutex<Option<Rectangle<i32, Global>>>>,
108-
mask: Arc<Mutex<Option<tiny_skia::Mask>>>,
96+
windows: Mutex<Vec<CosmicSurface>>,
97+
active: AtomicUsize,
98+
activated: AtomicBool,
99+
group_focused: AtomicBool,
100+
previous_index: Mutex<Option<(Serial, usize)>>,
101+
scroll_to_focus: AtomicBool,
102+
previous_keyboard: AtomicUsize,
103+
pointer_entered: AtomicU8,
104+
reenter: AtomicBool,
105+
potential_drag: Mutex<Option<usize>>,
106+
override_alive: AtomicBool,
107+
geometry: Mutex<Option<Rectangle<i32, Global>>>,
108+
mask: Mutex<Option<tiny_skia::Mask>>,
109109
}
110110

111111
impl CosmicStackInternal {
@@ -146,19 +146,19 @@ impl CosmicStack {
146146
let width = windows[0].geometry().size.w;
147147
CosmicStack(IcedElement::new(
148148
CosmicStackInternal {
149-
windows: Arc::new(Mutex::new(windows)),
150-
active: Arc::new(AtomicUsize::new(0)),
151-
activated: Arc::new(AtomicBool::new(false)),
152-
group_focused: Arc::new(AtomicBool::new(false)),
153-
previous_index: Arc::new(Mutex::new(None)),
154-
scroll_to_focus: Arc::new(AtomicBool::new(false)),
155-
previous_keyboard: Arc::new(AtomicUsize::new(0)),
156-
pointer_entered: Arc::new(AtomicU8::new(0)),
157-
reenter: Arc::new(AtomicBool::new(false)),
158-
potential_drag: Arc::new(Mutex::new(None)),
159-
override_alive: Arc::new(AtomicBool::new(true)),
160-
geometry: Arc::new(Mutex::new(None)),
161-
mask: Arc::new(Mutex::new(None)),
149+
windows: Mutex::new(windows),
150+
active: AtomicUsize::new(0),
151+
activated: AtomicBool::new(false),
152+
group_focused: AtomicBool::new(false),
153+
previous_index: Mutex::new(None),
154+
scroll_to_focus: AtomicBool::new(false),
155+
previous_keyboard: AtomicUsize::new(0),
156+
pointer_entered: AtomicU8::new(0),
157+
reenter: AtomicBool::new(false),
158+
potential_drag: Mutex::new(None),
159+
override_alive: AtomicBool::new(true),
160+
geometry: Mutex::new(None),
161+
mask: Mutex::new(None),
162162
},
163163
(width, TAB_HEIGHT),
164164
handle,

src/shell/element/window.rs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ use std::{
5050
fmt,
5151
hash::Hash,
5252
sync::{
53-
Arc, Mutex,
53+
Mutex,
5454
atomic::{AtomicBool, AtomicU8, Ordering},
5555
},
5656
};
@@ -72,13 +72,12 @@ impl fmt::Debug for CosmicWindow {
7272
}
7373
}
7474

75-
#[derive(Clone)]
7675
pub struct CosmicWindowInternal {
7776
pub(super) window: CosmicSurface,
78-
activated: Arc<AtomicBool>,
77+
activated: AtomicBool,
7978
/// TODO: This needs to be per seat
80-
pointer_entered: Arc<AtomicU8>,
81-
last_title: Arc<Mutex<String>>,
79+
pointer_entered: AtomicU8,
80+
last_title: Mutex<String>,
8281
}
8382

8483
impl fmt::Debug for CosmicWindowInternal {
@@ -192,9 +191,9 @@ impl CosmicWindow {
192191
CosmicWindow(IcedElement::new(
193192
CosmicWindowInternal {
194193
window,
195-
activated: Arc::new(AtomicBool::new(false)),
196-
pointer_entered: Arc::new(AtomicU8::new(0)),
197-
last_title: Arc::new(Mutex::new(last_title)),
194+
activated: AtomicBool::new(false),
195+
pointer_entered: AtomicU8::new(0),
196+
last_title: Mutex::new(last_title),
198197
},
199198
(width, SSD_HEIGHT),
200199
handle,

0 commit comments

Comments
 (0)