dynamic cursor color

This commit is contained in:
Michael Peters 2022-10-13 14:19:47 -07:00
parent 495eabd5cd
commit 41b16fe6a8
4 changed files with 81 additions and 36 deletions

View File

@ -0,0 +1,52 @@
From 01e706efbc13194a4a4404e91b93a9638a3c1bea Mon Sep 17 00:00:00 2001
From: Kipras Melnikovas <kipras@kipras.org>
Date: Thu, 25 Feb 2021 14:31:26 +0200
Subject: [PATCH] refactor dynamic-cursor-color patch
Signed-off-by: Kipras Melnikovas <kipras@kipras.org>
---
x.c | 19 +++++++++++++++++--
1 file changed, 17 insertions(+), 2 deletions(-)
diff --git a/x.c b/x.c
index 120e495..ab66364 100644
--- a/x.c
+++ b/x.c
@@ -1489,6 +1489,7 @@ void
xdrawcursor(int cx, int cy, Glyph g, int ox, int oy, Glyph og)
{
Color drawcol;
+ XRenderColor colbg;
/* remove the old cursor */
if (selected(ox, oy))
@@ -1518,10 +1519,24 @@ xdrawcursor(int cx, int cy, Glyph g, int ox, int oy, Glyph og)
g.fg = defaultfg;
g.bg = defaultrcs;
} else {
+ /** this is the main part of the dynamic cursor color patch */
+ g.bg = g.fg;
g.fg = defaultbg;
- g.bg = defaultcs;
}
- 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

View File

@ -0,0 +1,12 @@
diff --git a/x.c b/x.c
index e5f1737..5cabd60 100644
--- a/x.c
+++ b/x.c
@@ -673,6 +673,7 @@ setsel(char *str, Time t)
XSetSelectionOwner(xw.dpy, XA_PRIMARY, xw.win, t);
if (XGetSelectionOwner(xw.dpy, XA_PRIMARY) != xw.win)
selclear();
+ clipcopy(NULL);
}
void

View File

@ -1,34 +0,0 @@
From 63e717e51dcd2f59c7a3aa75b659926aa92e08f3 Mon Sep 17 00:00:00 2001
From: Jacob Louis Prosser <geriatricjacob@cumallover.me>
Date: Mon, 5 Aug 2019 18:20:25 +1000
Subject: [st] [patch] Exposed variable to easily change mouse scroll increment.
---
config.def.h | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/config.def.h b/config.def.h
index ad20c4c..47e4b66 100644
--- a/config.def.h
+++ b/config.def.h
@@ -154,6 +154,7 @@ static unsigned int defaultattr = 11;
* Internal mouse shortcuts.
* Beware that overloading Button1 will disable the selection.
*/
+const unsigned int mousescrollincrement = 1;
static MouseShortcut mshortcuts[] = {
/* button mask string */
{ Button4, XK_NO_MOD, "\031" },
@@ -162,8 +163,8 @@ static MouseShortcut mshortcuts[] = {
MouseKey mkeys[] = {
/* button mask function argument */
- { Button4, ShiftMask, kscrollup, {.i = 1} },
- { Button5, ShiftMask, kscrolldown, {.i = 1} },
+ { Button4, ShiftMask, kscrollup, {.i = mousescrollincrement} },
+ { Button5, ShiftMask, kscrolldown, {.i = mousescrollincrement} },
};
/* Internal keyboard shortcuts. */
--
2.22.0

19
x.c
View File

@ -2048,6 +2048,7 @@ void
xdrawcursor(int cx, int cy, Glyph g, int ox, int oy, Glyph og, Line line, int len)
{
Color drawcol;
XRenderColor colbg;
/* remove the old cursor */
if (selected(ox, oy))
@ -2080,10 +2081,24 @@ xdrawcursor(int cx, int cy, Glyph g, int ox, int oy, Glyph og, Line line, int le
g.fg = defaultfg;
g.bg = defaultrcs;
} else {
/** this is the main part of the dynamic cursor color patch */
g.bg = g.fg;
g.fg = defaultbg;
g.bg = defaultcs;
}
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 */