ref: 3418d331c7362194508aa93bc24a9216566d3ff3
parent: 48d23d0a45e59f4d51d14bf1053f76cb0756b277
author: kvik <kvik@a-b.xyz>
date: Mon Feb 3 17:10:46 EST 2020
Automatically shape newly open flayers. 99% of the time I want a default shaped window; there is resize for all other situations.
--- a/samterm/main.c
+++ b/samterm/main.c
@@ -235,31 +235,37 @@
getmouse();
}
-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;
+ int
+getr(Rectangle *rp, int full)
+ {
+ Point p;
+ Rectangle r;
+
+ if(full){
+ *rp = screen->r;
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;
- }
- }
+ rp->min.y = r.max.y;
+ }else{
+ *rp = getrect(3, mousectl);
+ if(Dx(*rp) <= 5 && Dy(*rp) <= 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;
+ }
+ }
+ }
return rectclip(rp, screen->r) &&
- rp->max.x-rp->min.x>100 && rp->max.y-rp->min.y>40;
-}
+ rp->max.x-rp->min.x>100 && rp->max.y-rp->min.y>40;
+ }
void
snarf(Text *t, int w)
--- a/samterm/menu.c
+++ b/samterm/menu.c
@@ -142,7 +142,7 @@
if(!hostlock){
setcursor(mousectl, &bullseye);
buttons(Down);
- if((mousep->buttons&4) && (l = flwhich(mousep->xy)) && getr(&r))
+ if((mousep->buttons&4) && (l = flwhich(mousep->xy)) && getr(&r, 0))
duplicate(l, r, l->f.font, m==Resize);
else
setcursor(mousectl, cursor);
@@ -205,7 +205,7 @@
Rectangle r;
Text *t;
- if(getr(&r) && (t = malloc(sizeof(Text)))){
+ if(getr(&r, 1) && (t = malloc(sizeof(Text)))){
memset((void*)t, 0, sizeof(Text));
current((Flayer *)0);
flnew(&t->l[0], gettext, 0, (char *)t);
--- a/samterm/samterm.h
+++ b/samterm/samterm.h
@@ -119,7 +119,7 @@
int center(Flayer*, long);
int xmenuhit(int, Menu*);
void buttons(int);
-int getr(Rectangle*);
+int getr(Rectangle*, int);
void current(Flayer*);
void duplicate(Flayer*, Rectangle, Font*, int);
void startfile(Text*);