mirror of
https://github.com/0intro/wmii
synced 2025-01-21 01:22:07 +03:00
removed /view indirection, instead tags occur in / directory, /view is a shorty for the viewed tag, fixed floating focus bug, fixed $MODKEY-s crashing bug on startup
This commit is contained in:
parent
ddd5dec606
commit
4e4793336f
@ -29,7 +29,7 @@ init_x_event_handler()
|
||||
int i;
|
||||
/* init event handler */
|
||||
for(i = 0; i < LASTEvent; i++)
|
||||
handler[i] = 0;
|
||||
handler[i] = nil;
|
||||
handler[ButtonPress] = handle_buttonpress;
|
||||
handler[ConfigureRequest] = handle_configurerequest;
|
||||
handler[DestroyNotify] = handle_destroynotify;
|
||||
|
151
cmd/wm/fs.c
151
cmd/wm/fs.c
@ -31,39 +31,37 @@ enum { WMII_IOUNIT = 2048 };
|
||||
|
||||
/*
|
||||
* filesystem specification
|
||||
* / FsDroot
|
||||
* /def/ FsDdef
|
||||
* /def/border FsFborder 0..n
|
||||
* /def/font FsFfont xlib font name
|
||||
* /def/selcolors FsFselcolors selected colors
|
||||
* /def/normcolors FsFnormcolors normal colors
|
||||
* /def/rules FsFrules rules
|
||||
* /def/keys FsFkeys keys
|
||||
* /def/grabmod FsFgrabmod grab modifier
|
||||
* /bar/ FsDbars
|
||||
* /bar/lab/ FsDbar
|
||||
* /bar/lab/data FsFdata <arbitrary data which gets displayed>
|
||||
* /bar/lab/colors FsFcolors <#RRGGBB> <#RRGGBB> <#RRGGBB>
|
||||
* /client/ FsDclients
|
||||
* /client/1/ FsDGclient see /view/X/X/X/ namespace below
|
||||
* /event FsFevent
|
||||
* /ctl FsFctl command interface (root)
|
||||
* /view/ FsDviews views
|
||||
* /view/ctl FsFctl command interface (view)
|
||||
* /view/sel/ FsDview
|
||||
* /view/X/ FsDview
|
||||
* /view/X/ctl FsFctl command interface (tag)
|
||||
* /view/X/name FsFname current view name
|
||||
* /view/X/sel/ FsDarea
|
||||
* /view/X/1/ FsDarea
|
||||
* /view/X/1/ctl FsFctl command interface (area)
|
||||
* /view/X/1/mode FsFmode column mode
|
||||
* /view/X/1/sel/ FsDclient
|
||||
* /view/X/1/1/class FsFclass class:instance of client
|
||||
* /view/X/1/1/name FsFname name of client
|
||||
* /view/X/1/1/tags FsFtags tag of client
|
||||
* /view/X/1/geom FsFgeom geometry of client
|
||||
* /view/X/1/ctl FsFctl command interface (client)
|
||||
* / FsDroot
|
||||
* /def/ FsDdef
|
||||
* /def/border FsFborder 0..n
|
||||
* /def/font FsFfont xlib font name
|
||||
* /def/selcolors FsFselcolors selected colors
|
||||
* /def/normcolors FsFnormcolors normal colors
|
||||
* /def/rules FsFrules rules
|
||||
* /def/keys FsFkeys keys
|
||||
* /def/grabmod FsFgrabmod grab modifier
|
||||
* /bar/ FsDbars
|
||||
* /bar/lab/ FsDbar
|
||||
* /bar/lab/data FsFdata <arbitrary data which gets displayed>
|
||||
* /bar/lab/colors FsFcolors <#RRGGBB> <#RRGGBB> <#RRGGBB>
|
||||
* /client/ FsDclients
|
||||
* /client/1/ FsDGclient see /view/X/X/X/ namespace below
|
||||
* /event FsFevent
|
||||
* /ctl FsFctl command interface (root)
|
||||
* /view/ FsDview
|
||||
* /view/ FsDview
|
||||
* /view/ctl FsFctl command interface (tag)
|
||||
* /view/name FsFname current view name
|
||||
* /view/sel/ FsDarea
|
||||
* /view/1/ FsDarea
|
||||
* /view/1/ctl FsFctl command interface (area)
|
||||
* /view/1/mode FsFmode column mode
|
||||
* /view/1/sel/ FsDclient
|
||||
* /view/1/1/class FsFclass class:instance of client
|
||||
* /view/1/1/name FsFname name of client
|
||||
* /view/1/1/tags FsFtags tag of client
|
||||
* /view/1/geom FsFgeom geometry of client
|
||||
* /view/1/ctl FsFctl command interface (client)
|
||||
*/
|
||||
|
||||
Qid root_qid;
|
||||
@ -150,12 +148,11 @@ qid2name(Qid *qid)
|
||||
case FsDdef: return "def"; break;
|
||||
case FsDclients: return "client"; break;
|
||||
case FsDbars: return "bar"; break;
|
||||
case FsDviews: return "view"; break;
|
||||
case FsDview:
|
||||
if(qid->dir_type != FsDroot)
|
||||
return nil;
|
||||
if(i1 == sel)
|
||||
return "sel";
|
||||
return "view";
|
||||
return view.data[i1]->name;
|
||||
break;
|
||||
case FsDbar:
|
||||
@ -241,7 +238,7 @@ name2type(char *name, unsigned char dir_type)
|
||||
if(!strncmp(name, "client", 7))
|
||||
return FsDclients;
|
||||
if(!strncmp(name, "view", 5))
|
||||
return FsDviews;
|
||||
return FsDview;
|
||||
if(!strncmp(name, "bar", 4))
|
||||
return FsDbars;
|
||||
if(!strncmp(name, "def", 4))
|
||||
@ -278,7 +275,7 @@ name2type(char *name, unsigned char dir_type)
|
||||
return FsFmode;
|
||||
if((dir_type == FsDbars) && bar_of_name(name))
|
||||
return FsDbar;
|
||||
if((dir_type == FsDviews) && view_of_name(name))
|
||||
if((dir_type == FsDroot) && view_of_name(name))
|
||||
return FsDview;
|
||||
if(!strncmp(name, "sel", 4))
|
||||
goto dyndir;
|
||||
@ -288,7 +285,6 @@ name2type(char *name, unsigned char dir_type)
|
||||
dyndir:
|
||||
/*fprintf(stderr, "nametotype: dir_type = %d\n", dir_type);*/
|
||||
switch(dir_type) {
|
||||
case FsDviews: return FsDview; break;
|
||||
case FsDbars: return FsDbar; break;
|
||||
case FsDview: return FsDarea; break;
|
||||
case FsDclients: return FsDGclient; break;
|
||||
@ -316,17 +312,16 @@ mkqid(Qid *dir, char *wname, Qid *new)
|
||||
case FsDdef:
|
||||
case FsDclients:
|
||||
case FsDbars:
|
||||
case FsDviews:
|
||||
if(dir_type != FsDroot)
|
||||
return -1;
|
||||
new->type = IXP_QTDIR;
|
||||
new->path = mkqpath(type, 0, 0, 0);
|
||||
break;
|
||||
case FsDview:
|
||||
if(dir_type != FsDviews)
|
||||
if(dir_type != FsDroot || !view.size)
|
||||
return -1;
|
||||
new->type = IXP_QTDIR;
|
||||
if(!strncmp(wname, "sel", 4))
|
||||
if(!strncmp(wname, "view", 5))
|
||||
new->path = mkqpath(FsDview, view.data[sel]->id, 0, 0);
|
||||
else {
|
||||
View *v;
|
||||
@ -471,7 +466,6 @@ type2stat(Stat *stat, char *wname, Qid *dir)
|
||||
case FsDclient:
|
||||
case FsDGclient:
|
||||
case FsDarea:
|
||||
case FsDviews:
|
||||
case FsDview:
|
||||
case FsDdef:
|
||||
case FsDclients:
|
||||
@ -723,6 +717,31 @@ xread(IXPConn *c, Fcall *fcall)
|
||||
fcall->count = 0;
|
||||
if(fcall->offset) {
|
||||
switch (type) {
|
||||
case FsDroot:
|
||||
/* jump to offset */
|
||||
len = type2stat(&stat, "ctl", &m->qid);
|
||||
len += type2stat(&stat, "event", &m->qid);
|
||||
len += type2stat(&stat, "def", &m->qid);
|
||||
len += type2stat(&stat, "bar", &m->qid);
|
||||
if(client.size)
|
||||
len += type2stat(&stat, "client", &m->qid);
|
||||
if(view.size)
|
||||
len += type2stat(&stat, "view", &m->qid);
|
||||
for(i = 0; i < view.size; i++) {
|
||||
len += type2stat(&stat, view.data[i]->name, &m->qid);
|
||||
if(len <= fcall->offset)
|
||||
continue;
|
||||
break;
|
||||
}
|
||||
/* offset found, proceeding */
|
||||
for(; i < view.size; i++) {
|
||||
len = type2stat(&stat, view.data[i]->name, &m->qid);
|
||||
if(fcall->count + len > fcall->iounit)
|
||||
break;
|
||||
fcall->count += len;
|
||||
p = ixp_enc_stat(p, &stat);
|
||||
}
|
||||
break;
|
||||
case FsDclients:
|
||||
/* jump to offset */
|
||||
len = 0;
|
||||
@ -761,26 +780,6 @@ xread(IXPConn *c, Fcall *fcall)
|
||||
p = ixp_enc_stat(p, &stat);
|
||||
}
|
||||
break;
|
||||
case FsDviews:
|
||||
/* jump to offset */
|
||||
len = type2stat(&stat, "ctl", &m->qid);
|
||||
if(view.size)
|
||||
len += type2stat(&stat, "sel", &m->qid);
|
||||
for(i = 0; i < view.size; i++) {
|
||||
len += type2stat(&stat, view.data[i]->name, &m->qid);
|
||||
if(len <= fcall->offset)
|
||||
continue;
|
||||
break;
|
||||
}
|
||||
/* offset found, proceeding */
|
||||
for(; i < view.size; i++) {
|
||||
len = type2stat(&stat, view.data[i]->name, &m->qid);
|
||||
if(fcall->count + len > fcall->iounit)
|
||||
break;
|
||||
fcall->count += len;
|
||||
p = ixp_enc_stat(p, &stat);
|
||||
}
|
||||
break;
|
||||
case FsDview:
|
||||
/* jump to offset */
|
||||
len = 0;
|
||||
@ -887,26 +886,18 @@ xread(IXPConn *c, Fcall *fcall)
|
||||
fcall->count += type2stat(&stat, "view", &m->qid);
|
||||
p = ixp_enc_stat(p, &stat);
|
||||
}
|
||||
break;
|
||||
case FsDclients:
|
||||
for(i = 0; i < client.size; i++) {
|
||||
snprintf(buf, sizeof(buf), "%u", i);
|
||||
len = type2stat(&stat, buf, &m->qid);
|
||||
for(i = 0; i < view.size; i++) {
|
||||
len = type2stat(&stat, view.data[i]->name, &m->qid);
|
||||
if(fcall->count + len > fcall->iounit)
|
||||
break;
|
||||
fcall->count += len;
|
||||
p = ixp_enc_stat(p, &stat);
|
||||
}
|
||||
break;
|
||||
case FsDviews:
|
||||
fcall->count = type2stat(&stat, "ctl", &m->qid);
|
||||
p = ixp_enc_stat(p, &stat);
|
||||
if(view.size) {
|
||||
fcall->count += type2stat(&stat, "sel", &m->qid);
|
||||
p = ixp_enc_stat(p, &stat);
|
||||
}
|
||||
for(i = 0; i < view.size; i++) {
|
||||
len = type2stat(&stat, view.data[i]->name, &m->qid);
|
||||
case FsDclients:
|
||||
for(i = 0; i < client.size; i++) {
|
||||
snprintf(buf, sizeof(buf), "%u", i);
|
||||
len = type2stat(&stat, buf, &m->qid);
|
||||
if(fcall->count + len > fcall->iounit)
|
||||
break;
|
||||
fcall->count += len;
|
||||
@ -1179,11 +1170,7 @@ xwrite(IXPConn *c, Fcall *fcall)
|
||||
srv.running = 0;
|
||||
else if(!strncmp(buf, "retag", 6))
|
||||
reapply_rules();
|
||||
else
|
||||
return Enocommand;
|
||||
break;
|
||||
case FsDviews:
|
||||
if(!strncmp(buf, "view ", 5))
|
||||
else if(!strncmp(buf, "view ", 5))
|
||||
select_view(&buf[5]);
|
||||
else
|
||||
return Enocommand;
|
||||
@ -1235,6 +1222,8 @@ xwrite(IXPConn *c, Fcall *fcall)
|
||||
return Ebadvalue;
|
||||
memcpy(buf, fcall->data, fcall->count);
|
||||
buf[fcall->count] = 0;
|
||||
if(!permit_tags(buf))
|
||||
return Ebadvalue;
|
||||
if(m->qid.dir_type == FsDclient)
|
||||
cl = view.data[i1]->area.data[i2]->frame.data[i3]->client;
|
||||
else
|
||||
|
@ -38,6 +38,26 @@ rule2vector(RuleVector *rv)
|
||||
return (Vector *) rv;
|
||||
}
|
||||
|
||||
Bool
|
||||
permit_tags(const char *tags)
|
||||
{
|
||||
static char *exclude[]
|
||||
= { "bar", "client", "ctl", "def", "event", "view" };
|
||||
char buf[256];
|
||||
char *toks[16];
|
||||
unsigned int i, j, n;
|
||||
|
||||
cext_strlcpy(buf, tags, sizeof(buf));
|
||||
n = cext_tokenize(toks, 16, buf, '+');
|
||||
for(i = 0; i < (sizeof(exclude)/sizeof(exclude[0])); i++)
|
||||
for(j = 0; j < n; j++) {
|
||||
if(!strncmp(exclude[i], toks[j], strlen(toks[j])) &&
|
||||
!strncmp(exclude[i], toks[j], strlen(exclude[i])))
|
||||
return False;
|
||||
}
|
||||
return True;
|
||||
}
|
||||
|
||||
void
|
||||
update_rules()
|
||||
{
|
||||
@ -80,12 +100,17 @@ update_rules()
|
||||
break;
|
||||
case TAGS:
|
||||
if(*p == '\n' || *(p + 1) == 0) {
|
||||
Rule *rul = cext_emallocz(sizeof(Rule));
|
||||
*t = 0;
|
||||
rul->is_valid = !regcomp(&rul->regex, regex, 0);
|
||||
cext_strlcpy(rul->tags, tags, sizeof(rul->tags));
|
||||
if(permit_tags(tags)) {
|
||||
Rule *rul = cext_emallocz(sizeof(Rule));
|
||||
rul->is_valid = !regcomp(&rul->regex, regex, 0);
|
||||
cext_strlcpy(rul->tags, tags, sizeof(rul->tags));
|
||||
cext_vattach(rule2vector(&rule), rul);
|
||||
}
|
||||
else
|
||||
fprintf(stderr, "wmiiwm: ignoring rule with tags '%s', restricted tag name\n",
|
||||
tags);
|
||||
mode = IGNORE;
|
||||
cext_vattach(rule2vector(&rule), rul);
|
||||
}
|
||||
else {
|
||||
if((*p == ' ' || *p == '\t') && (tags[0] == 0))
|
||||
|
@ -213,6 +213,7 @@ attach_to_view(View *v, Client *c)
|
||||
a = v->area.data[v->sel];
|
||||
|
||||
attach_to_area(a, c);
|
||||
v->sel = idx_of_area(a);
|
||||
map_client(c);
|
||||
XMapWindow(dpy, c->framewin);
|
||||
}
|
||||
|
@ -37,7 +37,6 @@ enum {
|
||||
enum {
|
||||
FsDroot,
|
||||
FsDdef,
|
||||
FsDviews,
|
||||
FsDview,
|
||||
FsDarea,
|
||||
FsDclients,
|
||||
@ -268,6 +267,7 @@ void ungrab_mouse(Window w, unsigned long mod, unsigned int button);
|
||||
void update_rules();
|
||||
void apply_rules(Client *c);
|
||||
void reapply_rules();
|
||||
Bool permit_tags(const char *tags);
|
||||
|
||||
/* view.c */
|
||||
void arrange_view(View *v, Bool dirty);
|
||||
|
42
rc/wmiirc
42
rc/wmiirc
@ -107,55 +107,55 @@ do
|
||||
exit
|
||||
fi;;
|
||||
BarClick)
|
||||
xwrite /view/ctl view "$1";;
|
||||
xwrite /ctl view "$1";;
|
||||
Key)
|
||||
case "$1" in
|
||||
$MODKEY-$LEFT)
|
||||
xwrite /view/sel/ctl select prev;;
|
||||
xwrite /view/ctl select prev;;
|
||||
$MODKEY-$RIGHT)
|
||||
xwrite /view/sel/ctl select next;;
|
||||
xwrite /view/ctl select next;;
|
||||
$MODKEY-$DOWN)
|
||||
xwrite /view/sel/sel/ctl select next;;
|
||||
xwrite /view/sel/ctl select next;;
|
||||
$MODKEY-$UP)
|
||||
xwrite /view/sel/sel/ctl select prev;;
|
||||
xwrite /view/sel/ctl select prev;;
|
||||
$MODKEY-space)
|
||||
xwrite /view/sel/ctl select toggle;;
|
||||
xwrite /view/ctl select toggle;;
|
||||
$MODKEY-d)
|
||||
xwrite /view/sel/sel/mode default;;
|
||||
xwrite /view/sel/mode default;;
|
||||
$MODKEY-s)
|
||||
xwrite /view/sel/sel/mode stack;;
|
||||
xwrite /view/sel/mode stack;;
|
||||
$MODKEY-m)
|
||||
xwrite /view/sel/sel/mode max;;
|
||||
xwrite /view/sel/mode max;;
|
||||
$MODKEY-a)
|
||||
`proglist CONFPREFIX/wmii-3:$HOME/.wmii-3 | wmiimenu` &;;
|
||||
$MODKEY-p)
|
||||
extern `wmiimenu </tmp/ns.$USER.$DISPLAY/progs` &;;
|
||||
$MODKEY-t)
|
||||
xwrite /view/ctl view "`wmiir read /view | awk '{print $10}' | grep -v 'sel' | grep -v 'ctl' | wmiimenu`" &;;
|
||||
xwrite /ctl view "`wmiir read / | awk '!/bar|client|ctl|def|event|view/{print $10}' | wmiimenu`" &;;
|
||||
$MODKEY-[0-9])
|
||||
xwrite /view/ctl view `echo $1 | sed 's/.*-//'`;;
|
||||
xwrite /ctl view `echo $1 | sed 's/.*-//'`;;
|
||||
$MODKEY-Return)
|
||||
extern xterm &;;
|
||||
$MODKEY-Shift-$LEFT)
|
||||
xwrite /view/sel/sel/sel/ctl sendto prev;;
|
||||
xwrite /view/sel/sel/ctl sendto prev;;
|
||||
$MODKEY-Shift-$RIGHT)
|
||||
xwrite /view/sel/sel/sel/ctl sendto next;;
|
||||
xwrite /view/sel/sel/ctl sendto next;;
|
||||
$MODKEY-Shift-space)
|
||||
xwrite /view/sel/sel/sel/ctl sendto toggle;;
|
||||
xwrite /view/sel/sel/ctl sendto toggle;;
|
||||
$MODKEY-Shift-c)
|
||||
xwrite /view/sel/sel/sel/ctl kill;;
|
||||
xwrite /view/sel/sel/ctl kill;;
|
||||
$MODKEY-Shift-t)
|
||||
xwrite /view/sel/sel/sel/tags "`wmiir read /view/sel/sel/sel/tags | wmiimenu`" &;;
|
||||
xwrite /view/sel/sel/tags "`wmiir read /view/sel/sel/tags | wmiimenu`" &;;
|
||||
$MODKEY-Shift-[0-9])
|
||||
xwrite /view/sel/sel/sel/tags `echo $1 | sed 's/.*-//'`;;
|
||||
xwrite /view/sel/sel/tags `echo $1 | sed 's/.*-//'`;;
|
||||
$MODKEY-Control-$LEFT)
|
||||
xwrite /view/sel/sel/sel/ctl swap prev;;
|
||||
xwrite /view/sel/sel/ctl swap prev;;
|
||||
$MODKEY-Control-$RIGHT)
|
||||
xwrite /view/sel/sel/sel/ctl swap next;;
|
||||
xwrite /view/sel/sel/ctl swap next;;
|
||||
$MODKEY-Control-$DOWN)
|
||||
xwrite /view/sel/sel/sel/ctl swap down;;
|
||||
xwrite /view/sel/sel/ctl swap down;;
|
||||
$MODKEY-Control-$UP)
|
||||
xwrite /view/sel/sel/sel/ctl swap up;;
|
||||
xwrite /view/sel/sel/ctl swap up;;
|
||||
esac;;
|
||||
esac
|
||||
done
|
||||
|
Loading…
Reference in New Issue
Block a user