git.strcat.st

/strcat/sel.git/ - summarytreelogarchive

subject
add border color patch
commit
ae3774c4e0a47257d613f617d3787b59690ec913
date
2026-04-21T02:36:25Z
message
diff
 patches/border_col.patch | 64 ++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 64 insertions(+)

diff --git a/patches/border_col.patch b/patches/border_col.patch
new file mode 100644
index 0000000..0c1a12b
--- /dev/null
+++ b/patches/border_col.patch
@@ -0,0 +1,64 @@
+--- a/sel.c
++++ b/sel.c
+@@ -2,6 +2,7 @@
+ #include <X11/cursorfont.h>
+ 
+ #include <stdio.h>
++#include <string.h>
+ 
+ static int
+ min(int a, int b)
+@@ -53,7 +54,7 @@
+ }
+ 
+ int
+-main(void)
++main(int argc, char **argv)
+ {
+ 	Display *dpy;
+ 	Window root;
+@@ -68,8 +69,19 @@
+ 	int sx, sy, ex, ey;
+ 	int dragx, dragy, dragw, dragh;
+ 	int hoverx, hovery, hoverw, hoverh;
++	char *colname;
++	Colormap cmap;
++	XColor color;
+ 	int done;
+ 
++	colname = NULL;
++	if (argc == 3 && !strcmp(argv[1], "-c"))
++	    colname = argv[2];
++	else if (argc != 1) {
++	    fprintf(stderr, "usage: sel [-c #RRGGBB]\n");
++	    return 1;
++	}
++
+ 	if ((dpy = XOpenDisplay(NULL)) == NULL) {
+ 	    fprintf(stderr, "failed to open X display\n");
+ 	    return 1;
+@@ -85,10 +97,22 @@
+ 	    return 1;
+ 	}
+ 
+-	gcv.function = GXinvert;
+ 	gcv.subwindow_mode = IncludeInferiors;
+ 	gcv.line_width = 1;
+-	gcv.foreground = WhitePixel(dpy, DefaultScreen(dpy));
++	if (colname != NULL) {
++	    cmap = DefaultColormap(dpy, DefaultScreen(dpy));
++	    if (!XParseColor(dpy, cmap, colname, &color) ||
++	        !XAllocColor(dpy, cmap, &color)) {
++	        fprintf(stderr, "failed to allocate color: %s\n", colname);
++	        XCloseDisplay(dpy);
++	        return 1;
++	    }
++	    gcv.function = GXcopy;
++	    gcv.foreground = color.pixel;
++	} else {
++	    gcv.function = GXinvert;
++	    gcv.foreground = WhitePixel(dpy, DefaultScreen(dpy));
++	}
+ 	gc = XCreateGC(dpy, root,
+ 	    GCFunction | GCSubwindowMode | GCLineWidth | GCForeground, &gcv);
+