From: Marco Peereboom Date: Tue, 3 Feb 2009 00:54:35 +0000 (+0000) Subject: Oops do some focus magic just as before. Note this is still hosed due to X-Git-Url: https://jasonwoof.com/gitweb/?a=commitdiff_plain;h=960330104901464793c7d129f6de51575509739d;p=spectrwm.git Oops do some focus magic just as before. Note this is still hosed due to enternotify but that is an older issue. --- diff --git a/scrotwm.c b/scrotwm.c index c5a225b..43ce724 100644 --- a/scrotwm.c +++ b/scrotwm.c @@ -2128,11 +2128,25 @@ manage_window(Window id) void unmanage_window(struct ws_win *win) { + struct workspace *ws; + if (win == NULL) return; DNPRINTF(SWM_D_MISC, "unmanage_window: %lu\n", win->id); + ws = win->ws; + /* find a window to focus */ + if (ws->focus == win) + ws->focus = TAILQ_PREV(win, ws_win_list, entry); + if (ws->focus == NULL) + ws->focus = TAILQ_FIRST(&ws->winlist); + if (ws->focus == NULL || ws->focus == win) { + ws->focus = NULL; + unfocus_all(); + } else + focus_win(ws->focus); + TAILQ_REMOVE(&win->ws->winlist, win, entry); set_win_state(win, WithdrawnState); if (win->ch.res_class) @@ -2213,22 +2227,10 @@ destroynotify(XEvent *e) { struct ws_win *win; XDestroyWindowEvent *ev = &e->xdestroywindow; - struct workspace *ws; DNPRINTF(SWM_D_EVENT, "destroynotify: window %lu\n", ev->window); if ((win = find_window(ev->window)) != NULL) { - ws = win->ws; - /* find a window to focus */ - if (ws->focus == win) - ws->focus = TAILQ_PREV(win, ws_win_list, entry); - if (ws->focus == NULL) - ws->focus = TAILQ_FIRST(&ws->winlist); - if (ws->focus == NULL || ws->focus == win) { - ws->focus = NULL; - unfocus_all(); - } else - focus_win(ws->focus); unmanage_window(win); stack(); }