aboutsummaryrefslogtreecommitdiffstats
path: root/dwl.c
diff options
context:
space:
mode:
authorAlexander Leonhardt <equinox.salexander@gmail.com>
2026-09-05 11:19:16 +0200
committerAlexander Leonhardt <equinox.salexander@gmail.com>
2026-09-05 11:19:16 +0200
commitb7503ea8749ce45fd48488af7c5f0005548c9326 (patch)
treea233cdff7e00221591c3f9b09e07c90655eb225e /dwl.c
parent5053813882d6a5eb79bed148e18e1dd34f13dae7 (diff)
parent61c438558ef09a9c13d204c9da4285fa705ee0aa (diff)
downloaddwl-b7503ea8749ce45fd48488af7c5f0005548c9326.tar.gz
dwl-b7503ea8749ce45fd48488af7c5f0005548c9326.tar.bz2
dwl-b7503ea8749ce45fd48488af7c5f0005548c9326.zip
Merge branch 'warpcursor' into merged
Diffstat (limited to 'dwl.c')
-rw-r--r--dwl.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/dwl.c b/dwl.c
index 727bed9..e512419 100644
--- a/dwl.c
+++ b/dwl.c
@@ -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)
{