]> git.neil.brown.name Git - edlib.git/commitdiff
Fix to problems with pane_masked
authorNeilBrown <neil@brown.name>
Mon, 23 Nov 2015 05:53:30 +0000 (16:53 +1100)
committerNeilBrown <neil@brown.name>
Mon, 23 Nov 2015 05:56:32 +0000 (16:56 +1100)
1/ off-by-one error case cause us no to clear just beyond a pane
2/ only reduce 'w', and 'h', don't increase.

Signed-off-by: NeilBrown <neil@brown.name>
core-pane.c

index 30098db6353c34cf2100c85d4efa2a84bd23a466..30fa8a6a39263e984af722a7c0ca2bfde1ed7c4d 100644 (file)
@@ -272,7 +272,7 @@ int pane_masked(struct pane *p, int x, int y, int z, int *w, int *h)
        int xh = x + (w ? *w : 1);
        int yh = y + (h ? *h : 1);
 
-       if (x > p->x+p->w || y > p->y+p->h)
+       if (x >= p->x+p->w || y >= p->y+p->h)
                /* x,y is beyond this pane, no overlap possible */
                return 0;
        if (xh <= p->x || yh <= p->y)
@@ -285,9 +285,9 @@ int pane_masked(struct pane *p, int x, int y, int z, int *w, int *h)
                        /* pane masks x,y itself */
                        return 1;
                /* pane must just mask some of the region beyond x,y */
-               if (w)
+               if (w && *w > p->x - x)
                        *w = p->x - x;
-               if (h)
+               if (h && *h > p->y - y)
                        *h = p->y - y;
 
                return 0;