diff options
| author | pml68 <tutorialmester@gmail.com> | 2024-02-11 12:02:25 +0100 |
|---|---|---|
| committer | pml68 <tutorialmester@gmail.com> | 2024-02-11 12:02:25 +0100 |
| commit | 0fc599dd50ff47717f6dc095c9d2f077030c909c (patch) | |
| tree | ae99905e28d2aa12a5a3c38e49bd29b6d425397b /dwm/dwm.c | |
| parent | feat: add shiftviewclients patch, remove unused tagkeys (diff) | |
| download | suckless-setup-0fc599dd50ff47717f6dc095c9d2f077030c909c.tar.gz | |
feat: add warp patch
Diffstat (limited to 'dwm/dwm.c')
| -rw-r--r-- | dwm/dwm.c | 26 |
1 files changed, 26 insertions, 0 deletions
@@ -229,6 +229,7 @@ static void updatetitle(Client *c); static void updatewindowtype(Client *c); static void updatewmhints(Client *c); static void view(const Arg *arg); +static void warp(const Client *c); static Client *wintoclient(Window w); static Monitor *wintomon(Window w); static int xerror(Display *dpy, XErrorEvent *ee); @@ -841,6 +842,7 @@ focusmon(const Arg *arg) unfocus(selmon->sel, 0); selmon = m; focus(NULL); + warp(selmon->sel); } void @@ -1407,6 +1409,8 @@ restack(Monitor *m) wc.sibling = c->win; } } + if (m == selmon && (m->tagset[m->seltags] & m->sel->tags) && m->lt[m->sellt]->arrange != &monocle) + warp(m->sel); XSync(dpy, False); while (XCheckMaskEvent(dpy, EnterWindowMask, &ev)); } @@ -2137,6 +2141,28 @@ view(const Arg *arg) arrange(selmon); } +void +warp(const Client *c) +{ + int x, y; + + if (!c) { + XWarpPointer(dpy, None, root, 0, 0, 0, 0, selmon->wx + selmon->ww / 2, selmon->wy + selmon->wh / 2); + return; + } + + if (!getrootptr(&x, &y) || + (x > c->x - c->bw && + y > c->y - c->bw && + x < c->x + c->w + c->bw*2 && + y < c->y + c->h + c->bw*2) || + (y > c->mon->by && y < c->mon->by + bh) || + (c->mon->topbar && !y)) + return; + + XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w / 2, c->h / 2); +} + Client * wintoclient(Window w) { |
