From: Walter Alejandro Iglesias Subject: cwm(1), when closing a window, pass focus to prev in stack To: tech@openbsd.org Date: Mon, 22 Jun 2026 09:49:42 +0200 This is a ping of a proposal I made last year. Current behaviour: when you close a window, whatever other window the pointer lands on gets the focus. Behavior proposed: when you close a window, the pointer warps (passing the focus) to the previous window in the stack. Conveniently, raise it first, otherwise if it's behind another window the latter will get the focus instead. The downside of this change is that when closing a window using the mouse, by clicking on a dialog "Close" button or "Quit" in the application menu, the pointer will jump while you're manually controlling the mouse, what can be confusing. Personally I find this less undesirable than randomly giving input to any client each time I close a window, as happens with the current behavior (which in some cases could lead to dangerous mistakes). Index: client.c =================================================================== RCS file: /cvs/xenocara/app/cwm/client.c,v diff -u -p -u -p -r1.267 client.c --- client.c 22 Mar 2023 08:27:36 -0000 1.267 +++ client.c 20 Jun 2026 11:05:37 -0000 @@ -210,6 +210,8 @@ client_remove(struct client_ctx *cc) { struct screen_ctx *sc = cc->sc; struct winname *wn; + struct client_ctx *prevcc; + int x, y; TAILQ_REMOVE(&sc->clientq, cc, entry); @@ -230,6 +232,23 @@ client_remove(struct client_ctx *cc) free(cc->res_class); free(cc->res_name); free(cc); + + if (TAILQ_EMPTY(&sc->clientq)) + return; + + prevcc = TAILQ_FIRST(&sc->clientq); + + /* Avoid windows with skip client flag or from other groups */ + if ((prevcc->flags & (CLIENT_SKIP_CYCLE)) && + ! (prevcc->flags & CWM_CYCLE_INGROUP)) + return; + + /* Raise previous window and warp the pointer to it */ + client_raise(prevcc); + xu_ptr_get(prevcc->win, &x, &y); + if (client_inbound(prevcc, x, y)) + return; + client_ptr_warp(prevcc); } void -- Walter