@@ -305,30 +305,28 @@ impl WindowManager {
305
305
306
306
let mut needs_reconciliation = false ;
307
307
308
- for ( i, monitors) in self . monitors ( ) . iter ( ) . enumerate ( ) {
309
- for ( j, workspace) in monitors. workspaces ( ) . iter ( ) . enumerate ( ) {
310
- if workspace. contains_window ( window. hwnd ) && focused_pair != ( i, j) {
311
- // At this point we know we are going to send a notification to the workspace reconciliator
312
- // So we get the topmost window returned by EnumWindows, which is almost always the window
313
- // that has been selected by alt-tab
314
- if let Ok ( alt_tab_windows) = WindowsApi :: alt_tab_windows ( ) {
315
- if let Some ( first) =
316
- alt_tab_windows. iter ( ) . find ( |w| w. title ( ) . is_ok ( ) )
317
- {
318
- // If our record of this HWND hasn't been updated in over a minute
319
- let mut instant = ALT_TAB_HWND_INSTANT . lock ( ) ;
320
- if instant. elapsed ( ) . gt ( & Duration :: from_secs ( 1 ) ) {
321
- // Update our record with the HWND we just found
322
- ALT_TAB_HWND . store ( Some ( first. hwnd ) ) ;
323
- // Update the timestamp of our record
324
- * instant = Instant :: now ( ) ;
325
- }
308
+ if let Some ( ( m_idx, w_idx) ) = self . known_hwnds . get ( & window. hwnd ) {
309
+ if focused_pair != ( * m_idx, * w_idx) {
310
+ // At this point we know we are going to send a notification to the workspace reconciliator
311
+ // So we get the topmost window returned by EnumWindows, which is almost always the window
312
+ // that has been selected by alt-tab
313
+ if let Ok ( alt_tab_windows) = WindowsApi :: alt_tab_windows ( ) {
314
+ if let Some ( first) =
315
+ alt_tab_windows. iter ( ) . find ( |w| w. title ( ) . is_ok ( ) )
316
+ {
317
+ // If our record of this HWND hasn't been updated in over a minute
318
+ let mut instant = ALT_TAB_HWND_INSTANT . lock ( ) ;
319
+ if instant. elapsed ( ) . gt ( & Duration :: from_secs ( 1 ) ) {
320
+ // Update our record with the HWND we just found
321
+ ALT_TAB_HWND . store ( Some ( first. hwnd ) ) ;
322
+ // Update the timestamp of our record
323
+ * instant = Instant :: now ( ) ;
326
324
}
327
325
}
328
-
329
- workspace_reconciliator:: send_notification ( i, j) ;
330
- needs_reconciliation = true ;
331
326
}
327
+
328
+ workspace_reconciliator:: send_notification ( * m_idx, * w_idx) ;
329
+ needs_reconciliation = true ;
332
330
}
333
331
}
334
332
@@ -339,11 +337,14 @@ impl WindowManager {
339
337
// duplicates across multiple workspaces, as it results in ghost layout tiles.
340
338
let mut proceed = true ;
341
339
342
- for ( i, monitor) in self . monitors ( ) . iter ( ) . enumerate ( ) {
343
- for ( j, workspace) in monitor. workspaces ( ) . iter ( ) . enumerate ( ) {
344
- if workspace. contains_window ( window. hwnd )
345
- && i != self . focused_monitor_idx ( )
346
- && j != monitor. focused_workspace_idx ( )
340
+ if let Some ( ( m_idx, w_idx) ) = self . known_hwnds . get ( & window. hwnd ) {
341
+ if let Some ( focused_workspace_idx) = self
342
+ . monitors ( )
343
+ . get ( * m_idx)
344
+ . map ( |m| m. focused_workspace_idx ( ) )
345
+ {
346
+ if * m_idx != self . focused_monitor_idx ( )
347
+ && * w_idx != focused_workspace_idx
347
348
{
348
349
tracing:: debug!(
349
350
"ignoring show event for window already associated with another workspace"
@@ -502,15 +503,9 @@ impl WindowManager {
502
503
// This will be true if we have moved to another monitor
503
504
let mut moved_across_monitors = false ;
504
505
505
- for ( i, monitors) in self . monitors ( ) . iter ( ) . enumerate ( ) {
506
- for workspace in monitors. workspaces ( ) {
507
- if workspace. contains_window ( window. hwnd ) && i != target_monitor_idx {
508
- moved_across_monitors = true ;
509
- break ;
510
- }
511
- }
512
- if moved_across_monitors {
513
- break ;
506
+ if let Some ( ( m_idx, _) ) = self . known_hwnds . get ( & window. hwnd ) {
507
+ if * m_idx != target_monitor_idx {
508
+ moved_across_monitors = true ;
514
509
}
515
510
}
516
511
0 commit comments