summaryrefslogtreecommitdiff
path: root/sys/src/cmd
diff options
context:
space:
mode:
authorcinap_lenrek <cinap_lenrek@gmx.de>2012-07-20 14:32:50 +0200
committercinap_lenrek <cinap_lenrek@gmx.de>2012-07-20 14:32:50 +0200
commit98d5687ce47dc3cb014d5c3cb951e05dfe9e9da5 (patch)
tree60426055aa98f7570e2d3c5a856f53df7a83a849 /sys/src/cmd
parent3707561e047f8e7c9993e0ba5a3a3fb5b5f6a6fd (diff)
mothra: delayed screen updates to reduce flicker
Diffstat (limited to 'sys/src/cmd')
-rw-r--r--sys/src/cmd/mothra/getpix.c8
-rw-r--r--sys/src/cmd/mothra/mothra.c30
-rw-r--r--sys/src/cmd/mothra/mothra.h1
-rw-r--r--sys/src/cmd/mothra/rdhtml.c13
4 files changed, 31 insertions, 21 deletions
diff --git a/sys/src/cmd/mothra/getpix.c b/sys/src/cmd/mothra/getpix.c
index 762b69fb0..d3896e159 100644
--- a/sys/src/cmd/mothra/getpix.c
+++ b/sys/src/cmd/mothra/getpix.c
@@ -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){
diff --git a/sys/src/cmd/mothra/mothra.c b/sys/src/cmd/mothra/mothra.c
index 9e16af66c..44ca1db15 100644
--- a/sys/src/cmd/mothra/mothra.c
+++ b/sys/src/cmd/mothra/mothra.c
@@ -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);
diff --git a/sys/src/cmd/mothra/mothra.h b/sys/src/cmd/mothra/mothra.h
index e56b11ea7..dc4b54103 100644
--- a/sys/src/cmd/mothra/mothra.h
+++ b/sys/src/cmd/mothra/mothra.h
@@ -77,7 +77,6 @@ enum{
POST,
};
-void update(Www *w);
void finish(Www *w);
void plrdhtml(char *, int, Www *);
void plrdplain(char *, int, Www *);
diff --git a/sys/src/cmd/mothra/rdhtml.c b/sys/src/cmd/mothra/rdhtml.c
index 7e663563b..0f0c90f1f 100644
--- a/sys/src/cmd/mothra/rdhtml.c
+++ b/sys/src/cmd/mothra/rdhtml.c
@@ -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;