From 13f0f8ce2e4b30e0332a6060778fdd018e5c88c7 Mon Sep 17 00:00:00 2001 From: Marco Peereboom Date: Wed, 30 Sep 2009 18:02:18 +0000 Subject: [PATCH] Fix move_to_ws as fallout from killing cur_focus --- scrotwm.c | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/scrotwm.c b/scrotwm.c index da7e130..adb386d 100644 --- a/scrotwm.c +++ b/scrotwm.c @@ -1857,7 +1857,7 @@ void send_to_ws(struct swm_region *r, union arg *args) { int wsid = args->id; - struct ws_win *win = r->ws->focus; + struct ws_win *win = r->ws->focus, *winfocus = NULL; struct workspace *ws, *nws; Atom ws_idx_atom = 0; unsigned char ws_idx_str[SWM_PROPLEN]; @@ -1870,14 +1870,20 @@ send_to_ws(struct swm_region *r, union arg *args) ws = win->ws; nws = &win->s->ws[wsid]; - XUnmapWindow(display, win->id); - /* find a window to focus */ - ws->focus = TAILQ_PREV(win, ws_win_list, entry); - if (ws->focus == NULL) - ws->focus = TAILQ_FIRST(&ws->winlist); - if (ws->focus == win) - ws->focus = NULL; + winfocus = TAILQ_PREV(win, ws_win_list, entry); + if (TAILQ_FIRST(&ws->winlist) == win) + winfocus = TAILQ_NEXT(win, entry); + else { + winfocus = TAILQ_PREV(ws->focus, ws_win_list, entry); + if (winfocus == NULL) + winfocus = TAILQ_LAST(&ws->winlist, ws_win_list); + } + /* out of windows in ws so focus on nws instead */ + if (winfocus == NULL) + winfocus = win; + + XUnmapWindow(display, win->id); TAILQ_REMOVE(&ws->winlist, win, entry); @@ -1900,6 +1906,7 @@ send_to_ws(struct swm_region *r, union arg *args) nws->restack = 1; stack(); + focus_win(winfocus); } void -- 1.7.10.4