From 47703bbeafea2d689a33fce27e46b0e05c6bcd4e Mon Sep 17 00:00:00 2001 From: Walter Alejandro Iglesias Date: Fri, 24 Jul 2020 15:37:19 +0200 Subject: Warp pointer to last active window if there is no active client If a client is killed and the cursor lands in the root window, no client is focused. Attempting to cycle back to the last focused client will instead focus the previous-to-last. Add specific checks that make sure the cursor is positioned where the user expects it to be. This patch was taken from a bug report on openbsd-misc [1]. [1] https://marc.info/?l=openbsd-tech&m=155931484124288&w=2 --- kbfunc.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/kbfunc.c b/kbfunc.c index ef8630e..cde37e3 100644 --- a/kbfunc.c +++ b/kbfunc.c @@ -451,6 +451,16 @@ kbfunc_client_cycle(void *ctx, struct cargs *cargs) newcc->ptr.y = newcc->geom.h / 2; } client_ptr_warp(newcc); + + /* When no client is active warp pointer to last active */ + if (oldcc->flags & (CLIENT_ACTIVE)) + client_ptr_warp(newcc); + else if (oldcc->flags & (CLIENT_SKIP_CYCLE)) + client_ptr_warp(newcc); + else { + client_raise(oldcc); + client_ptr_warp(oldcc); + } } void -- cgit v1.2.3-2-gb3c3