changeset: 2129:9facd84d13be
user: Kris Maglione <jg_AT_suckless.org>
date: Wed Apr 25 15:54:44 2007 -0400
summary: A bunch of fixes. Change wmiiloop to let the shell evaluate unindented lines.
diff -r 71f637937524 -r 9facd84d13be cmd/wmii/area.c
--- a/cmd/wmii/area.c Tue Apr 24 04:34:14 2007 -0400
+++ b/cmd/wmii/area.c Wed Apr 25 15:54:44 2007 -0400
@@ -180,11 +180,12 @@ attach_to_area(Area *a, Frame *f, Bool s
insert_frame(a->sel, f);
- if(a->floating)
+ if(a->floating) {
place_frame(f);
+ resize_client(f->client, &f->r);
+ }
focus_frame(f, False);
- resize_frame(f, f->r);
restack_view(a->view);
if(!a->floating)
diff -r 71f637937524 -r 9facd84d13be cmd/wmii/bar.c
--- a/cmd/wmii/bar.c Tue Apr 24 04:34:14 2007 -0400
+++ b/cmd/wmii/bar.c Wed Apr 25 15:54:44 2007 -0400
@@ -100,10 +100,6 @@ draw_bar(WMScreen *s) {
uint width, tw, nb, size;
float shrink;
- fill(screen->ibuf, s->brect, def.normcolor.bg);
- if(!s->bar[BarLeft] && !s->bar[BarRight])
- goto MapBar;
-
largest = b = tb = nil;
tw = width = nb = size = 0;
for(nb = 0; nb < nelem(s->bar); nb++)
@@ -152,13 +148,16 @@ draw_bar(WMScreen *s) {
if(tb)
b->r = rectaddpt(b->r, Pt( tb->r.max.x, 0));
+ }
+ r = rectsubpt(s->brect, s->brect.min);
+ fill(screen->ibuf, r, def.normcolor.bg);
+ for(nb = 0; nb < nelem(s->bar); nb++)
+ for(b = s->bar[nb]; b; tb=b, b=b->next) {
fill(screen->ibuf, b->r, b->col.bg);
drawstring(screen->ibuf, def.font, b->r, align, b->text, b->col.fg);
border(screen->ibuf, b->r, 1, b->col.border);
}
-MapBar:
- r = rectsubpt(s->brect, s->brect.min);
copyimage(s->barwin, r, screen->ibuf, ZP);
XSync(display, False);
}
diff -r 71f637937524 -r 9facd84d13be cmd/wmii/client.c
--- a/cmd/wmii/client.c Tue Apr 24 04:34:14 2007 -0400
+++ b/cmd/wmii/client.c Wed Apr 25 15:54:44 2007 -0400
@@ -104,7 +104,7 @@ manage_client(Client *c) {
r = c->w.r;
p.x = def.border;
p.y = labelh(def.font);
- reparent_client(c, c->framewin, p);
+ reparent_client(c, c->framewin, ZP);
if(!strlen(c->tags))
apply_rules(c);
@@ -358,9 +358,9 @@ resize_client(Client *c, Rectangle *r) {
map_frame(c);
unmap_client(c, IconicState);
}else {
- reshapewin(&c->w, f->crect);
map_client(c);
reshapewin(c->framewin, f->r);
+ reshapewin(&c->w, f->crect);
map_frame(c);
configure_client(c);
}
@@ -505,18 +505,18 @@ static void
static void
updatemwm(Client *c) {
enum {
- All = 1<<0,
- Border = 1<<1,
- Title = 1<<3,
+ All = 0x1,
+ Border = 0x2,
+ Title = 0x8,
};
Rectangle r;
ulong *ret, decor;
Atom real;
int n;
- decor = 0;
n = getproperty(&c->w, "_MOTIF_WM_HINTS", "_MOTIF_WM_HINTS", &real,
2L, (uchar**)&ret, 1L);
+
if(n == 0) {
c->borderless = 0;
c->titleless = 0;
diff -r 71f637937524 -r 9facd84d13be cmd/wmii/fns.h
--- a/cmd/wmii/fns.h Tue Apr 24 04:34:14 2007 -0400
+++ b/cmd/wmii/fns.h Wed Apr 25 15:54:44 2007 -0400
@@ -108,7 +108,7 @@ void kpress(XWindow, ulong mod, KeyCode)
void kpress(XWindow, ulong mod, KeyCode);
void update_keys();
void init_lock_keys();
-ulong mod_key_of_str(char*);
+ulong str2modmask(char*);
/* map.c */
MapEnt* mapget(Map*, ulong, int create);
@@ -125,7 +125,7 @@ char * read_root_ctl();
char * read_root_ctl();
char * message_client(Client*, Message*);
char *select_area(Area*, Message*);
-char *send_client(Frame*, Message*, Bool swap);
+char *send_client(View*, Message*, Bool swap);
/* mouse.c */
void mouse_resizecol(Divide*);
diff -r 71f637937524 -r 9facd84d13be cmd/wmii/key.c
--- a/cmd/wmii/key.c Tue Apr 24 04:34:14 2007 -0400
+++ b/cmd/wmii/key.c Wed Apr 25 15:54:44 2007 -0400
@@ -32,7 +32,7 @@ init_lock_keys() {
}
ulong
-mod_key_of_str(char *val) {
+str2modmask(char *val) {
ulong mod = 0;
if (strstr(val, "Shift"))
@@ -112,7 +112,7 @@ get_key(const char *name) {
else
kstr = seq[i];
k->key = XKeysymToKeycode(display, XStringToKeysym(kstr));
- k->mod = mod_key_of_str(seq[i]);
+ k->mod = str2modmask(seq[i]);
}
if(r) {
r->id = id++;
diff -r 71f637937524 -r 9facd84d13be cmd/wmii/main.c
--- a/cmd/wmii/main.c Tue Apr 24 04:34:14 2007 -0400
+++ b/cmd/wmii/main.c Wed Apr 25 15:54:44 2007 -0400
@@ -145,7 +145,7 @@ init_environment() {
static void
init_atoms() {
- Atom net[] = { xatom("_NET_SUPPORTED"), xatom("_NET_WM_NAME")};
+ Atom net[] = { xatom("_NET_SUPPORTED"), xatom("_NET_WM_NAME") };
changeprop(&scr.root, "_NET_SUPPORTED", "ATOM", net, nelem(net));
}
@@ -172,8 +172,7 @@ init_cursors() {
create_cursor(CurIcon, XC_icon);
XAllocNamedColor(display, scr.colormap,
- "black", &black,
- &dummy);
+ "black", &black, &dummy);
pix = XCreateBitmapFromData(
display, scr.root.w,
(char[]){0}, 1, 1);
diff -r 71f637937524 -r 9facd84d13be cmd/wmii/message.c
--- a/cmd/wmii/message.c Tue Apr 24 04:34:14 2007 -0400
+++ b/cmd/wmii/message.c Wed Apr 25 15:54:44 2007 -0400
@@ -1,6 +1,7 @@
/* Copyright ©2006-2007 Kris Maglione <fbsdaemon_AT_gmail.com>
* See LICENSE file for license details.
*/
+#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -8,15 +9,84 @@
#include "dat.h"
#include "fns.h"
+static char Ebadcmd[] = "bad command",
+ Ebadvalue[] = "bad value";
+
+/* Edit s/"([^"]+)"/L\1/g Edit |tr 'a-z' 'A-Z' */
+enum {
+ LNOTURGENT,
+ LURGENT,
+ LBORDER,
+ LCOLMODE,
+ LDOWN,
+ LEXEC,
+ LFOCUSCOLORS,
+ LFONT,
+ LGRABMOD,
+ LKILL,
+ LLEFT,
+ LNORMCOLORS,
+ LQUIT,
+ LRIGHT,
+ LSELCOLORS,
+ LSELECT,
+ LSEND,
+ LSWAP,
+ LTOGGLE,
+ LUP,
+ LVIEW,
+ LTILDE,
+};
+char *symtab[] = {
+ "NotUrgent",
+ "Urgent",
+ "border",
+ "colmode",
+ "down",
+ "exec",
+ "focuscolors",
+ "font",
+ "grabmod",
+ "kill",
+ "left",
+ "normcolors",
+ "quit",
+ "right",
+ "selcolors",
+ "select",
+ "send",
+ "swap",
+ "toggle",
+ "up",
+ "view",
+ "~",
+};
+
/* Edit ,y/^[a-zA-Z].*\n.* {\n/d
* Edit s/^([a-zA-Z].*)\n(.*) {\n/\1 \2;\n/
* Edit ,x/^static.*\n/d
*/
-#define strecmp(str, const) (strncmp((str), (const), sizeof(const)-1))
-
-static char Ebadcmd[] = "bad command",
- Ebadvalue[] = "bad value";
+static int
+getsym(char *s) {
+ int i, n, m, cmp;
+
+ n = nelem(symtab);
+ i = 0;
+ while(n) {
+ m = n/2;
+ cmp = strcmp(s, symtab[i+m]);
+ if(cmp == 0)
+ return i+m;
+ if(cmp > 0) {
+ i += m;
+ n = n-m;
+ }
+ else
+ n = m;
+ }
+ return -1;
+}
static void
eatrunes(Message *m, int (*p)(Rune), int val) {
@@ -48,13 +118,15 @@ getword(Message *m) {
return ret;
}
+
+#define strbcmp(str, const) (strncmp((str), (const), sizeof(const)-1))
static int
getbase(char **s) {
- if(!strecmp(*s, "0x")) {
+ if(!strbcmp(*s, "0x")) {
*s += 2;
return 16;
}
- if(strecmp(*s, "0")) {
+ if(!strbcmp(*s, "0")) {
*s += 1;
return 8;
}
@@ -126,30 +198,25 @@ strarea(View *v, char *s) {
char *
message_view(View *v, Message *m) {
- Client *c;
- Frame *f;
Area *a;
char *s;
int i;
- Bool swap;
-
- s = getword(m);
-
- if(!strcmp(s, "send")) {
- swap = False;
- goto send;
- }
- if(!strcmp(s, "swap")) {
- swap = True;
- goto send;
- }
- if(!strcmp(s, "select"))
+
+ s = getword(m);
+
+ switch(getsym(s)) {
+ case LSEND:
+ return send_client(v, m, 0);
+ case LSWAP:
+ return send_client(v, m, 1);
+ case LSELECT:
return select_area(v->sel, m);
- if(!strcmp(s, "colmode")) {
+ case LCOLMODE:
s = getword(m);
-
if((a = strarea(v, s)) == nil || a->floating)
return Ebadvalue;
+
+ s = getword(m);
if((i = str2colmode(s)) == -1)
return Ebadvalue;
@@ -161,18 +228,10 @@ message_view(View *v, Message *m) {
focus_view(screen, v);
draw_frames();
return nil;
- }
- return Ebadcmd;
-
-send:
- s = getword(m);
-
- if(!(c = strclient(v, s)))
- return Ebadvalue;
- if(!(f = view_clientframe(v, c)))
- return Ebadvalue;
-
- return send_client(f, m, swap);
+ default:
+ return Ebadcmd;
+ }
+ assert(!"can't get here");
}
char *
@@ -203,56 +262,64 @@ char *
char *
message_root(void *p, Message *m) {
Font *fn;
- char *s;
+ char *s, *ret;
ulong n;
- s = getword(m);
-
- if(!strcmp(s, "quit"))
+ ret = nil;
+ s = getword(m);
+
+ switch(getsym(s)) {
+ case LQUIT:
srv.running = 0;
- else if(!strcmp(s, "exec")) {
+ break;
+ case LEXEC:
execstr = emalloc(strlen(m->pos) + sizeof("exec "));
sprintf(execstr, "exec %s", m->pos);
srv.running = 0;
- }
- else if(!strcmp(s,"view"))
+ break;
+ case LVIEW:
select_view(m->pos);
- else if(!strcmp(s, "selcolors")) {
+ break;
+ case LSELCOLORS:
fprintf(stderr, "%s: warning: selcolors have been removed\n", argv0);
return Ebadcmd;
- }
- else if(!strcmp(s, "focuscolors"))
- return parse_colors(m, &def.focuscolor);
- else if(!strcmp(s, "normcolors"))
- return parse_colors(m, &def.normcolor);
- else if(!strcmp(s, "font")) {
+ case LFOCUSCOLORS:
+ ret = parse_colors(m, &def.focuscolor);
+ focus_view(screen, screen->sel);
+ break;
+ case LNORMCOLORS:
+ ret = parse_colors(m, &def.normcolor);
+ focus_view(screen, screen->sel);
+ break;
+ case LFONT:
fn = loadfont(m->pos);
if(fn) {
freefont(def.font);
def.font = fn;
resize_bar(screen);
}else
- return "can't load font";
- }
- else if(!strcmp(s, "border")) {
+ ret = "can't load font";
+ break;
+ case LBORDER:
if(!getulong(getword(m), &n))
return Ebadvalue;
def.border = n;
/* XXX: Apply the change */
- }
- else if(!strcmp(s, "grabmod")) {
+ break;
+ case LGRABMOD:
s = getword(m);
- n = mod_key_of_str(s);
+ n = str2modmask(s);
if(!(n & (Mod1Mask|Mod2Mask|Mod3Mask|Mod4Mask|Mod5Mask)))
return Ebadvalue;
strncpy(def.grabmod, s, sizeof(def.grabmod));
def.mod = n;
- }
- else
+ break;
+ default:
return Ebadcmd;
- return nil;
+ }
+ return ret;
}
char *
@@ -273,104 +340,131 @@ message_client(Client *c, Message *m) {
s = getword(m);
- if(!strcmp(s, "kill"))
+ switch(getsym(s)) {
+ case LKILL:
kill_client(c);
- else if(!strcmp(s, "Urgent"))
+ break;
+ case LURGENT:
set_urgent(c, True, True);
- else if(!strcmp(s, "NotUrgent"))
+ break;
+ case LNOTURGENT:
set_urgent(c, False, True);
- else
+ break;
+ default:
return Ebadcmd;
- return nil;
-}
-
-char *
-send_client(Frame *f, Message *m, Bool swap) {
+ }
+ return nil;
+}
+
+static char*
+send_frame(Frame *f, int sym, Bool swap) {
+ Frame *fp;
+ Area *a;
+
+ a = f->area;
+
+ switch(sym) {
+ case LUP:
+ fp = f->aprev;
+ if(!fp)
+ return Ebadvalue;
+ fp = fp->aprev;
+ break;
+ case LDOWN:
+ fp = f->anext;
+ if(!fp)
+ return Ebadvalue;
+ break;
+ }
+
+ if(swap) {
+ if(!fp)
+ return Ebadvalue;
+ swap_frames(f, fp);
+ }else {
+ remove_frame(f);
+ insert_frame(fp, f);
+ }
+
+ arrange_column(a, False);
+
+ flushevents(EnterWindowMask, False);
+ focus_frame(f, True);
+ update_views();
+ return nil;
+}
+
+char *
+send_client(View *v, Message *m, Bool swap) {
Area *to, *a;
+ Frame *f;
Client *c;
- Frame *tf;
- View *v;
char *s;
ulong i;
+ int sym;
+
+ s = getword(m);
+
+ c = strclient(v, s);
+ if(c == nil)
+ return Ebadvalue;
+
+ f = view_clientframe(v, c);
+ if(f == nil)
+ return Ebadvalue;
a = f->area;
- v = a->view;
- c = f->client;
-
- s = getword(m);
-
- if(!strcmp(s, "toggle")) {
+ to = nil;
+
+ s = getword(m);
+ sym = getsym(s);
+
+ switch(sym) {
+ case LTOGGLE:
if(!a->floating)
to = v->area;
else if(c->revert && !c->revert->floating)
to = c->revert;
else
to = v->area->next;
- goto send_area;
- }else if(!a->floating) {
- if(!strcmp(s, "left")) {
- if(a->floating)
- return Ebadvalue;
- for(to=v->area->next; to; to=to->next)
- if(a == to->next) break;
- if(!to && !swap && (f->anext || f != a->frame))
- to=new_column(v, v->area, 0);
- goto send_area;
- }
- else if(!strcmp(s, "right")) {
- if(a->floating)
- return Ebadvalue;
- to = a->next;
- if(!to && !swap && (f->anext || f != a->frame))
- to = new_column(v, a, 0);
- goto send_area;
- }
- else if(!strcmp(s, "up")) {
- tf = f->aprev;
- if(!tf)
- return Ebadvalue;
- tf = tf->aprev;
- goto send_frame;
- }
- else if(!strcmp(s, "down")) {
- tf = f->anext;
- if(!tf)
- return Ebadvalue;
- goto send_frame;
- }
- else {
- if(!getulong(s, &i) || i == 0)
- return Ebadvalue;
- for(to=v->area; to; to=to->next)
- if(!i--) break;
- goto send_area;
- }
- }
- return Ebadvalue;
-
-send_frame:
- if(!swap) {
- remove_frame(f);
- insert_frame(tf, f);
- }else {
- if(!tf)
- return Ebadvalue;
- swap_frames(f, tf);
- }
- arrange_column(a, False);
-
- flushevents(EnterWindowMask, False);
- focus_frame(f, True);
- update_views();
- return nil;
-
-send_area:
+ case LUP:
+ case LDOWN:
+ return send_frame(f, sym, swap);
+ case LLEFT:
+ if(a->floating)
+ return Ebadvalue;
+
+ if(a->prev != v->area)
+ to = a->prev;
+ a = v->area;
+ break;
+ case LRIGHT:
+ if(a->floating)
+ return Ebadvalue;
+
+ to = a->next;
+ break;
+ default:
+ if(!getulong(s, &i) || i == 0)
+ return Ebadvalue;
+
+ for(to=v->area; to; to=to->next)
+ if(!i--) break;
+ break;
+ }
+
+ if(!to && !swap && (f->anext || f != a->frame))
+ to = new_column(v, a, 0);
+
if(!to)
return Ebadvalue;
+
if(!swap)
send_to_area(to, f);
else if(to->sel)
swap_frames(f, to->sel);
+ else
+ return Ebadvalue;
flushevents(EnterWindowMask, False);
focus_frame(f, True);
@@ -378,71 +472,81 @@ send_area:
return nil;
}
-char *
+static char*
+select_frame(Frame *f, int sym) {
+ Frame *fp;
+ Area *a;
+
+ if(!f)
+ return Ebadvalue;
+ a = f->area;
+
+ switch(sym) {
+ case LUP:
+ for(fp = a->frame; fp->anext; fp = fp->anext)
+ if(fp->anext == f) break;
+ break;
+ case LDOWN:
+ fp = f->anext;
+ if(fp == nil)
+ fp = a->frame;
+ break;
+ }
+
+ focus_frame(fp, False);
+ frame_to_top(fp);
+ if(f->view == screen->sel)
+ restack_view(f->view);
+ return nil;
+}
+
+char*
select_area(Area *a, Message *m) {
- Frame *p, *f;
Area *ap;
View *v;
char *s;
ulong i;
+ int sym;
v = a->view;
- f = a->sel;
+ s = getword(m);
+ sym = getsym(s);
- s = getword(m);
-
-
- if(!strcmp(s, "toggle")) {
+ switch(sym) {
+ case LUP:
+ case LDOWN:
+ return select_frame(a->sel, sym);
+ case LTOGGLE:
if(!a->floating)
ap = v->area;
else if(v->revert && v->revert != a)
ap = v->revert;
else
ap = v->area->next;
- }
- else if(!strcmp(s, "left")) {
+ break;
+ case LLEFT:
if(a->floating)
return Ebadvalue;
for(ap=v->area->next; ap->next; ap=ap->next)
if(ap->next == a) break;
- }
- else if(!strcmp(s, "right")) {
+ break;
+ case LRIGHT:
if(a->floating)
return Ebadvalue;
ap = a->next;
if(ap == nil)
ap = v->area->next;
- }
- else if(!strcmp(s, "up")) {
- if(!f)
- return Ebadvalue;
- for(p = f->area->frame; p->anext; p = p->anext)
- if(p->anext == f) break;
- goto focus_frame;
- }
- else if(!strcmp(s, "down")) {
- if(!f)
- return Ebadvalue;
- p = f->anext;
- if(p == nil)
- p = a->frame;
- goto focus_frame;
- }
- else if(!strcmp(s, "~"))
+ break;
+ case LTILDE:
ap = v->area;
- else {
+ break;
+ default:
if(!getulong(s, &i) || i == 0)
return Ebadvalue;
for(ap=v->area->next; ap; ap=ap->next)
if(!--i) break;
}
+
focus_area(ap);
return nil;
-
-focus_frame:
- focus_frame(p, False);
- frame_to_top(p);
- if(v == screen->sel)
- restack_view(v);
- return nil;
-}
+}
diff -r 71f637937524 -r 9facd84d13be cmd/wmiiloop.awk
--- a/cmd/wmiiloop.awk Tue Apr 24 04:34:14 2007 -0400
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,35 +0,0 @@
-#!AWKPATH -f
-BEGIN {
- arg[1] = "Nop"
- body = "";
- writekeys = "wmiir write /keys"
- print "IFS=''"
-}
-
-function addevent() {
- if(arg[1] == "Key")
- keys[arg[2]] = 1;
-
- var = arg[1] "s"
- print var "=\"$" var " " arg[2] "\""
-
- gsub("[^a-zA-Z_0-9]", "_", arg[2]);
- if(body != "")
- print arg[1] "_" arg[2] "() {" body "\n}"
-}
-
-/^(Event|Key|Action)[ \t]/ {
- addevent()
- split($0, arg)
- body = ""
-}
-/^[ \t]/ {
- body = body"\n"$0
-}
-
-END {
- addevent()
- for(key in keys)
- print key | writekeys;
- close(writekeys);
-}
diff -r 71f637937524 -r 9facd84d13be cmd/wmiiloop.sh
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/cmd/wmiiloop.sh Wed Apr 25 15:54:44 2007 -0400
@@ -0,0 +1,49 @@
+#!/bin/sh
+
+eval "text() {
+ cat <<!
+$(sed '/^[[:blank:]]/s/\([$`]\)/\\\1/g')
+!
+}"
+
+script() {
+ cat <<'!'
+ BEGIN {
+ arg[1] = "Nop"
+ body = "";
+ writekeys = "wmiir write /keys"
+ print "IFS=''"
+ }
+
+ function addevent() {
+ if(arg[1] == "Key")
+ keys[arg[2]] = 1;
+
+ var = arg[1] "s"
+ print var "=\"$" var " " arg[2] "\""
+
+ gsub("[^a-zA-Z_0-9]", "_", arg[2]);
+ if(body != "")
+ print arg[1] "_" arg[2] "() {" body "\n}"
+ }
+
+ /^(Event|Key|Action)[ \t]/ {
+ addevent()
+ split($0, arg)
+ body = ""
+ }
+ /^[ \t]/ {
+ body = body"\n"$0
+ }
+
+ END {
+ addevent()
+ for(key in keys)
+ print key | writekeys;
+ close(writekeys);
+ }
+!
+}
+
+text | awk "`script`"
+
diff -r 71f637937524 -r 9facd84d13be rc/wmiirc.sh
--- a/rc/wmiirc.sh Tue Apr 24 04:34:14 2007 -0400
+++ b/rc/wmiirc.sh Wed Apr 25 15:54:44 2007 -0400
@@ -125,8 +125,6 @@ eventstuff() {
wmiir xwrite /client/sel/ctl kill
Key $MODKEY-Shift-t
wmiir xwrite "/client/$(wmiir read /client/sel/ctl)/tags" "$(tagsmenu)" &
-!
- cat<<!
Key $MODKEY-$LEFT
wmiir xwrite /tag/sel/ctl select left
Key $MODKEY-$RIGHT
@@ -164,9 +162,7 @@ EOF
EOF
# Feed events to `wmiiloop' for processing
-IFS=''
-eval $(eventstuff | sed "s/\$MODKEY/$MODKEY/g;s/^[ ]//" | wmiiloop)
-unset IFS
+eval "$(eventstuff | sed 's/^[ ]//' | wmiiloop)"
# Functions
Action() {
Received on Fri Jun 01 2007 - 03:10:25 UTC
This archive was generated by hypermail 2.2.0 : Sun Jul 13 2008 - 15:57:06 UTC