diff options
author | cinap_lenrek <cinap_lenrek@felloff.net> | 2016-09-18 21:16:45 +0200 |
---|---|---|
committer | cinap_lenrek <cinap_lenrek@felloff.net> | 2016-09-18 21:16:45 +0200 |
commit | 1447b95555d6afa39f7ab04f04f1415f8937d899 (patch) | |
tree | b9931ecb7ba91553ae81b0a4bf637624540b3bd4 /sys/src/cmd | |
parent | 31b10e364ff4ca7c04b96637dab6c6cf347a6a2a (diff) |
rio: improved bandsize()
when dragging a window edge, allow one to slide to a corner
or slide from corner to corner (usefull when inverting).
also make sure the right or bottom of the rectangle returned
by whichrect() is not outside of the screen (which makes
drawing slow).
Diffstat (limited to 'sys/src/cmd')
-rw-r--r-- | sys/src/cmd/rio/rio.c | 30 |
1 files changed, 16 insertions, 14 deletions
diff --git a/sys/src/cmd/rio/rio.c b/sys/src/cmd/rio/rio.c index 1a1c54002..a063b2b0f 100644 --- a/sys/src/cmd/rio/rio.c +++ b/sys/src/cmd/rio/rio.c @@ -364,6 +364,8 @@ inborder(Rectangle r, Point xy) Rectangle whichrect(Rectangle r, Point p, int which) { + p.x = min(p.x, screen->clipr.max.x-1); + p.y = min(p.y, screen->clipr.max.y-1); switch(which){ case 0: /* top left */ r = Rect(p.x, p.y, r.max.x, r.max.y); @@ -386,7 +388,7 @@ whichrect(Rectangle r, Point p, int which) case 7: /* bottom edge */ r = Rect(r.min.x, r.min.y, r.max.x, p.y+1); break; - case 3: /* left edge */ + case 3: /* left edge */ r = Rect(p.x, r.min.y, r.max.x, r.max.y); break; } @@ -978,27 +980,27 @@ bandsize(Window *w) { Rectangle r, or; Point p, startp; - int which, but; + int which, owhich, but; - p = mouse->xy; + owhich = -1; + or = w->screenr; but = mouse->buttons; - which = whichcorner(w->screenr, p); - riosetcursor(corners[which]); - r = whichrect(w->screenr, p, which); - drawborder(r, 1); - or = r; - startp = p; - - while(mouse->buttons==but){ + startp = onscreen(mouse->xy); + drawborder(or, 1); + while(mouse->buttons == but) { p = onscreen(mouse->xy); - r = whichrect(w->screenr, p, which); + which = whichcorner(or, p); + if(which != owhich && which != 4 && (owhich|~which) & 1){ + owhich = which; + riosetcursor(corners[which]); + } + r = whichrect(or, p, owhich); if(!eqrect(r, or) && goodrect(r)){ - drawborder(r, 1); or = r; + drawborder(r, 1); } readmouse(mousectl); } - p = mouse->xy; drawborder(or, 0); if(mouse->buttons!=0 || !goodrect(or) || eqrect(or, w->screenr) || abs(p.x-startp.x)+abs(p.y-startp.y) <= 1){ |