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 #include #include +#include #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;