wmii

git clone git://oldgit.suckless.org/wmii/
Log | Files | Refs | README | LICENSE

commit 83f184dad7ee80648b302096d302eaa92b7cdee9
parent 67c8bc998a69c7e00624aed502337d841308f2fd
Author: Anselm R. Garbe <garbeam@wmii.de>
Date:   Tue,  6 Jun 2006 21:10:30 +0200

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


Diffstat:
TODO.wmii-4 | 3---
cmd/wm/bar.c | 46++--------------------------------------------
cmd/wm/fs.c | 3---
cmd/wm/view.c | 19+++++++++++++++----
cmd/wm/wm.h | 2--
cmd/wm/wmii | 2+-
rc/wmiirc | 13+++++++++++++
7 files changed, 31 insertions(+), 57 deletions(-)

diff --git a/TODO.wmii-4 b/TODO.wmii-4 @@ -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) diff --git a/cmd/wm/bar.c b/cmd/wm/bar.c @@ -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(); -} diff --git a/cmd/wm/fs.c b/cmd/wm/fs.c @@ -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(); } diff --git a/cmd/wm/view.c b/cmd/wm/view.c @@ -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 diff --git a/cmd/wm/wm.h b/cmd/wm/wm.h @@ -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); diff --git a/cmd/wm/wmii b/cmd/wm/wmii @@ -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 & diff --git a/rc/wmiirc b/rc/wmiirc @@ -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)