Index | Thread | Search

From:
Walter Alejandro Iglesias <wai@roquesor.com>
Subject:
Re: cwm(1) warp pointer to prev when you close a window (PATCH) Ping!
To:
tech@openbsd.org
Date:
Mon, 8 Dec 2025 12:30:32 +0100

Download raw body.

Thread
The subject and the comment in the code explain what the diff does.

On Wed, Jul 30, 2025 at 03:04:58PM +0200, Walter Alejandro Iglesias wrote:
> A tweak and an improvement.
> 
> If the previous window in the stack is behind a third window covering
> the area where the pointer will warp, the third window will get the
> focus.  Raising first the previous window solves the problem.  Also, if
> the pointer is already in the window area there's no need to warp it.
> 

Index: client.c
===================================================================
RCS file: /cvs/xenocara/app/cwm/client.c,v
diff -u -p -r1.267 client.c
--- client.c	22 Mar 2023 08:27:36 -0000	1.267
+++ client.c	30 Jul 2025 10:41:07 -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,26 @@ client_remove(struct client_ctx *cc)
 	free(cc->res_class);
 	free(cc->res_name);
 	free(cc);
+
+	/*
+	 * Raise and warp pointer to previous window in stack when
+	 * a window is closed.
+	 */
+	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;
+
+	client_raise(prevcc);
+	xu_ptr_get(prevcc->win, &x, &y);
+	if (client_inbound(prevcc, x, y))
+		return;
+	client_ptr_warp(prevcc);
 }
 
 void


-- 
Walter