wmii

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

commit c855a6dad01adbd6cc70323ad27bf28c15948b06
parent 853fa6c9152ec0afac12beeace8b700d6b0dbdc0
Author: Anselm R. Garbe <garbeam@wmii.de>
Date:   Wed,  1 Mar 2006 11:09:49 +0100

indexes begin at 0 now, page 0 can be used as clutter page (actually it is, Alt-{d,a} back again), sendto has no shortcuts in other cases atm


Diffstat:
cmd/wm/area.c | 3+--
cmd/wm/client.c | 11+++++------
cmd/wm/column.c | 11+++++++++++
cmd/wm/fs.c | 79+++++++++++++++++++++++++++++++++++++++----------------------------------------
cmd/wm/page.c | 12++++++------
cmd/wm/wm.c | 4+++-
cmd/wm/wm.h | 1+
rc/wmiirc | 40+++++++++++++---------------------------
8 files changed, 79 insertions(+), 82 deletions(-)

diff --git a/cmd/wm/area.c b/cmd/wm/area.c @@ -82,10 +82,9 @@ select_area(Area *a, char *arg) } else { const char *errstr; - i = cext_strtonum(arg, 1, p->narea, &errstr); + i = cext_strtonum(arg, 0, p->narea - 1, &errstr); if(errstr) return; - i--; } new = p->area[i]; if(new->nclient) diff --git a/cmd/wm/client.c b/cmd/wm/client.c @@ -561,10 +561,9 @@ select_client(Client *c, char *arg) } else { const char *errstr; - i = cext_strtonum(arg, 1, a->nclient, &errstr); + i = cext_strtonum(arg, 0, a->nclient - 1, &errstr); if(errstr) return; - i--; } focus_client(a->client[i]); } @@ -580,10 +579,10 @@ sendtopage_client(Client *c, char *arg) { p = page[sel]; else { const char *errstr; - int i = cext_strtonum(arg, 1, npage, &errstr); + int i = cext_strtonum(arg, 0, npage - 1, &errstr); if(errstr) return; - p = page[i - 1]; + p = page[i]; } detach_client(c, False); attach_client2page(p, c); @@ -613,10 +612,10 @@ sendtoarea_client(Client *c, char *arg) { next = p->area[1]; } else { - i = cext_strtonum(arg, 1, p->narea, &errstr); + i = cext_strtonum(arg, 0, p->narea - 1, &errstr); if(errstr) return; - next = p->area[i - 1]; + next = p->area[i]; } sendto_area(next, c); } diff --git a/cmd/wm/column.c b/cmd/wm/column.c @@ -8,6 +8,17 @@ #include "wm.h" +char * +colmode2str(ColumnMode mode) +{ + switch(mode) { + case COL_EQUAL: return "equal"; break; + case COL_STACK: return "stack"; break; + default: break; + } + return nil; +} + ColumnMode str2colmode(char *arg) { diff --git a/cmd/wm/fs.c b/cmd/wm/fs.c @@ -159,29 +159,29 @@ qid2name(Qid *qid) case Dpage: if(i1 == sel) return "sel"; - snprintf(buf, sizeof(buf), "%u", i1 + 1); + snprintf(buf, sizeof(buf), "%u", i1); return buf; break; case Dlabel: - snprintf(buf, sizeof(buf), "%u", i1 + 1); + snprintf(buf, sizeof(buf), "%u", i1); return buf; break; case Darea: if(!i2) { - if(page[i1]->sel) - return "float"; - else + if(i2 == page[i1]->sel) return "sel"; + else + return "float"; } if(page[i1]->sel == i2) return "sel"; - snprintf(buf, sizeof(buf), "%u", i2 + 1); + snprintf(buf, sizeof(buf), "%u", i2); return buf; break; case Dclient: if(page[i1]->area[i2]->sel == i3) return "sel"; - snprintf(buf, sizeof(buf), "%u", i3 + 1); + snprintf(buf, sizeof(buf), "%u", i3); return buf; break; case Fselcolors: return "selcolors"; break; @@ -257,7 +257,7 @@ name2type(char *name, unsigned char dir_type) return Fkey; if(!strncmp(name, "sel", 4)) goto dyndir; - i = (unsigned short) cext_strtonum(name, 1, 0xffff, &err); + i = (unsigned short) cext_strtonum(name, 0, 0xffff, &err); if(err) return -1; dyndir: @@ -310,10 +310,10 @@ mkqid(Qid *dir, char *wname, Qid *new, Bool iswalk) new->path = mkqpath(Dlabel, 0,0 ,0); } else { - i = cext_strtonum(wname, 1, 0xffff, &err); - if(err || (i - 1 >= nlabel)) + i = cext_strtonum(wname, 0, 0xffff, &err); + if(err || (i >= nlabel)) return -1; - new->path = mkqpath(Dlabel, label[i - 1]->id, 0, 0); + new->path = mkqpath(Dlabel, label[i]->id, 0, 0); } break; case Dpage: @@ -332,10 +332,10 @@ mkqid(Qid *dir, char *wname, Qid *new, Bool iswalk) new->path = mkqpath(Dpage, page[sel]->id, 0, 0); } else { - i = cext_strtonum(wname, 1, 0xffff, &err); - if(err || (i - 1 >= npage)) + i = cext_strtonum(wname, 0, 0xffff, &err); + if(err || (i >= npage)) return -1; - new->path = mkqpath(Dpage, page[i - 1]->id, 0, 0); + new->path = mkqpath(Dpage, page[i]->id, 0, 0); } break; case Darea: @@ -356,10 +356,10 @@ mkqid(Qid *dir, char *wname, Qid *new, Bool iswalk) new->path = mkqpath(Darea, p->id, p->area[p->sel]->id, 0); } else { - i = cext_strtonum(wname, 1, 0xffff, &err); - if(err || (i - 1 >= p->narea)) + i = cext_strtonum(wname, 0, 0xffff, &err); + if(err || (i >= p->narea)) return -1; - new->path = mkqpath(Darea, p->id, p->area[i - 1]->id, 0); + new->path = mkqpath(Darea, p->id, p->area[i]->id, 0); } } break; @@ -374,10 +374,10 @@ mkqid(Qid *dir, char *wname, Qid *new, Bool iswalk) new->path = mkqpath(Dclient, p->id, a->id, a->client[a->sel]->id); } else { - i = cext_strtonum(wname, 1, 0xffff, &err); - if(err || (i - 1 >= a->nclient)) + i = cext_strtonum(wname, 0, 0xffff, &err); + if(err || (i >= a->nclient)) return -1; - new->path = mkqpath(Dclient, p->id, a->id, a->client[i - 1]->id); + new->path = mkqpath(Dclient, p->id, a->id, a->client[i]->id); } } break; @@ -578,7 +578,7 @@ type2stat(Stat *stat, char *wname, Qid *dir) return mkstat(stat, dir, wname, 0, DMWRITE); break; case Fexpand: - snprintf(buf, sizeof(buf), "%u", iexpand + 1); + snprintf(buf, sizeof(buf), "%u", iexpand); return mkstat(stat, dir, wname, strlen(buf), DMREAD | DMWRITE); break; case Fdata: @@ -589,8 +589,7 @@ type2stat(Stat *stat, char *wname, Qid *dir) return mkstat(stat, dir, wname, strlen(buf), DMREAD | DMWRITE); break; case Fmode: - snprintf(buf, sizeof(buf), "%d", page[dir_i1]->area[dir_i2]->mode); - return mkstat(stat, dir, wname, strlen(buf), DMREAD | DMWRITE); + return mkstat(stat, dir, wname, strlen(colmode2str(page[dir_i1]->area[dir_i2]->mode)), DMREAD | DMWRITE); break; case Fcolors: case Fselcolors: @@ -686,7 +685,7 @@ xread(IXPConn *c, Fcall *fcall) if(i == sel) snprintf(buf, sizeof(buf), "%s", "sel"); else - snprintf(buf, sizeof(buf), "%u", i + 1); + snprintf(buf, sizeof(buf), "%u", i); len += type2stat(&stat, buf, &m->qid); if(len <= fcall->offset) continue; @@ -697,7 +696,7 @@ xread(IXPConn *c, Fcall *fcall) if(i == sel) snprintf(buf, sizeof(buf), "%s", "sel"); else - snprintf(buf, sizeof(buf), "%u", i + 1); + snprintf(buf, sizeof(buf), "%u", i); len = type2stat(&stat, buf, &m->qid); if(fcall->count + len > fcall->iounit) break; @@ -728,7 +727,7 @@ xread(IXPConn *c, Fcall *fcall) 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); + snprintf(buf, sizeof(buf), "%u", i); len += type2stat(&stat, buf, &m->qid); if(len <= fcall->offset) continue; @@ -736,7 +735,7 @@ xread(IXPConn *c, Fcall *fcall) } /* offset found, proceeding */ for(; i < nlabel; i++) { - snprintf(buf, sizeof(buf), "%u", i + 1); + snprintf(buf, sizeof(buf), "%u", i); len = type2stat(&stat, buf, &m->qid); if(fcall->count + len > fcall->iounit) break; @@ -752,7 +751,7 @@ xread(IXPConn *c, Fcall *fcall) if(i == page[i1]->sel) snprintf(buf, sizeof(buf), "%s", "sel"); else - snprintf(buf, sizeof(buf), "%u", i + 1); + snprintf(buf, sizeof(buf), "%u", i); len += type2stat(&stat, buf, &m->qid); if(len <= fcall->offset) continue; @@ -763,7 +762,7 @@ xread(IXPConn *c, Fcall *fcall) if(i == page[i1]->sel) snprintf(buf, sizeof(buf), "%s", "sel"); else - snprintf(buf, sizeof(buf), "%u", i + 1); + snprintf(buf, sizeof(buf), "%u", i); len = type2stat(&stat, buf, &m->qid); if(fcall->count + len > fcall->iounit) break; @@ -782,7 +781,7 @@ xread(IXPConn *c, Fcall *fcall) if(i == page[i1]->area[i2]->sel) snprintf(buf, sizeof(buf), "%s", "sel"); else - snprintf(buf, sizeof(buf), "%u", i + 1); + snprintf(buf, sizeof(buf), "%u", i); len += type2stat(&stat, buf, &m->qid); if(len <= fcall->offset) continue; @@ -793,7 +792,7 @@ xread(IXPConn *c, Fcall *fcall) if(i == page[i1]->area[i2]->sel) snprintf(buf, sizeof(buf), "%s", "sel"); else - snprintf(buf, sizeof(buf), "%u", i + 1); + snprintf(buf, sizeof(buf), "%u", i); len = type2stat(&stat, buf, &m->qid); if(fcall->count + len > fcall->iounit) break; @@ -829,7 +828,7 @@ xread(IXPConn *c, Fcall *fcall) if(i == sel) snprintf(buf, sizeof(buf), "%s", "sel"); else - snprintf(buf, sizeof(buf), "%u", i + 1); + snprintf(buf, sizeof(buf), "%u", i); len = type2stat(&stat, buf, &m->qid); if(fcall->count + len > fcall->iounit) break; @@ -852,7 +851,7 @@ xread(IXPConn *c, Fcall *fcall) 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); + snprintf(buf, sizeof(buf), "%u", i); len = type2stat(&stat, buf, &m->qid); if(fcall->count + len > fcall->iounit) break; @@ -891,7 +890,7 @@ xread(IXPConn *c, Fcall *fcall) if(i == page[i1]->sel) snprintf(buf, sizeof(buf), "%s", "sel"); else - snprintf(buf, sizeof(buf), "%u", i + 1); + snprintf(buf, sizeof(buf), "%u", i); len = type2stat(&stat, buf, &m->qid); if(fcall->count + len > fcall->iounit) break; @@ -912,7 +911,7 @@ xread(IXPConn *c, Fcall *fcall) if(i == page[i1]->area[i2]->sel) snprintf(buf, sizeof(buf), "%s", "sel"); else - snprintf(buf, sizeof(buf), "%u", i + 1); + snprintf(buf, sizeof(buf), "%u", i); len = type2stat(&stat, buf, &m->qid); if(fcall->count + len > fcall->iounit) break; @@ -965,7 +964,7 @@ xread(IXPConn *c, Fcall *fcall) memcpy(p, page[i1]->area[i2]->client[i3]->name, fcall->count); break; case Fexpand: - snprintf(buf, sizeof(buf), "%u", iexpand + 1); + snprintf(buf, sizeof(buf), "%u", iexpand); fcall->count = strlen(buf); memcpy(p, buf, fcall->count); break; @@ -1003,7 +1002,7 @@ xread(IXPConn *c, Fcall *fcall) case Fmode: if(!i2) return Enofile; - snprintf(buf, sizeof(buf), "%d", page[i1]->area[i2]->mode); + snprintf(buf, sizeof(buf), "%s", colmode2str(page[i1]->area[i2]->mode)); fcall->count = strlen(buf); memcpy(p, buf, fcall->count); break; @@ -1142,9 +1141,9 @@ xwrite(IXPConn *c, Fcall *fcall) if(fcall->count && fcall->count < 16) { memcpy(buf, fcall->data, fcall->count); buf[fcall->count] = 0; - i = (unsigned short) cext_strtonum(buf, 1, 0xffff, &err); - if(!err && (i - 1 < nlabel)) { - iexpand = i - 1; + i = (unsigned short) cext_strtonum(buf, 0, 0xffff, &err); + if(!err && (i < nlabel)) { + iexpand = i; draw_bar(); break; } diff --git a/cmd/wm/page.c b/cmd/wm/page.c @@ -98,7 +98,7 @@ focus_page(Page *p) draw_client(c); } } - snprintf(buf, sizeof(buf), "PN %d\n", sel + 1); + snprintf(buf, sizeof(buf), "PN %d\n", sel); write_event(buf); XChangeProperty(dpy, root, net_atoms[NET_CURRENT_DESKTOP], XA_CARDINAL, 32, PropModeReplace, (unsigned char *) &sel, 1); @@ -155,18 +155,18 @@ select_page(char *arg) if(!npage) return; if(!strncmp(arg, "prev", 5)) { - if(!new) + if(new == 1) new = npage; new--; } else if(!strncmp(arg, "next", 5)) { if(new < npage - 1) new++; else - new = 0; + new = 1; } else { - int idx = cext_strtonum(arg, 1, npage, &err); - if(idx && (idx - 1 < npage)) - new = idx - 1; + int idx = cext_strtonum(arg, 0, npage - 1, &err); + if(idx < npage) + new = idx; } focus_page(page[new]); if((c = sel_client_of_page(page[new]))) diff --git a/cmd/wm/wm.c b/cmd/wm/wm.c @@ -550,7 +550,6 @@ main(int argc, char *argv[]) xfont = blitz_getfont(dpy, def.font); init_lock_modifiers(); init_screen(); - scan_wins(); wa.override_redirect = 1; wa.background_pixmap = ParentRelative; @@ -574,6 +573,9 @@ main(int argc, char *argv[]) XMapRaised(dpy, winbar); draw_bar(); + alloc_page(); /* page 0 */ + scan_wins(); + /* main event loop */ errstr = ixp_server_loop(&srv); if(errstr) diff --git a/cmd/wm/wm.h b/cmd/wm/wm.h @@ -283,6 +283,7 @@ void arrange_column(Area *col); void resize_column(Client *c, XRectangle *r, XPoint *pt); Area *new_column(Area *old); ColumnMode str2colmode(char *arg); +char *colmode2str(ColumnMode mode); /* wm.c */ void scan_wins(); diff --git a/rc/wmiirc b/rc/wmiirc @@ -33,6 +33,7 @@ xwrite /def/snap 20 xwrite /def/font $WMII_FONT xwrite /def/selcolors $WMII_SELCOLORS xwrite /def/normcolors $WMII_NORMCOLORS +wmiir read /new >/dev/null # BAR CONFIGURATION while wmiir remove /bar/1 2>/dev/null @@ -41,8 +42,8 @@ do done xwrite /bar/new/colors $WMII_NORMCOLORS xwrite /bar/new/colors $WMII_SELCOLORS -xwrite /bar/1/data 1 -xwrite /bar/expand 2 +xwrite /bar/0/data 1 +xwrite /bar/expand 1 # MISC xsetroot -solid '#0b1014' @@ -75,6 +76,7 @@ $MODKEY-Shift-h $MODKEY-Shift-l $MODKEY-Shift-p $MODKEY-Shift-Return +$MODKEY-Shift-0 $MODKEY-Shift-1 $MODKEY-Shift-2 $MODKEY-Shift-3 @@ -84,24 +86,8 @@ $MODKEY-Shift-6 $MODKEY-Shift-7 $MODKEY-Shift-8 $MODKEY-Shift-9 -$MODKEY-Control-1 -$MODKEY-Control-2 -$MODKEY-Control-3 -$MODKEY-Control-4 -$MODKEY-Control-5 -$MODKEY-Control-6 -$MODKEY-Control-7 -$MODKEY-Control-8 -$MODKEY-Control-9 -Control-Shift-1 -Control-Shift-2 -Control-Shift-3 -Control-Shift-4 -Control-Shift-5 -Control-Shift-6 -Control-Shift-7 -Control-Shift-8 -Control-Shift-9 +$MODKEY-d +$MODKEY-a EOF # EVENT LOOP @@ -112,9 +98,9 @@ do type="$1"; shift case "$type" in PN) - xwrite /bar/1/data "$@";; + xwrite /bar/0/data "$@";; CN) - xwrite /bar/2/data "$@";; + xwrite /bar/1/data "$@";; LB) case "$2" in 1) @@ -173,12 +159,12 @@ do xwrite /ctl select next;; $MODKEY-Shift-p) xwrite /ctl pager;; - $MODKEY-Shift-[1-9]) + $MODKEY-Shift-[0-9]) xwrite /ctl select `echo $1 | sed 's/.*-//'`;; - $MODKEY-Control-[1-9]) - xwrite /sel/sel/sel/ctl sendtopage `echo $1 | sed 's/.*-//'`;; - Control-Shift-[1-9]) - xwrite /`echo $1 | sed 's/.*-//'`/sel/sel/ctl sendtopage sel;; + $MODKEY-d) + xwrite /sel/sel/sel/ctl sendtopage 0;; + $MODKEY-a) + xwrite /0/sel/sel/ctl sendtopage sel;; esac;; esac done &