mothra: allow plmouse() to update mouse state, use a pipe to signal screen update
This commit is contained in:
parent
d09c46c352
commit
31109f5047
9 changed files with 34 additions and 20 deletions
|
@ -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){
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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 */
|
||||
|
|
|
@ -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){
|
||||
|
|
|
@ -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){
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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 */
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue