arp242 / find-cursor

Highlight the cursor position in X11

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Uses wrong colormap in transparent case (patch inside)

luebking opened this issue · comments

index 3d2dd7f..3931964 100644
--- a/find-cursor.c
+++ b/find-cursor.c
@@ -259,10 +259,11 @@ void draw(char *name, Display *display, int screen,
 	XSetWindowAttributes window_attr;
 	window_attr.override_redirect = 1;
 
+    Colormap colormap = DefaultColormap(display, screen);
 	if (transparent) {
 		XVisualInfo vinfo;
 		XMatchVisualInfo(display, screen, 32, TrueColor, &vinfo);
-		window_attr.colormap = XCreateColormap(display, DefaultRootWindow(display), vinfo.visual, AllocNone);
+		colormap = window_attr.colormap = XCreateColormap(display, DefaultRootWindow(display), vinfo.visual, AllocNone);
 		window_attr.background_pixel = 0;
 		window = XCreateWindow(display, XRootWindow(display, screen),
 			center_x,                               // x position
@@ -349,7 +350,6 @@ void draw(char *name, Display *display, int screen,
 	GC gc = XCreateGC(display, window, valuemask, &values);
 
 	// Get colours.
-	Colormap colormap = DefaultColormap(display, screen);
 	XColor color;
 	int err = XAllocNamedColor(display, colormap, color_name, &color, &color);
 	if (err == 0) {

What does this do/fix?

Using the default colormap on a drawable w/ specific (ARGB) colormap for rendering the arcs will lead to random colors being picked (typically "white", but it can actually be anything) for the arcs.
You have to use the colormap specific to the drawawble (window)