first
[dcc-suckless-config] / based-simple-term / patches / st-dynamic-cursor-color-0.8.4.diff
1 From 01e706efbc13194a4a4404e91b93a9638a3c1bea Mon Sep 17 00:00:00 2001
2 From: Kipras Melnikovas <kipras@kipras.org>
3 Date: Thu, 25 Feb 2021 14:31:26 +0200
4 Subject: [PATCH] refactor dynamic-cursor-color patch
5
6 Signed-off-by: Kipras Melnikovas <kipras@kipras.org>
7 ---
8  x.c | 19 +++++++++++++++++--
9  1 file changed, 17 insertions(+), 2 deletions(-)
10
11 diff --git a/x.c b/x.c
12 index 120e495..ab66364 100644
13 --- a/x.c
14 +++ b/x.c
15 @@ -1489,6 +1489,7 @@ void
16  xdrawcursor(int cx, int cy, Glyph g, int ox, int oy, Glyph og)
17  {
18         Color drawcol;
19 +       XRenderColor colbg;
20  
21         /* remove the old cursor */
22         if (selected(ox, oy))
23 @@ -1518,10 +1519,24 @@ xdrawcursor(int cx, int cy, Glyph g, int ox, int oy, Glyph og)
24                         g.fg = defaultfg;
25                         g.bg = defaultrcs;
26                 } else {
27 +                       /** this is the main part of the dynamic cursor color patch */
28 +                       g.bg = g.fg;
29                         g.fg = defaultbg;
30 -                       g.bg = defaultcs;
31                 }
32 -               drawcol = dc.col[g.bg];
33 +
34 +               /**
35 +                * and this is the second part of the dynamic cursor color patch.
36 +                * it handles the `drawcol` variable
37 +               */
38 +               if (IS_TRUECOL(g.bg)) {
39 +                       colbg.alpha = 0xffff;
40 +                       colbg.red = TRUERED(g.bg);
41 +                       colbg.green = TRUEGREEN(g.bg);
42 +                       colbg.blue = TRUEBLUE(g.bg);
43 +                       XftColorAllocValue(xw.dpy, xw.vis, xw.cmap, &colbg, &drawcol);
44 +               } else {
45 +                       drawcol = dc.col[g.bg];
46 +               }
47         }
48  
49         /* draw the new one */
50 -- 
51 2.30.1
52