Cursor Warp function in dwl (wayland compositor)

dwl is a compact, hackable compositor for Wayland based on wlroots. It is intended to fill the same space in the Wayland world that dwm does in X11, primarily in terms of functionality, and secondarily in terms of philosophy.

To add cursorwarp function in dwl is supposed to apply a right patch. But, as of 2024-04-19, no patch for cursorwarp function on the dwl's patches page.

Therefore, add the following code snippets in the right function in dwl.c file as follows;

/* Warp cursor to center of client if it is outside - msh added this */

if (c && cursor->y > selmon->m.y + selmon->b.height && (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);

in the focusclient(Client *c, int lift) function and

    if (!focustop(selmon)) {

        /* Move cursor to the center of the monitor output */

        wlr_cursor_warp_closest(cursor,

                NULL,

                selmon->m.x + selmon->m.width / 2.0,

                selmon->m.y + selmon->m.height / 2.0);

    }

    /* Focus top client on the selected monitor output - msh edited */

    focusclient(focustop(selmon), 1);

in the focusmon(const Arg *arg) function respectively.