applied Kris' idea to drop .0 suffixes in WMII_ADDRESS, removed internal labels, introduced several *Tag events, needs polishing

This commit is contained in:
Anselm R. Garbe 2006-06-06 21:10:30 +02:00
parent 67c8bc998a
commit 83f184dad7
7 changed files with 31 additions and 57 deletions

View File

@ -12,9 +12,6 @@
(stacked) client is made visible. So, when the fifth client is focused
and made visible, the third would disappear (with n=2) -- this means on
boundaries, like in mutt(1).
- remove internal labels, now tagging seems easy and straightforward that they
THINK: We'll need CreateTag, DestroyTag, UnfocusTag, FocusTag and the
event loop in wmiirc must be before TAGGING can be externalized again
- liblitz: window abstraction (creation, events), can be reused in menu and bar
and frames
- tagbars and grab-boxes (like in acme)

View File

@ -13,10 +13,6 @@ comp_bar(const void *b1, const void *b2)
{
Bar *bb1 = *(Bar **)b1;
Bar *bb2 = *(Bar **)b2;
if(bb1->intern && !bb2->intern)
return -1;
if(!bb1->intern && bb2->intern)
return 1;
return strcmp(bb1->name, bb2->name);
}
@ -36,7 +32,6 @@ create_bar(char *name, Bool intern)
return b;
b = cext_emallocz(sizeof(Bar));
b->id = id++;
b->intern = intern;
cext_strlcpy(b->name, name, sizeof(b->name));
cext_strlcpy(b->colstr, def.selcolor, sizeof(b->colstr));
b->color = def.sel;
@ -90,7 +85,6 @@ void
draw_bar()
{
unsigned int i = 0, w = 0;
int exp = -1;
BlitzDraw d = { 0 };
Bar *b = nil;
@ -109,12 +103,6 @@ draw_bar()
for(i = 0; (i < bar.size) && (w < brect.width); i++) {
b = bar.data[i];
if(b->intern) {
if(view.size && !strncmp(b->name, view.data[sel]->name, sizeof(b->name)))
b->color = def.sel;
else
b->color = def.norm;
}
b->rect.x = 0;
b->rect.y = 0;
b->rect.width = brect.height;
@ -133,11 +121,7 @@ draw_bar()
}
}
else { /* expand bar properly */
for(exp = 0; (exp < bar.size) && (bar.data[exp]->intern); exp++);
if(exp == bar.size)
exp = -1;
else
bar.data[exp]->rect.width += (brect.width - w);
bar.data[bar.size - 1]->rect.width += (brect.width - w);
for(i = 1; i < bar.size; i++)
bar.data[i]->rect.x = bar.data[i - 1]->rect.x + bar.data[i - 1]->rect.width;
}
@ -147,7 +131,7 @@ draw_bar()
d.color = b->color;
d.rect = b->rect;
d.data = b->data;
if(i == exp)
if(i == bar.size - 1)
d.align = EAST;
else
d.align = CENTER;
@ -191,29 +175,3 @@ bar_of_name(const char *name)
return bar.data[i];
return nil;
}
static Bar *
next_unused_bar()
{
unsigned int i;
for(i = 0; (i < bar.size) && bar.data[i]->intern; i++)
if(!view_of_name(bar.data[i]->name))
return bar.data[i];
return nil;
}
void
update_view_bars()
{
unsigned int i;
Bar *b = nil;
while((b = next_unused_bar()))
destroy_bar(b);
for(i = 0; i < view.size; i++) {
b = create_bar(view.data[i]->name, True);
cext_strlcpy(b->data, view.data[i]->name, sizeof(b->data));
}
draw_bar();
}

View File

@ -776,9 +776,6 @@ xremove(IXPConn *c, Fcall *fcall)
case FsDbar:
{
Bar *b = bar.data[i1];
if(b->intern)
return Enoperm;
/* now detach the bar */
destroy_bar(b);
draw_bar();
}

View File

@ -26,6 +26,7 @@ View *
create_view(const char *name)
{
static unsigned short id = 1;
static char buf[256];
View *v = cext_emallocz(sizeof(View));
v->id = id++;
@ -34,18 +35,23 @@ create_view(const char *name)
create_area(v, v->area.size, 0);
cext_vattach(vector_of_views(&view), v);
qsort(view.data, view.size, sizeof(View *), comp_view_name);
snprintf(buf, sizeof(buf), "CreateTag %s\n", name);
write_event(buf);
return v;
}
void
destroy_view(View *v)
{
static char buf[256];
while(v->area.size)
destroy_area(v->area.data[0]);
cext_vdetach(vector_of_views(&view), v);
if(sel >= view.size)
sel = 0;
snprintf(buf, sizeof(buf), "DestroyTag %s\n", v->name);
write_event(buf);
free(v);
}
@ -81,8 +87,14 @@ focus_view(View *v)
{
Client *c;
unsigned int i;
static char buf[256];
XGrabServer(dpy);
if(sel < view.size) {
snprintf(buf, sizeof(buf), "UnfocusTag %s\n", view.data[sel]->name);
write_event(buf);
}
sel = idx_of_view(v);
update_frame_selectors(v);
@ -102,10 +114,11 @@ focus_view(View *v)
if((c = sel_client_of_view(v)))
focus_client(c, True);
draw_clients();
update_view_bars();
XSync(dpy, False);
XUngrabServer(dpy);
flush_masked_events(EnterWindowMask);
snprintf(buf, sizeof(buf), "FocusTag %s\n", v->name);
write_event(buf);
}
XRectangle *
@ -163,7 +176,7 @@ select_view(const char *arg)
cext_trim(buf, " \t+");
if(!strlen(buf))
return;
sel = idx_of_view(get_view(arg));
focus_view(get_view(arg));
update_views(); /* performs focus_view */
}
@ -385,8 +398,6 @@ update_views()
focus_view(old);
else if(view.size)
focus_view(view.data[sel]);
else
update_view_bars();
}
unsigned int

View File

@ -147,7 +147,6 @@ typedef struct {
char colstr[24];
BlitzColor color;
XRectangle rect;
Bool intern;
} Bar;
/* default values */
@ -231,7 +230,6 @@ void resize_bar();
unsigned int height_of_bar();
Bar *bar_of_name(const char *name);
int idx_of_bar(Bar *b);
void update_view_bars();
/* client.c */
Client *create_client(Window w, XWindowAttributes *wa);

View File

@ -5,7 +5,7 @@ wmiiwm -c || exit 1
OLD_PATH="$PATH" export OLD_PATH
PATH="$HOME/.wmii-4:CONFPREFIX/wmii-4:$PATH" export PATH
WMII_ADDRESS=unix!/tmp/ns.$USER.$DISPLAY/wmii export WMII_ADDRESS
WMII_ADDRESS=unix!/tmp/ns.$USER.${DISPLAY%.0}/wmii export WMII_ADDRESS
mkdir -m 700 /tmp/ns.$USER.$DISPLAY 2>/dev/null
wmiiwm -a $WMII_ADDRESS &

View File

@ -117,6 +117,19 @@ do
rm -f $PROGS_FILE
exit
fi;;
CreateTag)
wmiir create /bar/$1
xwrite /bar/$1/data $1
;;
DestroyTag)
wmiir remove /bar/$1
;;
FocusTag)
xwrite /bar/$1/name $WMII_SELCOLORS
;;
UnfocusTag)
xwrite /bar/$1/name $WMII_NORMCOLORS
;;
BarClick)
xwrite /ctl view "$1";;
Key)