Skip to content

Commit 68a43ba

Browse files
committed
Fix workspace cleanup on RandR screenchange.
Fixes #127 and #120
1 parent 7880c3b commit 68a43ba

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

spectrwm.c

+14-8
Original file line numberDiff line numberDiff line change
@@ -11522,7 +11522,6 @@ scan_randr(int idx)
1152211522
int ncrtc = 0;
1152311523
#endif /* SWM_XRR_HAS_CRTC */
1152411524
struct swm_region *r;
11525-
struct ws_win *win;
1152611525
int num_screens;
1152711526
xcb_randr_get_screen_resources_current_cookie_t src;
1152811527
xcb_randr_get_screen_resources_current_reply_t *srr;
@@ -11597,13 +11596,8 @@ scan_randr(int idx)
1159711596
screen->height_in_pixels);
1159811597

1159911598
out:
11600-
/* Cleanup unused previously visible workspaces. */
11599+
/* The screen shouldn't focus on unused regions. */
1160111600
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. */
1160711601
if (screens[idx].r_focus == r)
1160811602
screens[idx].r_focus = NULL;
1160911603
}
@@ -11615,7 +11609,9 @@ void
1161511609
screenchange(xcb_randr_screen_change_notify_event_t *e)
1161611610
{
1161711611
struct swm_region *r;
11618-
int i, num_screens;
11612+
struct workspace *ws;
11613+
struct ws_win *win;
11614+
int i, j, num_screens;
1161911615

1162011616
DNPRINTF(SWM_D_EVENT, "screenchange: root: %#x\n", e->root);
1162111617

@@ -11648,6 +11644,16 @@ screenchange(xcb_randr_screen_change_notify_event_t *e)
1164811644
focus_region(r);
1164911645
}
1165011646

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+
1165111657
focus_flush();
1165211658

1165311659
/* Update workspace state and bar on all regions. */

0 commit comments

Comments
 (0)