changeset: 2265:fd899ccc36b1
tag: tip
user: Kris Maglione <jg_AT_suckless.org>
date: Sun Jan 27 16:08:25 2008 -0500
summary: Better rc.wmii menus. Some pseudo-BNF comments for message.c.
diff -r 5571d2245926 -r fd899ccc36b1 cmd/wmii.rc.rc
--- a/cmd/wmii.rc.rc Sat Jan 26 21:13:42 2008 -0500
+++ b/cmd/wmii.rc.rc Sun Jan 27 16:08:25 2008 -0500
@@ -55,6 +55,16 @@ fn wi_9menu {
-^(sf sb br)^$wmiifocuscol $*
}
+fn wi_fnmenu {
+ group=$1^Menu-$2 last=$group^_last fns=`{wi_getfuns $group} {
+ shift 2
+ if(! ~ $#fns 0) {
+ res = `{wi_9menu -initial $"($last) $fns} \
+ if(! ~ $res '') {
+ ($last) = $res
+ $group-$res $*}}}
+}
+
fn wi_fn-p {
rc -c 'whatis '$1 >[2]/dev/null | grep -s '^fn '
}
@@ -127,6 +137,10 @@ fn wi_tags {
wmiir ls /tag | sed 's,/,,; /^sel$/d'
}
+fn wi_seltag {
+ wmiir read /tag/sel/ctl | sed 1q
+}
+
fn wi_eventloop {
wi_initkeys
diff -r 5571d2245926 -r fd899ccc36b1 cmd/wmii/client.c
--- a/cmd/wmii/client.c Sat Jan 26 21:13:42 2008 -0500
+++ b/cmd/wmii/client.c Sun Jan 27 16:08:25 2008 -0500
@@ -194,7 +194,6 @@ client_manage(Client *c) {
|| group_leader(c->group) && !client_viewframe(group_leader(c->group), c->sel->view);
f = c->sel;
- if(f->view == screen->sel)
if(!(c->w.ewmh.type & TypeSplash))
if(newgroup) {
if(f->area != f->view->sel)
@@ -903,7 +902,7 @@ client_setviews(Client *c, char **tags)
}
f = *fp;
- area_detach(f);
+ view_detach(f);
*fp = f->cnext;
if(c->sel == f)
c->sel = *fp;
diff -r 5571d2245926 -r fd899ccc36b1 cmd/wmii/fns.h
--- a/cmd/wmii/fns.h Sat Jan 26 21:13:42 2008 -0500
+++ b/cmd/wmii/fns.h Sun Jan 27 16:08:25 2008 -0500
@@ -164,8 +164,8 @@ void* map_rm(Map*, ulong);
void* map_rm(Map*, ulong);
/* message.c */
-int getlong(const char*, long*);
-int getulong(const char*, ulong*);
+bool getlong(const char*, long*);
+bool getulong(const char*, ulong*);
char* message_client(Client*, IxpMsg*);
char* message_root(void*, IxpMsg*);
char* message_view(View*, IxpMsg*);
@@ -203,6 +203,7 @@ void view_attach(View*, Frame*);
void view_attach(View*, Frame*);
View* view_create(const char*);
void view_destroy(View*);
+void view_detach(Frame*);
Area* view_findarea(View*, int, bool);
void view_focus(WMScreen*, View*);
bool view_fullscreen_p(View*);
diff -r 5571d2245926 -r fd899ccc36b1 cmd/wmii/main.c
--- a/cmd/wmii/main.c Sat Jan 26 21:13:42 2008 -0500
+++ b/cmd/wmii/main.c Sun Jan 27 16:08:25 2008 -0500
@@ -483,7 +483,10 @@ main(int argc, char *argv[]) {
if(exitsignal)
raise(exitsignal);
- if(execstr)
+ if(execstr) {
+ quotefmtinstall();
+ print("/bin/sh -c %q\n", execstr);
execl("/bin/sh", "sh", "-c", execstr, nil);
+ }
return i;
}
diff -r 5571d2245926 -r fd899ccc36b1 cmd/wmii/message.c
--- a/cmd/wmii/message.c Sat Jan 26 21:13:42 2008 -0500
+++ b/cmd/wmii/message.c Sun Jan 27 16:08:25 2008 -0500
@@ -124,12 +124,9 @@ static int
static int
gettoggle(IxpMsg *m) {
switch(getsym(msg_getword(m))) {
- case LON:
- return On;
- case LOFF:
- return Off;
- case LTOGGLE:
- return Toggle;
+ case LON: return On;
+ case LOFF: return Off;
+ case LTOGGLE: return Toggle;
default:
return -1;
}
@@ -179,52 +176,68 @@ msg_getword(IxpMsg *m) {
#define strbcmp(str, const) (strncmp((str), (const), sizeof(const)-1))
static int
-getbase(const char **s) {
+getbase(const char **s, long *sign) {
const char *p;
+ int ret;
+
+ ret = 10;
+ *sign = 1;
+ if(**s == '-') {
+ *sign = -1;
+ *s += 1;
+ }else if(**s == '+')
+ *s += 1;
p = *s;
if(!strbcmp(p, "0x")) {
*s += 2;
- return 16;
- }
- if(isdigit(p[0])) {
+ ret = 16;
+ }
+ else if(isdigit(p[0])) {
if(p[1] == 'r') {
*s += 2;
- return p[0] - '0';
+ ret = p[0] - '0';
}
- if(isdigit(p[1]) && p[2] == 'r') {
+ else if(isdigit(p[1]) && p[2] == 'r') {
*s += 3;
- return 10*(p[0]-'0') + (p[1]-'0');
+ ret = 10*(p[0]-'0') + (p[1]-'0');
}
}
- if(p[0] == '0') {
- *s += 1;
- return 8;
- }
- return 10;
-}
-
-int
+ else if(p[0] == '0') {
+ ret = 8;
+ }
+ if(ret != 10 && (**s == '-' || **s == '+'))
+ *sign = 0;
+ return ret;
+}
+
+bool
getlong(const char *s, long *ret) {
const char *end;
char *rend;
int base;
+ long sign;
end = s+strlen(s);
- base = getbase(&s);
-
- *ret = strtol(s, &rend, base);
+ base = getbase(&s, &sign);
+ if(sign == 0)
+ return false;
+
+ *ret = sign * strtol(s, &rend, base);
return (end == rend);
}
-int
+bool
getulong(const char *s, ulong *ret) {
const char *end;
char *rend;
int base;
+ long sign;
end = s+strlen(s);
- base = getbase(&s);
+ base = getbase(&s, &sign);
+ if(sign < 1)
+ return false;
*ret = strtoul(s, &rend, base);
return (end == rend);
@@ -233,6 +246,11 @@ static Client*
static Client*
strclient(View *v, char *s) {
ulong id;
+
+ /*
+ * sel
+ * 0x<window xid>
+ */
if(!strcmp(s, "sel"))
return view_selclient(v);
@@ -246,6 +264,12 @@ strarea(View *v, const char *s) {
strarea(View *v, const char *s) {
Area *a;
long i;
+
+ /*
+ * sel
+ * ~
+ * <column number>
+ */
if(!strcmp(s, "sel"))
return v->sel;
@@ -275,6 +299,16 @@ message_client(Client *c, IxpMsg *m) {
int i;
s = msg_getword(m);
+
+ /*
+ * Toggle ::= on
+ * | off
+ * | toggle
+ * Fullscreen <toggle>
+ * Urgent <toggle>
+ * kill
+ * slay
+ */
switch(getsym(s)) {
case LFULLSCREEN:
@@ -379,6 +413,41 @@ message_view(View *v, IxpMsg *m) {
s = msg_getword(m);
if(s == nil)
return nil;
+
+ /*
+ * area ::= ~
+ * | <column number>
+ * | sel
+ * # This *should* be identical to <frame>
+ * place ::= <column number>
+ * #| ~ # This should be, but isn't.
+ * | left
+ * | right
+ * | up
+ * | down
+ * | toggle
+ * colmode ::= default
+ * | stack
+ * | normal
+ * column ::= sel
+ * | <column number>
+ * frame ::= up
+ * | down
+ * | left
+ * | right
+ * | toggle
+ * | client <window xid>
+ * | sel
+ * | ~
+ * | <column> <frame number>
+ * | <column>
+ *
+ * colmode <area> <colmode>
+ * select <area>
+ * send <frame> <place>
+ * swap <frame> <place>
+ * select <ordframe>
+ */
switch(getsym(s)) {
case LCOLMODE:
@@ -620,7 +689,6 @@ msg_sendclient(View *v, IxpMsg *m, bool
case LLEFT:
if(a->floating)
return Ebadvalue;
-
if(a->prev != v->area)
to = a->prev;
a = v->area;
@@ -628,7 +696,6 @@ msg_sendclient(View *v, IxpMsg *m, bool
case LRIGHT:
if(a->floating)
return Ebadvalue;
-
to = a->next;
break;
case LTOGGLE:
@@ -642,9 +709,7 @@ msg_sendclient(View *v, IxpMsg *m, bool
default:
if(!getulong(s, &i) || i == 0)
return Ebadvalue;
-
- for(to=v->area; to; to=to->next)
- if(!i--) break;
+ to = view_findarea(v, i, true);
break;
}
diff -r 5571d2245926 -r fd899ccc36b1 cmd/wmii/printevent.c
--- a/cmd/wmii/printevent.c Sat Jan 26 21:13:42 2008 -0500
+++ b/cmd/wmii/printevent.c Sun Jan 27 16:08:25 2008 -0500
@@ -66,7 +66,7 @@ search(Pair *lst, int key, char *(*def)(
}
static char*
-unmask(Pair * list, uint val)
+unmask(Pair *list, uint val)
{
Pair *p;
char *s, *end;
diff -r 5571d2245926 -r fd899ccc36b1 cmd/wmii/view.c
--- a/cmd/wmii/view.c Sat Jan 26 21:13:42 2008 -0500
+++ b/cmd/wmii/view.c Sun Jan 27 16:08:25 2008 -0500
@@ -299,6 +299,16 @@ view_attach(View *v, Frame *f) {
c->sel = f;
}
+void
+view_detach(Frame *f) {
+ View *v;
+
+ v = f->view;
+ area_detach(f);
+ if(v != screen->sel && empty_p(v))
+ view_destroy(v);
+}
+
char**
view_names(void) {
Vector_ptr vec;
diff -r 5571d2245926 -r fd899ccc36b1 rc/rc.wmii.rc
--- a/rc/rc.wmii.rc Sat Jan 26 21:13:42 2008 -0500
+++ b/rc/rc.wmii.rc Sun Jan 27 16:08:25 2008 -0500
@@ -96,19 +96,30 @@ fn Event-Notice {
fn Event-LeftBar^(Click DND) {
shift; wmiir xwrite /ctl view $*}
+
+fn ClientMenu-3-Delete {
+ wmiir xwrite /client/$1/ctl kill}
+fn ClientMenu-3-Fullscreen {
+ wmiir xwrite /client/$1/ctl Fullscreen on}
fn Event-ClientMouseDown {
- client = $1; button = $2
- if(~ $button 3) {
- do=`{wi_9menu -initial $menulast Nop Delete Fullscreen}
- switch($do) {
- case Delete
- wmiir xwrite /client/$client/ctl kill
- case Fullscreen
- wmiir xwrite /client/$client/ctl Fullscreen on
- }
- if(! ~ $do '')
- menulast = $do;}}
-menulast = Nop
+ wi_fnmenu Client $2 $1 &}
+
+fn LBarMenu-3-Delete {
+ tag=$1; clients=`{wmiir read /tag/$tag/index | awk '/[^#]/{print $2}'}
+ for(c in $clients) {
+ if(~ $tag `{wmiir read /client/$c/tags})
+ wmiir xwrite /client/$c/ctl kill
+ if not
+ wmiir xwrite /client/$c/tags -$tag}
+ if(~ $tag `{wi_seltag}) {
+ newtag = `{wi_tags | awk -v't='$tag '
+ $1 == t { if(!l) getline l
+ print l
+ exit }
+ { l = $0 }'}
+ wmiir xwrite /ctl view $newtag}}
+fn Event-LeftBarMouseDown {
+ wi_fnmenu LBar $* &}
# Actions
fn Action-rehash {
@@ -229,10 +240,11 @@ Action rehash
# Tag Bar Setup
ifs=$wi_nl{
- oldbars=`{comm -23 <{wmiir ls /lbar} <{wi_tags}}
+ oldbars=`{comm -23 <{wmiir ls /lbar} \
+ <{wi_tags}}
if(! ~ $oldbars '')
wmiir rm /lbar/^$oldbars
- seltag=`{wmiir read /tag/sel/ctl | sed 1q}
+ seltag=`{wi_seltag}
for(tag in `{wi_tags}) {
if(~ $tag $seltag)
echo $wmiifocuscol $tag | wmiir create /lbar/$tag
Received on Sun Jan 27 2008 - 22:08:49 UTC
This archive was generated by hypermail 2.2.0 : Sun Jul 13 2008 - 15:59:12 UTC