wmii

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

commit 2fd5866c98b641467e707d001e3bc0874f430c43
parent b32cb82867a0800caeca2aca2c7bce8d2db89813
Author: Anselm R. Garbe <garbeam@wmii.de>
Date:   Wed, 18 Jan 2006 18:45:27 +0200

page counting/addressing begins at 1 again


Diffstat:
cmd/wm/client.c | 3+--
cmd/wm/page.c | 18+++++++++++-------
cmd/wm/wm.c | 20++++++++++++++------
cmd/wm/wm.h | 1+
config.mk | 1+
5 files changed, 28 insertions(+), 15 deletions(-)

diff --git a/cmd/wm/client.c b/cmd/wm/client.c @@ -312,8 +312,7 @@ detach_client(Client * c, Bool unmap) l->def->detach(l, c, unmap); if(c->destroyed) destroy_client(c); - if(selpage) - focus_page(selpage); + focus_page(selpage); } Client * diff --git a/cmd/wm/page.c b/cmd/wm/page.c @@ -28,17 +28,17 @@ alloc_page() Page *p, *new = cext_emallocz(sizeof(Page)); char buf[MAX_BUF], buf2[16]; - snprintf(buf2, sizeof(buf2), "%d", (int)npages); - snprintf(buf, sizeof(buf), "/%d", (int)npages); + snprintf(buf2, sizeof(buf2), "%d", pageid); + snprintf(buf, sizeof(buf), "/%d", pageid); new->file[P_PREFIX] = ixp_create(ixps, buf); - snprintf(buf, sizeof(buf), "/%d/name", (int)npages); + snprintf(buf, sizeof(buf), "/%d/name", pageid); new->file[P_NAME] = wmii_create_ixpfile(ixps, buf, buf2); - snprintf(buf, sizeof(buf), "/%d/layout/", (int)npages); + snprintf(buf, sizeof(buf), "/%d/layout/", pageid); new->file[P_LAYOUT_PREFIX] = ixp_create(ixps, buf); - snprintf(buf, sizeof(buf), "/%d/layout/sel", (int)npages); + snprintf(buf, sizeof(buf), "/%d/layout/sel", pageid); new->file[P_SEL_LAYOUT] = ixp_create(ixps, buf); new->file[P_SEL_LAYOUT]->bind = 1; /* mount point */ - snprintf(buf, sizeof(buf), "/%d/ctl", (int)npages); + snprintf(buf, sizeof(buf), "/%d/ctl", pageid); new->file[P_CTL] = ixp_create(ixps, buf); new->file[P_CTL]->after_write = handle_after_write_page; new->floating = alloc_layout(new, "float"); @@ -55,6 +55,7 @@ alloc_page() } def[WM_SEL_PAGE]->content = new->file[P_PREFIX]->content; invoke_wm_event(def[WM_EVENT_PAGE_UPDATE]); + pageid++; npages++; XChangeProperty(dpy, root, net_atoms[NET_NUMBER_OF_DESKTOPS], XA_CARDINAL, 32, PropModeReplace, (unsigned char *) &npages, 1); return new; @@ -123,7 +124,10 @@ destroy_page(Page * p) void focus_page(Page * p) { - if(p && (p != selpage)) { + if(!p) + return; + + if((p != selpage)) { if(selpage) { unmap_layout(selpage->managed); unmap_layout(selpage->floating); diff --git a/cmd/wm/wm.c b/cmd/wm/wm.c @@ -238,8 +238,10 @@ handle_kpress(XKeyEvent * e) { KeySym ksym = XKeycodeToKeysym(dpy, e->keycode, 0); - if(ksym >= XK_0 && ksym <= XK_9) - return ksym - XK_0; + if(ksym >= XK_1 && ksym <= XK_9) + return ksym - XK_1; + else if(ksym == XK_0) + return 9; else if(ksym >= XK_a && ksym <= XK_z) return 10 + ksym - XK_a; @@ -437,8 +439,14 @@ _select_page(void *obj, char *arg) p = p->next; else p = pages; - } else - p = pageat(blitz_strtonum(arg, 0, npages - 1)); + } else { + int idx = blitz_strtonum(arg, 0, pageid); + if(idx) + idx--; + else + idx = 9; + p = pageat(idx); + } focus_page(p); } @@ -446,8 +454,7 @@ static void _destroy_page(void *obj, char *arg) { destroy_page(selpage); - if(selpage) - focus_page(selpage); + focus_page(selpage); } static void @@ -860,6 +867,7 @@ main(int argc, char *argv[]) pages = selpage = nil; ndetached = npages = 0; + pageid = 1; detached = nil; layouts = nil; attachqueue = nil; diff --git a/cmd/wm/wm.h b/cmd/wm/wm.h @@ -165,6 +165,7 @@ Page *pages; Page *selpage; AttachQueue *attachqueue; size_t npages; +int pageid; Client *detached; size_t ndetached; LayoutDef *layouts; diff --git a/config.mk b/config.mk @@ -10,6 +10,7 @@ X11INC = /usr/X11R6/include X11LIB = /usr/X11R6/lib VERSION = 3-current +VERSION = 20060118 # includes and libs LIBS = -L${PREFIX}/lib -L/usr/lib -lc -lm -L${X11LIB} -lX11