diff options
author | Squibid <me@zacharyscheiman.com> | 2025-02-11 21:07:14 -0600 |
---|---|---|
committer | Squibid <me@zacharyscheiman.com> | 2025-02-11 21:07:14 -0600 |
commit | 22891d3da5c7f06e80620d24599c0f12b6c5d18b (patch) | |
tree | 9a761a95c2828b180fbc28b36c89dd1e6b76538f /dwl.c | |
parent | 6539e07bbd39f0f2ed04331121f511d7b28a442f (diff) | |
download | dwl-22891d3da5c7f06e80620d24599c0f12b6c5d18b.tar.gz dwl-22891d3da5c7f06e80620d24599c0f12b6c5d18b.tar.bz2 dwl-22891d3da5c7f06e80620d24599c0f12b6c5d18b.zip |
add warp cursor
Diffstat (limited to 'dwl.c')
-rw-r--r-- | dwl.c | 36 |
1 files changed, 36 insertions, 0 deletions
@@ -1687,6 +1687,8 @@ focusclient(Client *c, int lift) void focusmon(const Arg *arg) { + Client *c; + int i = 0, nmons = wl_list_length(&mons); if (nmons) { do /* don't switch to disabled mons */ @@ -1694,6 +1696,16 @@ focusmon(const Arg *arg) while (!selmon->wlr_output->enabled && i++ < nmons); } focusclient(focustop(selmon), 1); + + if (warpcursor) { + wlr_cursor_warp_closest(cursor, NULL, selmon->w.x + selmon->w.width / 2.0, + selmon->w.y + selmon->w.height / 2.0); + c = focustop(selmon); + if (c) { + wlr_cursor_warp_closest(cursor, NULL, c->geom.x + c->geom.width / 2.0, + c->geom.y + c->geom.height / 2.0); + } + } } void @@ -1720,6 +1732,11 @@ focusstack(const Arg *arg) } /* If only one client is visible on selmon, then c == sel */ focusclient(c, 1); + + if (warpcursor) { + wlr_cursor_warp_closest( cursor, NULL, c->geom.x + c->geom.width / 2.0, + c->geom.y + c->geom.height / 2.0); + } } /* We probably should change the name of this, it sounds like @@ -1780,6 +1797,7 @@ handlesig(int signo) void incnmaster(const Arg *arg) { + Client *c; const MonitorRule *r; if (!arg || !selmon) @@ -1791,6 +1809,15 @@ incnmaster(const Arg *arg) } selmon->nmaster = MAX(selmon->nmaster + arg->i, 0); arrange(selmon); + + + if (warpcursor) { + c = focustop(selmon); + if (c) { + wlr_cursor_warp_closest(cursor, NULL, c->geom.x + c->geom.width / 2.0, + c->geom.y + c->geom.height / 2.0); + } + } } void @@ -2580,6 +2607,7 @@ setmfact(const Arg *arg) { float f; const MonitorRule *r; + Client *c; if (!arg || !selmon || !selmon->lt[selmon->sellt]->arrange) return; @@ -2593,6 +2621,14 @@ setmfact(const Arg *arg) else return; arrange(selmon); + + if (warpcursor) { + c = focustop(selmon); + if (c) { + wlr_cursor_warp_closest(cursor, NULL, c->geom.x + c->geom.width / 2.0, + c->geom.y + c->geom.height / 2.0); + } + } } void |