From 605c0ea102e334b6c05d635ca0e5b93bad0031ec Mon Sep 17 00:00:00 2001 From: rsc Date: Wed, 8 Feb 2006 22:39:54 +0000 Subject: cleanup --- src/cmd/faces/main.c | 137 +++++++++++++-------------------------------------- 1 file changed, 35 insertions(+), 102 deletions(-) (limited to 'src/cmd/faces/main.c') diff --git a/src/cmd/faces/main.c b/src/cmd/faces/main.c index 4be56230..86218849 100644 --- a/src/cmd/faces/main.c +++ b/src/cmd/faces/main.c @@ -3,7 +3,6 @@ #include #include #include -//jpc #include /* for support routines only */ #include #include #include @@ -20,6 +19,8 @@ enum Infolines = 9, HhmmTime = 18*60*60, /* max age of face to display hh:mm time */ + + STACK = 32768 }; enum @@ -27,6 +28,7 @@ enum Mainp, Timep, Mousep, + Resizep, NPROC }; @@ -34,7 +36,8 @@ int pids[NPROC]; char *procnames[] = { "main", "time", - "mouse" + "mouse", + "resize", }; Rectangle leftright = {0, 0, 20, 15}; @@ -57,7 +60,7 @@ uchar rightdata[] = { 0x18, 0x00, 0x00, 0x10, 0x00 }; -CFsys *upasfs; +CFsys *mailfs; Mousectl *mousectl; Image *blue; /* full arrow */ Image *bgrnd; /* pale blue background color */ @@ -74,7 +77,7 @@ int ndown; char date[64]; Face **faces; -char *maildir = "/mail/fs/mbox"; +char *maildir = "INBOX"; ulong now; Point datep = { 8, 6 }; @@ -83,6 +86,7 @@ Point enddate; /* where date ends on display; used to place arrows */ Rectangle leftr; /* location of left arrow on display */ Rectangle rightr; /* location of right arrow on display */ void updatetimes(void); +void eresized(int); void setdate(void) @@ -95,15 +99,12 @@ setdate(void) void init(void) { -#if 0 - mousefd = open("/dev/mouse", OREAD); - if(mousefd < 0){ - fprint(2, "faces: can't open mouse: %r\n"); - threadexitsall("mouse"); - } -#endif - upasfs = nsmount("upasfs",nil); - mousectl = initmouse(nil,screen); + mailfs = nsmount("mail", nil); + if(mailfs == nil) + sysfatal("mount mail: %r"); + mousectl = initmouse(nil, screen); + if(mousectl == nil) + sysfatal("initmouse: %r"); initplumb(); /* make background color */ @@ -332,7 +333,7 @@ addface(Face *f) /* always adds at 0 */ lockdisplay(display); if(first != 0){ first = 0; - resized(); + eresized(0); } findbit(f); @@ -366,27 +367,6 @@ addface(Face *f) /* always adds at 0 */ unlockdisplay(display); } -#if 0 -void -loadmboxfaces(char *maildir) -{ - int dirfd; - Dir *d; - int i, n; - - dirfd = open(maildir, OREAD); - if(dirfd >= 0){ - chdir(maildir); - while((n = dirread(dirfd, &d)) > 0){ - for(i=0; i 0){ - for(i=0; ibuttons = 0; - return 0; - } - //jpc n = eatomouse(m, buf, n); - if(n > 0) - return 1; - } + while(recv(mousectl->resizec, 0) == 1) + eresized(1); } -#endif + int getmouse(Mouse *m) { @@ -573,19 +534,13 @@ getmouse(Mouse *m) if(eof) return 0; - if( readmouse(mousectl) < 0 ) { + if(readmouse(mousectl) < 0){ eof = 1; m->buttons = 0; return 0; } - else { - *m = mousectl->m; -/* m->buttons = mousectl->m.buttons; - m->xy.x = mousectl->m.xy.x; - m->xy.y = mousectl->m.xy.y; - m->msec = mousectl->m.msec; */ - return 1; - } + *m = mousectl->m; + return 1; } enum @@ -680,9 +635,10 @@ click(int button, Mouse *m) } void -mouseproc(void *dummy) +mouseproc(void *v) { Mouse mouse; + USED(v); while(getmouse(&mouse)){ if(mouse.buttons == 1) @@ -700,35 +656,9 @@ mouseproc(void *dummy) void killall(char *s) { - int i, pid; - - pid = getpid(); - for(i=0; i= 0) - killall("process died"); - threadexitsall(nil); - } - if(index >= 0) - pids[index] = pid; -} - void usage(void) { @@ -741,6 +671,8 @@ threadmain(int argc, char *argv[]) { int i; + rfork(RFNOTEG); + ARGBEGIN{ case 'h': history++; @@ -772,8 +704,9 @@ threadmain(int argc, char *argv[]) eresized(0); pids[Mainp] = getpid(); - pids[Timep] = proccreate(timeproc, nil, 16000); - pids[Mousep] = proccreate(mouseproc, nil, 16000); + pids[Timep] = proccreate(timeproc, nil, STACK); + pids[Mousep] = proccreate(mouseproc, nil, STACK); + pids[Resizep] = proccreate(resizeproc, nil, STACK); if(initload) for(i = 0; i < nmaildirs; i++) loadmboxfaces(maildirs[i]); -- cgit v1.2.3