Hello, I've added a shortcut to toggle mouse cursor. Please find the patch in the attachment.
Disclaimer: my knowledge of X11 api is a bit rusty. I hope it helps. Cheers, A.
>From 5dc67f13e8e392a8ea9d413c5b47dabd27492c04 Mon Sep 17 00:00:00 2001 From: Alex Kozadaev <[email protected]> Date: Tue, 17 Nov 2015 12:06:35 +0000 Subject: [PATCH] a shortcut to toggle the mouse cursor --- config.def.h | 1 + sent.c | 26 ++++++++++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/config.def.h b/config.def.h index 6ecc267..96acbe1 100644 --- a/config.def.h +++ b/config.def.h @@ -39,4 +39,5 @@ static Shortcut shortcuts[] = { { XK_Up, advance, {.i = -1} }, { XK_Next, advance, {.i = +1} }, { XK_Prior, advance, {.i = -1} }, + { XK_x, toggle_cursor, {0} }, }; diff --git a/sent.c b/sent.c index 4e2e810..a14c49b 100644 --- a/sent.c +++ b/sent.c @@ -13,6 +13,7 @@ #include <X11/Xlib.h> #include <X11/Xutil.h> #include <X11/Xft/Xft.h> +#include <X11/cursorfont.h> #include "arg.h" #include "drw.h" @@ -92,6 +93,7 @@ static void eprintf(const char *, ...); static void die(const char *, ...); static void load(FILE *fp); static void advance(const Arg *arg); +static void toggle_cursor(const Arg *arg); static void quit(const Arg *arg); static void resize(int width, int height); static void run(); @@ -476,6 +478,30 @@ void advance(const Arg *arg) } } +void toggle_cursor(const Arg *arg) +{ + Cursor cursor; + XColor color; + Pixmap bitmapNoData; + char noData[] = { 0, 0, 0, 0, 0, 0, 0, 0 }; + static int cursor_visible = 1; + + memset(&color, 0, sizeof(color)); + + if (cursor_visible) { + bitmapNoData = XCreateBitmapFromData(xw.dpy, xw.win, noData, 8, 8); + cursor = XCreatePixmapCursor(xw.dpy, bitmapNoData, + bitmapNoData, &color, &color, 0, 0); + XFreePixmap(xw.dpy, bitmapNoData); + } else { + cursor = XCreateFontCursor(xw.dpy, XC_left_ptr); + } + XDefineCursor(xw.dpy, xw.win, cursor); + XFreeCursor(xw.dpy, cursor); + cursor_visible ^= 1; +} + void quit(const Arg *arg) { running = 0; -- 2.1.4
