wmii

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

commit 01db208f43df3a1c7d2ab1ef9a2c0771cdc94c05
parent 970e0d1fe535e4dc11cb1aa6a64f80676b5fa39c
Author: Anselm R. Garbe <garbeam@wmii.de>
Date:   Mon, 24 Apr 2006 16:03:37 +0200

changed UTF8 stuff somewhat


Diffstat:
cmd/wm/area.c | 16+++++++++++-----
cmd/wm/client.c | 34+++++++++++++++-------------------
cmd/wm/column.c | 55+++++++++++++++++++++++++++++++++----------------------
cmd/wm/wm.c | 2++
cmd/wm/wm.h | 2++
5 files changed, 63 insertions(+), 46 deletions(-)

diff --git a/cmd/wm/area.c b/cmd/wm/area.c @@ -226,15 +226,21 @@ place_client(Area *a, Client *c) void attach_to_area(Area *a, Client *c) { - unsigned int aidx = idx_of_area(a); - Frame *f = create_frame(a, c); + unsigned int h = 0, aidx = idx_of_area(a); + Frame *f; c->floating = !aidx; - if(aidx) { /* column */ + if(aidx && a->frame.size) { + h = a->rect.height / a->frame.size; if(a->frame.size > 1) - f->rect.height = a->rect.height / (a->frame.size - 1); - arrange_column(a, False); + scale_column(a, a->rect.height - h); } + + f = create_frame(a, c); + f->rect.height = h; + + if(aidx) /* column */ + arrange_column(a, False); else { /* floating */ place_client(a, c); resize_client(c, &f->rect, False); diff --git a/cmd/wm/client.c b/cmd/wm/client.c @@ -22,29 +22,25 @@ static void update_client_name(Client *c) { XTextProperty name; + + c->name[0] = 0; XGetTextProperty(dpy, c->win, &name, net_atom[NetWMName]); - if(!name.value || !name.nitems) - XGetTextProperty(dpy, c->win, &name, XA_WM_NAME); - if(name.value && name.nitems) { - if(name.encoding == XA_STRING) - cext_strlcpy(c->name, (char *)name.value, sizeof(c->name)); - else { - int n; - char **list = nil; - name.nitems = strlen((char *)name.value); - if(Xutf8TextPropertyToTextList(dpy, &name, &list, &n) == Success - && n > 0 && *list) - { - cext_strlcpy(c->name, *list, sizeof(c->name)); - XFreeStringList(list); - } - else - c->name[0] = 0; + if(name.value && name.nitems && name.encoding == UTF8_STRING && name.format == 8) { + int n; + char **list = nil; + if(Xutf8TextPropertyToTextList(dpy, &name, &list, &n) == Success + && n > 0 && *list) + { + cext_strlcpy(c->name, *list, sizeof(c->name)); + XFreeStringList(list); } XFree(name.value); + return; + } + if(XGetWMName(dpy, c->win, &name) && name.value) { + cext_strlcpy(c->name, (char *)name.value, sizeof(c->name)); + XFree(name.value); } - else - c->name[0] = 0; } Client * diff --git a/cmd/wm/column.c b/cmd/wm/column.c @@ -104,12 +104,40 @@ relax_column(Area *a) } void -arrange_column(Area *a, Bool dirty) +scale_column(Area *a, float h) { - unsigned int i, yoff = a->rect.y, h, dy = 0; - float scale = 1.0; + unsigned int i, yoff = a->rect.y; unsigned int min_height = 2 * height_of_bar(); int hdiff = 0; + float scale, dy = 0; + + if(!a->frame.size) + return; + + for(i = 0; i < a->frame.size; i++) + dy += a->frame.data[i]->rect.height; + scale = h / dy; + for(i = 0; i < a->frame.size; i++) { + Frame *f = a->frame.data[i]; + f->rect.x = a->rect.x; + f->rect.y = yoff; + f->rect.width = a->rect.width; + f->rect.height *= scale; + if(f->rect.height < min_height) + f->rect.height = min_height; + else if((hdiff = yoff + f->rect.height - h + (a->frame.size - i) * min_height) > 0) + f->rect.height -= hdiff; + if(i == a->frame.size - 1) + f->rect.height = a->rect.height - yoff; + yoff += f->rect.height; + resize_client(f->client, &f->rect, True); + } +} + +void +arrange_column(Area *a, Bool dirty) +{ + unsigned int i, yoff = a->rect.y, h; if(!a->frame.size) return; @@ -117,30 +145,13 @@ arrange_column(Area *a, Bool dirty) switch(a->mode) { case Coldefault: h = a->rect.height / a->frame.size; - if(h < (2 * height_of_bar())) + if(h < 2 * height_of_bar()) /* min height */ goto Fallthrough; if(dirty) { for(i = 0; i < a->frame.size; i++) a->frame.data[i]->rect.height = h; } - for(i = 0; i < a->frame.size; i++) - dy += a->frame.data[i]->rect.height; - scale = (float)a->rect.height / (float)dy; - for(i = 0; i < a->frame.size; i++) { - Frame *f = a->frame.data[i]; - f->rect.x = a->rect.x; - f->rect.y = yoff; - f->rect.width = a->rect.width; - f->rect.height *= scale; - if(f->rect.height < min_height) - f->rect.height = min_height; - else if((hdiff = f->rect.y + f->rect.height - a->rect.height + (a->frame.size - i) * min_height) > 0) - f->rect.height -= hdiff; - if(i == a->frame.size - 1) - f->rect.height = a->rect.height - f->rect.y + a->rect.y; - yoff += f->rect.height; - resize_client(f->client, &f->rect, True); - } + scale_column(a, a->rect.height); break; case Colstack: h = a->rect.height - (a->frame.size - 1) * height_of_bar(); diff --git a/cmd/wm/wm.c b/cmd/wm/wm.c @@ -127,6 +127,8 @@ init_atoms() XChangeProperty(dpy, root, net_atom[NetSupported], XA_ATOM, 32, PropModeReplace, (unsigned char *)net_atom, NetLast); + + UTF8_STRING = XInternAtom(dpy, "UTF8_STRING", False); } static void diff --git a/cmd/wm/wm.h b/cmd/wm/wm.h @@ -190,6 +190,7 @@ Qid root_qid; Default def; Atom wm_atom[WMLast]; Atom net_atom[NetLast]; +Atom UTF8_STRING; Cursor cursor[CurLast]; unsigned int valid_mask; unsigned int num_lock_mask; @@ -242,6 +243,7 @@ void draw_clients(); /* column.c */ void arrange_column(Area *a, Bool dirty); +void scale_column(Area *a, float h); void resize_column(Client *c, XRectangle *r, XPoint *pt); int column_mode_of_str(char *arg); char *str_of_column_mode(int mode);