From cee2b7fc791e89f89c6508afd795a32858394ed8 Mon Sep 17 00:00:00 2001 From: yosh Date: Thu, 5 Jan 2023 12:03:00 -0600 Subject: [PATCH] warp on close patch --- client.c | 19 +++++++++++++++++++ patches/warp-on-close.diff | 30 ++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+) create mode 100644 patches/warp-on-close.diff diff --git a/client.c b/client.c index 3cafac8..f7f6beb 100644 --- a/client.c +++ b/client.c @@ -653,6 +653,25 @@ client_wm_hints(struct client_ctx *cc) void client_close(struct client_ctx *cc) { + struct client_ctx *newcc = cc; + struct screen_ctx *sc = cc->sc; + + TAILQ_FOREACH(newcc, &sc->clientq, entry) { + if (newcc->gc != cc->gc) + continue; + if (newcc->flags & CLIENT_HIDDEN || + newcc->flags & CLIENT_IGNORE || (newcc == cc)) + continue; + break; + } + if (newcc != NULL) { + if (newcc->ptr.x < 0 || newcc->ptr.x > newcc->geom.w || + newcc->ptr.y < 0 || newcc->ptr.y > newcc->geom.h) { + newcc->ptr.x = newcc->geom.w / 2; + newcc->ptr.y = newcc->geom.h / 2; + } + client_ptr_warp(newcc); + } if (cc->flags & CLIENT_WM_DELETE_WINDOW) xu_send_clientmsg(cc->win, cwmh[WM_DELETE_WINDOW], CurrentTime); else diff --git a/patches/warp-on-close.diff b/patches/warp-on-close.diff new file mode 100644 index 0000000..11a9539 --- /dev/null +++ b/patches/warp-on-close.diff @@ -0,0 +1,30 @@ +diff --git a/client.c b/client.c +index 59bc7b0..9c04175 100644 +--- a/client.c ++++ b/client.c +@@ -652,6 +652,25 @@ client_wm_hints(struct client_ctx *cc) + void + client_close(struct client_ctx *cc) + { ++ struct client_ctx *newcc = cc; ++ struct screen_ctx *sc = cc->sc; ++ ++ TAILQ_FOREACH(newcc, &sc->clientq, entry) { ++ if (newcc->gc != cc->gc) ++ continue; ++ if (newcc->flags & CLIENT_HIDDEN || ++ newcc->flags & CLIENT_IGNORE || (newcc == cc)) ++ continue; ++ break; ++ } ++ if (newcc != NULL) { ++ if (newcc->ptr.x < 0 || newcc->ptr.x > newcc->geom.w || ++ newcc->ptr.y < 0 || newcc->ptr.y > newcc->geom.h) { ++ newcc->ptr.x = newcc->geom.w / 2; ++ newcc->ptr.y = newcc->geom.h / 2; ++ } ++ client_ptr_warp(newcc); ++ } + if (cc->flags & CLIENT_WM_DELETE_WINDOW) + xu_send_clientmsg(cc->win, cwmh[WM_DELETE_WINDOW], CurrentTime); + else