Adding mouse colour/shape settings

master
Alex Kozadaev 10 years ago committed by Roberto E. Vargas Caballero
parent dc33d1d66e
commit ee5cad439b

@ -105,6 +105,14 @@ static unsigned int defaultfg = 7;
static unsigned int defaultbg = 0; static unsigned int defaultbg = 0;
static unsigned int defaultcs = 256; static unsigned int defaultcs = 256;
/*
* Default colour and shape of the mouse cursor
*/
static unsigned int mouseshape = XC_xterm;
static unsigned int mousefg = 7;
static unsigned int mousebg = 0;
/* /*
* Colors used, when the specific fg == defaultfg. So in reverse mode this * Colors used, when the specific fg == defaultfg. So in reverse mode this
* will reverse too. Another logic would only make the simple feature too * will reverse too. Another logic would only make the simple feature too

20
st.c

@ -3411,6 +3411,7 @@ xinit(void)
Cursor cursor; Cursor cursor;
Window parent; Window parent;
pid_t thispid = getpid(); pid_t thispid = getpid();
XColor xmousefg, xmousebg;
if (!(xw.dpy = XOpenDisplay(NULL))) if (!(xw.dpy = XOpenDisplay(NULL)))
die("Can't open display\n"); die("Can't open display\n");
@ -3483,11 +3484,22 @@ xinit(void)
die("XCreateIC failed. Could not obtain input method.\n"); die("XCreateIC failed. Could not obtain input method.\n");
/* white cursor, black outline */ /* white cursor, black outline */
cursor = XCreateFontCursor(xw.dpy, XC_xterm); cursor = XCreateFontCursor(xw.dpy, mouseshape);
XDefineCursor(xw.dpy, xw.win, cursor); XDefineCursor(xw.dpy, xw.win, cursor);
XRecolorCursor(xw.dpy, cursor,
&(XColor){.red = 0xffff, .green = 0xffff, .blue = 0xffff}, if (XParseColor(xw.dpy, xw.cmap, colorname[mousefg], &xmousefg) == 0) {
&(XColor){.red = 0x0000, .green = 0x0000, .blue = 0x0000}); xmousefg.red = 0xffff;
xmousefg.green = 0xffff;
xmousefg.blue = 0xffff;
}
if (XParseColor(xw.dpy, xw.cmap, colorname[mousebg], &xmousebg) == 0) {
xmousebg.red = 0x0000;
xmousebg.green = 0x0000;
xmousebg.blue = 0x0000;
}
XRecolorCursor(xw.dpy, cursor, &xmousefg, &xmousebg);
xw.xembed = XInternAtom(xw.dpy, "_XEMBED", False); xw.xembed = XInternAtom(xw.dpy, "_XEMBED", False);
xw.wmdeletewin = XInternAtom(xw.dpy, "WM_DELETE_WINDOW", False); xw.wmdeletewin = XInternAtom(xw.dpy, "WM_DELETE_WINDOW", False);

Loading…
Cancel
Save