wmii

git clone git://oldgit.suckless.org/wmii/
Log | Files | Refs | README | LICENSE

commit 8a00a26c45f01dfb85f27d5102f10b87d7d10ec6
parent 447f1e24515ed4ee6f54fa5ee6c0ca244b6e55d6
Author: Anselm R. Garbe <garbeam@wmii.de>
Date:   Wed,  1 Feb 2006 17:27:53 +0200

 finised xread and xstat, now going to xwrite


Diffstat:
cmd/wm/client.c | 28++++++++++++++--------------
cmd/wm/fs.c | 298++++++++++++++++++++++++++++++++++++++++++++++++++++---------------------------
cmd/wm/page.c | 50+++++++++++++++++++++++++-------------------------
cmd/wm/wm.c | 4++--
cmd/wm/wm.h | 22++++++++--------------
cmd/wmiibar.c | 5++---
6 files changed, 246 insertions(+), 161 deletions(-)

diff --git a/cmd/wm/client.c b/cmd/wm/client.c @@ -123,14 +123,14 @@ focus_client(Client *c) focus_page(c->page); p = c->page; } - p->is_column = c->column != nil; + p->is_area = c->area != nil; p->file[P_SEL_PREFIX]->content = c->file[P_PREFIX]->content; - if(p->is_column) { - for(i = 0; (i < p->columnsz) && p->column[i]; i++) { - Column *col = p->column[i]; + if(p->is_area) { + for(i = 0; (i < p->areasz) && p->area[i]; i++) { + Area *col = p->area[i]; for(j = 0; (j < col->clientsz) && col->client[j] && (c != col->client[j]); j++); if((j < col->clientsz) && col->client[j]) { - p->sel_column = i; + p->sel_area = i; col->sel = j; break; } @@ -405,8 +405,8 @@ attach_client(Client *c) c->page = p; wmii_move_ixpfile(c->file[C_PREFIX], p->file[P_CLIENT_PREFIX]); - if(p->is_column) - attach_column(c); + if(p->is_area) + attach_area(c); else p->floating = (Client **)cext_array_attach((void **)p->floating, c, sizeof(Client *), &p->floatingsz); @@ -421,8 +421,8 @@ void detach_client(Client *c, Bool unmap) { wmii_move_ixpfile(c->file[C_PREFIX], def[WM_DETACHED_PREFIX]); - if(c->column) - detach_column(c); + if(c->area) + detach_area(c); else { cext_array_detach((void **)c->page->floating, c, &c->page->floatingsz); if(!c->destroyed) { @@ -446,8 +446,8 @@ Client * sel_client_of_page(Page *p) { if(p) { - if(p->is_column) { - Column *col = p->column[p->sel_column]; + if(p->is_area) { + Area *col = p->area[p->sel_area]; return (col && col->client) ? col->client[col->sel] : nil; } else @@ -534,8 +534,8 @@ resize_client(Client *c, XRectangle *r, XPoint *pt) unsigned int tabh = tab_height(c); unsigned int bw = border_width(c); - if(c->column) - resize_column(c, r, pt); + if(c->area) + resize_area(c, r, pt); /* resize if client requests special size */ check_dimensions(c, tabh, bw); @@ -622,7 +622,7 @@ max_client(void *obj, char *arg) } else { c->frame.revert = c->frame.rect; - c->frame.rect = c->column ? c->column->rect : rect; + c->frame.rect = c->area ? c->area->rect : rect; XRaiseWindow(dpy, c->frame.win); resize_client(c, &c->frame.rect, nil); } diff --git a/cmd/wm/fs.c b/cmd/wm/fs.c @@ -36,23 +36,24 @@ * /sel/ Dpage sel page * /1/ Dpage page * /1/ctl Fctl command interface (page) - * /1/sel/ Dcol - * /1/new/ Dcol - * /1/float/ Dcol floating clients in col 0 + * /1/sel/ Darea + * /1/new/ Darea + * /1/float/ Darea floating clients in area 0 + * /1/float/ctl Fctl command interface (area) * /1/float/sel/ Dclient * /1/float/1/ Dclient * /1/float/1/border Fborder 0..n * /1/float/1/title Ftitle 0, 1 * /1/float/1/name Fname name of client * /1/float/1/ctl Fctl command interface (client) - * /1/1/ Dcol + * /1/1/ Darea + * /1/1/ctl Fctl command interface (area) * /1/1/1/sel/ Dclient * /1/1/1/1/ Dclient * /1/1/1/border Fborder 0..n * /1/1/1/title Ftitle 0, 1 * /1/1/1/name Fname name of client * /1/1/1/ctl Fctl command interface (client) - * /1/1/ctl Fctl command interface (col) */ /* 8-bit qid.path.type */ @@ -60,7 +61,7 @@ enum { Droot, Ddefault, Dpage, - Dcol, + Darea, Dclient, Ffont, Fselcolor, @@ -87,10 +88,10 @@ static Qid root_qid; /* IXP stuff */ static unsigned long long -mkqpath(unsigned char type, unsigned short pg, unsigned short col, unsigned short cl) +mkqpath(unsigned char type, unsigned short pg, unsigned short area, unsigned short cl) { return ((unsigned long long) type << 48) | ((unsigned long long) pg << 32) - | ((unsigned long long) col << 16) | (unsigned long long) cl; + | ((unsigned long long) area << 16) | (unsigned long long) cl; } static unsigned char @@ -106,7 +107,7 @@ qpath_page(unsigned long long path) } static unsigned short -qpath_col(unsigned long long path) +qpath_area(unsigned long long path) { return (path >> 16) & 0xffff; } @@ -122,7 +123,7 @@ qid_to_name(Qid *qid) { unsigned char typ = qpath_type(qid->path); unsigned short pg = qpath_page(qid->path); - unsigned short col = qpath_col(qid->path); + unsigned short area = qpath_area(qid->path); unsigned short cl = qpath_client(qid->path); static char buf[32]; @@ -137,16 +138,18 @@ qid_to_name(Qid *qid) snprintf(buf, sizeof(buf), "%u", pg); return buf; break; - case Dcol: - if(page[pg]->ncol == col) + case Darea: + if(!area) + return "float"; + if(page[pg]->narea == area) return "new"; - if(page[pg]->sel_col == col) + if(page[pg]->sel == area) return "sel"; - snprintf(buf, sizeof(buf), "%u", col); + snprintf(buf, sizeof(buf), "%u", area); return buf; break; case Dclient: - if(!col && page[pg]->sel_float == cl) + if(page[pg]->area[area]->sel == cl) return "sel"; snprintf(buf, sizeof(buf), "%u", cl); return buf; @@ -175,7 +178,7 @@ name_to_type(char *name, unsigned char dtyp) if(dtyp == Droot) return Dpage; else if(dtyp == Dpage) - return Dcol; + return Darea; } if(!strncmp(name, "ctl", 4)) return Fctl; @@ -203,8 +206,8 @@ name_to_type(char *name, unsigned char dtyp) dyndir: switch(dtyp) { case Droot: return Dpage; break; - case Dcol: - case Dpage: return Dclient; break; + case Dpage: return Darea; break; + case Darea: return Dclient; break; } return -1; } @@ -215,7 +218,7 @@ mkqid(Qid *dir, char *wname, Qid *new) const char *err; unsigned char dtyp = qpath_type(dir->path); unsigned short dpg = qpath_page(dir->path); - unsigned short dcol = qpath_col(dir->path); + unsigned short darea = qpath_area(dir->path); unsigned short dcl = qpath_client(dir->path); unsigned short i; int type = name_to_type(wname, dtyp); @@ -246,43 +249,35 @@ mkqid(Qid *dir, char *wname, Qid *new) new->path = mkqpath(Dpage, i, 0, 0); } break; - case Dcol: + case Darea: new->type = IXP_QTDIR; if(!strncmp(wname, "new", 4)) - new->path = mkqpath(Dcol, dpg, page[dpg]->ncol, 0); + new->path = mkqpath(Darea, dpg, page[dpg]->narea, 0); + else if(!strncmp(wname, "float", 4)) + new->path = mkqpath(Darea, dpg, 0, 0); else if(!strncmp(wname, "sel", 4)) - new->path = mkqpath(Dcol, dpg, page[dpg]->sel_col, 0); + new->path = mkqpath(Darea, dpg, page[dpg]->sel, 0); else { i = cext_strtonum(wname, 1, 0xffff, &err); if(err) return -1; - new->path = mkqpath(Dcol, dpg, i, 0); + new->path = mkqpath(Darea, dpg, i, 0); } break; case Dclient: new->type = IXP_QTDIR; - if(!strncmp(wname, "new", 4)) { - if(dcol) - new->path = mkqpath(Dclient, dpg, dcol, page[dpg]->col[dcol]->nclient); - else - new->path = mkqpath(Dclient, dpg, dcol, page[dpg]->nfloat); - } - else if(!strncmp(wname, "sel", 4)) { - if(dcol) - new->path = mkqpath(Dclient, dpg, dcol, page[dpg]->col[dcol]->sel); - else - new->path = mkqpath(Dclient, dpg, dcol, page[dpg]->sel_float); - } + if(!strncmp(wname, "sel", 4)) + new->path = mkqpath(Dclient, dpg, darea, page[dpg]->area[darea]->sel); else { i = cext_strtonum(wname, 1, 0xffff, &err); if(err) return -1; - new->path = mkqpath(Dclient, dpg, dcol, i); + new->path = mkqpath(Dclient, dpg, darea, i); } break; default: new->type = IXP_QTFILE; - new->path = mkqpath(type, dpg, dcol, dcl); + new->path = mkqpath(type, dpg, darea, dcl); break; } return 0; @@ -389,11 +384,13 @@ mkstat(Stat *stat, Qid *dir, char *name, unsigned long long length, unsigned int } static unsigned int -type_to_stat(Stat *stat, char *name, Qid *dir, unsigned int idx) +type_to_stat(Stat *stat, char *name, Qid *dir) { unsigned char dtyp = qpath_type(dir->path); unsigned short dpg = qpath_page(dir->path); - unsigned short dcol = qpath_col(dir->path); + unsigned short darea = qpath_area(dir->path); + unsigned int idx; + const char *err; int type = name_to_type(name, dtyp); char buf[16]; @@ -401,7 +398,7 @@ type_to_stat(Stat *stat, char *name, Qid *dir, unsigned int idx) case Droot: case Ddefault: case Dpage: - case Dcol: + case Darea: case Dclient: return mkstat(stat, dir, name, 0, DMDIR | DMREAD | DMEXEC); break; @@ -424,12 +421,10 @@ type_to_stat(Stat *stat, char *name, Qid *dir, unsigned int idx) if(dtyp == Ddefault) snprintf(buf, sizeof(buf), "%d", def.border); else { - if(dcol) { - Column *col = page[dpg]->col[dcol]; - snprintf(buf, sizeof(buf), "%d", col->client[idx]->frame.border); - } - else - snprintf(buf, sizeof(buf), "%d", page[dpg]->floatc[idx]->frame.border); + idx = cext_strtonum(name, 1, 0xffff, &err); + if(err) + return 0; + snprintf(buf, sizeof(buf), "%d", page[dpg]->area[darea]->client[idx]->frame.border); } return mkstat(stat, dir, name, strlen(buf), DMREAD | DMWRITE); break; @@ -437,12 +432,10 @@ type_to_stat(Stat *stat, char *name, Qid *dir, unsigned int idx) if(dtyp == Ddefault) snprintf(buf, sizeof(buf), "%d", def.title); else { - if(dcol) { - Column *col = page[dpg]->col[dcol]; - snprintf(buf, sizeof(buf), "%d", col->client[idx]->frame.title); - } - else - snprintf(buf, sizeof(buf), "%d", page[dpg]->floatc[idx]->frame.title); + idx = cext_strtonum(name, 1, 0xffff, &err); + if(err) + return 0; + snprintf(buf, sizeof(buf), "%d", page[dpg]->area[darea]->client[idx]->frame.title); } return mkstat(stat, dir, name, strlen(buf), DMREAD | DMWRITE); break; @@ -451,12 +444,7 @@ type_to_stat(Stat *stat, char *name, Qid *dir, unsigned int idx) return mkstat(stat, dir, name, strlen(buf), DMREAD | DMWRITE); break; case Fname: - if(dcol) { - Column *col = page[dpg]->col[dcol]; - return mkstat(stat, dir, name, strlen(col->client[idx]->name), DMREAD); - } - else - return mkstat(stat, dir, name, strlen(page[dpg]->floatc[idx]->name), DMREAD | DMWRITE); + return mkstat(stat, dir, name, strlen(page[dpg]->area[darea]->client[idx]->name), DMREAD); break; default: errstr = "invalid stat"; @@ -471,7 +459,7 @@ xread(IXPConn *c) Stat stat; IXPMap *m = ixp_server_fid2map(c, c->fcall->fid); unsigned char typ, *p = c->fcall->data; - unsigned short pg, col, cl; + unsigned short pg, area, cl; unsigned int i, len; char buf[32]; @@ -481,31 +469,76 @@ xread(IXPConn *c) } typ = qpath_type(m->qid.path); pg = qpath_page(m->qid.path); - col = qpath_col(m->qid.path); + area = qpath_area(m->qid.path); cl = qpath_client(m->qid.path); + if(cl) + cl--; c->fcall->count = 0; if(c->fcall->offset) { switch (qpath_type(m->qid.path)) { case Droot: /* jump to offset */ - len = type_to_stat(&stat, "ctl", &m->qid, 0); - len += type_to_stat(&stat, "event", &m->qid, 0); - len += type_to_stat(&stat, "default", &m->qid, 0); - len += type_to_stat(&stat, "sel", &m->qid, 0); - len += type_to_stat(&stat, "new", &m->qid, 0); + len = type_to_stat(&stat, "ctl", &m->qid); + len += type_to_stat(&stat, "event", &m->qid); + len += type_to_stat(&stat, "default", &m->qid); + len += type_to_stat(&stat, "sel", &m->qid); + len += type_to_stat(&stat, "new", &m->qid); for(i = 1; i < npage; i++) { snprintf(buf, sizeof(buf), "%u", i); - len += type_to_stat(&stat, buf, &m->qid, 0); + len += type_to_stat(&stat, buf, &m->qid); if(len <= c->fcall->offset) continue; - else - break; + break; } /* offset found, proceeding */ for(; i < npage; i++) { snprintf(buf, sizeof(buf), "%u", i); - len = type_to_stat(&stat, buf, &m->qid, 0); + len = type_to_stat(&stat, buf, &m->qid); + if(c->fcall->count + len > c->fcall->iounit) + break; + c->fcall->count += len; + p = ixp_enc_stat(p, &stat); + } + break; + case Dpage: + /* jump to offset */ + len = type_to_stat(&stat, "ctl", &m->qid); + len += type_to_stat(&stat, "sel", &m->qid); + len += type_to_stat(&stat, "new", &m->qid); + len += type_to_stat(&stat, "float", &m->qid); + for(i = 1; i < page[pg]->narea; i++) { + snprintf(buf, sizeof(buf), "%u", i); + len += type_to_stat(&stat, buf, &m->qid); + if(len <= c->fcall->offset) + continue; + break; + } + /* offset found, proceeding */ + for(; i < page[pg]->narea; i++) { + snprintf(buf, sizeof(buf), "%u", i); + len = type_to_stat(&stat, buf, &m->qid); + if(c->fcall->count + len > c->fcall->iounit) + break; + c->fcall->count += len; + p = ixp_enc_stat(p, &stat); + } + break; + case Darea: + /* jump to offset */ + len = type_to_stat(&stat, "ctl", &m->qid); + len += type_to_stat(&stat, "sel", &m->qid); + for(i = 0; i < page[pg]->area[area]->nclient; i++) { + snprintf(buf, sizeof(buf), "%u", i + 1); + len += type_to_stat(&stat, buf, &m->qid); + if(len <= c->fcall->offset) + continue; + break; + } + /* offset found, proceeding */ + for(; i < page[pg]->area[area]->nclient; i++) { + snprintf(buf, sizeof(buf), "%u", i + 1); + len = type_to_stat(&stat, buf, &m->qid); if(c->fcall->count + len > c->fcall->iounit) break; c->fcall->count += len; @@ -522,19 +555,19 @@ xread(IXPConn *c) else { switch (qpath_type(m->qid.path)) { case Droot: - c->fcall->count = type_to_stat(&stat, "ctl", &m->qid, 0); + c->fcall->count = type_to_stat(&stat, "ctl", &m->qid); p = ixp_enc_stat(p, &stat); - c->fcall->count += type_to_stat(&stat, "event", &m->qid, 0); + c->fcall->count += type_to_stat(&stat, "event", &m->qid); p = ixp_enc_stat(p, &stat); - c->fcall->count += type_to_stat(&stat, "default", &m->qid, 0); + c->fcall->count += type_to_stat(&stat, "default", &m->qid); p = ixp_enc_stat(p, &stat); - c->fcall->count += type_to_stat(&stat, "sel", &m->qid, 0); + c->fcall->count += type_to_stat(&stat, "sel", &m->qid); p = ixp_enc_stat(p, &stat); - c->fcall->count += type_to_stat(&stat, "new", &m->qid, 0); + c->fcall->count += type_to_stat(&stat, "new", &m->qid); p = ixp_enc_stat(p, &stat); for(i = 1; i < npage; i++) { snprintf(buf, sizeof(buf), "%u", i); - len = type_to_stat(&stat, buf, &m->qid, 0); + len = type_to_stat(&stat, buf, &m->qid); if(c->fcall->count + len > c->fcall->iounit) break; c->fcall->count += len; @@ -542,13 +575,61 @@ xread(IXPConn *c) } break; case Ddefault: - if(i > nitem) - goto error_xread; - if(i == nitem) - new_item(); - c->fcall->count = type_to_stat(&stat, "color", i); + c->fcall->count = type_to_stat(&stat, "font", &m->qid); + p = ixp_enc_stat(p, &stat); + c->fcall->count += type_to_stat(&stat, "selcolor", &m->qid); + p = ixp_enc_stat(p, &stat); + c->fcall->count += type_to_stat(&stat, "normcolor", &m->qid); + p = ixp_enc_stat(p, &stat); + c->fcall->count += type_to_stat(&stat, "border", &m->qid); p = ixp_enc_stat(p, &stat); - c->fcall->count += type_to_stat(&stat, "data", i); + c->fcall->count += type_to_stat(&stat, "title", &m->qid); + p = ixp_enc_stat(p, &stat); + c->fcall->count += type_to_stat(&stat, "snap", &m->qid); + p = ixp_enc_stat(p, &stat); + break; + case Dpage: + c->fcall->count = type_to_stat(&stat, "ctl", &m->qid); + p = ixp_enc_stat(p, &stat); + c->fcall->count += type_to_stat(&stat, "sel", &m->qid); + p = ixp_enc_stat(p, &stat); + c->fcall->count += type_to_stat(&stat, "new", &m->qid); + p = ixp_enc_stat(p, &stat); + c->fcall->count += type_to_stat(&stat, "float", &m->qid); + p = ixp_enc_stat(p, &stat); + for(i = 1; i < page[pg]->narea; i++) { + snprintf(buf, sizeof(buf), "%u", i); + len = type_to_stat(&stat, buf, &m->qid); + if(c->fcall->count + len > c->fcall->iounit) + break; + c->fcall->count += len; + p = ixp_enc_stat(p, &stat); + } + break; + case Darea: + c->fcall->count = type_to_stat(&stat, "ctl", &m->qid); + p = ixp_enc_stat(p, &stat); + if(!page[pg]->area[area]->nclient) + break; + c->fcall->count += type_to_stat(&stat, "sel", &m->qid); + p = ixp_enc_stat(p, &stat); + for(i = 0; i < page[pg]->area[area]->nclient; i++) { + snprintf(buf, sizeof(buf), "%u", i + 1); + len = type_to_stat(&stat, buf, &m->qid); + if(c->fcall->count + len > c->fcall->iounit) + break; + c->fcall->count += len; + p = ixp_enc_stat(p, &stat); + } + break; + case Dclient: + c->fcall->count = type_to_stat(&stat, "border", &m->qid); + p = ixp_enc_stat(p, &stat); + c->fcall->count += type_to_stat(&stat, "title", &m->qid); + p = ixp_enc_stat(p, &stat); + c->fcall->count += type_to_stat(&stat, "name", &m->qid); + p = ixp_enc_stat(p, &stat); + c->fcall->count += type_to_stat(&stat, "ctl", &m->qid); p = ixp_enc_stat(p, &stat); break; case Fctl: @@ -556,35 +637,46 @@ xread(IXPConn *c) return -1; break; case Ffont: - if((c->fcall->count = strlen(font))) - memcpy(p, font, c->fcall->count); + if((c->fcall->count = strlen(def.font))) + memcpy(p, def.font, c->fcall->count); break; - case Fexpand: - snprintf(buf, sizeof(buf), "%u", iexpand); + case Fevent: + return 1; + break; + case Fselcolor: + if((c->fcall->count = strlen(def.selcolor))) + memcpy(p, def.selcolor, c->fcall->count); + break; + case Fnormcolor: + if((c->fcall->count = strlen(def.normcolor))) + memcpy(p, def.normcolor, c->fcall->count); + break; + case Fborder: + if(qpath_type(m->qid.dir->path) == Ddefault) + snprintf(buf, sizeof(buf), "%u", def.border); + else + snprintf(buf, sizeof(buf), "%u", page[pg]->area[area]->client[cl]->frame.border); c->fcall->count = strlen(buf); memcpy(p, buf, c->fcall->count); break; - case Fevent: - return 1; + case Ftitle: + if(qpath_type(m->qid.dir->path) == Ddefault) + snprintf(buf, sizeof(buf), "%u", def.title); + else + snprintf(buf, sizeof(buf), "%u", page[pg]->area[area]->client[cl]->frame.title); + c->fcall->count = strlen(buf); + memcpy(p, buf, c->fcall->count); break; - case Fdata: - if(i == nitem) - new_item(); - if(i >= nitem) - goto error_xread; - if((c->fcall->count = strlen(item[i]->data))) - memcpy(p, item[i]->data, c->fcall->count); + case Fsnap: + snprintf(buf, sizeof(buf), "%u", def.snap); + c->fcall->count = strlen(buf); + memcpy(p, buf, c->fcall->count); break; - case Fcolor: - if(i == nitem) - new_item(); - if(i >= nitem) - goto error_xread; - if((c->fcall->count = strlen(item[i]->color))) - memcpy(p, item[i]->color, c->fcall->count); + case Fname: + if((c->fcall->count = strlen(page[pg]->area[area]->client[cl]->name))) + memcpy(p, page[pg]->area[area]->client[cl]->name, c->fcall->count); break; default: - error_xread: if(!errstr) errstr = "invalid read"; return -1; @@ -607,7 +699,7 @@ xstat(IXPConn *c) } name = qid_to_name(&m->qid); - if(!type_to_stat(&c->fcall->stat, name, qpath_item(m->qid.path))) + if(!type_to_stat(&c->fcall->stat, name, &m->qid)) return -1; c->fcall->id = RSTAT; return 0; diff --git a/cmd/wm/page.c b/cmd/wm/page.c @@ -16,14 +16,14 @@ static void select_client(void *obj, char *arg); static void toggle_layout(void *obj, char *arg); static void xexec(void *obj, char *arg); static void swap_client(void *obj, char *arg); -static void xnew_column(void *obj, char *arg); +static void xnew_area(void *obj, char *arg); /* action table for /?/ namespace */ Action page_acttbl[] = { {"toggle", toggle_layout}, {"exec", xexec}, {"swap", swap_client}, - {"newcol", xnew_column}, + {"newcol", xnew_area}, {"select", select_client}, {0, 0} }; @@ -52,13 +52,13 @@ alloc_page() def[WM_SEL_PAGE]->content = p->file[P_PREFIX]->content; invoke_wm_event(def[WM_EVENT_PAGE_UPDATE]); id++; - p->rect_column = rect; + p->rect_area = rect; page = (Page **)cext_array_attach((void **)page, p, sizeof(Page *), &pagesz); for(np = 0; (np < pagesz) && page[np]; np++); focus_page(p); XChangeProperty(dpy, root, net_atoms[NET_NUMBER_OF_DESKTOPS], XA_CARDINAL, 32, PropModeReplace, (unsigned char *) &np, 1); - p->is_column = True; + p->is_area = True; return p; } @@ -184,9 +184,9 @@ toggle_layout(void *obj, char *arg) { Page *p = obj; - p->is_column = !p->is_column; - if(p->is_column) { - Column *col = p->column[p->sel_column]; + p->is_area = !p->is_area; + if(p->is_area) { + Area *col = p->area[p->sel_area]; if(col && col->clientsz && col->client[col->sel]) focus_client(col->client[col->sel]); } @@ -199,16 +199,16 @@ swap_client(void *obj, char *arg) { Page *p = obj; Client *c = sel_client_of_page(p); - Column *west = nil, *east = nil, *col = c->column; + Area *west = nil, *east = nil, *col = c->area; Client *north = nil, *south = nil; size_t i; if(!col || !arg) return; - for(i = 0; (i < p->columnsz) && p->column[i] && (p->column[i] != col); i++); - west = i ? p->column[i - 1] : nil; - east = (i < p->columnsz) && p->column[i + 1] ? p->column[i + 1] : nil; + for(i = 0; (i < p->areasz) && p->area[i] && (p->area[i] != col); i++); + west = i ? p->area[i - 1] : nil; + east = (i < p->areasz) && p->area[i + 1] ? p->area[i + 1] : nil; for(i = 0; (i < col->clientsz) && col->client[i] && (col->client[i] != c); i++); north = i ? col->client[i - 1] : nil; @@ -217,34 +217,34 @@ swap_client(void *obj, char *arg) if(!strncmp(arg, "north", 6) && north) { col->client[i] = col->client[i - 1]; col->client[i - 1] = c; - arrange_column(p, col); + arrange_area(p, col); } else if(!strncmp(arg, "south", 6) && south) { col->client[i] = col->client[i + 1]; col->client[i + 1] = c; - arrange_column(p, col); + arrange_area(p, col); } else if(!strncmp(arg, "west", 5) && west) { col->client[i] = west->client[west->sel]; - col->client[i]->column = col; + col->client[i]->area = col; west->client[west->sel] = c; - west->client[west->sel]->column = west; - arrange_column(p, col); - arrange_column(p, west); + west->client[west->sel]->area = west; + arrange_area(p, col); + arrange_area(p, west); } else if(!strncmp(arg, "east", 5) && east) { col->client[i] = west->client[west->sel]; - col->client[i]->column = col; + col->client[i]->area = col; east->client[east->sel] = c; - east->client[east->sel]->column = east; - arrange_column(p, col); - arrange_column(p, east); + east->client[east->sel]->area = east; + arrange_area(p, col); + arrange_area(p, east); } focus_client(c); } static void -xnew_column(void *obj, char *arg) +xnew_area(void *obj, char *arg) { - new_column(obj); + new_area(obj); } static void @@ -257,8 +257,8 @@ select_client(void *obj, char *arg) if(!c || !arg) return; - if(c->column) - select_column(c, arg); + if(c->area) + select_area(c, arg); else { for(i = 0; (i < p->floatingsz) && p->floating[i] && (p->floating[i] != c); i++); if(!strncmp(arg, "prev", 5)) { diff --git a/cmd/wm/wm.c b/cmd/wm/wm.c @@ -154,8 +154,8 @@ draw_pager_page(size_t idx, Draw *d) blitz_drawlabel(dpy, d); XSync(dpy, False); - for(i = 0; (i < page[idx]->columnsz) && page[idx]->column[i]; i++) { - Column *col = page[idx]->column[i]; + for(i = 0; (i < page[idx]->areasz) && page[idx]->area[i]; i++) { + Area *col = page[idx]->area[i]; for(j = 0; (i < col->clientsz) && col->client[j]; j++) draw_pager_client(col->client[j], d); } diff --git a/cmd/wm/wm.h b/cmd/wm/wm.h @@ -26,11 +26,11 @@ enum { #define ROOT_MASK SubstructureRedirectMask #define CLIENT_MASK (StructureNotifyMask | PropertyChangeMask) -typedef struct Column Column; +typedef struct Area Area; typedef struct Page Page; typedef struct Client Client; -struct Column { +struct Area { Client **client; size_t clientsz; size_t sel; @@ -39,16 +39,10 @@ struct Column { }; struct Page { - Client **floatc; - Column **col; - size_t floatcsz; - size_t colsz; - size_t sel_float; - size_t sel_col; - size_t nfloat; - size_t ncol; - Bool is_column; - XRectangle rect_column; + Area **area; + size_t areasz; + size_t narea; + size_t sel; }; struct Client { @@ -60,7 +54,7 @@ struct Client { Bool destroyed; Bool maximized; Bool attached; - Column *column; + Area *area; Window win; Window trans; XRectangle rect; @@ -185,7 +179,7 @@ XRectangle *rectangles(unsigned int *num); /* column.c */ void arrange_page(Page *p); -void arrange_column(Page *p, Column *col); +void arrange_column(Page *p, Area *col); void attach_column(Client *c); void detach_column(Client *c); void resize_column(Client *c, XRectangle *r, XPoint *pt); diff --git a/cmd/wmiibar.c b/cmd/wmiibar.c @@ -348,7 +348,7 @@ mkqid(Qid *dir, char *wname, Qid *new) new->path = mkqpath(Ditem, i); } break; - case Fdata: /* note, Fdata needs to be before Fcolor, fallthrough */ + case Fdata: /* note, Fdata has to be checked before Fcolor, fallthrough */ if(!i) return -1; case Fcolor: @@ -562,8 +562,7 @@ xread(IXPConn *c) len += type_to_stat(&stat, buf, &m->qid); if(len <= c->fcall->offset) continue; - else - break; + break; } /* offset found, proceeding */ for(; i < nitem; i++) {