From 771a35b0baf094c6de98697f5a8a210b0fecab21 Mon Sep 17 00:00:00 2001 From: rafa_99 Date: Sun, 6 Oct 2019 14:58:32 +0000 Subject: Toogle Cursor Patch --- .gitignore | 2 -- config.h | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ sent.c | 27 +++++++++++++++++++++++++++ 3 files changed, 84 insertions(+), 2 deletions(-) create mode 100644 config.h diff --git a/.gitignore b/.gitignore index 4c303b0..4efd0f7 100644 --- a/.gitignore +++ b/.gitignore @@ -26,5 +26,3 @@ # vim *.swp *~ - -config.h diff --git a/config.h b/config.h new file mode 100644 index 0000000..9e16d85 --- /dev/null +++ b/config.h @@ -0,0 +1,57 @@ +/* See LICENSE file for copyright and license details. */ + +static char *fontfallbacks[] = { + "dejavu sans", + "roboto", + "ubuntu", +}; +#define NUMFONTSCALES 42 +#define FONTSZ(x) ((int)(10.0 * powf(1.1288, (x)))) /* x in [0, NUMFONTSCALES-1] */ + +static const char *colors[] = { + "#000000", /* foreground color */ + "#FFFFFF", /* background color */ +}; + +static const float linespacing = 1.4; + +/* how much screen estate is to be used at max for the content */ +static const float usablewidth = 0.75; +static const float usableheight = 0.75; + +static Mousekey mshortcuts[] = { + /* button function argument */ + { Button1, advance, {.i = +1} }, + { Button3, advance, {.i = -1} }, + { Button4, advance, {.i = -1} }, + { Button5, advance, {.i = +1} }, +}; + +static Shortcut shortcuts[] = { + /* keysym function argument */ + { XK_Escape, quit, {0} }, + { XK_q, quit, {0} }, + { XK_Right, advance, {.i = +1} }, + { XK_Left, advance, {.i = -1} }, + { XK_Return, advance, {.i = +1} }, + { XK_space, advance, {.i = +1} }, + { XK_BackSpace, advance, {.i = -1} }, + { XK_l, advance, {.i = +1} }, + { XK_h, advance, {.i = -1} }, + { XK_j, advance, {.i = +1} }, + { XK_k, advance, {.i = -1} }, + { XK_Down, advance, {.i = +1} }, + { XK_Up, advance, {.i = -1} }, + { XK_Next, advance, {.i = +1} }, + { XK_Prior, advance, {.i = -1} }, + { XK_n, advance, {.i = +1} }, + { XK_p, advance, {.i = -1} }, + { XK_r, reload, {0} }, + { XK_x, toggle_cursor, {0} }, +}; + +static Filter filters[] = { + { "\\.ff$", "cat" }, + { "\\.ff.bz2$", "bunzip2" }, + { "\\.[a-z0-9]+$", "2ff" }, +}; diff --git a/sent.c b/sent.c index a2d9030..10de788 100644 --- a/sent.c +++ b/sent.c @@ -18,6 +18,7 @@ #include #include #include +#include #include "arg.h" #include "util.h" @@ -97,6 +98,7 @@ static void cleanup(int slidesonly); static void reload(const Arg *arg); 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(); @@ -515,6 +517,31 @@ advance(const Arg *arg) } void + +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; +} + quit(const Arg *arg) { running = 0; -- cgit v1.2.3