Add warpcursor patch
This commit is contained in:
parent
1b106aea12
commit
4d81408e32
14
README.org
14
README.org
@ -9,6 +9,7 @@
|
||||
- [[#patches][Patches]]
|
||||
- [[#attach-top][Attach Top]]
|
||||
- [[#auto-start][Auto Start]]
|
||||
- [[#warp-cursor][Warp Cursor]]
|
||||
- [[#dwl-configuration][dwl Configuration]]
|
||||
- [[#appearance][Appearance]]
|
||||
- [[#tagging][Tagging]]
|
||||
@ -69,6 +70,19 @@ Note: Commands from array are executed using execvp(). So if you need to execute
|
||||
#define AUTOSTART_PATCH 1
|
||||
#+END_SRC
|
||||
|
||||
** [[https://codeberg.org/dwl/dwl-patches/src/branch/main/patches/warpcursor][Warp Cursor]]
|
||||
|
||||
Warp cursor to the centre of newly focused clients.
|
||||
|
||||
Only moves the cursor if the cursor is currently not on the new client.
|
||||
|
||||
This is my version of the orphaned cursorwarp patch except I left out the config flag as I think it is unnecessary.
|
||||
|
||||
#+BEGIN_SRC c :tangle patches.def.h
|
||||
#define WARPCURSOR_PATCH 1
|
||||
#+END_SRC
|
||||
|
||||
|
||||
* dwl Configuration
|
||||
|
||||
Taken from https://github.com/djpohly/dwl/issues/466.
|
||||
|
35
dwl.c
35
dwl.c
@ -355,6 +355,9 @@ 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);
|
||||
#if WARPCURSOR_PATCH
|
||||
static void warpcursor(const Client *c);
|
||||
#endif // WARPCURSOR_PATCH
|
||||
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);
|
||||
@ -528,6 +531,9 @@ arrange(Monitor *m)
|
||||
m->lt[m->sellt]->arrange(m);
|
||||
motionnotify(0, NULL, 0, 0, 0, 0);
|
||||
checkidleinhibitor(NULL);
|
||||
#if WARPCURSOR_PATCH
|
||||
warpcursor(focustop(selmon));
|
||||
#endif // WARPCURSOR_PATCH
|
||||
}
|
||||
|
||||
void
|
||||
@ -1395,6 +1401,12 @@ focusclient(Client *c, int lift)
|
||||
if (locked)
|
||||
return;
|
||||
|
||||
#if WARPCURSOR_PATCH
|
||||
/* Warp cursor to center of client if it is outside */
|
||||
if (lift)
|
||||
warpcursor(c);
|
||||
#endif // WARPCURSOR_PATCH
|
||||
|
||||
/* Raise client in stacking order if requested */
|
||||
if (c && lift)
|
||||
wlr_scene_node_raise_to_top(&c->scene->node);
|
||||
@ -3077,6 +3089,29 @@ virtualpointer(struct wl_listener *listener, void *data)
|
||||
wlr_cursor_map_input_to_output(cursor, device, event->suggested_output);
|
||||
}
|
||||
|
||||
#if WARPCURSOR_PATCH
|
||||
void
|
||||
warpcursor(const Client *c) {
|
||||
if (cursor_mode != CurNormal) {
|
||||
return;
|
||||
}
|
||||
if (!c && selmon) {
|
||||
wlr_cursor_warp_closest(cursor,
|
||||
NULL,
|
||||
selmon->w.x + selmon->w.width / 2.0 ,
|
||||
selmon->w.y + selmon->w.height / 2.0);
|
||||
}
|
||||
else if ( c && (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);
|
||||
}
|
||||
#endif // WARPCURSOR_PATCH
|
||||
|
||||
Monitor *
|
||||
xytomon(double x, double y)
|
||||
{
|
||||
|
@ -1,3 +1,5 @@
|
||||
#define ATTACHTOP_PATCH 1
|
||||
|
||||
#define AUTOSTART_PATCH 1
|
||||
|
||||
#define WARPCURSOR_PATCH 1
|
||||
|
71
patches/warpcursor-20240715.patch
Normal file
71
patches/warpcursor-20240715.patch
Normal file
@ -0,0 +1,71 @@
|
||||
From 4951ccc89dac2b557994b2f6c3aacb2398e2d1b1 Mon Sep 17 00:00:00 2001
|
||||
From: Ben Collerson <benc@benc.cc>
|
||||
Date: Thu, 4 Jan 2024 20:30:01 +1000
|
||||
Subject: [PATCH] warpcursor
|
||||
|
||||
---
|
||||
dwl.c | 27 +++++++++++++++++++++++++++
|
||||
1 file changed, 27 insertions(+)
|
||||
|
||||
diff --git a/dwl.c b/dwl.c
|
||||
index 145fd018..f7ad6c13 100644
|
||||
--- a/dwl.c
|
||||
+++ b/dwl.c
|
||||
@@ -347,6 +347,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 warpcursor(const 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,7 @@ arrange(Monitor *m)
|
||||
m->lt[m->sellt]->arrange(m);
|
||||
motionnotify(0, NULL, 0, 0, 0, 0);
|
||||
checkidleinhibitor(NULL);
|
||||
+ warpcursor(focustop(selmon));
|
||||
}
|
||||
|
||||
void
|
||||
@@ -1323,6 +1325,10 @@ focusclient(Client *c, int lift)
|
||||
if (locked)
|
||||
return;
|
||||
|
||||
+ /* Warp cursor to center of client if it is outside */
|
||||
+ if (lift)
|
||||
+ warpcursor(c);
|
||||
+
|
||||
/* Raise client in stacking order if requested */
|
||||
if (c && lift)
|
||||
wlr_scene_node_raise_to_top(&c->scene->node);
|
||||
@@ -2927,6 +2933,27 @@ virtualpointer(struct wl_listener *listener, void *data)
|
||||
wlr_cursor_map_input_to_output(cursor, &pointer.base, event->suggested_output);
|
||||
}
|
||||
|
||||
+void
|
||||
+warpcursor(const Client *c) {
|
||||
+ if (cursor_mode != CurNormal) {
|
||||
+ return;
|
||||
+ }
|
||||
+ if (!c && selmon) {
|
||||
+ wlr_cursor_warp_closest(cursor,
|
||||
+ NULL,
|
||||
+ selmon->w.x + selmon->w.width / 2.0 ,
|
||||
+ selmon->w.y + selmon->w.height / 2.0);
|
||||
+ }
|
||||
+ else if ( c && (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)
|
||||
{
|
||||
--
|
||||
2.45.2
|
||||
|
Loading…
x
Reference in New Issue
Block a user