commit 564a3ecbf6beb4d4b90e23973183a4082d82f60b
parent d083e7e243db06b9b11b973dd3615924461dc546
Author: Anselm R. Garbe <garbeam@wmii.de>
Date: Wed, 22 Mar 2006 09:48:08 +0100
several fixes discussed on mailinglist this morning
Diffstat:
3 files changed, 34 insertions(+), 33 deletions(-)
diff --git a/cmd/wm/fs.c b/cmd/wm/fs.c
@@ -787,11 +787,10 @@ xread(IXPConn *c, Fcall *fcall)
/* jump to offset */
len = type2stat(&stat, "ctl", &m->qid);
len += type2stat(&stat, "tag", &m->qid);
+ if(tag[i1]->narea)
+ len += type2stat(&stat, "sel", &m->qid);
for(i = 0; i < tag[i1]->narea; i++) {
- if(i == tag[i1]->sel)
- snprintf(buf, sizeof(buf), "%s", "sel");
- else
- snprintf(buf, sizeof(buf), "%u", i);
+ snprintf(buf, sizeof(buf), "%u", i);
len += type2stat(&stat, buf, &m->qid);
if(len <= fcall->offset)
continue;
@@ -799,10 +798,7 @@ xread(IXPConn *c, Fcall *fcall)
}
/* offset found, proceeding */
for(; i < tag[i1]->narea; i++) {
- if(i == tag[i1]->sel)
- snprintf(buf, sizeof(buf), "%s", "sel");
- else
- snprintf(buf, sizeof(buf), "%u", i);
+ snprintf(buf, sizeof(buf), "%u", i);
len = type2stat(&stat, buf, &m->qid);
if(fcall->count + len > fcall->iounit)
break;
@@ -815,11 +811,10 @@ xread(IXPConn *c, Fcall *fcall)
len = type2stat(&stat, "ctl", &m->qid);
if(i2)
len += type2stat(&stat, "mode", &m->qid);
+ if(tag[i1]->area[i2]->nframe)
+ len += type2stat(&stat, "sel", &m->qid);
for(i = 0; i < tag[i1]->area[i2]->nframe; i++) {
- if(i == tag[i1]->area[i2]->sel)
- snprintf(buf, sizeof(buf), "%s", "sel");
- else
- snprintf(buf, sizeof(buf), "%u", i);
+ snprintf(buf, sizeof(buf), "%u", i);
len += type2stat(&stat, buf, &m->qid);
if(len <= fcall->offset)
continue;
@@ -827,10 +822,7 @@ xread(IXPConn *c, Fcall *fcall)
}
/* offset found, proceeding */
for(; i < tag[i1]->area[i2]->nframe; i++) {
- if(i == tag[i1]->area[i2]->sel)
- snprintf(buf, sizeof(buf), "%s", "sel");
- else
- snprintf(buf, sizeof(buf), "%u", i);
+ snprintf(buf, sizeof(buf), "%u", i);
len = type2stat(&stat, buf, &m->qid);
if(fcall->count + len > fcall->iounit)
break;
@@ -963,11 +955,12 @@ xread(IXPConn *c, Fcall *fcall)
p = ixp_enc_stat(p, &stat);
fcall->count += type2stat(&stat, "tag", &m->qid);
p = ixp_enc_stat(p, &stat);
+ if(tag[i1]->narea) {
+ fcall->count += type2stat(&stat, "sel", &m->qid);
+ p = ixp_enc_stat(p, &stat);
+ }
for(i = 0; i < tag[i1]->narea; i++) {
- if(i == tag[i1]->sel)
- snprintf(buf, sizeof(buf), "%s", "sel");
- else
- snprintf(buf, sizeof(buf), "%u", i);
+ snprintf(buf, sizeof(buf), "%u", i);
len = type2stat(&stat, buf, &m->qid);
if(fcall->count + len > fcall->iounit)
break;
@@ -978,14 +971,16 @@ xread(IXPConn *c, Fcall *fcall)
case FsDarea:
fcall->count = type2stat(&stat, "ctl", &m->qid);
p = ixp_enc_stat(p, &stat);
- if(i2)
+ if(i2) {
fcall->count += type2stat(&stat, "mode", &m->qid);
p = ixp_enc_stat(p, &stat);
+ }
+ if(tag[i1]->area[i2]->nframe) {
+ fcall->count += type2stat(&stat, "sel", &m->qid);
+ p = ixp_enc_stat(p, &stat);
+ }
for(i = 0; i < tag[i1]->area[i2]->nframe; i++) {
- if(i == tag[i1]->area[i2]->sel)
- snprintf(buf, sizeof(buf), "%s", "sel");
- else
- snprintf(buf, sizeof(buf), "%u", i);
+ snprintf(buf, sizeof(buf), "%u", i);
len = type2stat(&stat, buf, &m->qid);
if(fcall->count + len > fcall->iounit)
break;
diff --git a/cmd/wm/kb.c b/cmd/wm/kb.c
@@ -127,9 +127,11 @@ get_key(const char *name)
k->key = XKeysymToKeycode(dpy, XStringToKeysym(kstr));
k->mod = blitz_strtomod(seq[i]);
}
- r->id = id++;
- key = (Key **)cext_array_attach((void **)key, r, sizeof(Key *), &keysz);
- nkey++;
+ if(r) {
+ r->id = id++;
+ key = (Key **)cext_array_attach((void **)key, r, sizeof(Key *), &keysz);
+ nkey++;
+ }
return r;
}
@@ -258,6 +260,7 @@ handle_key(Window w, unsigned long mod, KeyCode keycode)
void
update_keys()
{
+ Key *k;
char *l, *p;
init_lock_modifiers();
@@ -270,15 +273,18 @@ update_keys()
for(l = p = def.keys; p && *p;) {
if(*p == '\n') {
*p = 0;
- grab_key(get_key(l));
+ if((k = get_key(l)))
+ grab_key(k);
*p = '\n';
l = ++p;
}
else
p++;
}
- if(l < p && strlen(l))
- grab_key(get_key(l));
+ if(l < p && strlen(l)) {
+ if((k = get_key(l)))
+ grab_key(k);
+ }
XSync(dpy, False);
}
diff --git a/cmd/wm/rule.c b/cmd/wm/rule.c
@@ -98,14 +98,14 @@ parse(char *data, unsigned int *n)
static void
-match(Rule *rule, unsigned int rulez, Client *c, const char *prop)
+match(Rule *rule, unsigned int rulesz, Client *c, const char *prop)
{
unsigned int i, j;
regex_t regex;
regmatch_t tmpregm;
c->ntag = 0;
- for(i = 0; i < rulez && c->ntag < MAX_TAGS; i++) {
+ for(i = 0; i < rulesz && c->ntag < MAX_TAGS; i++) {
Rule r = rule[i];
if(!regcomp(®ex, r.regex, 0)) {
if(!regexec(®ex, prop, 1, &tmpregm, 0)) {