mirror of
https://github.com/0intro/wmii
synced 2025-02-16 14:24:00 +03:00
Allow resizing of rightmost and leftmost divs. Needs work.
This commit is contained in:
parent
5d2ad493c6
commit
11143a9586
@ -74,16 +74,16 @@ area_name(Area *a) {
|
||||
Area*
|
||||
area_create(View *v, Area *pos, int scrn, uint width) {
|
||||
static ushort id = 1;
|
||||
uint i;
|
||||
uint minwidth;
|
||||
int i, j;
|
||||
uint minwidth, index;
|
||||
int numcols;
|
||||
Area *a;
|
||||
|
||||
assert(!pos || pos->screen == scrn);
|
||||
SET(i);
|
||||
if(v->areas) { /* Creating a column. */
|
||||
minwidth = Dx(v->r[scrn])/NCOL;
|
||||
i = pos ? area_idx(pos) : 1;
|
||||
minwidth = column_minwidth();
|
||||
index = pos ? area_idx(pos) : 1;
|
||||
numcols = 0;
|
||||
for(a=v->areas[scrn]; a; a=a->next)
|
||||
numcols++;
|
||||
@ -92,7 +92,7 @@ area_create(View *v, Area *pos, int scrn, uint width) {
|
||||
*/
|
||||
if(width == 0) {
|
||||
if(numcols >= 0) {
|
||||
width = view_newcolwidth(v, i);
|
||||
width = view_newcolwidth(v, index);
|
||||
if (width == 0)
|
||||
width = Dx(v->r[scrn]) / (numcols + 1);
|
||||
}
|
||||
@ -102,9 +102,17 @@ area_create(View *v, Area *pos, int scrn, uint width) {
|
||||
|
||||
if(width < minwidth)
|
||||
width = minwidth;
|
||||
if(numcols && (numcols * minwidth + width) > Dx(v->r[scrn]))
|
||||
minwidth = numcols * minwidth + minwidth;
|
||||
if(minwidth > Dx(v->r[scrn]))
|
||||
return nil;
|
||||
|
||||
i = minwidth - Dx(v->pad[scrn]) - Dx(v->r[scrn]);
|
||||
if(i > 0 && Dx(v->pad[scrn])) {
|
||||
j = min(i/2, v->pad[scrn].min.x);
|
||||
v->pad[scrn].min.x -= j;
|
||||
v->pad[scrn].max.x += i - j;
|
||||
}
|
||||
|
||||
view_scale(v, scrn, Dx(v->r[scrn]) - width);
|
||||
}
|
||||
|
||||
@ -145,7 +153,7 @@ area_create(View *v, Area *pos, int scrn, uint width) {
|
||||
area_focus(a);
|
||||
|
||||
if(!a->floating)
|
||||
event("CreateColumn %ud\n", i);
|
||||
event("CreateColumn %ud\n", index);
|
||||
return a;
|
||||
}
|
||||
|
||||
|
@ -80,6 +80,12 @@ column_getmode(Area *a) {
|
||||
a->max ? '+' : '-');
|
||||
}
|
||||
|
||||
int
|
||||
column_minwidth(void)
|
||||
{
|
||||
return 4 * labelh(def.font);
|
||||
}
|
||||
|
||||
Area*
|
||||
column_new(View *v, Area *pos, int scrn, uint w) {
|
||||
Area *a;
|
||||
@ -698,7 +704,7 @@ column_resizeframe(Frame *f, Rectangle r) {
|
||||
a = f->area;
|
||||
v = a->view;
|
||||
|
||||
minw = Dx(v->r[a->screen]) / NCOL;
|
||||
minw = column_minwidth();
|
||||
|
||||
al = a->prev;
|
||||
ar = a->next;
|
||||
|
@ -279,6 +279,7 @@ struct View {
|
||||
int selcol;
|
||||
bool dead;
|
||||
Rectangle *r;
|
||||
Rectangle *pad;
|
||||
};
|
||||
|
||||
/* Yuck. */
|
||||
|
@ -109,6 +109,7 @@ void column_attachrect(Area*, Frame*, Rectangle);
|
||||
void column_detach(Frame*);
|
||||
void column_frob(Area*);
|
||||
void column_insert(Area*, Frame*, Frame*);
|
||||
int column_minwidth(void);
|
||||
Area* column_new(View*, Area*, int, uint);
|
||||
void column_remove(Frame*);
|
||||
void column_resize(Area*, int);
|
||||
|
@ -203,7 +203,7 @@ hplace(Framewin *fw, Point pt) {
|
||||
return; /* XXX: Multihead. */
|
||||
|
||||
fw->ra = nil;
|
||||
minw = Dx(v->r[a->screen])/NCOL;
|
||||
minw = column_minwidth();
|
||||
if(abs(pt.x - a->r.min.x) < minw/2) {
|
||||
pt.x = a->r.min.x;
|
||||
fw->ra = a->prev;
|
||||
|
@ -178,6 +178,7 @@ init_screens(void) {
|
||||
for(v=view; v; v=v->next) {
|
||||
v->areas = erealloc(v->areas, m * sizeof *v->areas);
|
||||
v->r = erealloc(v->r, m * sizeof *v->r);
|
||||
v->pad = erealloc(v->pad, m * sizeof *v->pad);
|
||||
}
|
||||
|
||||
for(i=nscreens; i < m; i++) {
|
||||
|
@ -229,7 +229,7 @@ mouse_resizecolframe(Frame *f, Align align) {
|
||||
if(align&East)
|
||||
d = d->next;
|
||||
|
||||
min.x = Dx(v->r[a->screen])/NCOL;
|
||||
min.x = column_minwidth();
|
||||
min.y = /*frame_delta_h() +*/ labelh(def.font);
|
||||
/* Set the limits of where this box may be dragged. */
|
||||
#define frob(pred, f, aprev, rmin, rmax, plus, minus, xy) BLOCK( \
|
||||
@ -312,23 +312,19 @@ void
|
||||
mouse_resizecol(Divide *d) {
|
||||
Window *cwin;
|
||||
View *v;
|
||||
Area *a;
|
||||
Rectangle r;
|
||||
Point pt;
|
||||
int minw;
|
||||
int minw, scrn;
|
||||
|
||||
v = selview;
|
||||
|
||||
a = d->left;
|
||||
/* Fix later */
|
||||
if(a == nil || a->next == nil)
|
||||
return;
|
||||
scrn = (d->left ? d->left : d->right)->screen;
|
||||
|
||||
pt = querypointer(&scr.root);
|
||||
|
||||
minw = Dx(v->r[a->screen])/NCOL;
|
||||
r.min.x = a->r.min.x + minw;
|
||||
r.max.x = a->next->r.max.x - minw;
|
||||
minw = column_minwidth();
|
||||
r.min.x = d->left ? d->left->r.min.x + minw : v->r[scrn].min.x;
|
||||
r.max.x = d->right ? d->right->r.max.x - minw : v->r[scrn].max.x;
|
||||
r.min.y = pt.y;
|
||||
r.max.y = pt.y+1;
|
||||
|
||||
@ -340,7 +336,19 @@ mouse_resizecol(Divide *d) {
|
||||
while(readmotion(&pt))
|
||||
div_set(d, pt.x);
|
||||
|
||||
column_resize(a, pt.x - a->r.min.x);
|
||||
if(d->left)
|
||||
d->left->r.max.x = pt.x;
|
||||
else
|
||||
v->pad[scrn].min.x = pt.x - v->r[scrn].min.x;
|
||||
|
||||
if(d->right)
|
||||
d->right->r.min.x = pt.x;
|
||||
else
|
||||
v->pad[scrn].max.x = pt.x - v->r[scrn].max.x;
|
||||
print("%R\n", v->pad[scrn]);
|
||||
print("%d %d\n", pt.x - v->r[scrn].min.x, pt.x - v->r[scrn].max.x);
|
||||
|
||||
view_arrange(v);
|
||||
|
||||
done:
|
||||
ungrabpointer();
|
||||
|
@ -74,15 +74,18 @@ view_create(const char *name) {
|
||||
v = emallocz(sizeof *v);
|
||||
v->id = id++;
|
||||
v->r = emallocz(nscreens * sizeof *v->r);
|
||||
v->areas = emallocz(nscreens * sizeof *v->areas);
|
||||
v->pad = emallocz(nscreens * sizeof *v->pad);
|
||||
|
||||
utflcpy(v->name, name, sizeof v->name);
|
||||
|
||||
event("CreateTag %s\n", v->name);
|
||||
area_create(v, nil, screen->idx, 0);
|
||||
|
||||
v->areas = emallocz(nscreens * sizeof *v->areas);
|
||||
|
||||
for(i=0; i < nscreens; i++)
|
||||
view_init(v, i);
|
||||
|
||||
|
||||
area_focus(v->firstarea);
|
||||
|
||||
@ -104,6 +107,8 @@ view_create(const char *name) {
|
||||
|
||||
void
|
||||
view_init(View *v, int iscreen) {
|
||||
v->r[iscreen] = screens[iscreen]->r;
|
||||
print("%d: %R\n", iscreen, screens[iscreen]->r);;
|
||||
v->areas[iscreen] = nil;
|
||||
column_new(v, nil, iscreen, 0);
|
||||
}
|
||||
@ -469,9 +474,10 @@ view_scale(View *v, int scrn, int width) {
|
||||
uint minwidth;
|
||||
Area *a;
|
||||
float scale;
|
||||
int dx;
|
||||
int dx, minx;
|
||||
|
||||
minwidth = Dx(v->r[scrn])/NCOL; /* XXX: Multihead. */
|
||||
minwidth = column_minwidth();
|
||||
minx = v->r[scrn].min.x + v->pad[scrn].min.x;
|
||||
|
||||
if(!v->areas[scrn])
|
||||
return;
|
||||
@ -484,7 +490,7 @@ view_scale(View *v, int scrn, int width) {
|
||||
}
|
||||
|
||||
scale = (float)width / dx;
|
||||
xoff = v->r[scrn].min.x;
|
||||
xoff = minx;
|
||||
for(a=v->areas[scrn]; a; a=a->next) {
|
||||
a->r.max.x = xoff + Dx(a->r) * scale;
|
||||
a->r.min.x = xoff;
|
||||
@ -496,14 +502,14 @@ view_scale(View *v, int scrn, int width) {
|
||||
if(numcol * minwidth > width)
|
||||
return;
|
||||
|
||||
xoff = v->r[scrn].min.x;
|
||||
xoff = minx;
|
||||
for(a=v->areas[scrn]; a; a=a->next) {
|
||||
a->r.min.x = xoff;
|
||||
|
||||
if(Dx(a->r) < minwidth)
|
||||
a->r.max.x = xoff + minwidth;
|
||||
if(!a->next)
|
||||
a->r.max.x = v->r[scrn].min.x + width;
|
||||
a->r.max.x = minx + width;
|
||||
xoff = a->r.max.x;
|
||||
}
|
||||
}
|
||||
@ -519,7 +525,7 @@ view_arrange(View *v) {
|
||||
|
||||
view_update_rect(v);
|
||||
for(s=0; s < nscreens; s++)
|
||||
view_scale(v, s, Dx(v->r[s]));
|
||||
view_scale(v, s, Dx(v->r[s]) + Dx(v->pad[s]));
|
||||
foreach_area(v, s, a) {
|
||||
if(a->floating)
|
||||
continue;
|
||||
|
Loading…
x
Reference in New Issue
Block a user