Commit Diff


commit - 46cfcf550f190fdef3496ae81d52c621862d01b1
commit + dd4afdf4eb411c2899f792cb11380877af065b1d
blob - 9b563faf467362bbb86e0f5bead98dfa8638d635
blob + ce69c8ea8d007916490f9e70fbed1f13a7e129e8
--- include/mouse.h
+++ include/mouse.h
@@ -26,6 +26,11 @@ struct Mousectl
 	int		pid;		/* of slave proc */
 	Display		*display;
 	/*Image*	image;	/ * of associated window/display */
+	
+	/* clumsy hack for X11 */
+	struct Channel *ccursor;
+	struct Channel *ccursorwait;
+	QLock cursorlock;
 };
 
 struct Menu
blob - 1e7757582a55416225074829911c77ef2a87eb18
blob + 4440639549f0028761116d3ef55e33722195a50f
--- src/libdraw/x11-mouse.c
+++ src/libdraw/x11-mouse.c
@@ -46,8 +46,30 @@ readmouse(Mousectl *mc)
 	return 0;
 }
 
+/*
+ * This is necessary because some X libraries (e.g., on FC3)
+ * use an inordinate amount of stack space to do _xsetcursor.
+ * Perhaps instead there should be a generic "run this X routine"
+ * stack that you send a function and argument to.
+ */
 static
 void
+_cursorproc(void *arg)
+{
+	Mousectl *mc;
+	Cursor *c;
+	
+	mc = arg;
+	threadsetname("cursorproc (sigh)");
+	for(;;){
+		c = recvp(mc->ccursor);
+		_xsetcursor(c);
+		sendp(mc->ccursorwait, nil);
+	}
+}
+
+static
+void
 _ioproc(void *arg)
 {
 	int fd, one, buttons;
@@ -141,14 +163,22 @@ initmouse(char *file, Image *i)
 	chansetname(mc->c, "mousec");
 	mc->resizec = chancreate(sizeof(int), 2);
 	chansetname(mc->resizec, "resizec");
+	mc->ccursor = chancreate(sizeof(void*), 0);
+	chansetname(mc->ccursor, "ccursor");
+	mc->ccursorwait = chancreate(sizeof(void*), 0);
+	chansetname(mc->ccursor, "ccursorwait");
 	proccreate(_ioproc, mc, 256*1024);
+	proccreate(_cursorproc, mc, 256*1024);	/* sigh */
 	return mc;
 }
 
 void
 setcursor(Mousectl *mc, Cursor *c)
 {
-	_xsetcursor(c);
+	qlock(&mc->cursorlock);
+	sendp(mc->ccursor, c);
+	recvp(mc->ccursorwait);
+	qunlock(&mc->cursorlock);
 }
 
 /*