mirror of
https://github.com/0intro/wmii
synced 2025-01-22 10:02:23 +03:00
implemented maxclient property for areas, the default is now, that first column has maxclient==1 (though if detached things still don't behave like I want it, detaching from maxclient column should fetch from next column a client if possible)
This commit is contained in:
parent
9c6b2d5bb0
commit
e9243fc7ce
@ -95,7 +95,7 @@ select_area(Area *a, char *arg)
|
||||
}
|
||||
|
||||
void
|
||||
sendto_area(Area *new, Client *c)
|
||||
sendto_area(Area *to, Client *c)
|
||||
{
|
||||
Area *a = c->area;
|
||||
|
||||
@ -104,12 +104,39 @@ sendto_area(Area *new, Client *c)
|
||||
if(a->sel >= a->nclient)
|
||||
a->sel = 0;
|
||||
|
||||
new->client = (Client **)cext_array_attach(
|
||||
(void **)new->client, c, sizeof(Client *), &new->clientsz);
|
||||
new->nclient++;
|
||||
|
||||
c->area = new;
|
||||
arrange_column(a);
|
||||
arrange_column(new);
|
||||
attach_client2area(to, c);
|
||||
focus_client(c);
|
||||
}
|
||||
|
||||
void
|
||||
attach_client2area(Area *a, Client *c)
|
||||
{
|
||||
Page *p = a->page;
|
||||
if(area2index(a) && a->maxclient && (a->maxclient == a->nclient)) {
|
||||
Area *to = nil;
|
||||
int i;
|
||||
for(i = p->sel; i < p->narea; i++) {
|
||||
to = p->area[i];
|
||||
if(!to->maxclient || (to->maxclient > to->nclient))
|
||||
break;
|
||||
to = nil;
|
||||
}
|
||||
if(!to) {
|
||||
to = alloc_area(p);
|
||||
sendto_area(to, a->client[a->sel]);
|
||||
arrange_page(p, True);
|
||||
}
|
||||
else
|
||||
sendto_area(to, a->client[a->sel]);
|
||||
}
|
||||
|
||||
a->client = (Client **)cext_array_attach(
|
||||
(void **)a->client, c, sizeof(Client *), &a->clientsz);
|
||||
a->nclient++;
|
||||
c->area = a;
|
||||
if(p->sel > 0) /* column mode */
|
||||
arrange_column(a);
|
||||
else /* normal mode */
|
||||
resize_client(c, &c->frame.rect, nil, False);
|
||||
}
|
||||
|
||||
|
@ -352,14 +352,7 @@ attach_client2page(Page *p, Client *c)
|
||||
Area *a = p->area[p->sel];
|
||||
|
||||
reparent_client(c, c->frame.win, c->rect.x, c->rect.y);
|
||||
a->client = (Client **)cext_array_attach((void **)a->client, c,
|
||||
sizeof(Client *), &a->clientsz);
|
||||
a->nclient++;
|
||||
c->area = a;
|
||||
if(p->sel > 0) /* column mode */
|
||||
arrange_column(a);
|
||||
else /* normal mode */
|
||||
resize_client(c, &c->frame.rect, nil, False);
|
||||
attach_client2area(a, c);
|
||||
map_client(c);
|
||||
XMapWindow(dpy, c->frame.win);
|
||||
}
|
||||
@ -566,7 +559,7 @@ select_client(Client *c, char *arg)
|
||||
void
|
||||
sendtopage_client(Client *c, char *arg) {
|
||||
Page *p;
|
||||
Client *next;
|
||||
Client *to;
|
||||
|
||||
if(!strncmp(arg, "new", 4))
|
||||
p = alloc_page();
|
||||
@ -583,14 +576,14 @@ sendtopage_client(Client *c, char *arg) {
|
||||
attach_client2page(p, c);
|
||||
if(p == page[sel])
|
||||
focus_client(c);
|
||||
else if((next = sel_client_of_page(page[sel])))
|
||||
focus_client(next);
|
||||
else if((to = sel_client_of_page(page[sel])))
|
||||
focus_client(to);
|
||||
}
|
||||
|
||||
void
|
||||
sendtoarea_client(Client *c, char *arg) {
|
||||
const char *errstr;
|
||||
Area *next, *a = c->area;
|
||||
Area *to, *a = c->area;
|
||||
Page *p = a->page;
|
||||
int i = area2index(a);
|
||||
|
||||
@ -598,23 +591,24 @@ sendtoarea_client(Client *c, char *arg) {
|
||||
return;
|
||||
if(!strncmp(arg, "prev", 5)) {
|
||||
if(i == 1)
|
||||
next = p->area[p->narea - 1];
|
||||
to = p->area[p->narea - 1];
|
||||
else
|
||||
next = p->area[i - 1];
|
||||
to = p->area[i - 1];
|
||||
}
|
||||
else if(!strncmp(arg, "next", 5)) {
|
||||
if(i < p->narea - 1)
|
||||
next = p->area[i + 1];
|
||||
to = p->area[i + 1];
|
||||
else
|
||||
next = p->area[1];
|
||||
to = p->area[1];
|
||||
}
|
||||
else {
|
||||
i = cext_strtonum(arg, 0, p->narea - 1, &errstr);
|
||||
if(errstr)
|
||||
return;
|
||||
next = p->area[i];
|
||||
to = p->area[i];
|
||||
}
|
||||
sendto_area(next, c);
|
||||
sendto_area(to, c);
|
||||
arrange_column(to);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -232,8 +232,10 @@ drop_moving(Client *c, XRectangle *new, XPoint * pt)
|
||||
for(i = 1; (i < p->narea) &&
|
||||
!blitz_ispointinrect(pt->x, pt->y, &p->area[i]->rect); i++);
|
||||
if((tgt = ((i < p->narea) ? p->area[i] : nil))) {
|
||||
if(tgt != src)
|
||||
if(tgt != src) {
|
||||
sendto_area(tgt, c);
|
||||
arrange_column(tgt);
|
||||
}
|
||||
else {
|
||||
for(i = 0; (i < src->nclient) &&
|
||||
!blitz_ispointinrect(pt->x, pt->y, &src->client[i]->frame.rect); i++);
|
||||
|
@ -18,7 +18,7 @@ alloc_page()
|
||||
|
||||
p->id = id++;
|
||||
alloc_area(p);
|
||||
alloc_area(p);
|
||||
alloc_area(p)->maxclient = 1; /* default column is master */
|
||||
page = (Page **)cext_array_attach((void **)page, p, sizeof(Page *), &pagesz);
|
||||
npage++;
|
||||
focus_page(p);
|
||||
|
@ -195,7 +195,8 @@ int area2index(Area *a);
|
||||
int aid2index(Page *p, unsigned short id);
|
||||
void update_area_geometry(Area *a);
|
||||
void select_area(Area *a, char *arg);
|
||||
void sendto_area(Area *new, Client *c);
|
||||
void sendto_area(Area *to, Client *c);
|
||||
void attach_client2area(Area *a, Client *c);
|
||||
|
||||
/* bar.c */
|
||||
Label *new_label();
|
||||
|
Loading…
Reference in New Issue
Block a user