summaryrefslogtreecommitdiffstats
path: root/window.c
diff options
context:
space:
mode:
authorBert <ber.t@gmx.com>2011-02-21 18:26:21 +0100
committerBert <ber.t@gmx.com>2011-02-21 18:26:21 +0100
commitfde9f5bf859e582fb85d43831b90b7588ebfc3d3 (patch)
tree5293ce2837f092ce2aa36152afdf972d3a465eb5 /window.c
parent280fcf6bf005476fb51330f22ef503d4474a13f7 (diff)
downloadnsxiv-fde9f5bf859e582fb85d43831b90b7588ebfc3d3.tar.zst
Hide cursor on redraw or after 1.5s mouse inactivity
Diffstat (limited to 'window.c')
-rw-r--r--window.c19
1 files changed, 16 insertions, 3 deletions
diff --git a/window.c b/window.c
index 857b3b5..d50d2f2 100644
--- a/window.c
+++ b/window.c
@@ -27,6 +27,7 @@
#include "window.h"
static Cursor carrow;
+static Cursor cnone;
static Cursor chand;
static Cursor cwatch;
static GC gc;
@@ -52,6 +53,8 @@ void win_open(win_t *win) {
XClassHint classhint;
XColor col;
XGCValues gcval;
+ char none_data[] = {0, 0, 0, 0, 0, 0, 0, 0};
+ Pixmap none;
int gmask;
if (!win)
@@ -69,12 +72,12 @@ void win_open(win_t *win) {
e->depth = DefaultDepth(e->dpy, e->scr);
if (XAllocNamedColor(e->dpy, DefaultColormap(e->dpy, e->scr), BG_COLOR,
- &col, &col))
+ &col, &col))
win->bgcol = col.pixel;
else
die("could not allocate color: %s", BG_COLOR);
if (XAllocNamedColor(e->dpy, DefaultColormap(e->dpy, e->scr), SEL_COLOR,
- &col, &col))
+ &col, &col))
win->selcol = col.pixel;
else
die("could not allocate color: %s", BG_COLOR);
@@ -112,12 +115,18 @@ void win_open(win_t *win) {
die("could not create window");
XSelectInput(e->dpy, win->xwin, StructureNotifyMask | KeyPressMask |
- ButtonPressMask | ButtonReleaseMask | Button2MotionMask);
+ ButtonPressMask | ButtonReleaseMask | PointerMotionMask);
carrow = XCreateFontCursor(e->dpy, XC_left_ptr);
chand = XCreateFontCursor(e->dpy, XC_fleur);
cwatch = XCreateFontCursor(e->dpy, XC_watch);
+ if (!XAllocNamedColor(e->dpy, DefaultColormap(e->dpy, e->scr), "black",
+ &col, &col))
+ die("could not allocate color: black");
+ none = XCreateBitmapFromData(e->dpy, win->xwin, none_data, 8, 8);
+ cnone = XCreatePixmapCursor(e->dpy, none, none, &col, &col, 0, 0);
+
gcval.line_width = 2;
gc = XCreateGC(e->dpy, win->xwin, GCLineWidth, &gcval);
@@ -145,6 +154,7 @@ void win_close(win_t *win) {
return;
XFreeCursor(win->env.dpy, carrow);
+ XFreeCursor(win->env.dpy, cnone);
XFreeCursor(win->env.dpy, chand);
XFreeCursor(win->env.dpy, cwatch);
@@ -307,6 +317,9 @@ void win_set_cursor(win_t *win, win_cur_t cursor) {
return;
switch (cursor) {
+ case CURSOR_NONE:
+ XDefineCursor(win->env.dpy, win->xwin, cnone);
+ break;
case CURSOR_HAND:
XDefineCursor(win->env.dpy, win->xwin, chand);
break;