summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSquibid <me@zacharyscheiman.com>2025-02-11 21:07:14 -0600
committerSquibid <me@zacharyscheiman.com>2025-02-11 21:07:14 -0600
commit22891d3da5c7f06e80620d24599c0f12b6c5d18b (patch)
tree9a761a95c2828b180fbc28b36c89dd1e6b76538f
parent6539e07bbd39f0f2ed04331121f511d7b28a442f (diff)
downloaddwl-22891d3da5c7f06e80620d24599c0f12b6c5d18b.tar.gz
dwl-22891d3da5c7f06e80620d24599c0f12b6c5d18b.tar.bz2
dwl-22891d3da5c7f06e80620d24599c0f12b6c5d18b.zip
add warp cursor
Diffstat (limited to '')
-rw-r--r--config.def.h1
-rw-r--r--dwl.c36
2 files changed, 37 insertions, 0 deletions
diff --git a/config.def.h b/config.def.h
index ec2c729..a92e06d 100644
--- a/config.def.h
+++ b/config.def.h
@@ -5,6 +5,7 @@
(hex & 0xFF) / 255.0f }
/* appearance */
static const int sloppyfocus = 1; /* focus follows mouse */
+static const int warpcursor = 1; /* weather the cursor should move with client focus */
static const int bypass_surface_visibility = 0; /* 1 means idle inhibitors will disable idle tracking even if it's surface isn't visible */
static const int smartgaps = 0; /* 1 means no outer gap when there is only one window */
static const unsigned int borderpx = 1; /* border pixel of windows */
diff --git a/dwl.c b/dwl.c
index d076e26..96f3271 100644
--- a/dwl.c
+++ b/dwl.c
@@ -1687,6 +1687,8 @@ focusclient(Client *c, int lift)
void
focusmon(const Arg *arg)
{
+ Client *c;
+
int i = 0, nmons = wl_list_length(&mons);
if (nmons) {
do /* don't switch to disabled mons */
@@ -1694,6 +1696,16 @@ focusmon(const Arg *arg)
while (!selmon->wlr_output->enabled && i++ < nmons);
}
focusclient(focustop(selmon), 1);
+
+ if (warpcursor) {
+ wlr_cursor_warp_closest(cursor, NULL, selmon->w.x + selmon->w.width / 2.0,
+ selmon->w.y + selmon->w.height / 2.0);
+ c = focustop(selmon);
+ if (c) {
+ wlr_cursor_warp_closest(cursor, NULL, c->geom.x + c->geom.width / 2.0,
+ c->geom.y + c->geom.height / 2.0);
+ }
+ }
}
void
@@ -1720,6 +1732,11 @@ focusstack(const Arg *arg)
}
/* If only one client is visible on selmon, then c == sel */
focusclient(c, 1);
+
+ if (warpcursor) {
+ wlr_cursor_warp_closest( cursor, NULL, c->geom.x + c->geom.width / 2.0,
+ c->geom.y + c->geom.height / 2.0);
+ }
}
/* We probably should change the name of this, it sounds like
@@ -1780,6 +1797,7 @@ handlesig(int signo)
void
incnmaster(const Arg *arg)
{
+ Client *c;
const MonitorRule *r;
if (!arg || !selmon)
@@ -1791,6 +1809,15 @@ incnmaster(const Arg *arg)
}
selmon->nmaster = MAX(selmon->nmaster + arg->i, 0);
arrange(selmon);
+
+
+ if (warpcursor) {
+ c = focustop(selmon);
+ if (c) {
+ wlr_cursor_warp_closest(cursor, NULL, c->geom.x + c->geom.width / 2.0,
+ c->geom.y + c->geom.height / 2.0);
+ }
+ }
}
void
@@ -2580,6 +2607,7 @@ setmfact(const Arg *arg)
{
float f;
const MonitorRule *r;
+ Client *c;
if (!arg || !selmon || !selmon->lt[selmon->sellt]->arrange)
return;
@@ -2593,6 +2621,14 @@ setmfact(const Arg *arg)
else
return;
arrange(selmon);
+
+ if (warpcursor) {
+ c = focustop(selmon);
+ if (c) {
+ wlr_cursor_warp_closest(cursor, NULL, c->geom.x + c->geom.width / 2.0,
+ c->geom.y + c->geom.height / 2.0);
+ }
+ }
}
void