From 0e4b36e0ffaf9e5e95229ce27fd0a4ebe63b7b25 Mon Sep 17 00:00:00 2001 From: "Anselm R. Garbe" Date: Sun, 19 Feb 2006 16:21:01 +0100 Subject: [PATCH] enabled basic navigation in column layout --- cmd/wm/area.c | 33 +++++++++++++++++++++++++ cmd/wm/client.c | 66 ++++++++++++++++--------------------------------- cmd/wm/column.c | 46 +++------------------------------- cmd/wm/fs.c | 2 ++ cmd/wm/wm.h | 3 +-- rc/wmiirc | 4 +-- 6 files changed, 62 insertions(+), 92 deletions(-) diff --git a/cmd/wm/area.c b/cmd/wm/area.c index 43e82990..aa52c06d 100644 --- a/cmd/wm/area.c +++ b/cmd/wm/area.c @@ -4,6 +4,7 @@ */ #include +#include #include "wm.h" @@ -61,3 +62,35 @@ aid_to_index(Page *p, unsigned short id) return i; return -1; } + +void +select_area(Area *a, char *arg) +{ + Area *new; + Page *p = a->page; + int i = area_to_index(a); + if(i == -1) + return; + if(!strncmp(arg, "prev", 5)) { + if(!i) + i = p->narea - 1; + else + i--; + } else if(!strncmp(arg, "next", 5)) { + if(i + 1 < p->narea) + i++; + else + i = 0; + } + else { + const char *errstr; + i = cext_strtonum(arg, 1, p->narea, &errstr); + if(errstr) + return; + i--; + } + new = p->area[i]; + if(new->nclient) + focus_client(new->client[new->sel], True); +} + diff --git a/cmd/wm/client.c b/cmd/wm/client.c index e6cc7d4c..c2131728 100644 --- a/cmd/wm/client.c +++ b/cmd/wm/client.c @@ -547,26 +547,6 @@ resize_client(Client *c, XRectangle *r, XPoint *pt) configure_client(c); } -/* -static void -max_client(void *obj, char *arg) -{ - Client *c = obj; - - if(c->maximized) { - c->frame.rect = c->frame.revert; - resize_client(c, &c->frame.revert, nil); - } - else { - c->frame.revert = c->frame.rect; - c->frame.rect = c->area->rect; - XRaiseWindow(dpy, c->frame.win); - resize_client(c, &c->frame.rect, nil); - } - c->maximized = !c->maximized; -} -*/ - int cid_to_index(Area *a, unsigned short id) { @@ -591,31 +571,27 @@ client_to_index(Client *c) void select_client(Client *c, char *arg) { - if(area_to_index(c->area) > 0) - select_column(c, arg); - else { - Area *a = c->area; - int i = client_to_index(c); - if(i == -1) - return; - if(!strncmp(arg, "prev", 5)) { - if(!i) - i = a->nclient - 1; - else - i--; - } else if(!strncmp(arg, "next", 5)) { - if(i + 1 < a->nclient) - i++; - else - i = 0; - } - else { - const char *errstr; - i = cext_strtonum(arg, 1, a->nclient, &errstr); - if(errstr) - return; + Area *a = c->area; + int i = client_to_index(c); + if(i == -1) + return; + if(!strncmp(arg, "prev", 5)) { + if(!i) + i = a->nclient - 1; + else i--; - } - focus_client(a->client[i], True); + } else if(!strncmp(arg, "next", 5)) { + if(i + 1 < a->nclient) + i++; + else + i = 0; } + else { + const char *errstr; + i = cext_strtonum(arg, 1, a->nclient, &errstr); + if(errstr) + return; + i--; + } + focus_client(a->client[i], True); } diff --git a/cmd/wm/column.c b/cmd/wm/column.c index 3e46f232..cccda6ea 100644 --- a/cmd/wm/column.c +++ b/cmd/wm/column.c @@ -42,7 +42,7 @@ arrange_page(Page *p, Bool update_colums) for(i = 1; i < p->narea; i++) { Area *a = p->area[i]; if(update_colums) { - a->rect = rect; + update_area_geometry(a); a->rect.x = (i - 1) * width; a->rect.width = width; } @@ -161,48 +161,6 @@ resize_column(Client *c, XRectangle *r, XPoint *pt) drop_resize(c, r); } -void -select_column(Client *c, char *arg) -{ - Area *col = c->area; - Page *p = col->page; - size_t i; - - for(i = 0; (i < col->clientsz) && col->client[i] && (col->client[i] != c); i++); - if(!strncmp(arg, "prev", 5)) { - if(!i) - for(i = 0; (i < col->clientsz) && col->client[i]; i++); - focus_client(col->client[i - 1], True); - return; - } else if(!strncmp(arg, "next", 5)) { - if(col->client[i + 1]) - focus_client(col->client[i + 1], True); - else - focus_client(col->client[0], True); - return; - } - - for(i = 0; (i < p->areasz) && p->area[i] && (p->area[i] != col); i++); - if(!strncmp(arg, "west", 5)) { - if(!i) - for(i = 0; (i < p->areasz) && p->area[i]; i++); - col = p->area[i - 1]; - } else if(!strncmp(arg, "east", 5)) { - if(p->area[i + 1]) - col = p->area[i + 1]; - else - col = p->area[0]; - } else { - const char *errstr; - for(i = 0; (i < p->areasz) && p->area[i]; i++); - i = cext_strtonum(arg, 0, i - 1, &errstr); - if(errstr) - return; - col = p->area[i]; - } - focus_client(col->client[col->sel], True); -} - Area * new_column(Area *old) { @@ -216,6 +174,8 @@ new_column(Area *old) col = alloc_area(p); cext_array_detach((void **)old->client, c, &old->clientsz); old->nclient--; + if(old->sel == old->nclient) + old->sel = 0; col->client = (Client **)cext_array_attach((void **)col->client, c, sizeof(Client *), &col->clientsz); col->nclient++; diff --git a/cmd/wm/fs.c b/cmd/wm/fs.c index 407d7473..793fff09 100644 --- a/cmd/wm/fs.c +++ b/cmd/wm/fs.c @@ -1065,6 +1065,8 @@ xwrite(IXPConn *c, Fcall *fcall) return Enocommand; break; case Dpage: + if(!strncmp(buf, "select ", 7)) + select_area(page[i1]->area[page[i1]->sel], &buf[7]); break; case Darea: if(!strncmp(buf, "select ", 7)) { diff --git a/cmd/wm/wm.h b/cmd/wm/wm.h index c7c0e395..10b4c397 100644 --- a/cmd/wm/wm.h +++ b/cmd/wm/wm.h @@ -84,7 +84,6 @@ struct Client { int proto; unsigned int border; Bool destroyed; - Bool maximized; Area *area; Window win; Window trans; @@ -197,6 +196,7 @@ void destroy_area(Area *a); int area_to_index(Area *a); int aid_to_index(Page *p, unsigned short id); void update_area_geometry(Area *a); +void select_area(Area *a, char *arg); /* bar.c */ Label *new_label(); @@ -275,7 +275,6 @@ void spawn(char *cmd); void arrange_page(Page *p, Bool update_colums); void arrange_column(Area *col); void resize_column(Client *c, XRectangle *r, XPoint *pt); -void select_column(Client *c, char *arg); Area *new_column(Area *old); /* wm.c */ diff --git a/rc/wmiirc b/rc/wmiirc index 9b7ba35c..623fd431 100755 --- a/rc/wmiirc +++ b/rc/wmiirc @@ -146,9 +146,9 @@ while(event=`{read}) { case $MODKEY-Control-y wmiir read /new >/dev/null >[2=1] case $MODKEY-h - xwrite /sel/ctl 'select next' - case $MODKEY-l xwrite /sel/ctl 'select prev' + case $MODKEY-l + xwrite /sel/ctl 'select next' case $MODKEY-Tab xwrite /sel/sel/ctl 'select next' case $MODKEY-j