mirror of https://github.com/0intro/wmii
Allow Mod+Mouse3 to resize windows and columns unidirectionally.
This commit is contained in:
parent
57dbe8eb38
commit
678979319c
|
@ -223,7 +223,7 @@ readmotion(Point *p) {
|
||||||
|
|
||||||
static void
|
static void
|
||||||
mouse_resizecolframe(Frame *f, Align align) {
|
mouse_resizecolframe(Frame *f, Align align) {
|
||||||
Window *cwin, *hwin;
|
Window *cwin, *hwin = nil;
|
||||||
Divide *d;
|
Divide *d;
|
||||||
View *v;
|
View *v;
|
||||||
Area *a;
|
Area *a;
|
||||||
|
@ -245,7 +245,7 @@ mouse_resizecolframe(Frame *f, Align align) {
|
||||||
d = d->next;
|
d = d->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(align&East)
|
if(align & East)
|
||||||
d = d->next;
|
d = d->next;
|
||||||
|
|
||||||
min.x = column_minwidth();
|
min.x = column_minwidth();
|
||||||
|
@ -263,72 +263,82 @@ mouse_resizecolframe(Frame *f, Align align) {
|
||||||
r.rmax.xy = r.rmin.xy plus 1; \
|
r.rmax.xy = r.rmin.xy plus 1; \
|
||||||
})
|
})
|
||||||
|
|
||||||
|
r = f->r;
|
||||||
if(align & North)
|
if(align & North)
|
||||||
frob(f->aprev, f, aprev, min, max, +, -, y, false);
|
frob(f->aprev, f, aprev, min, max, +, -, y, false);
|
||||||
else
|
else if(align & South)
|
||||||
frob(f->anext, f, anext, max, min, -, +, y, false);
|
frob(f->anext, f, anext, max, min, -, +, y, false);
|
||||||
if(align & West)
|
if(align & West)
|
||||||
frob(a->prev, a, prev, min, max, +, -, x, true);
|
frob(a->prev, a, prev, min, max, +, -, x, true);
|
||||||
else
|
else if(align & East)
|
||||||
frob(a->next, a, next, max, min, -, +, x, true);
|
frob(a->next, a, next, max, min, -, +, x, true);
|
||||||
#undef frob
|
#undef frob
|
||||||
|
|
||||||
cwin = constraintwin(r);
|
cwin = constraintwin(r);
|
||||||
|
|
||||||
r = f->r;
|
r = f->r;
|
||||||
if(align&North)
|
if(align & North)
|
||||||
r.min.y--;
|
r.min.y--;
|
||||||
else
|
else if(align & South)
|
||||||
r.min.y = r.max.y - 1;
|
r.min.y = r.max.y - 1;
|
||||||
r.max.y = r.min.y + 2;
|
r.max.y = r.min.y + 2;
|
||||||
|
|
||||||
hwin = gethsep(r);
|
if(align & (North|South))
|
||||||
|
hwin = gethsep(r);
|
||||||
|
|
||||||
if(!grabpointer(&scr.root, cwin, cursor[CurSizing], MouseMask))
|
if(!grabpointer(&scr.root, cwin, cursor[CurSizing], MouseMask))
|
||||||
goto done;
|
goto done;
|
||||||
|
|
||||||
pt.x = ((align&West) ? f->r.min.x : f->r.max.x);
|
pt.x = (align & West ? f->r.min.x : f->r.max.x);
|
||||||
pt.y = ((align&North) ? f->r.min.y : f->r.max.y);
|
pt.y = (align & North ? f->r.min.y : f->r.max.y);
|
||||||
warppointer(pt);
|
warppointer(pt);
|
||||||
|
|
||||||
while(readmotion(&pt)) {
|
while(readmotion(&pt)) {
|
||||||
if(align&West)
|
if(align & West)
|
||||||
r.min.x = pt.x;
|
r.min.x = pt.x;
|
||||||
else
|
else if(align & East)
|
||||||
r.max.x = pt.x;
|
r.max.x = pt.x;
|
||||||
r.min.y = ((align&South) ? pt.y : pt.y-1);
|
|
||||||
|
if(align & South)
|
||||||
|
r.min.y = pt.y;
|
||||||
|
else if(align & North)
|
||||||
|
r.min.y = pt.y - 1;
|
||||||
r.max.y = r.min.y+2;
|
r.max.y = r.min.y+2;
|
||||||
|
|
||||||
div_set(d, pt.x);
|
if(align & (East|West))
|
||||||
reshapewin(hwin, r);
|
div_set(d, pt.x);
|
||||||
|
if(hwin)
|
||||||
|
reshapewin(hwin, r);
|
||||||
}
|
}
|
||||||
|
|
||||||
r = f->r;
|
r = f->r;
|
||||||
if(align&West)
|
if(align & West)
|
||||||
r.min.x = pt.x;
|
r.min.x = pt.x;
|
||||||
else
|
else if(align & East)
|
||||||
r.max.x = pt.x;
|
r.max.x = pt.x;
|
||||||
if(align&North)
|
if(align & North)
|
||||||
r.min.y = pt.y;
|
r.min.y = pt.y;
|
||||||
else
|
else if(align & South)
|
||||||
r.max.y = pt.y;
|
r.max.y = pt.y;
|
||||||
column_resizeframe(f, r);
|
column_resizeframe(f, r);
|
||||||
|
|
||||||
/* XXX: Magic number... */
|
/* XXX: Magic number... */
|
||||||
if(align&West)
|
if(align & West)
|
||||||
pt.x = f->r.min.x + 4;
|
pt.x = f->r.min.x + 4;
|
||||||
else
|
else if(align & East)
|
||||||
pt.x = f->r.max.x - 4;
|
pt.x = f->r.max.x - 4;
|
||||||
if(align&North)
|
|
||||||
|
if(align & North)
|
||||||
pt.y = f->r.min.y + 4;
|
pt.y = f->r.min.y + 4;
|
||||||
else
|
else if(align & South)
|
||||||
pt.y = f->r.max.y - 4;
|
pt.y = f->r.max.y - 4;
|
||||||
warppointer(pt);
|
warppointer(pt);
|
||||||
|
|
||||||
done:
|
done:
|
||||||
ungrabpointer();
|
ungrabpointer();
|
||||||
destroyconstraintwin(cwin);
|
destroyconstraintwin(cwin);
|
||||||
destroywindow(hwin);
|
if (hwin)
|
||||||
|
destroywindow(hwin);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
@ -8,10 +8,10 @@ quadrant(Rectangle r, Point pt) {
|
||||||
Align ret;
|
Align ret;
|
||||||
|
|
||||||
pt = subpt(pt, r.min);
|
pt = subpt(pt, r.min);
|
||||||
ret = East * (pt.x >= Dx(r) * .5)
|
ret = East * (pt.x >= Dx(r) * .7)
|
||||||
| West * (pt.x < Dx(r) * .5)
|
| West * (pt.x <= Dx(r) * .3)
|
||||||
| South * (pt.y >= Dy(r) * .5)
|
| South * (pt.y >= Dy(r) * .7)
|
||||||
| North * (pt.y < Dy(r) * .5);
|
| North * (pt.y <= Dy(r) * .3);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue