tfix too-aggressive tag redraw - plan9port - [fork] Plan 9 from user space
 (HTM) git clone git://src.adamsgaard.dk/plan9port
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) README
 (DIR) LICENSE
       ---
 (DIR) commit 1bcfd909e712ae3478e2ad81561ca95f7b92c8fe
 (DIR) parent 642d87aa2f01fd9ef390b99b2e43d9d661755107
 (HTM) Author: rsc <devnull@localhost>
       Date:   Thu, 15 Mar 2007 16:26:09 +0000
       
       fix too-aggressive tag redraw
       
       Diffstat:
         M src/cmd/acme/wind.c                 |      54 ++++++++++++++++++++-----------
       
       1 file changed, 35 insertions(+), 19 deletions(-)
       ---
 (DIR) diff --git a/src/cmd/acme/wind.c b/src/cmd/acme/wind.c
       t@@ -92,6 +92,24 @@ wininit(Window *w, Window *clone, Rectangle r)
        }
        
        /*
       + * Draw the appropriate button.
       + */
       +void
       +windrawbutton(Window *w)
       +{
       +        Image *b;
       +        Rectangle br;
       +        
       +        b = button;
       +        if(!w->isdir && !w->isscratch && (w->body.file->mod || w->body.ncache))
       +                b = modbutton;
       +        br.min = w->tag.scrollr.min;
       +        br.max.x = br.min.x + Dx(b->r);
       +        br.max.y = br.min.y + Dy(b->r);
       +        draw(screen, br, b, nil, b->r.min);
       +}
       +
       +/*
         * Compute number of tag lines required
         * to display entire tag text.
         */
       t@@ -100,13 +118,25 @@ wintaglines(Window *w, Rectangle r)
        {
                int n;
                Rune rune;
       +        Rectangle all, scrollr;
        
        /* TAG policy here */
        
                if(!w->tagexpand)
                        return 1;
                w->tag.fr.noredraw = 1;
       +        /*
       +         * clumsy: since we are calling textresize but
       +         * not redrawing, we need to leave all and
       +         * scrollr unchanged, so that the computation
       +         * in winresize will decide to redraw the tag
       +         * when the rectangle does move.
       +         */
       +        all = w->tag.all;
       +        scrollr = w->tag.scrollr;
                textresize(&w->tag, r, TRUE);
       +        w->tag.all = all;
       +        w->tag.scrollr = scrollr;
                w->tag.fr.noredraw = 0;
                
                /* can't use more than we have */
       t@@ -128,9 +158,8 @@ int
        winresize(Window *w, Rectangle r, int safe, int keepextra)
        {
                int oy, y, mouseintag, tagresized;
       -        Image *b;
                Point p;
       -        Rectangle br, r1;
       +        Rectangle r1;
        
        if(0) fprint(2, "winresize %d %R safe=%d keep=%d h=%d\n", w->id, r, safe, keepextra, font->height);
                w->tagtop = r;
       t@@ -155,19 +184,14 @@ if(0) fprint(2, "winresize %d %R safe=%d keep=%d h=%d\n", w->id, r, safe, keepex
                r1.max.y = min(r.max.y, r1.min.y + w->taglines*font->height);
                y = r1.max.y;
                tagresized = 0;
       -        if(1 || !safe || !eqrect(w->tag.all, r1)){
       +if(0) fprint(2, "winresize tag %R %R\n", w->tag.all, r1);
       +        if(!safe || !eqrect(w->tag.all, r1)){
                        tagresized = 1;
        if(0) fprint(2, "resize tag %R => %R\n", w->tag.all, r1);
                        textresize(&w->tag, r1, TRUE);
        if(0) fprint(2, "=> %R (%R)\n", w->tag.all, w->tag.fr.r);
                        y = w->tag.fr.r.max.y;
       -                b = button;
       -                if(w->body.file->mod && !w->isdir && !w->isscratch)
       -                        b = modbutton;
       -                br.min = w->tag.scrollr.min;
       -                br.max.x = br.min.x + Dx(b->r);
       -                br.max.y = br.min.y + Dy(b->r);
       -                draw(screen, br, b, nil, b->r.min);
       +                windrawbutton(w);
        /* TAG */
                        if(mouseintag && !ptinrect(mouse->xy, w->tag.all)){
                                p = mouse->xy;
       t@@ -397,9 +421,7 @@ winsettag1(Window *w)
        {
                int bar, dirty, i, j, k, n, ntagname, resize;
                Rune *new, *old, *r, *tagname;
       -        Image *b;
                uint q0, q1;
       -        Rectangle br;
                static Rune Ldelsnarf[] = { ' ', 'D', 'e', 'l', ' ',
                        'S', 'n', 'a', 'r', 'f', 0 };
                static Rune Lundo[] = { ' ', 'U', 'n', 'd', 'o', 0 };
       t@@ -524,13 +546,7 @@ winsettag1(Window *w)
                if(w->tag.q1 > n)
                        w->tag.q1 = n;
                textsetselect(&w->tag, w->tag.q0, w->tag.q1);
       -        b = button;
       -        if(!w->isdir && !w->isscratch && (w->body.file->mod || w->body.ncache))
       -                b = modbutton;
       -        br.min = w->tag.scrollr.min;
       -        br.max.x = br.min.x + Dx(b->r);
       -        br.max.y = br.min.y + Dy(b->r);
       -        draw(screen, br, b, nil, b->r.min);
       +        windrawbutton(w);
                if(resize){
                        w->tagsafe = 0;
                        winresize(w, w->r, TRUE, TRUE);