diff options
| author | Alexander Leonhardt <equinox.salexander@gmail.com> | |
|---|---|---|
| 2026-09-05 11:19:16 +0200 | ||
| committer | Alexander Leonhardt <equinox.salexander@gmail.com> | |
| 2026-09-05 11:19:16 +0200 | ||
| commit | b7503ea8749ce45fd48488af7c5f0005548c9326 (patch) | |
| tree | a233cdff7e00221591c3f9b09e07c90655eb225e | |
| parent | 5053813882d6a5eb79bed148e18e1dd34f13dae7 (diff) | |
| parent | 61c438558ef09a9c13d204c9da4285fa705ee0aa (diff) | |
| download | dwl-b7503ea8749ce45fd48488af7c5f0005548c9326.tar.gz dwl-b7503ea8749ce45fd48488af7c5f0005548c9326.tar.bz2 dwl-b7503ea8749ce45fd48488af7c5f0005548c9326.zip | |
Merge branch 'warpcursor' into merged
@@ -360,6 +360,7 @@ static void urgent(struct wl_listener *listener, void *data); static void view(const Arg *arg); static void virtualkeyboard(struct wl_listener *listener, void *data); static void virtualpointer(struct wl_listener *listener, void *data); +static void warpcursor(const Client *c); static Monitor *xytomon(double x, double y); static void xytonode(double x, double y, struct wlr_surface **psurface, Client **pc, LayerSurface **pl, double *nx, double *ny); @@ -561,6 +562,7 @@ arrange(Monitor *m) m->lt[m->sellt]->arrange(m); motionnotify(0, NULL, 0, 0, 0, 0); checkidleinhibitor(NULL); + warpcursor(focustop(selmon)); } void @@ -1430,6 +1432,10 @@ focusclient(Client *c, int lift) if (locked) return; + /* Warp cursor to center of client if it is outside */ + if (lift) + warpcursor(c); + /* Raise client in stacking order if requested */ if (c && lift) wlr_scene_node_raise_to_top(&c->scene->node); @@ -3157,6 +3163,27 @@ virtualpointer(struct wl_listener *listener, void *data) wlr_cursor_map_input_to_output(cursor, device, event->suggested_output); } +void +warpcursor(const Client *c) { + if (cursor_mode != CurNormal) { + return; + } + if (!c && selmon) { + wlr_cursor_warp_closest(cursor, + NULL, + selmon->w.x + selmon->w.width / 2.0 , + selmon->w.y + selmon->w.height / 2.0); + } + else if ( c && (cursor->x < c->geom.x || + cursor->x > c->geom.x + c->geom.width || + cursor->y < c->geom.y || + cursor->y > c->geom.y + c->geom.height)) + wlr_cursor_warp_closest(cursor, + NULL, + c->geom.x + c->geom.width / 2.0, + c->geom.y + c->geom.height / 2.0); +} + Monitor * xytomon(double x, double y) { |