summaryrefslogtreecommitdiff
path: root/dwl.c
diff options
context:
space:
mode:
Diffstat (limited to 'dwl.c')
-rw-r--r--dwl.c21
1 files changed, 20 insertions, 1 deletions
diff --git a/dwl.c b/dwl.c
index dc0c861..73d3c00 100644
--- a/dwl.c
+++ b/dwl.c
@@ -351,6 +351,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 warpcursortoclient(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);
@@ -514,6 +515,8 @@ arrange(Monitor *m)
if (m->lt[m->sellt]->arrange)
m->lt[m->sellt]->arrange(m);
motionnotify(0, NULL, 0, 0, 0, 0);
+
+ if (c && mousefollowsfocus) warpcursortoclient(c);
checkidleinhibitor(NULL);
}
@@ -1410,12 +1413,17 @@ void
focusmon(const Arg *arg)
{
int i = 0, nmons = wl_list_length(&mons);
+ Client *c = NULL;
if (nmons) {
do /* don't switch to disabled mons */
selmon = dirtomon(arg->i);
while (!selmon->wlr_output->enabled && i++ < nmons);
}
- focusclient(focustop(selmon), 1);
+
+ c = focustop(selmon);
+ focusclient(c, 1);
+
+ if (mousefollowsfocus) warpcursortoclient(c);
}
void
@@ -1442,6 +1450,7 @@ focusstack(const Arg *arg)
}
/* If only one client is visible on selmon, then c == sel */
focusclient(c, 1);
+ if (mousefollowsfocus) warpcursortoclient(c);
}
/* We probably should change the name of this, it sounds like
@@ -2942,6 +2951,16 @@ virtualpointer(struct wl_listener *listener, void *data)
wlr_cursor_map_input_to_output(cursor, device, event->suggested_output);
}
+void
+warpcursortoclient(Client *c) {
+ struct wlr_box mg = c->mon->m;
+ struct wlr_box cg = c->geom;
+ if (!VISIBLEON(c, selmon)) return;
+ wlr_cursor_warp_absolute(cursor, NULL,
+ ((double)cg.x + (double)cg.width / 2.0) / (double)mg.width,
+ ((double)cg.y + (double)cg.height / 2.0) / (double)mg.height);
+}
+
Monitor *
xytomon(double x, double y)
{