warp on move to group patch

This commit is contained in:
yosh 2023-01-06 20:49:54 -06:00
parent f33922312b
commit d3f660dbd7
3 changed files with 50 additions and 0 deletions

3
README
View File

@ -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

18
group.c
View File

@ -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) {

View File

@ -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) {