update unclutter

This commit is contained in:
Guido Cella 2024-03-11 18:48:08 +01:00
parent 8f6a71e1e9
commit 7ee501eaea

View File

@ -1,6 +1,6 @@
From 9527cf91cc8dc07a2c74f85460dc90120519190f Mon Sep 17 00:00:00 2001
From 703ed4801b654d1af7c35c2e19e3bf27160414d5 Mon Sep 17 00:00:00 2001
From: Guido Cella <guido@guidocella.xyz>
Date: Fri, 9 Feb 2024 14:57:32 +0100
Date: Mon, 11 Mar 2024 18:47:47 +0100
Subject: [PATCH] =?UTF-8?q?hide=20the=20mouse=20cursor=20if=20it=20isn?=
=?UTF-8?q?=E2=80=99t=20being=20used?=
MIME-Version: 1.0
@ -9,8 +9,8 @@ Content-Transfer-Encoding: 8bit
---
config.def.h | 2 ++
dwl.c | 46 ++++++++++++++++++++++++++++++++++++++++++++--
2 files changed, 46 insertions(+), 2 deletions(-)
dwl.c | 45 +++++++++++++++++++++++++++++++++++++++++++--
2 files changed, 45 insertions(+), 2 deletions(-)
diff --git a/config.def.h b/config.def.h
index 9009517..a85ca27 100644
@ -26,10 +26,10 @@ index 9009517..a85ca27 100644
#define MODKEY WLR_MODIFIER_ALT
diff --git a/dwl.c b/dwl.c
index fa76db2..2eb5447 100644
index d508d79..a90e68a 100644
--- a/dwl.c
+++ b/dwl.c
@@ -271,6 +271,8 @@ static void focusmon(const Arg *arg);
@@ -283,6 +283,8 @@ static void focusmon(const Arg *arg);
static void focusstack(const Arg *arg);
static Client *focustop(Monitor *m);
static void fullscreennotify(struct wl_listener *listener, void *data);
@ -38,7 +38,7 @@ index fa76db2..2eb5447 100644
static void handlesig(int signo);
static void incnmaster(const Arg *arg);
static void inputdevice(struct wl_listener *listener, void *data);
@@ -368,6 +370,8 @@ static struct wlr_cursor_shape_manager_v1 *cursor_shape_mgr;
@@ -385,6 +387,8 @@ static struct wlr_pointer_constraint_v1 *active_constraint;
static struct wlr_cursor *cursor;
static struct wlr_xcursor_manager *cursor_mgr;
@ -47,7 +47,7 @@ index fa76db2..2eb5447 100644
static struct wlr_scene_rect *root_bg;
static struct wlr_session_lock_manager_v1 *session_lock_mgr;
@@ -548,6 +552,7 @@ axisnotify(struct wl_listener *listener, void *data)
@@ -565,6 +569,7 @@ axisnotify(struct wl_listener *listener, void *data)
* for example when you move the scroll wheel. */
struct wlr_pointer_axis_event *event = data;
wlr_idle_notifier_v1_notify_activity(idle_notifier, seat);
@ -55,7 +55,7 @@ index fa76db2..2eb5447 100644
/* TODO: allow usage of scroll whell for mousebindings, it can be implemented
* checking the event's orientation and the delta of the event */
/* Notify the client with pointer focus of the axis event. */
@@ -566,6 +571,7 @@ buttonpress(struct wl_listener *listener, void *data)
@@ -583,6 +588,7 @@ buttonpress(struct wl_listener *listener, void *data)
const Button *b;
wlr_idle_notifier_v1_notify_activity(idle_notifier, seat);
@ -63,7 +63,7 @@ index fa76db2..2eb5447 100644
switch (event->state) {
case WLR_BUTTON_PRESSED:
@@ -1320,6 +1326,33 @@ handlesig(int signo)
@@ -1388,6 +1394,32 @@ handlesig(int signo)
}
}
@ -84,9 +84,8 @@ index fa76db2..2eb5447 100644
+int
+hidecursor(void *data)
+{
+ // uncomment this if using the pointer constraints PR
+ // if (active_constraint)
+ // return 1;
+ if (active_constraint)
+ return 1;
+
+ wlr_cursor_unset_image(cursor);
+ wlr_seat_pointer_notify_clear_focus(seat);
@ -97,15 +96,15 @@ index fa76db2..2eb5447 100644
void
incnmaster(const Arg *arg)
{
@@ -1620,6 +1653,7 @@ motionnotify(uint32_t time)
/* time is 0 in internal calls meant to restore pointer focus. */
if (time) {
@@ -1718,6 +1750,7 @@ motionnotify(uint32_t time, struct wlr_input_device *device, double dx, double d
wlr_cursor_move(cursor, device, dx, dy);
wlr_idle_notifier_v1_notify_activity(idle_notifier, seat);
+ handlecursoractivity(false);
/* Update selmon (even while dragging a window) */
if (sloppyfocus)
@@ -1655,7 +1689,7 @@ motionnotify(uint32_t time)
@@ -1753,7 +1786,7 @@ motionnotify(uint32_t time, struct wlr_input_device *device, double dx, double d
/* If there's no client surface under the cursor, set the cursor image to a
* default. This is what makes the cursor image appear when you move it
* off of a client or over its border. */
@ -114,7 +113,7 @@ index fa76db2..2eb5447 100644
wlr_cursor_set_xcursor(cursor, cursor_mgr, "default");
pointerfocus(c, surface, sx, sy, time);
@@ -1798,7 +1832,10 @@ pointerfocus(Client *c, struct wlr_surface *surface, double sx, double sy,
@@ -1897,7 +1930,10 @@ pointerfocus(Client *c, struct wlr_surface *surface, double sx, double sy,
/* Let the client know that the mouse cursor has entered one
* of its surfaces, and make keyboard focus follow if desired.
* wlroots makes this a no-op if surface is already focused */
@ -124,9 +123,9 @@ index fa76db2..2eb5447 100644
+ if (!cursor_hidden)
+ wlr_seat_pointer_notify_enter(seat, surface, sx, sy);
wlr_seat_pointer_notify_motion(seat, time, sx, sy);
}
@@ -2001,6 +2038,7 @@ run(char *startup_cmd)
@@ -2099,6 +2135,7 @@ run(char *startup_cmd)
* monitor when displayed here */
wlr_cursor_warp_closest(cursor, NULL, cursor->x, cursor->y);
wlr_cursor_set_xcursor(cursor, cursor_mgr, "default");
@ -134,7 +133,7 @@ index fa76db2..2eb5447 100644
/* Run the Wayland event loop. This does not return until you exit the
* compositor. Starting the backend rigged up all of the necessary event
@@ -2328,6 +2366,9 @@ setup(void)
@@ -2431,6 +2468,9 @@ setup(void)
cursor_shape_mgr = wlr_cursor_shape_manager_v1_create(dpy, 1);
LISTEN_STATIC(&cursor_shape_mgr->events.request_set_shape, setcursorshape);
@ -144,7 +143,7 @@ index fa76db2..2eb5447 100644
/*
* Configures a seat, which is a single "seat" at which a user sits and
* operates the computer. This conceptually includes up to one keyboard,
@@ -2750,6 +2791,7 @@ virtualpointer(struct wl_listener *listener, void *data)
@@ -2853,6 +2893,7 @@ virtualpointer(struct wl_listener *listener, void *data)
wlr_cursor_attach_input_device(cursor, &pointer.base);
if (event->suggested_output)
wlr_cursor_map_input_to_output(cursor, &pointer.base, event->suggested_output);
@ -153,5 +152,5 @@ index fa76db2..2eb5447 100644
Monitor *
--
2.43.0
2.44.0