aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2014-04-21 00:05:05 -0400
committerJesse Luehrs <doy@tozt.net>2014-04-21 00:05:05 -0400
commiteeae1cc578e709742ffd9c7563ce48220d97c0da (patch)
treeaa0088f9dfa8560169ce63327fbfe03aded2c1ef
parent52ea09e49afd5965fc79d78317a481a29d2c0ff5 (diff)
downloadrunes-eeae1cc578e709742ffd9c7563ce48220d97c0da.tar.gz
runes-eeae1cc578e709742ffd9c7563ce48220d97c0da.zip
allow configuring the color of the mouse cursor
-rw-r--r--src/config.c10
-rw-r--r--src/term.h1
-rw-r--r--src/window-xlib.c14
3 files changed, 23 insertions, 2 deletions
diff --git a/src/config.c b/src/config.c
index 6bcf824..7353ce7 100644
--- a/src/config.c
+++ b/src/config.c
@@ -30,6 +30,8 @@ static void runes_config_set_defaults(RunesTerm *t)
t->bold_is_bold = 1;
t->audible_bell = 1;
+ t->mousecursorcolor = cairo_pattern_create_rgb(1.0, 1.0, 1.0);
+
t->fgdefault = cairo_pattern_create_rgb(0.827, 0.827, 0.827);
t->bgdefault = cairo_pattern_create_rgb(0.0, 0.0, 0.0);
@@ -195,6 +197,14 @@ static void runes_config_set(RunesTerm *t, char *key, char *val)
t->fgdefault = newcolor;
}
}
+ else if (!strcmp(key, "mousecursorcolor")) {
+ cairo_pattern_t *newcolor;
+ newcolor = runes_config_parse_color(val);
+ if (newcolor) {
+ cairo_pattern_destroy(t->mousecursorcolor);
+ t->mousecursorcolor = newcolor;
+ }
+ }
else if (!strncmp(key, "color", 5)
&& strlen(key) == 6 && key[5] >= '0' && key[5] <= '7') {
cairo_pattern_t *newcolor;
diff --git a/src/term.h b/src/term.h
index 8f9d6a4..c083eb2 100644
--- a/src/term.h
+++ b/src/term.h
@@ -10,6 +10,7 @@ struct runes_term {
cairo_t *alternate_cr;
uv_loop_t *loop;
+ cairo_pattern_t *mousecursorcolor;
cairo_pattern_t *cursorcolor;
cairo_pattern_t *fgdefault;
diff --git a/src/window-xlib.c b/src/window-xlib.c
index 0051fae..b747915 100644
--- a/src/window-xlib.c
+++ b/src/window-xlib.c
@@ -97,6 +97,7 @@ void runes_window_backend_create_window(RunesTerm *t, int argc, char *argv[])
unsigned long white;
XIM im;
Cursor cursor;
+ double mouse_r, mouse_g, mouse_b;
XColor cursor_fg, cursor_bg;
Visual *vis;
cairo_surface_t *surface;
@@ -153,8 +154,17 @@ void runes_window_backend_create_window(RunesTerm *t, int argc, char *argv[])
runes_window_backend_set_window_title(t, "runes", 5);
cursor = XCreateFontCursor(w->dpy, XC_xterm);
- cursor_fg.red = cursor_fg.green = cursor_fg.blue = 65535;
- cursor_bg.red = cursor_bg.green = cursor_bg.blue = 0;
+ cairo_pattern_get_rgba(
+ t->mousecursorcolor, &mouse_r, &mouse_g, &mouse_b, NULL);
+ cursor_fg.red = (unsigned short)(mouse_r * 65535);
+ cursor_fg.green = (unsigned short)(mouse_g * 65535);
+ cursor_fg.blue = (unsigned short)(mouse_b * 65535);
+ if ((mouse_r + mouse_g + mouse_b) / 3.0 > 0.5) {
+ cursor_bg.red = cursor_bg.green = cursor_bg.blue = 0;
+ }
+ else {
+ cursor_bg.red = cursor_bg.green = cursor_bg.blue = 65535;
+ }
XRecolorCursor(w->dpy, cursor, &cursor_fg, &cursor_bg);
XDefineCursor(w->dpy, w->w, cursor);