commit d9e811ec0c9d0da2d345d9e2f3d73f9b4a883639
parent 4296b31b3c73e0db99f0fcc20e12289ec7d901ec
Author: Anselm R. Garbe <garbeam@wmii.de>
Date: Mon, 24 Apr 2006 17:39:58 +0200
finished scaling separation from arrange_* functions
Diffstat:
6 files changed, 45 insertions(+), 34 deletions(-)
diff --git a/TODO b/TODO
@@ -1,3 +1,2 @@
-- separate scaling stuff from arrange_{view,column} to scale_{view,column}
- FocusIn sets focus handling
- maximize stuff
diff --git a/cmd/wm/area.c b/cmd/wm/area.c
@@ -17,31 +17,34 @@ vector_of_areas(AreaVector *av)
Area *
create_area(View *v)
{
+ static unsigned short id = 1;
unsigned int w;
- if(v->area.size < 2)
- w = rect.width;
- else if(def.colw)
- w = def.colw;
+ Area *a = nil;
+
+ if(v->area.size > 1) {
+ if(def.colw)
+ w = def.colw;
+ else
+ w = rect.width / v->area.size - 1;
+ }
else
- w = rect.width / v->area.size;
+ w = rect.width;
+
if(v->area.size >= 2 && (v->area.size - 1) * MIN_COLWIDTH + w > rect.width)
return nil;
- else
- {
- static unsigned short id = 1;
- Area *a = cext_emallocz(sizeof(Area));
- a->view = v;
- a->id = id++;
- a->rect = rect;
- a->rect.height = rect.height - brect.height;
- a->mode = def.colmode;
- if(v->area.size > 1)
- w = rect.width / ((float)rect.width / w - 1);
- a->rect.width = w;
- cext_vattach(vector_of_areas(&v->area), a);
- v->sel = v->area.size - 1;
- return a;
- }
+
+ if(v->area.size > 1)
+ scale_view(v, rect.width - w);
+ a = cext_emallocz(sizeof(Area));
+ a->view = v;
+ a->id = id++;
+ a->rect = rect;
+ a->rect.height = rect.height - brect.height;
+ a->mode = def.colmode;
+ a->rect.width = w;
+ cext_vattach(vector_of_areas(&v->area), a);
+ v->sel = v->area.size - 1;
+ return a;
}
void
@@ -232,7 +235,6 @@ attach_to_area(Area *a, Client *c)
c->floating = !aidx;
if(aidx) {
h = a->rect.height / (a->frame.size + 1);
- fprintf(stderr, "attach height=%d\n", h);
if(a->frame.size)
scale_column(a, a->rect.height - h);
}
diff --git a/cmd/wm/client.c b/cmd/wm/client.c
@@ -28,7 +28,7 @@ update_client_name(Client *c)
if(name.value && name.nitems && name.encoding == UTF8_STRING && name.format == 8) {
int n;
char **list = nil;
- if(Xutf8TextPropertyToTextList(dpy, &name, &list, &n) == Success
+ if(XmbTextPropertyToTextList(dpy, &name, &list, &n) == Success
&& n > 0 && *list)
{
cext_strlcpy(c->name, *list, sizeof(c->name));
diff --git a/cmd/wm/column.c b/cmd/wm/column.c
@@ -112,17 +112,13 @@ scale_column(Area *a, float h)
if(!a->frame.size)
return;
- fprintf(stderr, " >>> scale column h=%f\n", h);
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];
- fprintf(stderr, "old height: %d, ", f->rect.height);
f->rect.height *= scale;
- fprintf(stderr, "new height: %d\n", f->rect.height);
}
- fprintf(stderr, "%s", " <<< scale column\n");
}
void
diff --git a/cmd/wm/view.c b/cmd/wm/view.c
@@ -276,25 +276,38 @@ restack_view(View *v)
}
void
+scale_view(View *v, float w)
+{
+ unsigned int i;
+ float scale, dx = 0;
+
+ if(v->area.size == 1)
+ return;
+
+ for(i = 1; i < v->area.size; i++)
+ dx += v->area.data[i]->rect.width;
+ scale = w / dx;
+ for(i = 1; i < v->area.size; i++) {
+ Area *a = v->area.data[i];
+ a->rect.width *= scale;
+ }
+}
+
+void
arrange_view(View *v)
{
unsigned int i, xoff = 0;
- unsigned int dx = 0;
int wdiff = 0;
- float scale = 1.0;
if(v->area.size == 1)
return;
- for(i = 1; i < v->area.size; i++)
- dx += v->area.data[i]->rect.width;
- scale = (float)rect.width / (float)dx;
+ scale_view(v, rect.width);
for(i = 1; i < v->area.size; i++) {
Area *a = v->area.data[i];
a->rect.x = xoff;
a->rect.y = 0;
a->rect.height = rect.height - brect.height;
- a->rect.width *= scale;
if(a->rect.width < MIN_COLWIDTH)
a->rect.width = MIN_COLWIDTH;
else if((wdiff = a->rect.x + a->rect.width - rect.width + (v->area.size - 1 - i) * MIN_COLWIDTH) > 0)
diff --git a/cmd/wm/wm.h b/cmd/wm/wm.h
@@ -286,6 +286,7 @@ Bool permit_tags(const char *tags);
/* view.c */
void arrange_view(View *v);
+void scale_view(View *v, float w);
View *create_view(char *name);
void focus_view(View *v);
XRectangle *rects_of_view(View *v, Bool isfloat, unsigned int *num);