add warp
This commit is contained in:
parent
4b5bcedb87
commit
4659b67d7d
2
config.h
2
config.h
|
@ -13,6 +13,8 @@ static const float focuscolor[] = { 1, 1, 1, 1 };
|
|||
/* To conform the xdg-protocol, set the alpha to zero to restore the old behavior */
|
||||
static const float fullscreen_bg[] = {0.1, 0.1, 0.1, 1.0};
|
||||
|
||||
static const int warpcursor = 1; /* Warp cursor to focused client */
|
||||
|
||||
/* Autostart */
|
||||
static const char *const autostart[] = {
|
||||
"/bin/sh", "-c", "$HOME/.config/hypr/autostart.sh", NULL,
|
||||
|
|
22
dwl.c
22
dwl.c
|
@ -343,6 +343,7 @@ static void updatetitle(struct wl_listener *listener, void *data);
|
|||
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 warp_cursor(const Client *c);
|
||||
static Monitor *xytomon(double x, double y);
|
||||
static struct wlr_scene_node *xytonode(double x, double y, struct wlr_surface **psurface,
|
||||
Client **pc, LayerSurface **pl, double *nx, double *ny);
|
||||
|
@ -530,6 +531,11 @@ arrange(Monitor *m)
|
|||
m->lt[m->sellt]->arrange(m);
|
||||
motionnotify(0);
|
||||
checkidleinhibitor(NULL);
|
||||
|
||||
c = focustop(selmon);
|
||||
|
||||
if (c)
|
||||
warp_cursor(c);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -1454,6 +1460,10 @@ focusclient(Client *c, int lift)
|
|||
if (locked)
|
||||
return;
|
||||
|
||||
/* Warp cursor to center of client if it is outside */
|
||||
if (warpcursor && c)
|
||||
warp_cursor(c);
|
||||
|
||||
/* Raise client in stacking order if requested */
|
||||
if (c && lift)
|
||||
wlr_scene_node_raise_to_top(&c->scene->node);
|
||||
|
@ -2982,6 +2992,18 @@ virtualkeyboard(struct wl_listener *listener, void *data)
|
|||
createkeyboard(&keyboard->keyboard);
|
||||
}
|
||||
|
||||
void
|
||||
warp_cursor(const Client *c) {
|
||||
if (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)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue