some tiny refactoring (renamed _to_ occurences into 2, removed crappy MAX mode from columns, we don't need it, set max to 1 instead (aka exclusive flag))

This commit is contained in:
Anselm R. Garbe 2006-03-01 07:51:04 +01:00
parent e1c2e31c16
commit e5ecb84d2d
18 changed files with 168 additions and 163 deletions

View File

@ -13,6 +13,7 @@ SRC = area.c bar.c fs.c wm.c kb.c client.c event.c mouse.c page.c column.c
OBJ = ${SRC:.c=.o}
all: wmiiwm
@echo built core window manager
.c.o:
@echo CC $<

View File

@ -41,7 +41,7 @@ destroy_area(Area *a)
}
int
area_to_index(Area *a)
area2index(Area *a)
{
int i;
Page *p = a->page;
@ -52,7 +52,7 @@ area_to_index(Area *a)
}
int
aid_to_index(Page *p, unsigned short id)
aid2index(Page *p, unsigned short id)
{
int i;
for(i = 0; i < p->narea; i++)
@ -66,7 +66,7 @@ select_area(Area *a, char *arg)
{
Area *new;
Page *p = a->page;
int i = area_to_index(a);
int i = area2index(a);
if(i == -1)
return;
if(!strncmp(arg, "prev", 5)) {

View File

@ -119,7 +119,7 @@ draw_bar()
}
int
lid_to_index(unsigned short id)
lid2index(unsigned short id)
{
int i;
for(i = 0; i < nlabel; i++)

View File

@ -95,10 +95,10 @@ void
focus_client(Client *c)
{
Client *old = sel_client();
int i = area_to_index(c->area);
int i = area2index(c->area);
c->area->page->sel = i;
c->area->sel = client_to_index(c);
c->area->sel = client2index(c);
if(old && (old != c)) {
c->revert = old;
grab_mouse(old->win, AnyModifier, Button1);
@ -346,7 +346,7 @@ gravitate(Client * c, unsigned int tabh, unsigned int bw, int invert)
}
void
attach_client_to_page(Page *p, Client *c)
attach_client2page(Page *p, Client *c)
{
Area *a = p->area[p->sel];
@ -372,7 +372,7 @@ attach_client(Client *c)
else
p = page[sel];
attach_client_to_page(p, c);
attach_client2page(p, c);
focus_client(c);
}
@ -398,7 +398,7 @@ detach_client(Client *c, Bool unmap)
reparent_client(c, root, c->rect.x, c->rect.y);
XUnmapWindow(dpy, c->frame.win);
}
if(area_to_index(a)) { /* column */
if(area2index(a)) { /* column */
if(!a->nclient) {
Page *p = a->page;
if(p->narea != 2) {
@ -434,7 +434,7 @@ sel_client()
}
Client *
win_to_clientframe(Window w)
win2clientframe(Window w)
{
size_t i;
for(i = 0; (i < clientsz) && client[i]; i++)
@ -493,11 +493,11 @@ resize_client(Client *c, XRectangle *r, XPoint *pt)
{
unsigned int bh = bar_height();
unsigned int bw = def.border;
int pi = page_to_index(c->area->page);
int pi = page2index(c->area->page);
int px = sel * rect.width;
if(area_to_index(c->area) > 0)
if(area2index(c->area) > 0)
resize_column(c, r, pt);
else
c->frame.rect = *r;
@ -521,7 +521,7 @@ resize_client(Client *c, XRectangle *r, XPoint *pt)
}
int
cid_to_index(Area *a, unsigned short id)
cid2index(Area *a, unsigned short id)
{
int i;
for(i = 0; i < a->nclient; i++)
@ -531,7 +531,7 @@ cid_to_index(Area *a, unsigned short id)
}
int
client_to_index(Client *c)
client2index(Client *c)
{
int i;
Area *a = c->area;
@ -545,7 +545,7 @@ void
select_client(Client *c, char *arg)
{
Area *a = c->area;
int i = client_to_index(c);
int i = client2index(c);
if(i == -1)
return;
if(!strncmp(arg, "prev", 5)) {
@ -586,7 +586,7 @@ sendtopage_client(Client *c, char *arg) {
p = page[i - 1];
}
detach_client(c, False);
attach_client_to_page(p, c);
attach_client2page(p, c);
if((next = sel_client_of_page(page[sel])))
focus_client(next);
}
@ -596,7 +596,7 @@ sendtoarea_client(Client *c, char *arg) {
const char *errstr;
Area *next, *a = c->area;
Page *p = a->page;
int i = area_to_index(a);
int i = area2index(a);
if(i == -1 || a->nclient < 2)
return;

View File

@ -8,6 +8,16 @@
#include "wm.h"
ColumnMode
str2colmode(char *arg)
{
if(!strncmp("equal", arg, 6))
return COL_EQUAL;
else if(!strncmp("stack", arg, 6))
return COL_STACK;
return -1;
}
void
arrange_column(Area *col)
{
@ -30,13 +40,6 @@ arrange_column(Area *col)
resize_client(c, &c->frame.rect, 0);
}
break;
case COL_MAX:
for(i = 0; i < col->nclient; i++) {
Client *c = col->client[i];
c->frame.rect = col->rect;
resize_client(c, &c->frame.rect, 0);
}
break;
case COL_STACK:
yoff = col->rect.y;
h = col->rect.height - (col->nclient - 1) * bar_height();
@ -161,7 +164,7 @@ drop_moving(Client *c, XRectangle *new, XPoint * pt)
for(i = 0; (i < src->nclient) &&
!blitz_ispointinrect(pt->x, pt->y, &src->client[i]->frame.rect); i++);
if((i < src->nclient) && (c != src->client[i])) {
size_t j = client_to_index(c);
size_t j = client2index(c);
Client *tmp = src->client[j];
src->client[j] = src->client[i];
src->client[i] = tmp;
@ -189,7 +192,7 @@ new_column(Area *old)
Client *c = sel_client_of_page(p);
Area *col;
if(!area_to_index(old) || (old->nclient < 2))
if(!area2index(old) || (old->nclient < 2))
return nil;
col = alloc_area(p);

View File

@ -72,13 +72,13 @@ handle_buttonpress(XEvent *e)
write_event(buf);
}
}
else if((c = win_to_clientframe(ev->window))) {
else if((c = win2clientframe(ev->window))) {
if(ev->button == Button1) {
if(sel_client() != c) {
focus(c);
return;
}
align = cursor_to_align(c->frame.cursor);
align = cursor2align(c->frame.cursor);
if(align == CENTER)
mouse_move(c);
else
@ -86,11 +86,11 @@ handle_buttonpress(XEvent *e)
}
if(c && c->area) {
snprintf(buf, sizeof(buf), "CB %d %d\n", client_to_index(c) + 1, ev->button);
snprintf(buf, sizeof(buf), "CB %d %d\n", client2index(c) + 1, ev->button);
write_event(buf);
}
}
else if((c = win_to_client(ev->window))) {
else if((c = win2client(ev->window))) {
ev->state &= valid_mask;
if(ev->state & Mod1Mask) {
XRaiseWindow(dpy, c->frame.win);
@ -101,7 +101,7 @@ handle_buttonpress(XEvent *e)
break;
case Button3:
focus(c);
align = xy_to_align(&c->rect, ev->x, ev->y);
align = xy2align(&c->rect, ev->x, ev->y);
if(align == CENTER)
mouse_move(c);
else
@ -113,7 +113,7 @@ handle_buttonpress(XEvent *e)
focus(c);
if(c) {
snprintf(buf, sizeof(buf), "CB %d %d\n", client_to_index(c) + 1, ev->button);
snprintf(buf, sizeof(buf), "CB %d %d\n", client2index(c) + 1, ev->button);
write_event(buf);
}
}
@ -128,7 +128,7 @@ handle_configurerequest(XEvent *e)
Client *c;
unsigned int bw = 0, bh = 0;
c = win_to_client(ev->window);
c = win2client(ev->window);
ev->value_mask &= ~CWSibling;
if(c) {
@ -188,7 +188,7 @@ static void
handle_destroynotify(XEvent *e)
{
XDestroyWindowEvent *ev = &e->xdestroywindow;
Client *c = win_to_client(ev->window);
Client *c = win2client(ev->window);
if(c) {
fprintf(stderr, "destroy: %s\n", c->name);
c->destroyed = True;
@ -204,7 +204,7 @@ handle_expose(XEvent *e)
if(ev->count == 0) {
if(ev->window == winbar)
draw_bar();
else if((c = win_to_clientframe(ev->window)))
else if((c = win2clientframe(ev->window)))
draw_client(c);
}
}
@ -243,7 +243,7 @@ handle_maprequest(XEvent *e)
}
/* there're client which send map requests twice */
c = win_to_client(ev->window);
c = win2client(ev->window);
if(!c)
c = alloc_client(ev->window, &wa);
if(!c->area)
@ -253,7 +253,7 @@ handle_maprequest(XEvent *e)
static void
handle_motionnotify(XEvent *e)
{
Client *c = win_to_clientframe(e->xmotion.window);
Client *c = win2clientframe(e->xmotion.window);
if(c) {
Cursor cursor = cursor_for_motion(c, e->xmotion.x, e->xmotion.y);
if(cursor != c->frame.cursor) {
@ -272,7 +272,7 @@ handle_propertynotify(XEvent *e)
if(ev->state == PropertyDelete)
return; /* ignore */
if((c = win_to_client(ev->window)))
if((c = win2client(ev->window)))
handle_client_property(c, ev);
}
@ -281,7 +281,7 @@ handle_unmapnotify(XEvent *e)
{
XUnmapEvent *ev = &e->xunmap;
Client *c;
if((c = win_to_client(ev->window))) {
if((c = win2client(ev->window))) {
fprintf(stderr, "unmap %s\n", c->name);
detach_client(c, True);
}

View File

@ -126,22 +126,22 @@ decode_qpath(Qid *qid, unsigned char *type, int *i1, int *i2, int *i3)
if(i1id) {
switch(*type) {
case Fkey: *i1 = kid_to_index(i1id); break;
case Fkey: *i1 = kid2index(i1id); break;
case Fdata:
case Fcolors:
case Dlabel: *i1 = lid_to_index(i1id); break;
default: *i1 = pid_to_index(i1id); break;
case Dlabel: *i1 = lid2index(i1id); break;
default: *i1 = pid2index(i1id); break;
}
if(i2id && (*i1 != -1)) {
*i2 = aid_to_index(page[*i1], i2id);
*i2 = aid2index(page[*i1], i2id);
if(i3id && (*i2 != -1))
*i3 = cid_to_index(page[*i1]->area[*i2], i3id);
*i3 = cid2index(page[*i1]->area[*i2], i3id);
}
}
}
static char *
qid_to_name(Qid *qid)
qid2name(Qid *qid)
{
unsigned char type;
int i1 = 0, i2 = 0, i3 = 0;
@ -205,7 +205,7 @@ qid_to_name(Qid *qid)
}
static int
name_to_type(char *name, unsigned char dir_type)
name2type(char *name, unsigned char dir_type)
{
unsigned int i;
if(!name || !name[0] || !strncmp(name, "/", 2) || !strncmp(name, "..", 3))
@ -253,7 +253,7 @@ name_to_type(char *name, unsigned char dir_type)
return Fmax;
if(!strncmp(name, "mode", 5))
return Fmode;
if(name_to_key(name))
if(name2key(name))
return Fkey;
if(!strncmp(name, "sel", 4))
goto dyndir;
@ -281,7 +281,7 @@ mkqid(Qid *dir, char *wname, Qid *new, Bool iswalk)
decode_qpath(dir, &dir_type, &dir_i1, &dir_i2, &dir_i3);
if((dir_i1 == -1) || (dir_i2 == -1) || (dir_i3 == -1))
return -1;
type = name_to_type(wname, dir_type);
type = name2type(wname, dir_type);
new->dir_type = dir_type;
new->version = 0;
@ -384,7 +384,7 @@ mkqid(Qid *dir, char *wname, Qid *new, Bool iswalk)
case Fkey:
{
Key *k;
if(!(k = name_to_key(wname)))
if(!(k = name2key(wname)))
return -1;
new->type = IXP_QTFILE;
new->path = mkqpath(Fkey, k->id, 0, 0);
@ -524,7 +524,7 @@ mkstat(Stat *stat, Qid *dir, char *name, unsigned long long length, unsigned int
}
static unsigned int
type_to_stat(Stat *stat, char *wname, Qid *dir)
type2stat(Stat *stat, char *wname, Qid *dir)
{
unsigned char dir_type;
int dir_i1 = 0, dir_i2 = 0, dir_i3 = 0;
@ -535,7 +535,7 @@ type_to_stat(Stat *stat, char *wname, Qid *dir)
decode_qpath(dir, &dir_type, &dir_i1, &dir_i2, &dir_i3);
if((dir_i1 == -1) || (dir_i2 == -1) || (dir_i3 == -1))
return -1;
type = name_to_type(wname, dir_type);
type = name2type(wname, dir_type);
switch (type) {
case Dclient:
@ -676,18 +676,18 @@ xread(IXPConn *c, Fcall *fcall)
switch (type) {
case Droot:
/* jump to offset */
len = type_to_stat(&stat, "ctl", &m->qid);
len += type_to_stat(&stat, "event", &m->qid);
len += type_to_stat(&stat, "def", &m->qid);
len += type_to_stat(&stat, "keys", &m->qid);
len += type_to_stat(&stat, "bar", &m->qid);
len += type_to_stat(&stat, "new", &m->qid);
len = type2stat(&stat, "ctl", &m->qid);
len += type2stat(&stat, "event", &m->qid);
len += type2stat(&stat, "def", &m->qid);
len += type2stat(&stat, "keys", &m->qid);
len += type2stat(&stat, "bar", &m->qid);
len += type2stat(&stat, "new", &m->qid);
for(i = 0; i < npage; i++) {
if(i == sel)
snprintf(buf, sizeof(buf), "%s", "sel");
else
snprintf(buf, sizeof(buf), "%u", i + 1);
len += type_to_stat(&stat, buf, &m->qid);
len += type2stat(&stat, buf, &m->qid);
if(len <= fcall->offset)
continue;
break;
@ -698,7 +698,7 @@ xread(IXPConn *c, Fcall *fcall)
snprintf(buf, sizeof(buf), "%s", "sel");
else
snprintf(buf, sizeof(buf), "%u", i + 1);
len = type_to_stat(&stat, buf, &m->qid);
len = type2stat(&stat, buf, &m->qid);
if(fcall->count + len > fcall->iounit)
break;
fcall->count += len;
@ -709,14 +709,14 @@ xread(IXPConn *c, Fcall *fcall)
/* jump to offset */
len = 0;
for(i = 0; i < nkey; i++) {
len += type_to_stat(&stat, key[i]->name, &m->qid);
len += type2stat(&stat, key[i]->name, &m->qid);
if(len <= fcall->offset)
continue;
break;
}
/* offset found, proceeding */
for(; i < nkey; i++) {
len = type_to_stat(&stat, key[i]->name, &m->qid);
len = type2stat(&stat, key[i]->name, &m->qid);
if(fcall->count + len > fcall->iounit)
break;
fcall->count += len;
@ -725,11 +725,11 @@ xread(IXPConn *c, Fcall *fcall)
break;
case Dbar:
/* jump to offset */
len = type_to_stat(&stat, "expand", &m->qid);
len += type_to_stat(&stat, "new", &m->qid);
len = type2stat(&stat, "expand", &m->qid);
len += type2stat(&stat, "new", &m->qid);
for(i = 0; i < nlabel; i++) {
snprintf(buf, sizeof(buf), "%u", i + 1);
len += type_to_stat(&stat, buf, &m->qid);
len += type2stat(&stat, buf, &m->qid);
if(len <= fcall->offset)
continue;
break;
@ -737,7 +737,7 @@ xread(IXPConn *c, Fcall *fcall)
/* offset found, proceeding */
for(; i < nlabel; i++) {
snprintf(buf, sizeof(buf), "%u", i + 1);
len = type_to_stat(&stat, buf, &m->qid);
len = type2stat(&stat, buf, &m->qid);
if(fcall->count + len > fcall->iounit)
break;
fcall->count += len;
@ -746,14 +746,14 @@ xread(IXPConn *c, Fcall *fcall)
break;
case Dpage:
/* jump to offset */
len = type_to_stat(&stat, "ctl", &m->qid);
len += type_to_stat(&stat, "new", &m->qid);
len = type2stat(&stat, "ctl", &m->qid);
len += type2stat(&stat, "new", &m->qid);
for(i = 0; i < page[i1]->narea; i++) {
if(i == page[i1]->sel)
snprintf(buf, sizeof(buf), "%s", "sel");
else
snprintf(buf, sizeof(buf), "%u", i + 1);
len += type_to_stat(&stat, buf, &m->qid);
len += type2stat(&stat, buf, &m->qid);
if(len <= fcall->offset)
continue;
break;
@ -764,7 +764,7 @@ xread(IXPConn *c, Fcall *fcall)
snprintf(buf, sizeof(buf), "%s", "sel");
else
snprintf(buf, sizeof(buf), "%u", i + 1);
len = type_to_stat(&stat, buf, &m->qid);
len = type2stat(&stat, buf, &m->qid);
if(fcall->count + len > fcall->iounit)
break;
fcall->count += len;
@ -773,17 +773,17 @@ xread(IXPConn *c, Fcall *fcall)
break;
case Darea:
/* jump to offset */
len = type_to_stat(&stat, "ctl", &m->qid);
len = type2stat(&stat, "ctl", &m->qid);
if(i2) {
len += type_to_stat(&stat, "max", &m->qid);
len += type_to_stat(&stat, "mode", &m->qid);
len += type2stat(&stat, "max", &m->qid);
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");
else
snprintf(buf, sizeof(buf), "%u", i + 1);
len += type_to_stat(&stat, buf, &m->qid);
len += type2stat(&stat, buf, &m->qid);
if(len <= fcall->offset)
continue;
break;
@ -794,7 +794,7 @@ xread(IXPConn *c, Fcall *fcall)
snprintf(buf, sizeof(buf), "%s", "sel");
else
snprintf(buf, sizeof(buf), "%u", i + 1);
len = type_to_stat(&stat, buf, &m->qid);
len = type2stat(&stat, buf, &m->qid);
if(fcall->count + len > fcall->iounit)
break;
fcall->count += len;
@ -813,24 +813,24 @@ xread(IXPConn *c, Fcall *fcall)
else {
switch (type) {
case Droot:
fcall->count = type_to_stat(&stat, "ctl", &m->qid);
fcall->count = type2stat(&stat, "ctl", &m->qid);
p = ixp_enc_stat(p, &stat);
fcall->count += type_to_stat(&stat, "event", &m->qid);
fcall->count += type2stat(&stat, "event", &m->qid);
p = ixp_enc_stat(p, &stat);
fcall->count += type_to_stat(&stat, "def", &m->qid);
fcall->count += type2stat(&stat, "def", &m->qid);
p = ixp_enc_stat(p, &stat);
fcall->count += type_to_stat(&stat, "keys", &m->qid);
fcall->count += type2stat(&stat, "keys", &m->qid);
p = ixp_enc_stat(p, &stat);
fcall->count += type_to_stat(&stat, "bar", &m->qid);
fcall->count += type2stat(&stat, "bar", &m->qid);
p = ixp_enc_stat(p, &stat);
fcall->count += type_to_stat(&stat, "new", &m->qid);
fcall->count += type2stat(&stat, "new", &m->qid);
p = ixp_enc_stat(p, &stat);
for(i = 0; i < npage; i++) {
if(i == sel)
snprintf(buf, sizeof(buf), "%s", "sel");
else
snprintf(buf, sizeof(buf), "%u", i + 1);
len = type_to_stat(&stat, buf, &m->qid);
len = type2stat(&stat, buf, &m->qid);
if(fcall->count + len > fcall->iounit)
break;
fcall->count += len;
@ -839,7 +839,7 @@ xread(IXPConn *c, Fcall *fcall)
break;
case Dkeys:
for(i = 0; i < nkey; i++) {
len = type_to_stat(&stat, key[i]->name, &m->qid);
len = type2stat(&stat, key[i]->name, &m->qid);
if(fcall->count + len > fcall->iounit)
break;
fcall->count += len;
@ -847,13 +847,13 @@ xread(IXPConn *c, Fcall *fcall)
}
break;
case Dbar:
fcall->count = type_to_stat(&stat, "expand", &m->qid);
fcall->count = type2stat(&stat, "expand", &m->qid);
p = ixp_enc_stat(p, &stat);
fcall->count += type_to_stat(&stat, "new", &m->qid);
fcall->count += type2stat(&stat, "new", &m->qid);
p = ixp_enc_stat(p, &stat);
for(i = 0; i < nlabel; i++) {
snprintf(buf, sizeof(buf), "%u", i + 1);
len = type_to_stat(&stat, buf, &m->qid);
len = type2stat(&stat, buf, &m->qid);
if(fcall->count + len > fcall->iounit)
break;
fcall->count += len;
@ -863,36 +863,36 @@ xread(IXPConn *c, Fcall *fcall)
case Dlabel:
if(i1 >= nlabel)
return Enofile;
fcall->count = type_to_stat(&stat, "colors", &m->qid);
fcall->count = type2stat(&stat, "colors", &m->qid);
p = ixp_enc_stat(p, &stat);
fcall->count += type_to_stat(&stat, "data", &m->qid);
fcall->count += type2stat(&stat, "data", &m->qid);
p = ixp_enc_stat(p, &stat);
break;
case Ddef:
fcall->count += type_to_stat(&stat, "border", &m->qid);
fcall->count += type2stat(&stat, "border", &m->qid);
p = ixp_enc_stat(p, &stat);
fcall->count += type_to_stat(&stat, "inc", &m->qid);
fcall->count += type2stat(&stat, "inc", &m->qid);
p = ixp_enc_stat(p, &stat);
fcall->count += type_to_stat(&stat, "snap", &m->qid);
fcall->count += type2stat(&stat, "snap", &m->qid);
p = ixp_enc_stat(p, &stat);
fcall->count += type_to_stat(&stat, "selcolors", &m->qid);
fcall->count += type2stat(&stat, "selcolors", &m->qid);
p = ixp_enc_stat(p, &stat);
fcall->count += type_to_stat(&stat, "normcolors", &m->qid);
fcall->count += type2stat(&stat, "normcolors", &m->qid);
p = ixp_enc_stat(p, &stat);
fcall->count += type_to_stat(&stat, "font", &m->qid);
fcall->count += type2stat(&stat, "font", &m->qid);
p = ixp_enc_stat(p, &stat);
break;
case Dpage:
fcall->count = type_to_stat(&stat, "ctl", &m->qid);
fcall->count = type2stat(&stat, "ctl", &m->qid);
p = ixp_enc_stat(p, &stat);
fcall->count += type_to_stat(&stat, "new", &m->qid);
fcall->count += type2stat(&stat, "new", &m->qid);
p = ixp_enc_stat(p, &stat);
for(i = 0; i < page[i1]->narea; i++) {
if(i == page[i1]->sel)
snprintf(buf, sizeof(buf), "%s", "sel");
else
snprintf(buf, sizeof(buf), "%u", i + 1);
len = type_to_stat(&stat, buf, &m->qid);
len = type2stat(&stat, buf, &m->qid);
if(fcall->count + len > fcall->iounit)
break;
fcall->count += len;
@ -900,12 +900,12 @@ xread(IXPConn *c, Fcall *fcall)
}
break;
case Darea:
fcall->count = type_to_stat(&stat, "ctl", &m->qid);
fcall->count = type2stat(&stat, "ctl", &m->qid);
p = ixp_enc_stat(p, &stat);
if(i2) {
fcall->count += type_to_stat(&stat, "max", &m->qid);
fcall->count += type2stat(&stat, "max", &m->qid);
p = ixp_enc_stat(p, &stat);
fcall->count += type_to_stat(&stat, "mode", &m->qid);
fcall->count += type2stat(&stat, "mode", &m->qid);
p = ixp_enc_stat(p, &stat);
}
for(i = 0; i < page[i1]->area[i2]->nclient; i++) {
@ -913,7 +913,7 @@ xread(IXPConn *c, Fcall *fcall)
snprintf(buf, sizeof(buf), "%s", "sel");
else
snprintf(buf, sizeof(buf), "%u", i + 1);
len = type_to_stat(&stat, buf, &m->qid);
len = type2stat(&stat, buf, &m->qid);
if(fcall->count + len > fcall->iounit)
break;
fcall->count += len;
@ -921,13 +921,13 @@ xread(IXPConn *c, Fcall *fcall)
}
break;
case Dclient:
fcall->count = type_to_stat(&stat, "border", &m->qid);
fcall->count = type2stat(&stat, "border", &m->qid);
p = ixp_enc_stat(p, &stat);
fcall->count += type_to_stat(&stat, "name", &m->qid);
fcall->count += type2stat(&stat, "name", &m->qid);
p = ixp_enc_stat(p, &stat);
fcall->count += type_to_stat(&stat, "geometry", &m->qid);
fcall->count += type2stat(&stat, "geometry", &m->qid);
p = ixp_enc_stat(p, &stat);
fcall->count += type_to_stat(&stat, "ctl", &m->qid);
fcall->count += type2stat(&stat, "ctl", &m->qid);
p = ixp_enc_stat(p, &stat);
break;
case Fctl:
@ -1025,8 +1025,8 @@ xstat(IXPConn *c, Fcall *fcall)
if(!m)
return Enofid;
name = qid_to_name(&m->qid);
if(!type_to_stat(&fcall->stat, name, &m->qid))
name = qid2name(&m->qid);
if(!type2stat(&fcall->stat, name, &m->qid))
return Enofile;
fcall->id = RSTAT;
ixp_server_respond_fcall(c, fcall);
@ -1097,22 +1097,22 @@ xwrite(IXPConn *c, Fcall *fcall)
break;
case Fsnap:
if(fcall->count > sizeof(buf))
return "snap value out of range 0..0xffff";
return "snap value out of range 0x0000,..,0xffff";
memcpy(buf, fcall->data, fcall->count);
buf[fcall->count] = 0;
i = cext_strtonum(buf, 0, 0xffff, &err);
if(err)
return "snap value out of range 0..0xffff";
return "snap value out of range 0x0000,..,0xffff";
def.snap = i;
break;
case Fborder:
if(fcall->count > sizeof(buf))
return "border value out of range 0..0xffff";
return "border value out of range 0x0000,..,0xffff";
memcpy(buf, fcall->data, fcall->count);
buf[fcall->count] = 0;
i = cext_strtonum(buf, 0, 0xffff, &err);
if(err)
return "border value out of range 0..0xffff";
return "border value out of range 0x0000,..,0xffff";
def.border = i;
resize_all_clients();
break;
@ -1221,15 +1221,18 @@ xwrite(IXPConn *c, Fcall *fcall)
/* TODO: detach to many clients/attach */
break;
case Fmode:
if(!i2)
return Enofile;
memcpy(buf, fcall->data, fcall->count);
buf[fcall->count] = 0;
i = cext_strtonum(buf, 0, COL_MODE_LAST - 1, &err);
if(err)
return "max value out of range 0x0000..0xffff";
page[i1]->area[i2]->mode = i;
arrange_column(page[i1]->area[i2]);
{
ColumnMode mode;
if(!i2)
return Enofile;
memcpy(buf, fcall->data, fcall->count);
buf[fcall->count] = 0;
mode = str2colmode(buf);
if(mode == -1)
return "invalid column mode";
page[i1]->area[i2]->mode = mode;
arrange_column(page[i1]->area[i2]);
}
break;
case Fkey:
break;

View File

@ -96,7 +96,7 @@ create_key(char *name)
static unsigned short id = 1;
Key *k = 0, *r = 0;
if((k = name_to_key(name)))
if((k = name2key(name)))
return k;
cext_strlcpy(buf, name, sizeof(buf));
@ -246,7 +246,7 @@ handle_key(Window w, unsigned long mod, KeyCode keycode)
}
Key *
name_to_key(char *name)
name2key(char *name)
{
size_t i;
for(i = 0; i < nkey; i++)
@ -256,7 +256,7 @@ name_to_key(char *name)
}
int
kid_to_index(unsigned short id)
kid2index(unsigned short id)
{
int i;
for(i = 0; i < nkey; i++)

View File

@ -53,7 +53,7 @@ cursor_for_motion(Client *c, int x, int y)
}
Align
xy_to_align(XRectangle * rect, int x, int y)
xy2align(XRectangle * rect, int x, int y)
{
int w = x <= rect->x + rect->width / 2;
@ -85,7 +85,7 @@ xy_to_align(XRectangle * rect, int x, int y)
}
Align
cursor_to_align(Cursor cursor)
cursor2align(Cursor cursor)
{
if(cursor == w_cursor)
return WEST;

View File

@ -63,7 +63,7 @@ destroy_page(Page *p)
}
int
page_to_index(Page *p)
page2index(Page *p)
{
int i;
for(i = 0; i < npage; i++)
@ -78,7 +78,7 @@ focus_page(Page *p)
Page *old = page ? page[sel] : nil;
char buf[16];
Client *c;
int i, pi = page_to_index(p);
int i, pi = page2index(p);
int px;
if(!npage || (pi == -1))
@ -92,7 +92,7 @@ focus_page(Page *p)
for(i = 0; i < nclient; i++) {
c = client[i];
if(c->area) {
pi = page_to_index(c->area->page);
pi = page2index(c->area->page);
XMoveWindow(dpy, c->frame.win, px - (pi * rect.width) + c->frame.rect.x, c->frame.rect.y);
if(c->area->page == p)
draw_client(c);
@ -136,7 +136,7 @@ rectangles(unsigned int *num)
}
int
pid_to_index(unsigned short id)
pid2index(unsigned short id)
{
int i;
for(i = 0; i < npage; i++)

View File

@ -120,7 +120,7 @@ draw_pager()
}
static int
xy_to_pager_page(int x, int y)
xy2pager_page(int x, int y)
{
unsigned int i, ic, ir, tw, th, rows, cols;
int dx;
@ -215,7 +215,7 @@ pager()
case ButtonPress:
XUnmapWindow(dpy, transient);
if(ev.xbutton.button == Button1) {
i = xy_to_pager_page(ev.xbutton.x, ev.xbutton.y);
i = xy2pager_page(ev.xbutton.x, ev.xbutton.y);
focus_page(page[i]);
if((c = sel_client_of_page(page[i])))
focus_client(c);
@ -230,7 +230,7 @@ pager()
}
Client *
win_to_client(Window w)
win2client(Window w)
{
size_t i;

View File

@ -193,8 +193,8 @@ unsigned int valid_mask, num_lock_mask;
/* area.c */
Area *alloc_area(Page *p);
void destroy_area(Area *a);
int area_to_index(Area *a);
int aid_to_index(Page *p, unsigned short id);
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);
@ -203,7 +203,7 @@ void sendto_area(Area *new, Client *c);
Label *new_label();
void detach_label(Label *l);
void draw_bar();
int lid_to_index(unsigned short id);
int lid2index(unsigned short id);
void update_bar_geometry();
unsigned int bar_height();
@ -219,15 +219,15 @@ void unmap_client(Client *c);
void map_client(Client *c);
void reparent_client(Client *c, Window w, int x, int y);
void attach_client(Client *c);
void attach_client_to_page(Page *p, Client *c);
void attach_client2page(Page *p, Client *c);
void detach_client(Client *c, Bool unmap);
Client *sel_client();
Client *sel_client_of_page(Page *p);
void focus_client(Client *c);
Client *win_to_clientframe(Window w);
Client *win2clientframe(Window w);
void resize_client(Client *c, XRectangle *r, XPoint *pt);
int cid_to_index(Area *a, unsigned short id);
int client_to_index(Client *c);
int cid2index(Area *a, unsigned short id);
int client2index(Client *c);
void select_client(Client *c, char *arg);
void sendtopage_client(Client *c, char *arg);
void sendtoarea_client(Client *c, char *arg);
@ -248,8 +248,8 @@ void new_ixp_conn(IXPConn *c);
void handle_key(Window w, unsigned long mod, KeyCode keycode);
void grab_key(Key *k);
void ungrab_key(Key *k);
Key * name_to_key(char *name);
int kid_to_index(unsigned short id);
Key * name2key(char *name);
int kid2index(unsigned short id);
Key *create_key(char *name);
void destroy_key(Key *k);
void init_lock_modifiers();
@ -258,8 +258,8 @@ void init_lock_modifiers();
void mouse_resize(Client *c, Align align);
void mouse_move(Client *c);
Cursor cursor_for_motion(Client *c, int x, int y);
Align cursor_to_align(Cursor cursor);
Align xy_to_align(XRectangle * rect, int x, int y);
Align cursor2align(Cursor cursor);
Align xy2align(XRectangle * rect, int x, int y);
void drop_move(Client *c, XRectangle *new, XPoint *pt);
void grab_mouse(Window w, unsigned long mod, unsigned int button);
void ungrab_mouse(Window w, unsigned long mod, unsigned int button);
@ -270,9 +270,9 @@ Page *alloc_page();
char *destroy_page(Page *p);
void focus_page(Page *p);
XRectangle *rectangles(unsigned int *num);
int pid_to_index(unsigned short id);
int pid2index(unsigned short id);
void select_page(char *arg);
int page_to_index(Page *p);
int page2index(Page *p);
/* spawn.c */
void spawn(char *cmd);
@ -282,10 +282,11 @@ void arrange_page(Page *p, Bool update_colums);
void arrange_column(Area *col);
void resize_column(Client *c, XRectangle *r, XPoint *pt);
Area *new_column(Area *old);
ColumnMode str2colmode(char *arg);
/* wm.c */
void scan_wins();
Client *win_to_client(Window w);
Client *win2client(Window w);
int win_proto(Window w);
int win_state(Window w);
/*void handle_after_write(IXPServer * s, File * f);*/

View File

@ -107,7 +107,7 @@ setrwx(long m, char *s)
}
static char *
mode_to_str(unsigned int mode)
mode2str(unsigned int mode)
{
static char buf[16];
@ -125,7 +125,7 @@ mode_to_str(unsigned int mode)
}
static char *
time_to_str(unsigned int t)
time2str(unsigned int t)
{
static char buf[32];
cext_strlcpy(buf, ctime((time_t *)&t), sizeof(buf));
@ -153,9 +153,9 @@ xls(void *result, unsigned int msize)
while(p - result < msize);
qsort(dir, n, sizeof(Stat), comp_stat);
for(i = 0; i < n; i++) {
fprintf(stdout, "%s %s %s %5lld %s %s\n", mode_to_str(dir[i].mode),
fprintf(stdout, "%s %s %s %5lld %s %s\n", mode2str(dir[i].mode),
dir[i].uid, dir[i].gid, dir[i].length,
time_to_str(dir[i].mtime), dir[i].name);
time2str(dir[i].mtime), dir[i].name);
}
free(dir);
}

View File

@ -18,13 +18,13 @@ int
ixp_client_do_fcall(IXPClient * c)
{
static unsigned char msg[IXP_MAX_MSG];
unsigned int msize = ixp_fcall_to_msg(msg, &c->fcall, IXP_MAX_MSG);
unsigned int msize = ixp_fcall2msg(msg, &c->fcall, IXP_MAX_MSG);
c->errstr = 0;
if(ixp_send_message(c->fd, msg, msize, &c->errstr) != msize)
return -1;
if(!ixp_recv_message(c->fd, msg, IXP_MAX_MSG, &c->errstr))
return -1;
if(!(msize = ixp_msg_to_fcall(&c->fcall, msg, IXP_MAX_MSG))) {
if(!(msize = ixp_msg2fcall(&c->fcall, msg, IXP_MAX_MSG))) {
c->errstr = "received bad message";
return -1;
}

View File

@ -275,8 +275,8 @@ void *ixp_dec_stat(unsigned char *msg, Stat *stat);
/* message.c */
unsigned short ixp_sizeof_stat(Stat *stat);
unsigned int ixp_fcall_to_msg(void *msg, Fcall *fcall, unsigned int msglen);
unsigned int ixp_msg_to_fcall(Fcall *call, void *msg, unsigned int msglen);
unsigned int ixp_fcall2msg(void *msg, Fcall *fcall, unsigned int msglen);
unsigned int ixp_msg2fcall(Fcall *call, void *msg, unsigned int msglen);
/* server.c */
IXPConn *ixp_server_open_conn(IXPServer *s, int fd,

View File

@ -31,7 +31,7 @@ ixp_sizeof_stat(Stat * stat)
}
unsigned int
ixp_fcall_to_msg(void *msg, Fcall *fcall, unsigned int msglen)
ixp_fcall2msg(void *msg, Fcall *fcall, unsigned int msglen)
{
unsigned int i, msize =
sizeof(unsigned char) + sizeof(unsigned short) +
@ -210,7 +210,7 @@ ixp_fcall_to_msg(void *msg, Fcall *fcall, unsigned int msglen)
}
unsigned int
ixp_msg_to_fcall(Fcall *fcall, void *msg, unsigned int msglen)
ixp_msg2fcall(Fcall *fcall, void *msg, unsigned int msglen)
{
unsigned int i, msize;
unsigned short len;

View File

@ -113,14 +113,14 @@ ixp_server_receive_fcall(IXPConn *c, Fcall *fcall)
c->close(c);
return 0;
}
return ixp_msg_to_fcall(fcall, msg, IXP_MAX_MSG);
return ixp_msg2fcall(fcall, msg, IXP_MAX_MSG);
}
int
ixp_server_respond_fcall(IXPConn *c, Fcall *fcall)
{
char *errstr;
unsigned int msize = ixp_fcall_to_msg(msg, fcall, IXP_MAX_MSG);
unsigned int msize = ixp_fcall2msg(msg, fcall, IXP_MAX_MSG);
if(ixp_send_message(c->fd, msg, msize, &errstr) != msize) {
if(c->close)
c->close(c);
@ -135,7 +135,7 @@ ixp_server_respond_error(IXPConn *c, Fcall *fcall, char *errstr)
unsigned int msize;
fcall->id = RERROR;
cext_strlcpy(fcall->errstr, errstr, sizeof(fcall->errstr));
msize = ixp_fcall_to_msg(msg, fcall, IXP_MAX_MSG);
msize = ixp_fcall2msg(msg, fcall, IXP_MAX_MSG);
if(ixp_send_message(c->fd, msg, msize, &errstr) != msize) {
if(c->close)
c->close(c);

View File

@ -69,7 +69,6 @@ $MODKEY-l
$MODKEY-j
$MODKEY-k
$MODKEY-Tab
$MODKEY-Shift-m
$MODKEY-Shift-s
$MODKEY-Shift-equal
$MODKEY-Shift-h
@ -148,12 +147,10 @@ do
extern xterm &;;
$MODKEY-n)
wmiir read /sel/new >/dev/null;;
$MODKEY-Shift-m)
xwrite /sel/sel/mode 2;;
$MODKEY-Shift-s)
xwrite /sel/sel/mode 1;;
xwrite /sel/sel/mode stack;;
$MODKEY-Shift-equal)
xwrite /sel/sel/mode 0;;
xwrite /sel/sel/mode equal;;
$MODKEY-Return)
xwrite /sel/sel/sel/ctl sendtoarea prev;;
$MODKEY-Shift-Return)