--- a/sys/src/cmd/samterm/flayer.c
+++ b/sys/src/cmd/samterm/flayer.c
@@ -144,6 +144,33 @@
newvisibilities(0);
}
+Rectangle
+flautosize(Point p)
+{
+ int i;
+ Rectangle b, r;
+
+ b = screen->r;
+ for(i = 0; i <nllist; i++){
+ if(llist[i]->visible != All)
+ continue;
+ if(ptinrect(p, llist[i]->entire))
+ continue;
+
+ r = llist[i]->entire;
+ /* prefer expanding vertically over horizontally */
+ if(p.x > r.max.x)
+ rectclip(&b, Rpt(Pt(r.max.x, screen->r.min.y), screen->r.max));
+ else if(p.x < r.min.x)
+ rectclip(&b, Rpt(screen->r.min, Pt(r.min.x, screen->r.max.y)));
+ else if(p.y > r.max.y)
+ rectclip(&b, Rpt(Pt(screen->r.min.x, r.max.y), screen->r.max));
+ else if(p.y < r.min.y)
+ rectclip(&b, Rpt(screen->r.min, Pt(screen->r.max.x, r.min.y)));
+ }
+ return b;
+}
+
void
newvisibilities(int redraw)
/* if redraw false, we know it's a flupfront, and needn't
--- a/sys/src/cmd/samterm/flayer.h
+++ b/sys/src/cmd/samterm/flayer.h
@@ -41,6 +41,7 @@
void flstart(Rectangle);
void flupfront(Flayer*);
Flayer *flwhich(Point);
+Rectangle flautosize(Point);
#define FLMARGIN 4
#define FLSCROLLWID 12
--- a/sys/src/cmd/samterm/main.c
+++ b/sys/src/cmd/samterm/main.c
@@ -271,25 +271,10 @@
int
getr(Rectangle *rp)
{
- Point p;
- Rectangle r;
-
*rp = getrect(3, mousectl);
- if(rp->max.x && rp->max.x-rp->min.x<=5 && rp->max.y-rp->min.y<=5){
- p = rp->min;
- r = cmd.l[cmd.front].entire;
- *rp = screen->r;
- if(cmd.nwin==1){
- if (p.y <= r.min.y)
- rp->max.y = r.min.y;
- else if (p.y >= r.max.y)
- rp->min.y = r.max.y;
- if (p.x <= r.min.x)
- rp->max.x = r.min.x;
- else if (p.x >= r.max.x)
- rp->min.x = r.max.x;
- }
- }
+ if(rp->max.x && rp->max.x-rp->min.x<=5 && rp->max.y-rp->min.y<=5)
+ *rp = flautosize(rp->min);
+
return rectclip(rp, screen->r) &&
rp->max.x-rp->min.x>100 && rp->max.y-rp->min.y>40;
}