[wiki] [sites] [st][patch] refactor dynamic-cursor-color || Kipras Melnikovas

From: <git_AT_suckless.org>
Date: Thu, 25 Feb 2021 13:53:00 +0100

commit 76b6a6d322059902c4651863d1eef5ca85da680b
Author: Kipras Melnikovas <kipras_AT_kipras.org>
Date: Thu Feb 25 14:41:11 2021 +0200

    [st][patch] refactor dynamic-cursor-color
    
    probably the last fix, for now.
    feel free to squash the commits (I didn't want to modify the history)
    
    Signed-off-by: Kipras Melnikovas <kipras_AT_kipras.org>

diff --git a/st.suckless.org/patches/dynamic-cursor-color/index.md b/st.suckless.org/patches/dynamic-cursor-color/index.md
index 5b8635e1..612c81d1 100644
--- a/st.suckless.org/patches/dynamic-cursor-color/index.md
+++ b/st.suckless.org/patches/dynamic-cursor-color/index.md
_AT_@ -23,3 +23,5 @@ Authors
 -------
 * Kipras Melnikovas ([kipras.org](http://kipras.org)) <kipras_AT_kipras.org>
 * Stein Gunnar Bakkeby ([github.com/bakkeby](http://github.com/bakkeby))
+
+See also: [github.com/bakkeby/st-flexipatch/issues/10](https://github.com/bakkeby/st-flexipatch/issues/10)
diff --git a/st.suckless.org/patches/dynamic-cursor-color/st-dynamic-cursor-color-0.8.4.diff b/st.suckless.org/patches/dynamic-cursor-color/st-dynamic-cursor-color-0.8.4.diff
index adf24fd2..a763d6d0 100644
--- a/st.suckless.org/patches/dynamic-cursor-color/st-dynamic-cursor-color-0.8.4.diff
+++ b/st.suckless.org/patches/dynamic-cursor-color/st-dynamic-cursor-color-0.8.4.diff
_AT_@ -1,80 +1,52 @@
-From 1115d1d45effebc728891f76b6c8a44568a81bb3 Mon Sep 17 00:00:00 2001
+From 01e706efbc13194a4a4404e91b93a9638a3c1bea Mon Sep 17 00:00:00 2001
 From: Kipras Melnikovas <kipras_AT_kipras.org>
-Date: Thu, 25 Feb 2021 04:13:49 +0200
-Subject: [PATCH] improve cursor-color patch and add dynamic- prefix
-
-very thankful to Bakkeby [1] for helping out with various improvements,
-crash fixes etc., as seen in [2]!
-
-also renamed the patch (added dynamic- prefix),
-because I think this better describes it.
-
-[1] https://github.com/bakkeby
-[2] https://github.com/bakkeby/st-flexipatch/issues/10
+Date: Thu, 25 Feb 2021 14:31:26 +0200
+Subject: [PATCH] refactor dynamic-cursor-color patch
 
 Signed-off-by: Kipras Melnikovas <kipras_AT_kipras.org>
 ---
- x.c | 39 ++++++++++++++++++++++++++++++++++++---
- 1 file changed, 36 insertions(+), 3 deletions(-)
+ x.c | 19 +++++++++++++++++--
+ 1 file changed, 17 insertions(+), 2 deletions(-)
 
 diff --git a/x.c b/x.c
-index 120e495..e47e236 100644
+index 120e495..ab66364 100644
 --- a/x.c
 +++ b/x.c
 _AT_@ -1489,6 +1489,7 @@ void
  xdrawcursor(int cx, int cy, Glyph g, int ox, int oy, Glyph og)
  {
          Color drawcol;
-+ XRenderColor colfg;
++ XRenderColor colbg;
  
          /* remove the old cursor */
          if (selected(ox, oy))
-_AT_@ -1517,11 +1518,43 @@ xdrawcursor(int cx, int cy, Glyph g, int ox, int oy, Glyph og)
- if (selected(cx, cy)) {
+_AT_@ -1518,10 +1519,24 @@ xdrawcursor(int cx, int cy, Glyph g, int ox, int oy, Glyph og)
                          g.fg = defaultfg;
                          g.bg = defaultrcs;
-+ drawcol = dc.col[g.bg];
                  } else {
-- g.fg = defaultbg;
++ /** this is the main part of the dynamic cursor color patch */
++ g.bg = g.fg;
+ g.fg = defaultbg;
 - g.bg = defaultcs;
-+ /** this is the main part of the dynamic cursor color */
-+ if (IS_SET(MODE_FOCUSED)) {
-+ g.bg = g.fg;
-+ g.fg = defaultbg;
-+ }
-+
-+ /**
-+ * the following 2 sections are identical,
-+ * they differ only by either using `g.fg` or `g.bg`,
-+ * and it depends on what background+foreground
-+ * the user has configured (light+dark vs dark+light)
-+ *
-+ * otherwise, in one of the cases, the cursor will be invisible
-+ */
-+
-+ if (IS_TRUECOL(g.fg)) {
-+ colfg.alpha = 0xffff;
-+ colfg.red = TRUERED(g.fg);
-+ colfg.green = TRUEGREEN(g.fg);
-+ colfg.blue = TRUEBLUE(g.fg);
-+ XftColorAllocValue(xw.dpy, xw.vis, xw.cmap, &colfg, &drawcol);
-+ } else {
-+ drawcol = dc.col[g.fg];
-+ }
-+
-+ if (IS_TRUECOL(g.bg)) {
-+ colfg.alpha = 0xffff;
-+ colfg.red = TRUERED(g.bg);
-+ colfg.green = TRUEGREEN(g.bg);
-+ colfg.blue = TRUEBLUE(g.bg);
-+ XftColorAllocValue(xw.dpy, xw.vis, xw.cmap, &colfg, &drawcol);
-+ } else {
-+ drawcol = dc.col[g.bg];
-+ }
                  }
 - drawcol = dc.col[g.bg];
++
++ /**
++ * and this is the second part of the dynamic cursor color patch.
++ * it handles the `drawcol` variable
++ */
++ if (IS_TRUECOL(g.bg)) {
++ colbg.alpha = 0xffff;
++ colbg.red = TRUERED(g.bg);
++ colbg.green = TRUEGREEN(g.bg);
++ colbg.blue = TRUEBLUE(g.bg);
++ XftColorAllocValue(xw.dpy, xw.vis, xw.cmap, &colbg, &drawcol);
++ } else {
++ drawcol = dc.col[g.bg];
++ }
          }
  
          /* draw the new one */
 --
 2.30.1
+
Received on Thu Feb 25 2021 - 13:53:00 CET

This archive was generated by hypermail 2.3.0 : Thu Feb 25 2021 - 14:00:45 CET