[hackers] Patch that adds mouse cursor colour/shape to the config.h

From: Alex K <akozadaev_AT_yahoo.com>
Date: Tue, 28 Jul 2015 10:06:58 +0000 (UTC)

Sorry for spam. Here is the git-format-patch version of the patch:-----------------------------------From e35bd4f977ad1a7acd9e9925eed485f6462f84f9 Mon Sep 17 00:00:00 2001
From: Alex Kozadaev <akozadaev at yahoo com>
Date: Tue, 28 Jul 2015 10:30:14 +0100
Subject: [PATCH] Adding mouse colour/shape settings

---
 config.def.h |  8 ++++++++
 st.c         | 20 ++++++++++++++++----
 2 files changed, 24 insertions(+), 4 deletions(-)
diff --git a/config.def.h b/config.def.h
index 2616dea..930e468 100644
--- a/config.def.h
+++ b/config.def.h
_AT__AT_ -105,6 +105,14 @@ static unsigned int defaultfg = 7;
 static unsigned int defaultbg = 0;
 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
  * will reverse too. Another logic would only make the simple feature too
diff --git a/st.c b/st.c
index 0db3d58..1df4fde 100644
--- a/st.c
+++ b/st.c
_AT__AT_ -3411,6 +3411,7 @@ xinit(void)
     Cursor cursor;
     Window parent;
     pid_t thispid = getpid();
+    XColor xmousefg, xmousebg;
 
     if (!(xw.dpy = XOpenDisplay(NULL)))
         die("Can't open display\n");
_AT__AT_ -3483,11 +3484,22 @@ xinit(void)
         die("XCreateIC failed. Could not obtain input method.\n");
 
     /* white cursor, black outline */
-    cursor = XCreateFontCursor(xw.dpy, XC_xterm);
+    cursor = XCreateFontCursor(xw.dpy, mouseshape);
     XDefineCursor(xw.dpy, xw.win, cursor);
-    XRecolorCursor(xw.dpy, cursor,
-        &(XColor){.red = 0xffff, .green = 0xffff, .blue = 0xffff},
-        &(XColor){.red = 0x0000, .green = 0x0000, .blue = 0x0000});
+
+    if (XParseColor(xw.dpy, xw.cmap, colorname[mousefg], &xmousefg) == 0) {
+        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.wmdeletewin = XInternAtom(xw.dpy, "WM_DELETE_WINDOW", False);
-- 
2.1.4
-----------------------------------
Cheers,Alex
Received on Tue Jul 28 2015 - 12:06:58 CEST

This archive was generated by hypermail 2.3.0 : Tue Jul 28 2015 - 12:12:11 CEST