Skip to content

Commit

Permalink
feat(sei.c): cursorwarp patch
Browse files Browse the repository at this point in the history
  • Loading branch information
Fuwn committed Jan 15, 2024
1 parent f01436f commit 34cde22
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,5 @@ makepkg -si
- [nametag](https://dwm.suckless.org/patches/nametag/): Name tags using <kbd>mod+n</kbd>
- [centretitle](https://dwm.suckless.org/patches/centretitle/): Optionally
centre the focused client's title
- [cursor](https://dwm.suckless.org/patches/cursorwarp/): Warps the mouse cursor
to the center of the target window when changing focus
2 changes: 1 addition & 1 deletion config.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ static const char *wmname = "sei";
static unsigned int borderpx = 2; /* border pixel of windows */
static unsigned int snap = 32; /* snap pixel */
static const unsigned int systraypinning =
0; /* 0: sloppy systray follows selected monitor, >0: pin systray to monitor
1; /* 0: sloppy systray follows selected monitor, >0: pin systray to monitor
X */
static const unsigned int systrayonleft =
1; /* 0: systray in the right corner, >0: systray on left of status text */
Expand Down
12 changes: 12 additions & 0 deletions sei.c
Original file line number Diff line number Diff line change
Expand Up @@ -1282,6 +1282,9 @@ void focusmon(const Arg *arg) {
unfocus(selmon->sel, 0);
selmon = m;
focus(NULL);
if (selmon->sel)
XWarpPointer(dpy, None, selmon->sel->win, 0, 0, 0, 0, selmon->sel->w / 2,
selmon->sel->h / 2);
}

void focusstack(const Arg *arg) {
Expand All @@ -1296,6 +1299,7 @@ void focusstack(const Arg *arg) {
;
focus(c ? c : p);
restack(selmon);
XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w / 2, c->h / 2);
}

Atom getatomprop(Client *c, Atom prop) {
Expand Down Expand Up @@ -1657,6 +1661,8 @@ void manage(Window w, XWindowAttributes *wa) {
swallow(term, c);
arrange(c->mon);
focus(NULL);
if (c && c->mon == selmon)
XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w / 2, c->h / 2);
}

void mappingnotify(XEvent *e) {
Expand Down Expand Up @@ -2581,6 +2587,9 @@ void unmanage(Client *c, int destroyed) {
s->swallowing = NULL;
arrange(m);
focus(NULL);
if (m == selmon && m->sel)
XWarpPointer(dpy, None, m->sel->win, 0, 0, 0, 0, m->sel->w / 2,
m->sel->h / 2);
return;
}

Expand All @@ -2605,6 +2614,9 @@ void unmanage(Client *c, int destroyed) {
arrange(m);
focus(NULL);
updateclientlist();
if (m == selmon && m->sel)
XWarpPointer(dpy, None, m->sel->win, 0, 0, 0, 0, m->sel->w / 2,
m->sel->h / 2);
}
}

Expand Down

0 comments on commit 34cde22

Please sign in to comment.