commit 80bde63776b80e6454984c0f58100c638f55816f
parent 9bc3e63b9a80086090864a65ef52bf4886fa8847
Author: Anselm R. Garbe <garbeam@wmii.de>
Date: Thu, 23 Mar 2006 20:48:26 +0100
moving the view label stuff from wmiirc to wmiiwm (removed expand), merging with available tags and click handling will follow
Diffstat:
7 files changed, 35 insertions(+), 82 deletions(-)
diff --git a/cmd/wm/bar.c b/cmd/wm/bar.c
@@ -29,7 +29,8 @@ get_label(char *name)
cext_strlcpy(l->name, name, sizeof(l->name));
cext_strlcpy(l->colstr, def.selcolor, sizeof(l->colstr));
l->color = def.sel;
- label = (Label **)cext_array_attach((void **)label, l, sizeof(Label *), &labelsz);
+ label = (Label **)cext_array_attach((void **)label, l,
+ sizeof(Label *), &labelsz);
nlabel++;
qsort(label, nlabel, sizeof(Label *), comp_label);
@@ -79,51 +80,64 @@ update_bar_geometry()
void
draw_bar()
{
- unsigned int i, iexp = 0;
- unsigned int w = 0;
- Label *exp = name2label(expand);
+ unsigned int i = 0;
+ unsigned int x = 0, w = 0;
+ char name[256];
Draw d = { 0 };
- if(exp)
- iexp = label2index(exp);
-
d.align = WEST;
d.gc = bargc;
d.drawable = barpmap;
d.rect = brect;
- d.rect.y = 0;
+ d.rect.x = d.rect.y = 0;
d.font = xfont;
- if(!nlabel) { /* /default only */
- d.color = def.sel;
- blitz_drawlabel(dpy, &d);
- blitz_drawborder(dpy, &d);
+ d.color = def.norm;
+ blitz_drawlabel(dpy, &d);
+ blitz_drawborder(dpy, &d);
+ if(ntag) {
+ for(i = 0; i < nview; i++) {
+ View *v = view[i];
+ tags2str(name, sizeof(name), v->tag, v->ntag);
+ d.data = name;
+ if(i == sel)
+ d.color = def.sel;
+ else
+ d.color = def.norm;
+ d.rect.x = x;
+ d.rect.width = brect.height;
+ if(strlen(name))
+ d.rect.width += XTextWidth(xfont, name, strlen(name));
+ blitz_drawlabel(dpy, &d);
+ blitz_drawborder(dpy, &d);
+ x += d.rect.width;
+ }
}
- else {
+
+ if(nlabel) {
for(i = 0; i < nlabel; i++) {
Label *l = label[i];
- l->rect.x = l->rect.y = 0;
+ l->rect.x = x;
+ l->rect.y = 0;
l->rect.height = brect.height;
- if(i == iexp)
- continue;
l->rect.width = brect.height;
if(strlen(l->data))
l->rect.width += XTextWidth(xfont, l->data, strlen(l->data));
w += l->rect.width;
}
- if(w >= brect.width) {
+ if(w >= brect.width - x) {
/* failsafe mode, give all labels same width */
- w = brect.width / nlabel;
+ w = (brect.width - x) / nlabel;
for(i = 0; i < nlabel; i++) {
- label[i]->rect.x = i * w;
+ label[i]->rect.x = x + i * w;
label[i]->rect.width = w;
}
i--;
label[i]->rect.width = brect.width - label[i]->rect.x;
}
else {
- label[iexp]->rect.width = brect.width - w;
+ label[0]->rect.x = brect.width - w;
for(i = 1; i < nlabel; i++)
label[i]->rect.x = label[i - 1]->rect.x + label[i - 1]->rect.width;
}
diff --git a/cmd/wm/fs.c b/cmd/wm/fs.c
@@ -41,7 +41,6 @@ static char Ebadvalue[] = "bad value";
* /def/keys FsFkeys keys
* /tags FsFtags
* /bar/ FsDbar
- * /bar/expand FsFexpand id of expandable label
* /bar/lab/ FsDlabel
* /bar/lab/data FsFdata <arbitrary data which gets displayed>
* /bar/lab/colors FsFcolors <#RRGGBB> <#RRGGBB> <#RRGGBB>
@@ -191,11 +190,6 @@ qid2name(Qid *qid)
return nil;
return "data";
break;
- case FsFexpand:
- if(i1 == -1)
- return nil;
- return "expand";
- break;
case FsFctl: return "ctl"; break;
case FsFborder: return "border"; break;
case FsFgeom:
@@ -261,8 +255,6 @@ name2type(char *name, unsigned char dir_type)
return FsFborder;
if(!strncmp(name, "geom", 5))
return FsFgeom;
- if(!strncmp(name, "expand", 7))
- return FsFexpand;
if(!strncmp(name, "colors", 7))
return FsFcolors;
if(!strncmp(name, "selcolors", 10))
@@ -413,11 +405,6 @@ mkqid(Qid *dir, char *wname, Qid *new)
return -1;
goto Mkfile;
break;
- case FsFexpand:
- if(dir_type != FsDbar)
- return -1;
- goto Mkfile;
- break;
case FsFborder:
case FsFfont:
case FsFrules:
@@ -546,9 +533,6 @@ type2stat(Stat *stat, char *wname, Qid *dir)
if(dir_type == FsDview)
return mkstat(stat, dir, wname, strlen(def.tag), DMREAD);
break;
- case FsFexpand:
- return mkstat(stat, dir, wname, strlen(expand), DMREAD | DMWRITE);
- break;
case FsFdata:
return mkstat(stat, dir, wname, (dir_i1 == nlabel) ? 0 : strlen(label[dir_i1]->data), DMREAD | DMWRITE);
break;
@@ -651,8 +635,6 @@ xcreate(IXPConn *c, Fcall *fcall)
type = qpath_type(m->qid.path);
switch(type) {
case FsDbar:
- if(!strncmp(fcall->name, "expand", 7))
- return "illegal file name";
get_label(fcall->name);
break;
default:
@@ -761,7 +743,6 @@ xread(IXPConn *c, Fcall *fcall)
break;
case FsDbar:
/* jump to offset */
- len = type2stat(&stat, "expand", &m->qid);
for(i = 0; i < nlabel; i++) {
len += type2stat(&stat, label[i]->name, &m->qid);
if(len <= fcall->offset)
@@ -916,8 +897,6 @@ xread(IXPConn *c, Fcall *fcall)
}
break;
case FsDbar:
- fcall->count = type2stat(&stat, "expand", &m->qid);
- p = ixp_enc_stat(p, &stat);
for(i = 0; i < nlabel; i++) {
len = type2stat(&stat, label[i]->name, &m->qid);
if(fcall->count + len > fcall->iounit)
@@ -1075,10 +1054,6 @@ xread(IXPConn *c, Fcall *fcall)
break;
}
break;
- case FsFexpand:
- fcall->count = strlen(expand);
- memcpy(p, expand, fcall->count);
- break;
case FsFdata:
if(i1 >= nlabel)
return Enofile;
@@ -1268,11 +1243,6 @@ xwrite(IXPConn *c, Fcall *fcall)
resize_client(f->client, &f->rect, False);
}
break;
- case FsFexpand:
- memcpy(expand, fcall->data, fcall->count);
- expand[fcall->count] = 0;
- draw_bar();
- break;
case FsFdata:
len = fcall->count;
if(len >= sizeof(label[i1]->data))
diff --git a/cmd/wm/tag.c b/cmd/wm/tag.c
@@ -48,8 +48,6 @@ void
update_tags()
{
unsigned int i, j;
- char buf[1024];
-
for(i = 0; i < ntag; i++) {
free(tag[i]);
tag[i] = nil;
@@ -68,15 +66,6 @@ update_tags()
}
}
- cext_strlcpy(buf, "UpdateTags ", sizeof(buf));
- for(i = 0; i < ntag; i++) {
- cext_strlcat(buf, tag[i], sizeof(buf) - strlen(buf));
- if(i + 1 < ntag)
- cext_strlcat(buf, "+", sizeof(buf) - strlen(buf));
- }
- cext_strlcat(buf, "\n", sizeof(buf) - strlen(buf));
- write_event(buf);
-
for(i = 0; nview && (i < nclient); i++) {
for(j = 0; j < nview; j++) {
View *v = view[j];
diff --git a/cmd/wm/view.c b/cmd/wm/view.c
@@ -63,8 +63,6 @@ update_frame_selectors(View *v)
void
focus_view(View *v)
{
- char buf[256];
- char name[256];
unsigned int i;
if(!nview)
@@ -89,9 +87,7 @@ focus_view(View *v)
XMoveWindow(dpy, client[i]->framewin,
2 * rect.width + f->rect.x, f->rect.y);
}
- tags2str(name, sizeof(name), v->tag, v->ntag);
- snprintf(buf, sizeof(buf), "FocusTag %s\n", name);
- write_event(buf);
+ draw_bar();
XSync(dpy, False);
XUngrabServer(dpy);
}
diff --git a/cmd/wm/wm.c b/cmd/wm/wm.c
@@ -300,7 +300,6 @@ main(int argc, char *argv[])
tag = nil;
client = nil;
- expand[0] = 0;
key = nil;
keysz = nkey = 0;
label = nil;
diff --git a/cmd/wm/wm.h b/cmd/wm/wm.h
@@ -44,7 +44,6 @@ enum {
FsDGclient,
FsDbar,
FsDlabel,
- FsFexpand,
FsFdata,
FsFcolors,
FsFfont,
@@ -172,7 +171,6 @@ unsigned int nkey;
Label **label;
unsigned int nlabel;
unsigned int labelsz;
-char expand[256];
char **tag;
unsigned int ntag;
unsigned int tagsz;
diff --git a/rc/wmiirc b/rc/wmiirc
@@ -35,15 +35,6 @@ wmiir write /def/rules <<EOF
/Gimp.*:.*/ -> ~
EOF
-# BAR CONFIGURATION
-wmiir create /bar/0tag
-xwrite /bar/0tag/colors $WMII_SELCOLORS
-wmiir create /bar/0tags
-xwrite /bar/0tags/colors $WMII_NORMCOLORS
-wmiir create /bar/spare
-xwrite /bar/spare/colors $WMII_SELCOLORS
-xwrite /bar/expand spare
-
# MISC
xsetroot -solid '#0b1014'
status &
@@ -104,10 +95,6 @@ do
then
exit
fi;;
- FocusTag)
- xwrite /bar/0tag/data $1;;
- UpdateTags)
- xwrite /bar/0tags/data $1;;
Key)
case "$1" in
$MODKEY-Control-c)