removed much crap due to column simplifications

This commit is contained in:
Anselm R. Garbe 2006-03-02 19:58:54 +01:00
parent 02c8d279c3
commit 5789638533
5 changed files with 27 additions and 111 deletions

View File

@ -34,6 +34,8 @@ void
destroy_area(Area *a)
{
Page *p = a->page;
if(a->nclient)
return;
if(a->client)
free(a->client);
cext_array_detach((void **)p->area, a, &p->areasz);
@ -44,7 +46,6 @@ destroy_area(Area *a)
else
p->sel = 0;
}
fprintf(stderr, "destroy_area: p->sel == %d\n", p->sel);
free(a);
}
@ -112,32 +113,13 @@ send_toarea(Area *to, Client *c)
void
attach_toarea(Area *a, Client *c)
{
Page *p = a->page;
if(0 && area2index(a) && a->capacity && (a->capacity == a->nclient)) {
Area *to = nil;
int i;
for(i = p->sel; i < p->narea; i++) {
to = p->area[i];
if(!to->capacity || (to->capacity > to->nclient))
break;
to = nil;
}
if(!to) {
to = alloc_area(p);
send_toarea(to, a->client[a->sel]);
arrange_page(p, True);
}
else
send_toarea(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) /* area mode */
if(area2index(a)) /* column */
arrange_area(a);
else /* normal mode */
else /* floating */
resize_client(c, &c->frame.rect, nil, False);
}
@ -145,43 +127,13 @@ void
detach_fromarea(Client *c)
{
Area *a = c->area;
Page *p = a->page;
int i = area2index(a);
cext_array_detach((void **)a->client, c, &a->clientsz);
a->nclient--;
if(a->sel >= a->nclient)
a->sel = 0;
if(0 && i > 0) {
if(a->nclient < a->capacity) {
for(++i; i < p->narea; i++) {
Area *tmp = p->area[i];
if(!tmp->nclient)
continue;
send_toarea(a, tmp->client[0]);
arrange_page(p, True);
}
}
}
if(!a->nclient) {
destroy_area(a);
arrange_page(p, True);
}
else
arrange_area(a);
}
void
match_capacity(Area *a)
{
while(a->nclient > a->capacity) {
Client *c = a->client[a->nclient - 1];
detach_fromarea(c);
attach_client(c);
}
}
char *
colmode2str(ColumnMode mode)
{
@ -437,26 +389,10 @@ resize_area(Client *c, XRectangle *r, XPoint *pt)
}
Area *
new_area(Area *old)
new_area(Page *p)
{
Page *p = old->page;
Client *c = sel_client_of_page(p);
Area *a;
if(!area2index(old) || (old->nclient < 2))
return nil;
a = alloc_area(p);
cext_array_detach((void **)old->client, c, &old->clientsz);
old->nclient--;
if(old->sel == old->nclient)
old->sel = 0;
a->client = (Client **)cext_array_attach((void **)a->client, c,
sizeof(Client *), &a->clientsz);
a->nclient++;
c->area = a;
Area *a = alloc_area(p);
arrange_page(p, True);
focus_client(c);
return a;
}

View File

@ -74,6 +74,14 @@ set_client_state(Client * c, int state)
(unsigned char *) data, 2);
}
static void
area_name_event(int aidx)
{
char buf[256];
snprintf(buf, sizeof(buf), "AN %d\n", aidx);
write_event(buf);
}
static void
client_name_event(Client *c)
{
@ -98,6 +106,7 @@ focus_client(Client *c)
int i = area2index(c->area);
c->area->page->sel = i;
area_name_event(i);
c->area->sel = client2index(c);
if(old && (old != c)) {
if(old->area == c->area)

View File

@ -194,7 +194,6 @@ qid2name(Qid *qid)
case Fsnap: return "border"; break;
case Fgeom: return "geometry"; break;
case Fname: return "name"; break;
case Fcapacity: return "capacity"; break;
case Fmode: return "mode"; break;
case Fevent: return "event"; break;
case Fkey: return key[i1]->name; break;
@ -245,8 +244,6 @@ name2type(char *name, unsigned char dir_type)
return Ffont;
if(!strncmp(name, "data", 5))
return Fdata;
if(!strncmp(name, "capacity", 9))
return Fcapacity;
if(!strncmp(name, "mode", 5))
return Fmode;
if(name2key(name))
@ -340,7 +337,7 @@ mkqid(Qid *dir, char *wname, Qid *new, Bool iswalk)
new->type = IXP_QTDIR;
if(!strncmp(wname, "new", 4)) {
if(iswalk) {
Area *a = new_area(p->area[p->sel]);
Area *a = new_area(p);
if(!a)
return -1;
new->path = mkqpath(Darea, p->id, a->id, 0);
@ -576,10 +573,6 @@ type2stat(Stat *stat, char *wname, Qid *dir)
case Fdata:
return mkstat(stat, dir, wname, (dir_i1 == nlabel) ? 0 : strlen(label[dir_i1]->data), DMREAD | DMWRITE);
break;
case Fcapacity:
snprintf(buf, sizeof(buf), "%d", page[dir_i1]->area[dir_i2]->capacity);
return mkstat(stat, dir, wname, strlen(buf), DMREAD | DMWRITE);
break;
case Fmode:
return mkstat(stat, dir, wname, strlen(colmode2str(page[dir_i1]->area[dir_i2]->mode)), DMREAD | DMWRITE);
break;
@ -765,10 +758,8 @@ xread(IXPConn *c, Fcall *fcall)
case Darea:
/* jump to offset */
len = type2stat(&stat, "ctl", &m->qid);
if(i2) {
len += type2stat(&stat, "capacity", &m->qid);
if(i2)
len += type2stat(&stat, "mode", &m->qid);
}
for(i = 0; i < page[i1]->area[i2]->nclient; i++) {
if(i == page[i1]->area[i2]->sel)
snprintf(buf, sizeof(buf), "%s", "sel");
@ -891,12 +882,9 @@ xread(IXPConn *c, Fcall *fcall)
case Darea:
fcall->count = type2stat(&stat, "ctl", &m->qid);
p = ixp_enc_stat(p, &stat);
if(i2) {
fcall->count += type2stat(&stat, "capacity", &m->qid);
p = ixp_enc_stat(p, &stat);
if(i2)
fcall->count += type2stat(&stat, "mode", &m->qid);
p = ixp_enc_stat(p, &stat);
}
for(i = 0; i < page[i1]->area[i2]->nclient; i++) {
if(i == page[i1]->area[i2]->sel)
snprintf(buf, sizeof(buf), "%s", "sel");
@ -977,13 +965,6 @@ xread(IXPConn *c, Fcall *fcall)
if((fcall->count = strlen(def.font)))
memcpy(p, def.font, fcall->count);
break;
case Fcapacity:
if(!i2)
return Enofile;
snprintf(buf, sizeof(buf), "%d", page[i1]->area[i2]->capacity);
fcall->count = strlen(buf);
memcpy(p, buf, fcall->count);
break;
case Fmode:
if(!i2)
return Enofile;
@ -1182,17 +1163,6 @@ xwrite(IXPConn *c, Fcall *fcall)
update_bar_geometry();
resize_all_clients();
break;
case Fcapacity:
if(!i2)
return Enofile;
memcpy(buf, fcall->data, fcall->count);
buf[fcall->count] = 0;
i = cext_strtonum(buf, 0, 0xffff, &err);
if(err)
return "max value out of range 0x0000..0xffff";
page[i1]->area[i2]->capacity = i;
match_capacity(page[i1]->area[i2]);
break;
case Fmode:
{
ColumnMode mode;

View File

@ -42,7 +42,6 @@ enum {
Fevent,
Fctl,
Fname,
Fcapacity,
Fmode
};
@ -69,7 +68,6 @@ struct Area {
unsigned int clientsz;
unsigned int sel;
unsigned int nclient;
unsigned int capacity;
ColumnMode mode;
XRectangle rect;
};
@ -201,10 +199,9 @@ void detach_fromarea(Client *c);
void arrange_page(Page *p, Bool updategeometry);
void arrange_area(Area *a);
void resize_area(Client *c, XRectangle *r, XPoint *pt);
Area *new_area(Area *old);
Area *new_area(Page *p);
ColumnMode str2colmode(char *arg);
char *colmode2str(ColumnMode mode);
void match_capacity(Area *a);
/* bar.c */
Label *new_label();

View File

@ -40,9 +40,11 @@ do
:
done
xwrite /bar/new/colors $WMII_NORMCOLORS
xwrite /bar/new/colors $WMII_NORMCOLORS
xwrite /bar/new/colors $WMII_SELCOLORS
xwrite /bar/0/data 1
xwrite /bar/expand 1
xwrite /bar/1/data 1
xwrite /bar/expand 2
# MISC
xsetroot -solid '#0b1014'
@ -99,8 +101,10 @@ do
case "$type" in
PN)
xwrite /bar/0/data "$@";;
CN)
AN)
xwrite /bar/1/data "$@";;
CN)
xwrite /bar/2/data "$@";;
LB)
case "$2" in
1)