ref: 3c5d750245fd21bde28a4b322a197c13628b3c8d
parent: 8456690db7e4fc2f5f17c70233e29aec233fec60
author: Sigrid Solveig Haflínudóttir <ftrvxmtrx@gmail.com>
date: Mon Jan 25 10:44:01 EST 2021
use channel instead of wrong display locking
--- a/bar.c
+++ b/bar.c
@@ -114,8 +114,6 @@
Tm tm;
lockdisplay(display);
- if(screen == nil)
- return;
r = screen->r;
draw(screen, r, cback, nil, ZP);
@@ -186,7 +184,7 @@
}
static void
-auxproc(void *)
+auxproc(void *c)
{Biobuf b;
char *s;
@@ -194,13 +192,7 @@
Binit(&b, 0, OREAD);
for(;;){s = Brdstr(&b, '\n', 1);
- lockdisplay(display);
- free(aux);
- aux = s ? s : strdup("");- unlockdisplay(display);
- redraw();
- if(wctl >= 0)
- fprint(wctl, bottom ? "bottom" : "top");
+ sendp(c, s);
if(s == nil)
break;
}
@@ -230,6 +222,7 @@
Emouse,
Eresize,
Ekeyboard,
+ Eaux,
Eend,
};
Alt a[] = {@@ -236,6 +229,7 @@
[Emouse] = { nil, &m, CHANRCV }, [Eresize] = { nil, nil, CHANRCV }, [Ekeyboard] = { nil, &key, CHANRCV },+ [Eaux] = { nil, &s, CHANRCV }, [Eend] = { nil, nil, CHANEND },};
@@ -272,9 +266,10 @@
if((kctl = initkeyboard(nil)) == nil)
sysfatal("initkeyboard: %r");- a[0].c = mctl->c;
- a[1].c = mctl->resizec;
- a[2].c = kctl->c;
+ a[Emouse].c = mctl->c;
+ a[Eresize].c = mctl->resizec;
+ a[Ekeyboard].c = kctl->c;
+ a[Eaux].c = chancreate(sizeof(s), 4);
brgb = DPalegreygreen;
if((b = Bopen("/dev/theme", OREAD)) != nil){@@ -296,7 +291,7 @@
readbattery();
redraw();
proccreate(updateproc, nil, 4096);
- proccreate(auxproc, nil, 16384);
+ proccreate(auxproc, a[Eaux].c, 16384);
for(;;){ switch(alt(a)){@@ -303,13 +298,6 @@
case Emouse:
break;
- case Eresize:
- if(getwindow(display, Refnone) < 0)
- threadexitsall(nil);
- redraw();
- place();
- break;
-
case Ekeyboard:
if(key == Kdel){close(wctl);
@@ -316,6 +304,20 @@
wctl = -1;
threadexitsall(nil);
}
+ break;
+
+ case Eresize:
+ if(getwindow(display, Refnone) < 0)
+ threadexitsall(nil);
+ /* wet floor */
+
+ case Eaux:
+ if(wctl >= 0)
+ fprint(wctl, bottom ? "bottom" : "top");
+ free(aux);
+ aux = strdup(s ? s : "");
+ redraw();
+ place();
break;
}
}
--
⑨