From 6503a474b088869eddb073dd9df57b371583e7fb Mon Sep 17 00:00:00 2001 From: Ryan Date: Mon, 25 Sep 2023 18:43:30 -0400 Subject: [PATCH] apply hidecursor patch --- config.def.h | 4 ++-- dwl.c | 24 ++++++++++++++++++++++++ 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/config.def.h b/config.def.h index 26b4b34..af29e7b 100644 --- a/config.def.h +++ b/config.def.h @@ -17,6 +17,8 @@ static const char *const autostart[] = { #define TAGCOUNT (9) static const int tagcount = TAGCOUNT; +static const int hide_type = 1; + static const Rule rules[] = { /* app_id title tags mask isfloating monitor */ /* examples: @@ -116,8 +118,6 @@ static const char *menucmd[] = { "bemenu-run", NULL }; static const Key keys[] = { /* Note that Shift changes certain key codes: c -> C, 2 -> at, etc. */ /* modifier key function argument */ - - { MODKEY, XKB_KEY_p, spawn, {.v = menucmd} }, { MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_Return, spawn, {.v = termcmd} }, { MODKEY, XKB_KEY_b, togglebar, {0}}, diff --git a/dwl.c b/dwl.c index 279ca52..0b23c33 100644 --- a/dwl.c +++ b/dwl.c @@ -283,6 +283,7 @@ static Client *focustop(Monitor *m); static void fullscreennotify(struct wl_listener *listener, void *data); static void handlesig(int signo); static size_t getunusedtag(void); +static void hidecursor(int hide); static void incnmaster(const Arg *arg); static void inputdevice(struct wl_listener *listener, void *data); static int keybinding(uint32_t mods, xkb_keysym_t sym); @@ -375,6 +376,7 @@ static struct wlr_virtual_keyboard_manager_v1 *virtual_keyboard_mgr; static struct wlr_cursor *cursor; static struct wlr_xcursor_manager *cursor_mgr; +static int cursor_hidden; static struct wlr_session_lock_manager_v1 *session_lock_mgr; static struct wlr_scene_rect *locked_bg; @@ -619,6 +621,8 @@ axisnotify(struct wl_listener *listener, void *data) * for example when you move the scroll wheel. */ struct wlr_pointer_axis_event *event = data; IDLE_NOTIFY_ACTIVITY; + if(cursor_hidden) + hidecursor(0); /* 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. */ @@ -637,6 +641,8 @@ buttonpress(struct wl_listener *listener, void *data) const Button *b; IDLE_NOTIFY_ACTIVITY; + if(cursor_hidden) + hidecursor(0); switch (event->state) { case WLR_BUTTON_PRESSED: @@ -1602,6 +1608,20 @@ getunusedtag(void) return i; } +void +hidecursor(int hide) +{ + if (hide) { + wlr_cursor_set_image(cursor, NULL, 0, 0, 0, 0, 0, 0); + wlr_seat_pointer_notify_clear_focus(seat); + cursor_hidden = 1; + return; + } + wlr_xcursor_manager_set_cursor_image(cursor_mgr, "left_ptr", cursor); + cursor_hidden = false; + motionnotify(0); +} + void handlesig(int signo) { @@ -1740,6 +1760,8 @@ keypress(struct wl_listener *listener, void *data) wlr_seat_set_keyboard(seat, kb->wlr_keyboard); wlr_seat_keyboard_notify_key(seat, event->time_msec, event->keycode, event->state); + if(hide_type) + hidecursor(1); } void @@ -1945,6 +1967,8 @@ motionnotify(uint32_t time) /* time is 0 in internal calls meant to restore pointer focus. */ if (time) { IDLE_NOTIFY_ACTIVITY; + if(cursor_hidden) + hidecursor(0); /* Update selmon (even while dragging a window) */ if (sloppyfocus)