From d3f660dbd7aa2e52034b58bab8ab495359a3a5ac Mon Sep 17 00:00:00 2001 From: yosh Date: Fri, 6 Jan 2023 20:49:54 -0600 Subject: [PATCH] warp on move to group patch --- README | 3 +++ group.c | 18 ++++++++++++++++++ patches/warp-on-movetogroup.diff | 29 +++++++++++++++++++++++++++++ 3 files changed, 50 insertions(+) create mode 100644 patches/warp-on-movetogroup.diff diff --git a/README b/README index 33ca846..3976698 100644 --- a/README +++ b/README @@ -8,6 +8,9 @@ The patches applied in the patched branch include: mimic the layout of awesomewm's fair layouts, because I like those layouts * warp-on-close.diff - when closing a window with window-close, the pointer automatically focuses the next available window in the group +* warp-on-movetogroup.diff - when moving a window to another group with + window-movetogroup-n, the pointer automatically focuses the next available + window in the group you can clone the linux branch of this repository and apply patches individually if you don't want all the patches the patched branch offers diff --git a/group.c b/group.c index af4c759..9c93497 100644 --- a/group.c +++ b/group.c @@ -152,6 +152,24 @@ group_movetogroup(struct client_ctx *cc, int idx) { struct screen_ctx *sc = cc->sc; struct group_ctx *gc; + struct client_ctx *newcc = cc; + + 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); + } TAILQ_FOREACH(gc, &sc->groupq, entry) { if (gc->num == idx) { diff --git a/patches/warp-on-movetogroup.diff b/patches/warp-on-movetogroup.diff new file mode 100644 index 0000000..1babb71 --- /dev/null +++ b/patches/warp-on-movetogroup.diff @@ -0,0 +1,29 @@ +diff --git a/group.c b/group.c +index af4c759..9c93497 100644 +--- a/group.c ++++ b/group.c +@@ -152,6 +152,24 @@ group_movetogroup(struct client_ctx *cc, int idx) + { + struct screen_ctx *sc = cc->sc; + struct group_ctx *gc; ++ struct client_ctx *newcc = cc; ++ ++ 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); ++ } + + TAILQ_FOREACH(gc, &sc->groupq, entry) { + if (gc->num == idx) {