Skip to content

Commit b35ad79

Browse files
committed
fix: don't snap to non-visible windows
1 parent 0ee2748 commit b35ad79

1 file changed

Lines changed: 21 additions & 1 deletion

File tree

‎player/src/gui.rs‎

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,8 @@ struct WindowEdges {
165165

166166
width: i32,
167167
height: i32,
168+
169+
shown: bool,
168170
}
169171
impl WindowEdges {
170172
fn update(&mut self, win: &DoubleWindow) {
@@ -175,6 +177,8 @@ impl WindowEdges {
175177

176178
self.width = win.width();
177179
self.height = win.height();
180+
181+
self.shown = win.visible();
178182
}
179183
}
180184

@@ -285,6 +289,8 @@ impl UIThread {
285289

286290
// i made the name short so it doesnt autoformat the lines above on to multiple lines
287291
// but also it probably shouldnt be in scope as `e` so (lol?)
292+
// TODO i forget what i was gonna do here so uhh
293+
let edges_state = e.clone();
288294
drop(e);
289295

290296
while self.app.wait() {
@@ -337,16 +343,28 @@ impl UIThread {
337343
self.tx
338344
.send(UIEvent::ConnectionDlg(ConnectionDlgEvent::BtnRefresh))
339345
.unwrap();
346+
edges_state
347+
.blocking_write()
348+
.update_window(2, &self.connection_gui.main_win);
340349
}
341350
UIEvent::BtnQueue => {
342351
self.queue_gui.main_win.show();
343352
//ui_tx.send(UIEvent::Update(UIUpdateEvent::UpdateQueue(self.queue.clone())));
353+
edges_state
354+
.blocking_write()
355+
.update_window(1, &self.queue_gui.main_win);
344356
}
345357
UIEvent::HideQueue => {
346358
self.queue_gui.main_win.hide();
359+
edges_state
360+
.blocking_write()
361+
.update_window(1, &self.queue_gui.main_win);
347362
}
348363
UIEvent::HideConnectionWindow => {
349364
self.connection_gui.main_win.hide();
365+
edges_state
366+
.blocking_write()
367+
.update_window(2, &self.connection_gui.main_win);
350368
}
351369
UIEvent::ShowPrefsWindow => {
352370
self.prefs_gui.main_win.show();
@@ -648,7 +666,9 @@ fn handle_window_drag(
648666
.iter()
649667
.enumerate()
650668
// don't snap to ourself
651-
.filter_map(|(i, o)| if i == id { None } else { Some(o) });
669+
.filter_map(|(i, o)| if i == id { None } else { Some(o) })
670+
// don't snap to non-visible windows
671+
.filter(|e| e.shown);
652672

653673
let mut left_right_edges = valid_edges
654674
.clone()

0 commit comments

Comments
 (0)