From c5f74d71084376f1efe440d400d2f477c5f0f9b8 Mon Sep 17 00:00:00 2001 From: HuntedByTheIRS Date: Tue, 30 Jun 2026 02:07:19 -0400 Subject: [PATCH] Fix sloppy_focus --- .luarc.json | 9 +++++++-- src/peachwm.c | 11 ++++++++++- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/.luarc.json b/.luarc.json index 04e07dc..fb01539 100644 --- a/.luarc.json +++ b/.luarc.json @@ -12,6 +12,11 @@ "library": [] }, "diagnostics": { - "globals": [] - } + "globals": [ + "input" + ] + }, + "diagnostics.disable": [ + "lowercase-global" + ] } diff --git a/src/peachwm.c b/src/peachwm.c index 83b87e7..4935db4 100644 --- a/src/peachwm.c +++ b/src/peachwm.c @@ -1596,6 +1596,8 @@ Monitor *dirtomon(enum wlr_direction dir) { return selmon; } +static bool warp_focus = true; + void focusclient(Client *c, int lift) { struct wlr_surface *old = seat->keyboard_state.focused_surface; int unused_lx, unused_ly, old_client_type; @@ -1672,6 +1674,10 @@ void focusclient(Client *c, int lift) { /* Activate the new client */ client_activate_surface(client_surface(c), 1); + + if (cfg.sloppyfocus && warp_focus) + wlr_cursor_warp(cursor, NULL, c->geom.x + c->geom.width / 2, + c->geom.y + c->geom.height / 2); } void focusmon(const Arg *arg) { @@ -2594,8 +2600,11 @@ void pointerfocus(Client *c, struct wlr_surface *surface, double sx, double sy, struct timespec now; if (surface != seat->pointer_state.focused_surface && cfg.sloppyfocus && - time && c && !client_is_unmanaged(c)) + time && c && !client_is_unmanaged(c)) { + warp_focus = false; focusclient(c, 0); + warp_focus = true; + } /* If surface is NULL, clear pointer focus */ if (!surface) {