mirror of
https://github.com/0intro/wmii
synced 2024-11-22 05:42:05 +03:00
Improve mouse resizing.
This commit is contained in:
parent
68f249f726
commit
c35dbc2636
@ -316,9 +316,8 @@ static void
|
||||
column_squeeze(Area *a) {
|
||||
static Vector_ptr fvec;
|
||||
WinHints h;
|
||||
Frame **fp;
|
||||
Frame *f;
|
||||
int surplus, osurplus, dy;
|
||||
int surplus, osurplus, dy, i;
|
||||
|
||||
fvec.n = 0;
|
||||
for(f=a->frame; f; f=f->anext)
|
||||
@ -327,13 +326,13 @@ column_squeeze(Area *a) {
|
||||
f->r = sizehint(&h, f->r);
|
||||
vector_ppush(&fvec, f);
|
||||
}
|
||||
fp = (Frame**)fvec.ary;
|
||||
qsort(fp, fvec.n, sizeof *fp, comp_frame);
|
||||
|
||||
surplus = column_surplus(a);
|
||||
for(osurplus=0; surplus != osurplus;) {
|
||||
osurplus = surplus;
|
||||
for(; f=*fp; fp++) {
|
||||
qsort(fvec.ary, fvec.n, sizeof *fvec.ary, comp_frame);
|
||||
for(i=0; i < fvec.n; i++) {
|
||||
f=fvec.ary[i];
|
||||
dy = foo(f);
|
||||
if(dy > surplus)
|
||||
break;
|
||||
|
@ -365,7 +365,9 @@ frame_resize(Frame *f, Rectangle r) {
|
||||
if(f->area->floating)
|
||||
f->collapsed = false;
|
||||
|
||||
fr = frame_hints(f, r, get_sticky(f->r, r));
|
||||
fr = r;
|
||||
if(def.incmode != IIgnore)
|
||||
fr = frame_hints(f, r, get_sticky(f->r, r));
|
||||
if(f->area->floating && !c->strut)
|
||||
fr = constrain(fr);
|
||||
|
||||
@ -381,8 +383,10 @@ frame_resize(Frame *f, Rectangle r) {
|
||||
ewmh_updatestate(c);
|
||||
|
||||
fr.max.x = max(fr.max.x, fr.min.x + 2*labelh(def.font));
|
||||
/*
|
||||
if(f->collapsed)
|
||||
fr.max.y = fr.min.y + labelh(def.font);
|
||||
*/
|
||||
|
||||
cr = frame_rect2client(c, fr, f->area->floating);
|
||||
if(f->area->floating)
|
||||
|
102
cmd/wmii/mouse.c
102
cmd/wmii/mouse.c
@ -452,40 +452,116 @@ mouse_resize(Client *c, Align align) {
|
||||
ungrabpointer();
|
||||
}
|
||||
|
||||
static int
|
||||
pushstack_down(Frame *f, int y) {
|
||||
int ret;
|
||||
int dh, dy;
|
||||
|
||||
if(f == nil)
|
||||
return 0;;
|
||||
ret = 0;
|
||||
dy = y - f->colr.min.y;
|
||||
if(dy < 0)
|
||||
return 0;
|
||||
if(!f->collapsed) {
|
||||
dh = Dy(f->colr) - labelh(def.font);
|
||||
if(dy <= dh) {
|
||||
f->colr.min.y += dy;
|
||||
return dy;
|
||||
}else {
|
||||
f->collapsed = true;
|
||||
f->colr.min.y += dh;
|
||||
ret = dh;
|
||||
dy -= dh;
|
||||
}
|
||||
}
|
||||
dy = pushstack_down(f->anext, f->colr.max.y + dy);
|
||||
f->colr.min.y += dy;
|
||||
f->colr.max.y += dy;
|
||||
return ret + dy;
|
||||
}
|
||||
|
||||
static int
|
||||
pushstack_up(Frame *f, int y) {
|
||||
int ret;
|
||||
int dh, dy;
|
||||
|
||||
if(f == nil)
|
||||
return 0;
|
||||
ret = 0;
|
||||
dy = f->colr.max.y - y;
|
||||
if(dy < 0)
|
||||
return 0;
|
||||
if(!f->collapsed) {
|
||||
dh = Dy(f->colr) - labelh(def.font);
|
||||
if(dy <= dh) {
|
||||
f->colr.max.y -= dy;
|
||||
return dy;
|
||||
}else {
|
||||
f->collapsed = true;
|
||||
f->colr.max.y -= dh;
|
||||
ret = dh;
|
||||
dy -= dh;
|
||||
}
|
||||
}
|
||||
dy = pushstack_up(f->aprev, f->colr.min.y - dy);
|
||||
f->colr.min.y -= dy;
|
||||
f->colr.max.y -= dy;
|
||||
return ret + dy;
|
||||
}
|
||||
|
||||
static void
|
||||
mouse_tempvertresize(Area *a, Point p) {
|
||||
Frame *fa, *fb;
|
||||
Frame *fa, *fb, *f;
|
||||
Window *cwin;
|
||||
Rectangle r;
|
||||
int dy, incmode;
|
||||
Point pt;
|
||||
int incmode, nabove, nbelow;
|
||||
|
||||
if(a->mode != Coldefault)
|
||||
return;
|
||||
|
||||
for(fa=a->frame; fa; fa=fa->anext)
|
||||
if(p.y < fa->r.max.y + labelh(def.font)/2)
|
||||
break;
|
||||
if(!(fa && fa->anext))
|
||||
return;
|
||||
for(fb=fa->anext; fb->anext; fb=fb->anext)
|
||||
if(!fb->collapsed) break;
|
||||
fb = fa->anext;
|
||||
nabove=0;
|
||||
nbelow=0;
|
||||
for(f=fa; f; f=f->aprev)
|
||||
nabove++;
|
||||
for(f=fa->anext; f; f=f->anext)
|
||||
nbelow++;
|
||||
|
||||
incmode = def.incmode;
|
||||
def.incmode = IShow;
|
||||
def.incmode = IIgnore;
|
||||
column_arrange(a, false);
|
||||
|
||||
dy = fb->colr.min.y - fa->colr.max.y;
|
||||
|
||||
r.min.x = p.x;
|
||||
r.max.x = p.x + 1;
|
||||
r.min.y = fa->r.min.y + labelh(def.font);
|
||||
r.max.y = a->r.max.y - dy;
|
||||
r.min.y = a->r.min.y + labelh(def.font) * nabove;
|
||||
r.max.y = a->r.max.y - labelh(def.font) * nbelow;
|
||||
cwin = constraintwin(r);
|
||||
|
||||
if(!grabpointer(&scr.root, cwin, cursor[CurDVArrow], MouseMask))
|
||||
goto done;
|
||||
|
||||
while(readmotion(&p)) {
|
||||
fa->colr.max.y = p.y;
|
||||
fb->colr.min.y = p.y + dy;
|
||||
column_arrange(a, false);
|
||||
for(f=a->frame; f; f=f->anext)
|
||||
f->colr_old = f->colr;
|
||||
|
||||
while(readmotion(&pt)) {
|
||||
for(f=a->frame; f; f=f->anext) {
|
||||
f->collapsed = false;
|
||||
f->colr = f->colr_old;
|
||||
}
|
||||
if(pt.y > p.y)
|
||||
pushstack_down(fb, pt.y);
|
||||
else
|
||||
pushstack_up(fa, pt.y);
|
||||
fa->colr.max.y = pt.y;
|
||||
fb->colr.min.y = pt.y;
|
||||
column_frob(a);
|
||||
}
|
||||
|
||||
done:
|
||||
|
Loading…
Reference in New Issue
Block a user