diff options
author | cinap_lenrek <cinap_lenrek@centraldogma> | 2012-01-01 16:59:42 +0100 |
---|---|---|
committer | cinap_lenrek <cinap_lenrek@centraldogma> | 2012-01-01 16:59:42 +0100 |
commit | 31109f5047f04a3ab0a9a9b78910ef1c193e3e6f (patch) | |
tree | d5b87280a10ef837535419583ec522ff1c170409 /sys/src | |
parent | d09c46c352ca2595454c54b8d30aea1f0a0f6607 (diff) |
mothra: allow plmouse() to update mouse state, use a pipe to signal screen update
Diffstat (limited to 'sys/src')
-rw-r--r-- | sys/src/cmd/mothra/getpix.c | 6 | ||||
-rw-r--r-- | sys/src/cmd/mothra/libpanel/event.c | 12 | ||||
-rw-r--r-- | sys/src/cmd/mothra/libpanel/panel.h | 2 | ||||
-rw-r--r-- | sys/src/cmd/mothra/libpanel/popup.c | 2 | ||||
-rw-r--r-- | sys/src/cmd/mothra/libpanel/pulldown.c | 2 | ||||
-rw-r--r-- | sys/src/cmd/mothra/libpanel/textview.c | 2 | ||||
-rw-r--r-- | sys/src/cmd/mothra/mothra.c | 16 | ||||
-rw-r--r-- | sys/src/cmd/mothra/mothra.h | 2 | ||||
-rw-r--r-- | sys/src/cmd/mothra/rdhtml.c | 10 |
9 files changed, 34 insertions, 20 deletions
diff --git a/sys/src/cmd/mothra/getpix.c b/sys/src/cmd/mothra/getpix.c index d82957c3c..d966de53c 100644 --- a/sys/src/cmd/mothra/getpix.c +++ b/sys/src/cmd/mothra/getpix.c @@ -35,7 +35,7 @@ void getimage(Rtext *t, Www *w){ for(p=w->pix;p!=nil; p=p->next) if(strcmp(ap->image, p->name)==0 && ap->width==p->width && ap->height==p->height){ t->b = p->b; - w->changed=1; + update(w); return; } fd=urlopen(&url, GET, 0); @@ -44,7 +44,7 @@ void getimage(Rtext *t, Www *w){ snprint(err, sizeof(err), "[%s: %r]", url.fullname); free(t->text); t->text=strdup(err); - w->changed=1; + update(w); close(fd); return; } @@ -82,7 +82,7 @@ void getimage(Rtext *t, Www *w){ p->next=w->pix; w->pix=p; t->b=b; - w->changed=1; + update(w); } void getpix(Rtext *t, Www *w){ diff --git a/sys/src/cmd/mothra/libpanel/event.c b/sys/src/cmd/mothra/libpanel/event.c index bd34ace15..8634c1f5d 100644 --- a/sys/src/cmd/mothra/libpanel/event.c +++ b/sys/src/cmd/mothra/libpanel/event.c @@ -26,21 +26,21 @@ Panel *pl_ptinpanel(Point p, Panel *g){ } return 0; } -void plmouse(Panel *g, Mouse mouse){ +void plmouse(Panel *g, Mouse *m){ Panel *hit, *last; if(g->flags&REMOUSE) hit=g->lastmouse; else{ - hit=pl_ptinpanel(mouse.xy, g); + hit=pl_ptinpanel(m->xy, g); last=g->lastmouse; if(last && last!=hit){ - mouse.buttons|=OUT; - last->hit(last, &mouse); - mouse.buttons&=~OUT; + m->buttons|=OUT; + last->hit(last, m); + m->buttons&=~OUT; } } if(hit){ - if(hit->hit(hit, &mouse)) + if(hit->hit(hit, m)) g->flags|=REMOUSE; else g->flags&=~REMOUSE; diff --git a/sys/src/cmd/mothra/libpanel/panel.h b/sys/src/cmd/mothra/libpanel/panel.h index d5546de27..f85c94121 100644 --- a/sys/src/cmd/mothra/libpanel/panel.h +++ b/sys/src/cmd/mothra/libpanel/panel.h @@ -104,7 +104,7 @@ void pldraw(Panel *, Image *); /* display the panel on the bitmap */ void plfree(Panel *); /* give back space */ void plgrabkb(Panel *); /* this Panel should receive keyboard events */ void plkeyboard(Rune); /* send a keyboard event to the appropriate Panel */ -void plmouse(Panel *, Mouse); /* send a Mouse event to a Panel tree */ +void plmouse(Panel *, Mouse *); /* send a Mouse event to a Panel tree */ void plscroll(Panel *, Panel *, Panel *); /* link up scroll bars */ char *plentryval(Panel *); /* entry delivers its value */ void plsetbutton(Panel *, int); /* set or clear the mark on a button */ diff --git a/sys/src/cmd/mothra/libpanel/popup.c b/sys/src/cmd/mothra/libpanel/popup.c index c4c4d7a0e..5409f24e4 100644 --- a/sys/src/cmd/mothra/libpanel/popup.c +++ b/sys/src/cmd/mothra/libpanel/popup.c @@ -74,7 +74,7 @@ int pl_hitpopup(Panel *g, Mouse *m){ g->state=UP; } } - plmouse(p, *m); + plmouse(p, m); return (m->buttons&7)!=0; } void pl_typepopup(Panel *g, Rune c){ diff --git a/sys/src/cmd/mothra/libpanel/pulldown.c b/sys/src/cmd/mothra/libpanel/pulldown.c index 828fce42c..3b05d2f97 100644 --- a/sys/src/cmd/mothra/libpanel/pulldown.c +++ b/sys/src/cmd/mothra/libpanel/pulldown.c @@ -96,7 +96,7 @@ int pl_hitpulldown(Panel *g, Mouse *m){ } } if(g->state!=oldstate) pldraw(g, g->b); - if(hitme) plmouse(hitme, *m); + if(hitme) plmouse(hitme, m); return g->state==DOWN; } void pl_typepulldown(Panel *p, Rune c){ diff --git a/sys/src/cmd/mothra/libpanel/textview.c b/sys/src/cmd/mothra/libpanel/textview.c index 0eb9448a3..785d6da89 100644 --- a/sys/src/cmd/mothra/libpanel/textview.c +++ b/sys/src/cmd/mothra/libpanel/textview.c @@ -103,7 +103,7 @@ void pl_drawtextview(Panel *p){ * If t is a panel word, pass the mouse event on to it */ void pl_passon(Rtext *t, Mouse *m){ - if(t && t->b==0 && t->p!=0) plmouse(t->p, *m); + if(t && t->b==0 && t->p!=0) plmouse(t->p, m); } int pl_hittextview(Panel *p, Mouse *m){ Rtext *oldhitword; diff --git a/sys/src/cmd/mothra/mothra.c b/sys/src/cmd/mothra/mothra.c index 711feedff..9e20fcdad 100644 --- a/sys/src/cmd/mothra/mothra.c +++ b/sys/src/cmd/mothra/mothra.c @@ -90,6 +90,8 @@ Www *current=0; Url *selection=0; int logfile; int mothmode; +int kickpipe[2]; + void docmd(Panel *, char *); void doprev(Panel *, int, int); char *urlstr(Url *); @@ -310,7 +312,9 @@ void main(int argc, char *argv[]){ pltabsize(chrwidth, 8*chrwidth); einit(Emouse|Ekeyboard); eplumb(Eplumb, "web"); - etimer(0, 1000); + if(pipe(kickpipe) < 0) + sysfatal("pipe: %r"); + estart(0, kickpipe[0], 256); plinit(screen->depth); if(debug) notify(dienow); getfonts(); @@ -394,7 +398,7 @@ void main(int argc, char *argv[]){ break; case Emouse: mouse=e.mouse; - plmouse(root, e.mouse); + plmouse(root, &mouse); break; case Eplumb: pm=e.v; @@ -1084,6 +1088,14 @@ void updtext(Www *w){ plsetpostextview(text, w->yoffs); pldraw(root, screen); } +void update(Www *w){ + w->changed = 1; + write(kickpipe[1], "C", 1); +} +void finish(Www *w){ + w->finished = 1; + write(kickpipe[1], "F", 1); +} void mothon(Www *w, int on) diff --git a/sys/src/cmd/mothra/mothra.h b/sys/src/cmd/mothra/mothra.h index 8c45b8ec6..7c1a04bcc 100644 --- a/sys/src/cmd/mothra/mothra.h +++ b/sys/src/cmd/mothra/mothra.h @@ -78,6 +78,8 @@ enum{ POST, }; +void update(Www *w); +void finish(Www *w); void plrdhtml(char *, int, Www *); void plrdplain(char *, int, Www *); void htmlerror(char *, int, char *, ...); /* user-supplied routine */ diff --git a/sys/src/cmd/mothra/rdhtml.c b/sys/src/cmd/mothra/rdhtml.c index c60f18293..fb0553484 100644 --- a/sys/src/cmd/mothra/rdhtml.c +++ b/sys/src/cmd/mothra/rdhtml.c @@ -100,7 +100,7 @@ void pl_htmloutput(Hglob *g, int nsp, char *s, Field *field){ if(g->tp!=g->text && g->tp!=g->etext && g->tp[-1]!=' ') *g->tp++=' '; while(g->tp!=g->etext && *s) *g->tp++=*s++; - if(g->state->tag==Tag_title) g->dst->changed=1; + if(g->state->tag==Tag_title) update(g->dst); *g->tp='\0'; } return; @@ -151,7 +151,7 @@ void pl_htmloutput(Hglob *g, int nsp, char *s, Field *field){ g->state->link[0] || g->state->image[0], ap); g->para=0; g->linebrk=0; - g->dst->changed=1; + update(g->dst); } /* @@ -588,7 +588,7 @@ void plrdplain(char *name, int fd, Www *dst){ g.form=0; strncpy(g.text, name, NTITLE); plaintext(&g); - dst->finished=1; + finish(dst); } void plrdhtml(char *name, int fd, Www *dst){ Stack *sp; @@ -1049,9 +1049,9 @@ void plrdhtml(char *name, int fd, Www *dst){ htmlerror(g.name, g.lineno, "missing </%s> at EOF", tag[g.state->tag].name); *g.tp='\0'; - dst->changed=1; + update(dst); getpix(dst->text, dst); - dst->finished=1; + finish(dst); return; } } |