ref: 98d5687ce47dc3cb014d5c3cb951e05dfe9e9da5
parent: 3707561e047f8e7c9993e0ba5a3a3fb5b5f6a6fd
author: cinap_lenrek <[email protected]>
date: Fri Jul 20 10:32:50 EDT 2012
mothra: delayed screen updates to reduce flicker
--- a/sys/src/cmd/mothra/getpix.c
+++ b/sys/src/cmd/mothra/getpix.c
@@ -36,16 +36,16 @@
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 @@
p->next=w->pix;
w->pix=p;
t->b=b;
- update(w);
+ w->changed=1;
}
void getpix(Rtext *t, Www *w){
--- a/sys/src/cmd/mothra/mothra.c
+++ b/sys/src/cmd/mothra/mothra.c
@@ -241,7 +241,7 @@
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 @@
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 @@
message(mothra);
donecurs();
}
- else if(current->changed){
- updtext(current);
- current->changed=0;
- }
}
flushimage(display, 1);
@@ -345,6 +341,13 @@
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 @@
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 @@
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);
--- a/sys/src/cmd/mothra/mothra.h
+++ b/sys/src/cmd/mothra/mothra.h
@@ -77,7 +77,6 @@
POST,
};
-void update(Www *w);
void finish(Www *w);
void plrdhtml(char *, int, Www *);
void plrdplain(char *, int, Www *);
--- a/sys/src/cmd/mothra/rdhtml.c
+++ b/sys/src/cmd/mothra/rdhtml.c
@@ -98,7 +98,7 @@
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 @@
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 @@
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,6 +774,8 @@
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"))
@@ -779,11 +782,10 @@
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 @@
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;