aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Leonhardt <equinox.salexander@gmail.com>
2026-09-05 11:19:00 +0200
committerAlexander Leonhardt <equinox.salexander@gmail.com>
2026-09-05 11:19:00 +0200
commit61c438558ef09a9c13d204c9da4285fa705ee0aa (patch)
tree51b864c72b647b0447cddea8efad57a677a49f84
parent2554be4300170799a64c68b02a420b4fcdb90431 (diff)
downloaddwl-61c438558ef09a9c13d204c9da4285fa705ee0aa.tar.gz
dwl-61c438558ef09a9c13d204c9da4285fa705ee0aa.tar.bz2
dwl-61c438558ef09a9c13d204c9da4285fa705ee0aa.zip
Added warpcursor
-rw-r--r--dwl.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/dwl.c b/dwl.c
index 101a45f..4f58103 100644
--- a/dwl.c
+++ b/dwl.c
@@ -348,6 +348,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);
@@ -542,6 +543,7 @@ arrange(Monitor *m)
m->lt[m->sellt]->arrange(m);
motionnotify(0, NULL, 0, 0, 0, 0);
checkidleinhibitor(NULL);
+ warpcursor(focustop(selmon));
}
void
@@ -1411,6 +1413,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);
@@ -3006,6 +3012,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)
{