@@ -11522,7 +11522,6 @@ scan_randr(int idx)
11522
11522
int ncrtc = 0 ;
11523
11523
#endif /* SWM_XRR_HAS_CRTC */
11524
11524
struct swm_region * r ;
11525
- struct ws_win * win ;
11526
11525
int num_screens ;
11527
11526
xcb_randr_get_screen_resources_current_cookie_t src ;
11528
11527
xcb_randr_get_screen_resources_current_reply_t * srr ;
@@ -11597,13 +11596,8 @@ scan_randr(int idx)
11597
11596
screen -> height_in_pixels );
11598
11597
11599
11598
out :
11600
- /* Cleanup unused previously visible workspaces . */
11599
+ /* The screen shouldn't focus on unused regions . */
11601
11600
TAILQ_FOREACH (r , & screens [idx ].orl , entry ) {
11602
- TAILQ_FOREACH (win , & r -> ws -> winlist , entry )
11603
- unmap_window (win );
11604
- r -> ws -> state = SWM_WS_STATE_HIDDEN ;
11605
-
11606
- /* The screen shouldn't focus on an unused region. */
11607
11601
if (screens [idx ].r_focus == r )
11608
11602
screens [idx ].r_focus = NULL ;
11609
11603
}
@@ -11615,7 +11609,9 @@ void
11615
11609
screenchange (xcb_randr_screen_change_notify_event_t * e )
11616
11610
{
11617
11611
struct swm_region * r ;
11618
- int i , num_screens ;
11612
+ struct workspace * ws ;
11613
+ struct ws_win * win ;
11614
+ int i , j , num_screens ;
11619
11615
11620
11616
DNPRINTF (SWM_D_EVENT , "screenchange: root: %#x\n" , e -> root );
11621
11617
@@ -11648,6 +11644,16 @@ screenchange(xcb_randr_screen_change_notify_event_t *e)
11648
11644
focus_region (r );
11649
11645
}
11650
11646
11647
+ /* Cleanup unused previously visible workspaces. */
11648
+ for (j = 0 ; j < workspace_limit ; j ++ ) {
11649
+ ws = & screens [i ].ws [j ];
11650
+ if (ws -> r == NULL && ws -> state != SWM_WS_STATE_HIDDEN ) {
11651
+ TAILQ_FOREACH (win , & ws -> winlist , entry )
11652
+ unmap_window (win );
11653
+ ws -> state = SWM_WS_STATE_HIDDEN ;
11654
+ }
11655
+ }
11656
+
11651
11657
focus_flush ();
11652
11658
11653
11659
/* Update workspace state and bar on all regions. */
0 commit comments