mothra: delayed screen updates to reduce flicker
This commit is contained in:
parent
3707561e04
commit
98d5687ce4
4 changed files with 31 additions and 21 deletions
|
@ -36,16 +36,16 @@ 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;
|
||||
update(w);
|
||||
w->changed=1;
|
||||
return;
|
||||
}
|
||||
fd=urlget(&url, -1);
|
||||
if(fd==-1){
|
||||
Err:
|
||||
snprint(err, sizeof(err), "[%s: %r]", url.fullname);
|
||||
snprint(err, sizeof(err), "[img: %s: %r]", url.reltext);
|
||||
free(t->text);
|
||||
t->text=strdup(err);
|
||||
update(w);
|
||||
w->changed=1;
|
||||
close(fd);
|
||||
return;
|
||||
}
|
||||
|
@ -83,7 +83,7 @@ void getimage(Rtext *t, Www *w){
|
|||
p->next=w->pix;
|
||||
w->pix=p;
|
||||
t->b=b;
|
||||
update(w);
|
||||
w->changed=1;
|
||||
}
|
||||
|
||||
void getpix(Rtext *t, Www *w){
|
||||
|
|
|
@ -241,7 +241,7 @@ extern char *mtpt; /* url */
|
|||
|
||||
void main(int argc, char *argv[]){
|
||||
Event e;
|
||||
enum { Eplumb = 128 };
|
||||
enum { Eplumb = 128, Ekick = 256 };
|
||||
Plumbmsg *pm;
|
||||
Www *new;
|
||||
Action *a;
|
||||
|
@ -298,7 +298,7 @@ void main(int argc, char *argv[]){
|
|||
eplumb(Eplumb, "web");
|
||||
if(pipe(kickpipe) < 0)
|
||||
sysfatal("pipe: %r");
|
||||
estart(0, kickpipe[0], 256);
|
||||
estart(Ekick, kickpipe[0], 256);
|
||||
plinit(screen->depth);
|
||||
if(debug) notify(dienow);
|
||||
getfonts();
|
||||
|
@ -333,10 +333,6 @@ void main(int argc, char *argv[]){
|
|||
message(mothra);
|
||||
donecurs();
|
||||
}
|
||||
else if(current->changed){
|
||||
updtext(current);
|
||||
current->changed=0;
|
||||
}
|
||||
}
|
||||
|
||||
flushimage(display, 1);
|
||||
|
@ -345,6 +341,13 @@ void main(int argc, char *argv[]){
|
|||
lockdisplay(display);
|
||||
|
||||
switch(i){
|
||||
case Ekick:
|
||||
if(mouse.buttons==0 && current && current->changed){
|
||||
if(!current->finished)
|
||||
updtext(current);
|
||||
current->changed=0;
|
||||
}
|
||||
break;
|
||||
case Ekeyboard:
|
||||
switch(e.kbdc){
|
||||
default:
|
||||
|
@ -906,6 +909,16 @@ void geturl(char *urlname, int post, int plumb, int map){
|
|||
w->finished = 0;
|
||||
w->alldone = 0;
|
||||
gettext(w, fd, typ);
|
||||
if(rfork(RFPROC|RFMEM|RFNOWAIT) == 0){
|
||||
for(;;){
|
||||
sleep(1000);
|
||||
if(w->finished || w->alldone)
|
||||
break;
|
||||
if(w->changed)
|
||||
write(kickpipe[1], "C", 1);
|
||||
}
|
||||
_exits(0);
|
||||
}
|
||||
plinitlist(list, PACKN|FILLX, genwww, 8, doprev);
|
||||
if(defdisplay) pldraw(list, screen);
|
||||
setcurrent(i, selection->tag);
|
||||
|
@ -940,10 +953,7 @@ 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);
|
||||
|
|
|
@ -77,7 +77,6 @@ enum{
|
|||
POST,
|
||||
};
|
||||
|
||||
void update(Www *w);
|
||||
void finish(Www *w);
|
||||
void plrdhtml(char *, int, Www *);
|
||||
void plrdplain(char *, int, Www *);
|
||||
|
|
|
@ -98,7 +98,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) update(g->dst);
|
||||
if(g->state->tag==Tag_title) g->dst->changed=1;
|
||||
*g->tp='\0';
|
||||
}
|
||||
return;
|
||||
|
@ -149,7 +149,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;
|
||||
update(g->dst);
|
||||
g->dst->changed=1;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -760,10 +760,11 @@ void plrdhtml(char *name, int fd, Www *dst){
|
|||
if((str=strchr(str, '='))==0)
|
||||
break;
|
||||
str++;
|
||||
pl_htmloutput(&g, 0, "[refresh: ", 0);
|
||||
str=unquot(g.state->link, str, sizeof(g.state->link));
|
||||
pl_htmloutput(&g, 0, "refresh: ", 0);
|
||||
pl_htmloutput(&g, 0, str, 0);
|
||||
g.state->link[0]=0;
|
||||
pl_htmloutput(&g, 0, "]", 0);
|
||||
g.linebrk=1;
|
||||
g.spacc=0;
|
||||
break;
|
||||
|
@ -773,17 +774,18 @@ void plrdhtml(char *name, int fd, Www *dst){
|
|||
case Tag_embed:
|
||||
case Tag_frame:
|
||||
case Tag_iframe:
|
||||
snprint(buf, sizeof(buf), "[%s: ", tag[g.tag].name);
|
||||
pl_htmloutput(&g, 0, buf, 0);
|
||||
if(str=pl_getattr(g.attr, "src"))
|
||||
nstrcpy(g.state->link, str, sizeof(g.state->link));
|
||||
if(str=pl_getattr(g.attr, "name"))
|
||||
nstrcpy(g.state->name, str, sizeof(g.state->name));
|
||||
else
|
||||
str = g.state->link;
|
||||
pl_htmloutput(&g, 0, tag[g.tag].name, 0);
|
||||
pl_htmloutput(&g, 0, ": ", 0);
|
||||
pl_htmloutput(&g, 0, str, 0);
|
||||
g.state->link[0]=0;
|
||||
g.state->name[0]=0;
|
||||
pl_htmloutput(&g, 0, "]", 0);
|
||||
g.linebrk=1;
|
||||
g.spacc=0;
|
||||
break;
|
||||
|
@ -1092,7 +1094,6 @@ 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';
|
||||
update(dst);
|
||||
getpix(dst->text, dst);
|
||||
finish(dst);
|
||||
return;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue