commit 67cac9a10e4640288a3b18f86f6b424f007f9f06
parent c243337350a0b9d77f234c2b14c2e890c436d288
Author: Anselm R. Garbe <garbeam@wmii.de>
Date: Sun, 5 Mar 2006 01:55:45 +0100
added Frame redirection to allow arbitrary tag references to clients
Diffstat:
8 files changed, 246 insertions(+), 226 deletions(-)
diff --git a/cmd/wm/area.c b/cmd/wm/area.c
@@ -34,10 +34,10 @@ void
destroy_area(Area *a)
{
Tag *t = a->tag;
- if(a->nclient)
+ if(a->nframe)
return;
- if(a->client)
- free(a->client);
+ if(a->frame)
+ free(a->frame);
cext_array_detach((void **)t->area, a, &t->areasz);
t->narea--;
if(t->sel == t->narea) {
@@ -96,8 +96,8 @@ select_area(Area *a, char *arg)
return;
}
new = t->area[i];
- if(new->nclient)
- focus_client(new->client[new->sel]);
+ if(new->nframe)
+ focus_client(new->frame[new->sel]->client);
t->sel = i;
fprintf(stderr, "select_area: t->sel == %d\n", t->sel);
}
@@ -113,24 +113,36 @@ send_toarea(Area *to, Client *c)
void
attach_toarea(Area *a, Client *c)
{
- a->client = (Client **)cext_array_attach(
- (void **)a->client, c, sizeof(Client *), &a->clientsz);
- a->nclient++;
- c->area = a;
+ static unsigned short id = 1;
+ Frame *f = cext_emallocz(sizeof(Frame));
+
+ f->id = id++;
+ f->area = a;
+ f->client = c;
+ f->rect = c->rect;
+ f->rect.width += 2 * def.border;
+ f->rect.height += def.border + bar_height();
+ c->frame = f;
+ a->frame = (Frame **)cext_array_attach(
+ (void **)a->frame, f, sizeof(Frame *), &a->framesz);
+ a->nframe++;
if(area2index(a)) /* column */
arrange_area(a);
else /* floating */
- resize_client(c, &c->frect, nil, False);
+ resize_client(c, &f->rect, nil, False);
}
void
detach_fromarea(Client *c)
{
- Area *a = c->area;
- cext_array_detach((void **)a->client, c, &a->clientsz);
- a->nclient--;
- if(a->nclient) {
- if(a->sel >= a->nclient)
+ Frame *f = c->frame;
+ Area *a = f->area;
+ cext_array_detach((void **)a->frame, f, &a->framesz);
+ free(f);
+ a->nframe--;
+ c->frame = nil;
+ if(a->nframe) {
+ if(a->sel >= a->nframe)
a->sel = 0;
arrange_area(a);
}
@@ -170,41 +182,41 @@ relax_area(Area *a)
{
unsigned int i, yoff, h, hdiff;
- if(!a->nclient)
+ if(!a->nframe)
return;
/* some relaxing from potential increment gaps */
h = 0;
- for(i = 0; i < a->nclient; i++) {
- Client *c = a->client[i];
+ for(i = 0; i < a->nframe; i++) {
+ Frame *f = a->frame[i];
if(a->mode == Colmax) {
- if(h < c->frect.height)
- h = c->frect.height;
+ if(h < f->rect.height)
+ h = f->rect.height;
}
else
- h += c->frect.height;
+ h += f->rect.height;
}
/* try to add rest space to all clients if not COL_STACK mode */
if(a->mode != Colstack) {
- for(i = 0; (h < a->rect.height) && (i < a->nclient); i++) {
- Client *c = a->client[i];
- unsigned int tmp = c->frect.height;
- c->frect.height += (a->rect.height - h);
- resize_client(c, &c->frect, 0, True);
- h += (c->frect.height - tmp);
+ for(i = 0; (h < a->rect.height) && (i < a->nframe); i++) {
+ Frame *f = a->frame[i];
+ unsigned int tmp = f->rect.height;
+ f->rect.height += (a->rect.height - h);
+ resize_client(f->client, &f->rect, 0, True);
+ h += (f->rect.height - tmp);
}
}
- hdiff = (a->rect.height - h) / a->nclient;
+ hdiff = (a->rect.height - h) / a->nframe;
yoff = a->rect.y + hdiff / 2;
- for(i = 0; i < a->nclient; i++) {
- Client *c = a->client[i];
- c->frect.x = a->rect.x + (a->rect.width - c->frect.width) / 2;
- c->frect.y = yoff;
+ for(i = 0; i < a->nframe; i++) {
+ Frame *f = a->frame[i];
+ f->rect.x = a->rect.x + (a->rect.width - f->rect.width) / 2;
+ f->rect.y = yoff;
if(a->mode != Colmax)
- yoff = c->frect.y + c->frect.height + hdiff;
- resize_client(c, &c->frect, 0, False);
+ yoff = f->rect.y + f->rect.height + hdiff;
+ resize_client(f->client, &f->rect, 0, False);
}
}
@@ -213,45 +225,45 @@ arrange_area(Area *a)
{
unsigned int i, yoff, h;
- if(!a->nclient)
+ if(!a->nframe)
return;
switch(a->mode) {
case Colequal:
h = a->rect.height;
- h /= a->nclient;
- for(i = 0; i < a->nclient; i++) {
- Client *c = a->client[i];
- c->frect = a->rect;
- c->frect.y += i * h;
- if(i + 1 < a->nclient)
- c->frect.height = h;
+ h /= a->nframe;
+ for(i = 0; i < a->nframe; i++) {
+ Frame *f = a->frame[i];
+ f->rect = a->rect;
+ f->rect.y += i * h;
+ if(i + 1 < a->nframe)
+ f->rect.height = h;
else
- c->frect.height =
- a->rect.height - c->frect.y + a->rect.y;
- resize_client(c, &c->frect, 0, True);
+ f->rect.height =
+ a->rect.height - f->rect.y + a->rect.y;
+ resize_client(f->client, &f->rect, 0, True);
}
break;
case Colstack:
yoff = a->rect.y;
- h = a->rect.height - (a->nclient - 1) * bar_height();
- for(i = 0; i < a->nclient; i++) {
- Client *c = a->client[i];
- c->frect = a->rect;
- c->frect.y = yoff;
+ h = a->rect.height - (a->nframe - 1) * bar_height();
+ for(i = 0; i < a->nframe; i++) {
+ Frame *f = a->frame[i];
+ f->rect = a->rect;
+ f->rect.y = yoff;
if(i == a->sel)
- c->frect.height = h;
+ f->rect.height = h;
else
- c->frect.height = bar_height();
- yoff += c->frect.height;
- resize_client(c, &c->frect, 0, True);
+ f->rect.height = bar_height();
+ yoff += f->rect.height;
+ resize_client(f->client, &f->rect, 0, True);
}
break;
case Colmax:
- for(i = 0; i < a->nclient; i++) {
- Client *c = a->client[i];
- c->frect = a->rect;
- resize_client(c, &c->frect, 0, True);
+ for(i = 0; i < a->nframe; i++) {
+ Frame *f = a->frame[i];
+ f->rect = a->rect;
+ resize_client(f->client, &f->rect, 0, True);
}
break;
default:
@@ -287,20 +299,20 @@ match_horiz(Area *a, XRectangle *r)
{
unsigned int i;
- for(i = 0; i < a->nclient; i++) {
- Client *c = a->client[i];
- c->frect.x = r->x;
- c->frect.width = r->width;
- resize_client(c, &c->frect, nil, False);
+ for(i = 0; i < a->nframe; i++) {
+ Frame *f = a->frame[i];
+ f->rect.x = r->x;
+ f->rect.width = r->width;
+ resize_client(f->client, &f->rect, nil, False);
}
}
static void
-drop_resize(Client *c, XRectangle *new)
+drop_resize(Frame *f, XRectangle *new)
{
- Area *west = nil, *east = nil, *a = c->area;
+ Area *west = nil, *east = nil, *a = f->area;
Tag *t = a->tag;
- Client *north = nil, *south = nil;
+ Frame *north = nil, *south = nil;
unsigned int i;
for(i = 1; (i < t->narea) && (t->area[i] != a); i++);
@@ -308,20 +320,20 @@ drop_resize(Client *c, XRectangle *new)
west = (i > 1) ? t->area[i - 1] : nil;
east = i + 1 < t->narea ? t->area[i + 1] : nil;
- for(i = 1; (i < a->nclient) && (a->client[i] != c); i++);
- north = i ? a->client[i - 1] : nil;
- south = i + 1 < a->nclient ? a->client[i + 1] : nil;
+ for(i = 1; (i < a->nframe) && (a->frame[i] != f); i++);
+ north = i ? a->frame[i - 1] : nil;
+ south = i + 1 < a->nframe ? a->frame[i + 1] : nil;
/* horizontal resize */
- if(west && (new->x != c->frect.x)) {
+ if(west && (new->x != f->rect.x)) {
west->rect.width = new->x - west->rect.x;
- a->rect.width += c->frect.x - new->x;
+ a->rect.width += f->rect.x - new->x;
a->rect.x = new->x;
match_horiz(west, &west->rect);
match_horiz(a, &a->rect);
relax_area(west);
}
- if(east && (new->x + new->width != c->frect.x + c->frect.width)) {
+ if(east && (new->x + new->width != f->rect.x + f->rect.width)) {
east->rect.width -= new->x + new->width - east->rect.x;
east->rect.x = new->x + new->width;
a->rect.x = new->x;
@@ -332,51 +344,51 @@ drop_resize(Client *c, XRectangle *new)
}
/* vertical resize */
- if(north && (new->y != c->frect.y)) {
- north->frect.height = new->y - north->frect.y;
- c->frect.height += c->frect.y - new->y;
- c->frect.y = new->y;
- resize_client(north, &north->frect, nil, False);
- resize_client(c, &c->frect, nil, False);
+ if(north && (new->y != f->rect.y)) {
+ north->rect.height = new->y - north->rect.y;
+ f->rect.height += f->rect.y - new->y;
+ f->rect.y = new->y;
+ resize_client(north->client, &north->rect, nil, False);
+ resize_client(f->client, &f->rect, nil, False);
}
- if(south && (new->y + new->height != c->frect.y + c->frect.height)) {
- south->frect.height -= new->y + new->height - south->frect.y;
- south->frect.y = new->y + new->height;
- c->frect.y = new->y;
- c->frect.height = new->height;
- resize_client(c, &c->frect, nil, False);
- resize_client(south, &south->frect, nil, False);
+ if(south && (new->y + new->height != f->rect.y + f->rect.height)) {
+ south->rect.height -= new->y + new->height - south->rect.y;
+ south->rect.y = new->y + new->height;
+ f->rect.y = new->y;
+ f->rect.height = new->height;
+ resize_client(f->client, &f->rect, nil, False);
+ resize_client(south->client, &south->rect, nil, False);
}
relax_area(a);
}
static void
-drop_moving(Client *c, XRectangle *new, XPoint * pt)
+drop_moving(Frame *f, XRectangle *new, XPoint * pt)
{
- Area *tgt = nil, *src = c->area;
+ Area *tgt = nil, *src = f->area;
Tag *t = src->tag;
unsigned int i;
- if(!pt || src->nclient < 2)
+ if(!pt || src->nframe < 2)
return;
for(i = 1; (i < t->narea) &&
!blitz_ispointinrect(pt->x, pt->y, &t->area[i]->rect); i++);
if((tgt = ((i < t->narea) ? t->area[i] : nil))) {
if(tgt != src) {
- send_toarea(tgt, c);
+ send_toarea(tgt, f->client);
arrange_area(tgt);
}
else {
- for(i = 0; (i < src->nclient) && !blitz_ispointinrect(
- pt->x, pt->y, &src->client[i]->frect); i++);
- if((i < src->nclient) && (c != src->client[i])) {
- unsigned int j = client2index(c);
- Client *tmp = src->client[j];
- src->client[j] = src->client[i];
- src->client[i] = tmp;
+ for(i = 0; (i < src->nframe) && !blitz_ispointinrect(
+ pt->x, pt->y, &src->frame[i]->rect); i++);
+ if((i < src->nframe) && (f != src->frame[i])) {
+ unsigned int j = frame2index(f);
+ Frame *tmp = src->frame[j];
+ src->frame[j] = src->frame[i];
+ src->frame[i] = tmp;
arrange_area(src);
- focus_client(c);
+ focus_client(f->client);
}
}
}
@@ -385,11 +397,12 @@ drop_moving(Client *c, XRectangle *new, XPoint * pt)
void
resize_area(Client *c, XRectangle *r, XPoint *pt)
{
- if((c->frect.width == r->width)
- && (c->frect.height == r->height))
- drop_moving(c, r, pt);
+ Frame *f = c->frame;
+ if((f->rect.width == r->width)
+ && (f->rect.height == r->height))
+ drop_moving(f, r, pt);
else
- drop_resize(c, r);
+ drop_resize(f, r);
}
Area *
diff --git a/cmd/wm/client.c b/cmd/wm/client.c
@@ -17,9 +17,7 @@ alloc_client(Window w, XWindowAttributes *wa)
Client *c = (Client *) cext_emallocz(sizeof(Client));
XSetWindowAttributes fwa;
long msize;
- static unsigned short id = 1;
- c->id = id++;
c->win = w;
c->rect.x = wa->x;
c->rect.y = wa->y;
@@ -42,11 +40,8 @@ alloc_client(Window w, XWindowAttributes *wa)
fwa.background_pixmap = ParentRelative;
fwa.event_mask = SubstructureRedirectMask | ExposureMask | ButtonPressMask | PointerMotionMask;
- c->frect = c->rect;
- c->frect.width += 2 * def.border;
- c->frect.height += def.border + bar_height();
- c->framewin = XCreateWindow(dpy, root, c->frect.x, c->frect.y,
- c->frect.width, c->frect.height, 0,
+ c->framewin = XCreateWindow(dpy, root, c->rect.x, c->rect.y,
+ c->rect.width + 2 * def.border, c->rect.height + def.border + bar_height(), 0,
DefaultDepth(dpy, screen), CopyFromParent,
DefaultVisual(dpy, screen),
CWOverrideRedirect | CWBackPixmap | CWEventMask, &fwa);
@@ -84,8 +79,8 @@ static void
client_focus_event(Client *c)
{
char buf[256];
- snprintf(buf, sizeof(buf), "CF %d %d %d %d\n", c->frect.x, c->frect.y,
- c->frect.width, c->frect.height);
+ snprintf(buf, sizeof(buf), "CF %d %d %d %d\n", c->frame->rect.x, c->frame->rect.y,
+ c->frame->rect.width, c->frame->rect.height);
write_event(buf);
}
@@ -93,10 +88,11 @@ void
focus_client(Client *c)
{
Client *old = sel_client();
- int i = area2index(c->area);
+ Frame *f = c->frame;
+ int i = area2index(f->area);
- c->area->tag->sel = i;
- c->area->sel = client2index(c);
+ f->area->tag->sel = i;
+ f->area->sel = frame2index(f);
if(old && (old != c)) {
grab_mouse(old->win, AnyModifier, Button1);
draw_client(old);
@@ -110,8 +106,8 @@ focus_client(Client *c)
XSync(dpy, False);
client_name_event(c);
client_focus_event(c);
- if(i > 0 && c->area->mode == Colstack)
- arrange_area(c->area);
+ if(i > 0 && f->area->mode == Colstack)
+ arrange_area(f->area);
}
void
@@ -142,17 +138,18 @@ reparent_client(Client *c, Window w, int x, int y)
}
void
-configure_client(Client * c)
+configure_client(Client *c)
{
XConfigureEvent e;
+ Frame *f = c->frame;
e.type = ConfigureNotify;
e.event = c->win;
e.window = c->win;
e.x = c->rect.x;
e.y = c->rect.y;
- if(c->area) {
- e.x += c->frect.x;
- e.y += c->frect.y;
+ if(f) {
+ e.x += f->rect.x;
+ e.y += f->rect.y;
}
e.width = c->rect.width;
e.height = c->rect.height;
@@ -207,7 +204,7 @@ handle_client_property(Client *c, XPropertyEvent *e)
cext_strlcpy(c->name, (char*) name.value, sizeof(c->name));
free(name.value);
}
- if(c->area)
+ if(c->frame)
draw_client(c);
if(c == sel_client())
client_name_event(c);
@@ -252,14 +249,14 @@ draw_client(Client *c)
/* draw border */
if(def.border) {
- d.rect = c->frect;
+ d.rect = c->frame->rect;
d.rect.x = d.rect.y = 0;
d.notch = &c->rect;
blitz_drawlabel(dpy, &d);
}
d.rect.x = 0;
d.rect.y = 0;
- d.rect.width = c->frect.width;
+ d.rect.width = c->frame->rect.width;
d.rect.height = bar_height();
d.notch = nil;
d.data = c->name;
@@ -355,19 +352,18 @@ attach_client(Client *c)
void
detach_client(Client *c, Bool unmap)
{
- Area *a = c->area;
- if(a) {
+ Frame *f = c->frame;
+ if(f) {
if(!c->destroyed) {
if(!unmap)
unmap_client(c);
- c->rect.x = c->frect.x;
- c->rect.y = c->frect.y;
+ c->rect.x = f->rect.x;
+ c->rect.y = f->rect.y;
reparent_client(c, root, c->rect.x, c->rect.y);
XUnmapWindow(dpy, c->framewin);
}
detach_fromarea(c);
}
- c->area = nil;
if(c->destroyed)
destroy_client(c);
}
@@ -377,7 +373,7 @@ sel_client_of_tag(Tag *t)
{
if(t) {
Area *a = t->narea ? t->area[t->sel] : nil;
- return (a && a->nclient) ? a->client[a->sel] : nil;
+ return (a && a->nframe) ? a->frame[a->sel]->client : nil;
}
return nil;
}
@@ -428,62 +424,63 @@ match_sizehints(Client *c)
h = c->size.min_height;
}
/* client_width = base_width + i * c->size.width_inc for an integer i */
- w = c->frect.width - 2 * def.border - w;
+ w = c->frame->rect.width - 2 * def.border - w;
if(s->width_inc > 0)
- c->frect.width -= w % s->width_inc;
+ c->frame->rect.width -= w % s->width_inc;
- h = c->frect.height - def.border - bar_height() - h;
+ h = c->frame->rect.height - def.border - bar_height() - h;
if(s->height_inc > 0)
- c->frect.height -= h % s->height_inc;
+ c->frame->rect.height -= h % s->height_inc;
}
}
void
resize_client(Client *c, XRectangle *r, XPoint *pt, Bool ignore_xcall)
{
- int pi = tag2index(c->area->tag);
+ Frame *f = c->frame;
+ int pi = tag2index(f->area->tag);
int px = sel * rect.width;
- if(area2index(c->area) > 0)
+ if(area2index(f->area) > 0)
resize_area(c, r, pt);
else
- c->frect = *r;
+ f->rect = *r;
- if((c->area->mode != Colstack) || (c->area->sel == client2index(c)))
+ if((f->area->mode != Colstack) || (f->area->sel == frame2index(f)))
match_sizehints(c);
if(!ignore_xcall)
- XMoveResizeWindow(dpy, c->framewin, px - (pi * rect.width) + c->frect.x, c->frect.y,
- c->frect.width, c->frect.height);
+ XMoveResizeWindow(dpy, c->framewin, px - (pi * rect.width) + f->rect.x, f->rect.y,
+ f->rect.width, f->rect.height);
- if((c->area->mode != Colstack) || (c->area->sel == client2index(c))) {
+ if((f->area->mode != Colstack) || (f->area->sel == frame2index(f))) {
c->rect.x = def.border;
c->rect.y = bar_height();
- c->rect.width = c->frect.width - 2 * def.border;
- c->rect.height = c->frect.height - def.border - bar_height();
+ c->rect.width = f->rect.width - 2 * def.border;
+ c->rect.height = f->rect.height - def.border - bar_height();
XMoveResizeWindow(dpy, c->win, c->rect.x, c->rect.y, c->rect.width, c->rect.height);
configure_client(c);
}
}
int
-cid2index(Area *a, unsigned short id)
+frid2index(Area *a, unsigned short id)
{
int i;
- for(i = 0; i < a->nclient; i++)
- if(a->client[i]->id == id)
+ for(i = 0; i < a->nframe; i++)
+ if(a->frame[i]->id == id)
return i;
return -1;
}
int
-client2index(Client *c)
+frame2index(Frame *f)
{
int i;
- Area *a = c->area;
- for(i = 0; i < a->nclient; i++)
- if(a->client[i] == c)
+ Area *a = f->area;
+ for(i = 0; i < a->nframe; i++)
+ if(a->frame[i] == f)
return i;
return -1;
}
@@ -491,28 +488,29 @@ client2index(Client *c)
void
select_client(Client *c, char *arg)
{
- Area *a = c->area;
- int i = client2index(c);
+ Frame *f = c->frame;
+ Area *a = f->area;
+ int i = frame2index(f);
if(i == -1)
return;
if(!strncmp(arg, "prev", 5)) {
if(!i)
- i = a->nclient - 1;
+ i = a->nframe - 1;
else
i--;
} else if(!strncmp(arg, "next", 5)) {
- if(i + 1 < a->nclient)
+ if(i + 1 < a->nframe)
i++;
else
i = 0;
}
else {
const char *errstr;
- i = cext_strtonum(arg, 0, a->nclient - 1, &errstr);
+ i = cext_strtonum(arg, 0, a->nframe - 1, &errstr);
if(errstr)
return;
}
- focus_client(a->client[i]);
+ focus_client(a->frame[i]->client);
}
void
@@ -544,7 +542,8 @@ void
sendtoarea_client(Client *c, char *arg)
{
const char *errstr;
- Area *to, *a = c->area;
+ Frame *f = c->frame;
+ Area *to, *a = f->area;
Tag *t = a->tag;
int i = area2index(a);
@@ -582,15 +581,16 @@ resize_all_clients()
{
unsigned int i;
for(i = 0; i < nclient; i++)
- if(client[i]->area)
- resize_client(client[i], &client[i]->frect, 0, False);
+ if(client[i]->frame->area)
+ resize_client(client[i], &client[i]->frame->rect, 0, False);
}
/* convenience function */
void
focus(Client *c)
{
- Tag *t = c->area->tag;
+ Frame *f = c->frame;
+ Tag *t = f->area->tag;
if(tag[sel] != t)
focus_tag(t);
focus_client(c);
diff --git a/cmd/wm/event.c b/cmd/wm/event.c
@@ -85,8 +85,8 @@ handle_buttonpress(XEvent *e)
mouse_resize(c, align);
}
- if(c && c->area) {
- snprintf(buf, sizeof(buf), "CB %d %d\n", client2index(c) + 1, ev->button);
+ if(c->frame) {
+ snprintf(buf, sizeof(buf), "CB %d %d\n", frame2index(c->frame) + 1, ev->button);
write_event(buf);
}
}
@@ -112,8 +112,8 @@ handle_buttonpress(XEvent *e)
else if(ev->button == Button1)
focus(c);
- if(c) {
- snprintf(buf, sizeof(buf), "CB %d %d\n", client2index(c) + 1, ev->button);
+ if(c->frame) {
+ snprintf(buf, sizeof(buf), "CB %d %d\n", frame2index(c->frame) + 1, ev->button);
write_event(buf);
}
}
@@ -146,11 +146,12 @@ handle_configurerequest(XEvent *e)
gravitate(c, False);
- if(c->area) {
- c->frect.x = wc.x = c->rect.x - def.border;
- c->frect.y = wc.y = c->rect.y - bar_height();
- c->frect.width = wc.width = c->rect.width + 2 * def.border;
- c->frect.height = wc.height = c->rect.height + def.border + bar_height();
+ if(c->frame) {
+ Frame *f = c->frame;
+ f->rect.x = wc.x = c->rect.x - def.border;
+ f->rect.y = wc.y = c->rect.y - bar_height();
+ f->rect.width = wc.width = c->rect.width + 2 * def.border;
+ f->rect.height = wc.height = c->rect.height + def.border + bar_height();
wc.border_width = 1;
wc.sibling = None;
wc.stack_mode = ev->detail;
@@ -161,7 +162,7 @@ handle_configurerequest(XEvent *e)
wc.x = ev->x;
wc.y = ev->y;
- if(c && c->area) {
+ if(c && c->frame) {
wc.x = def.border;
wc.y = bar_height();
}
@@ -197,7 +198,7 @@ handle_expose(XEvent *e)
if(ev->count == 0) {
if(ev->window == winbar)
draw_bar();
- else if((c = win2clientframe(ev->window)))
+ else if((c = win2clientframe(ev->window)) && c->frame)
draw_client(c);
}
}
@@ -239,7 +240,7 @@ handle_maprequest(XEvent *e)
c = win2client(ev->window);
if(!c)
c = alloc_client(ev->window, &wa);
- if(!c->area)
+ if(!c->frame)
attach_client(c);
}
diff --git a/cmd/wm/fs.c b/cmd/wm/fs.c
@@ -133,7 +133,7 @@ decode_qpath(Qid *qid, unsigned char *type, int *i1, int *i2, int *i3)
if(i2id && (*i1 != -1)) {
*i2 = aid2index(tag[*i1], i2id);
if(i3id && (*i2 != -1))
- *i3 = cid2index(tag[*i1]->area[*i2], i3id);
+ *i3 = frid2index(tag[*i1]->area[*i2], i3id);
}
}
}
@@ -350,15 +350,15 @@ mkqid(Qid *dir, char *wname, Qid *new, Bool iswalk)
Area *a = p->area[dir_i2];
new->type = IXP_QTDIR;
if(!strncmp(wname, "sel", 4)) {
- if(!a->nclient)
+ if(!a->nframe)
return -1;
- new->path = mkqpath(Dclient, p->id, a->id, a->client[a->sel]->id);
+ new->path = mkqpath(Dclient, p->id, a->id, a->frame[a->sel]->id);
}
else {
i = cext_strtonum(wname, 0, 0xffff, &err);
- if(err || (i >= a->nclient))
+ if(err || (i >= a->nframe))
return -1;
- new->path = mkqpath(Dclient, p->id, a->id, a->client[i]->id);
+ new->path = mkqpath(Dclient, p->id, a->id, a->frame[i]->id);
}
}
break;
@@ -511,7 +511,7 @@ type2stat(Stat *stat, char *wname, Qid *dir)
int dir_i1 = 0, dir_i2 = 0, dir_i3 = 0;
int type;
char buf[32];
- Client *c;
+ Frame *f;
decode_qpath(dir, &dir_type, &dir_i1, &dir_i2, &dir_i3);
if((dir_i1 == -1) || (dir_i2 == -1) || (dir_i3 == -1))
@@ -538,9 +538,9 @@ type2stat(Stat *stat, char *wname, Qid *dir)
return mkstat(stat, dir, wname, strlen(buf), DMREAD | DMWRITE);
break;
case Fgeom:
- c = tag[dir_i1]->area[dir_i2]->client[dir_i3];
- snprintf(buf, sizeof(buf), "%d %d %d %d", c->frect.x, c->frect.y,
- c->frect.width, c->frect.height);
+ f = tag[dir_i1]->area[dir_i2]->frame[dir_i3];
+ snprintf(buf, sizeof(buf), "%d %d %d %d", f->rect.x, f->rect.y,
+ f->rect.width, f->rect.height);
return mkstat(stat, dir, wname, strlen(buf), DMREAD | DMWRITE);
break;
case Fsnap:
@@ -548,8 +548,8 @@ type2stat(Stat *stat, char *wname, Qid *dir)
return mkstat(stat, dir, wname, strlen(buf), DMREAD | DMWRITE);
break;
case Fname:
- c = tag[dir_i1]->area[dir_i2]->client[dir_i3];
- return mkstat(stat, dir, wname, strlen(c->name), DMREAD);
+ f = tag[dir_i1]->area[dir_i2]->frame[dir_i3];
+ return mkstat(stat, dir, wname, strlen(f->client->name), DMREAD);
break;
case Fkey:
return mkstat(stat, dir, wname, 0, DMWRITE);
@@ -633,7 +633,7 @@ xread(IXPConn *c, Fcall *fcall)
char buf[32];
unsigned char type;
int i1 = 0, i2 = 0, i3 = 0;
- Client *client;
+ Frame *f;
if(!m)
return Enofid;
@@ -745,7 +745,7 @@ xread(IXPConn *c, Fcall *fcall)
len = type2stat(&stat, "ctl", &m->qid);
if(i2)
len += type2stat(&stat, "mode", &m->qid);
- for(i = 0; i < tag[i1]->area[i2]->nclient; i++) {
+ for(i = 0; i < tag[i1]->area[i2]->nframe; i++) {
if(i == tag[i1]->area[i2]->sel)
snprintf(buf, sizeof(buf), "%s", "sel");
else
@@ -756,7 +756,7 @@ xread(IXPConn *c, Fcall *fcall)
break;
}
/* offset found, proceeding */
- for(; i < tag[i1]->area[i2]->nclient; i++) {
+ for(; i < tag[i1]->area[i2]->nframe; i++) {
if(i == tag[i1]->area[i2]->sel)
snprintf(buf, sizeof(buf), "%s", "sel");
else
@@ -868,7 +868,7 @@ xread(IXPConn *c, Fcall *fcall)
if(i2)
fcall->count += type2stat(&stat, "mode", &m->qid);
p = ixp_enc_stat(p, &stat);
- for(i = 0; i < tag[i1]->area[i2]->nclient; i++) {
+ for(i = 0; i < tag[i1]->area[i2]->nframe; i++) {
if(i == tag[i1]->area[i2]->sel)
snprintf(buf, sizeof(buf), "%s", "sel");
else
@@ -904,9 +904,9 @@ xread(IXPConn *c, Fcall *fcall)
memcpy(p, buf, fcall->count);
break;
case Fgeom:
- client = tag[i1]->area[i2]->client[i3];
- snprintf(buf, sizeof(buf), "%d %d %d %d", client->frect.x, client->frect.y,
- client->frect.width, client->frect.height);
+ f = tag[i1]->area[i2]->frame[i3];
+ snprintf(buf, sizeof(buf), "%d %d %d %d", f->rect.x, f->rect.y,
+ f->rect.width, f->rect.height);
fcall->count = strlen(buf);
memcpy(p, buf, fcall->count);
break;
@@ -916,8 +916,8 @@ xread(IXPConn *c, Fcall *fcall)
memcpy(p, buf, fcall->count);
break;
case Fname:
- if((fcall->count = strlen(tag[i1]->area[i2]->client[i3]->name)))
- memcpy(p, tag[i1]->area[i2]->client[i3]->name, fcall->count);
+ if((fcall->count = strlen(tag[i1]->area[i2]->frame[i3]->client->name)))
+ memcpy(p, tag[i1]->area[i2]->frame[i3]->client->name, fcall->count);
break;
case Fexpand:
snprintf(buf, sizeof(buf), "%u", iexpand);
@@ -988,7 +988,7 @@ xwrite(IXPConn *c, Fcall *fcall)
IXPMap *m = ixp_server_fid2map(c, fcall->fid);
unsigned char type;
int i, i1 = 0, i2 = 0, i3 = 0;
- Client *cl;
+ Frame *f;
if(!m)
return Enofid;
@@ -1023,18 +1023,18 @@ xwrite(IXPConn *c, Fcall *fcall)
case Darea:
if(!strncmp(buf, "select ", 7)) {
Area *a = tag[i1]->area[i2];
- if(a->nclient)
- select_client(a->client[a->sel], &buf[7]);
+ if(a->nframe)
+ select_client(a->frame[a->sel]->client, &buf[7]);
}
break;
case Dclient:
- cl = tag[i1]->area[i2]->client[i3];
+ f = tag[i1]->area[i2]->frame[i3];
if(!strncmp(buf, "kill", 5))
- kill_client(cl);
+ kill_client(f->client);
else if(!strncmp(buf, "sendtotag ", 11))
- sendtotag_client(cl, &buf[11]);
+ sendtotag_client(f->client, &buf[11]);
else if(!strncmp(buf, "sendtoarea ", 11))
- sendtoarea_client(cl, &buf[11]);
+ sendtoarea_client(f->client, &buf[11]);
break;
default:
break;
@@ -1062,13 +1062,13 @@ xwrite(IXPConn *c, Fcall *fcall)
resize_all_clients();
break;
case Fgeom:
- cl = tag[i1]->area[i2]->client[i3];
+ f = tag[i1]->area[i2]->frame[i3];
if(fcall->count > sizeof(buf))
return "geometry values out of range";
memcpy(buf, fcall->data, fcall->count);
buf[fcall->count] = 0;
- blitz_strtorect(&rect, &cl->frect, buf);
- resize_client(cl, &cl->frect, 0, False);
+ blitz_strtorect(&rect, &f->rect, buf);
+ resize_client(f->client, &f->rect, 0, False);
break;
case Fexpand:
{
@@ -1117,7 +1117,7 @@ xwrite(IXPConn *c, Fcall *fcall)
def.selcolor[fcall->count] = 0;
blitz_loadcolor(dpy, screen, def.selcolor, &def.sel);
for(i = 0; i < nclient; i++)
- if(client[i]->area->tag == tag[sel])
+ if(client[i]->frame->area->tag == tag[sel])
draw_client(client[i]);
break;
case Fnormcolors:
@@ -1130,7 +1130,7 @@ xwrite(IXPConn *c, Fcall *fcall)
def.normcolor[fcall->count] = 0;
blitz_loadcolor(dpy, screen, def.normcolor, &def.norm);
for(i = 0; i < nclient; i++)
- if(client[i]->area->tag == tag[sel])
+ if(client[i]->frame->area->tag == tag[sel])
draw_client(client[i]);
break;
case Ffont:
diff --git a/cmd/wm/mouse.c b/cmd/wm/mouse.c
@@ -12,6 +12,7 @@
Cursor
cursor_for_motion(Client *c, int x, int y)
{
+ Frame *f = c->frame;
int n, e, w, s, tn, te, tw, ts;
if(!def.border)
@@ -19,14 +20,14 @@ cursor_for_motion(Client *c, int x, int y)
/* rectangle attributes of client are used */
w = x < def.border;
- e = x >= c->frect.width - def.border;
+ e = x >= f->rect.width - def.border;
n = y < def.border;
- s = y >= c->frect.height - def.border;
+ s = y >= f->rect.height - def.border;
tw = x < bar_height();
- te = x > c->frect.width - bar_height();
+ te = x > f->rect.width - bar_height();
tn = y < bar_height();
- ts = s > c->frect.height - bar_height();
+ ts = s > f->rect.height - bar_height();
if((w && n) || (w && tn) || (n && tw))
return nw_cursor;
@@ -305,7 +306,7 @@ mouse_move(Client *c)
unsigned int num;
unsigned int dmask;
XRectangle *rects = rectangles(&num);
- XRectangle frect = c->frect;
+ XRectangle frect = c->frame->rect;
XPoint pt;
XQueryPointer(dpy, c->framewin, &dummy, &dummy, &i, &i, &wex, &wey, &dmask);
@@ -550,7 +551,7 @@ mouse_resize(Client *c, Align align)
unsigned int dmask;
unsigned int num;
XRectangle *rects = rectangles(&num);
- XRectangle frect = c->frect;
+ XRectangle frect = c->frame->rect;
XRectangle origin = frect;
XQueryPointer(dpy, c->framewin, &dummy, &dummy, &i, &i, &ox, &oy, &dmask);
diff --git a/cmd/wm/tag.c b/cmd/wm/tag.c
@@ -33,7 +33,7 @@ destroy_tag(Tag *t)
unsigned int i;
for(i = 0; i < t->narea; i++)
- if(t->area[i]->nclient)
+ if(t->area[i]->nframe)
return "tag not empty";
while(t->narea)
@@ -64,7 +64,6 @@ void
focus_tag(Tag *t)
{
char buf[16];
- Client *c;
int i, pi = tag2index(t);
int px;
@@ -75,12 +74,12 @@ focus_tag(Tag *t)
px = sel * rect.width;
/* gives all(!) clients proper geometry (for use of different tagrs) */
for(i = 0; i < nclient; i++) {
- c = client[i];
- if(c->area) {
- pi = tag2index(c->area->tag);
- XMoveWindow(dpy, c->framewin, px - (pi * rect.width) + c->frect.x, c->frect.y);
- if(c->area->tag == t)
- draw_client(c);
+ if(client[i]->frame) {
+ Frame *f = client[i]->frame;
+ pi = tag2index(f->area->tag);
+ XMoveWindow(dpy, client[i]->framewin, px - (pi * rect.width) + f->rect.x, f->rect.y);
+ if(f->area->tag == t)
+ draw_client(client[i]);
}
}
snprintf(buf, sizeof(buf), "PN %d\n", sel);
diff --git a/cmd/wm/wm.c b/cmd/wm/wm.c
@@ -226,7 +226,7 @@ cleanup()
Client *c;
for(i = 0; client && client[i]; i++) {
c = client[i];
- reparent_client(c, root, c->frect.x, c->frect.y);
+ reparent_client(c, root, c->frame->rect.x, c->frame->rect.y);
}
XSetInputFocus(dpy, PointerRoot, RevertToPointerRoot, CurrentTime);
XSync(dpy, False);
diff --git a/cmd/wm/wm.h b/cmd/wm/wm.h
@@ -65,18 +65,19 @@ enum {
#define ROOT_MASK SubstructureRedirectMask
#define CLIENT_MASK (StructureNotifyMask | PropertyChangeMask)
-typedef struct Area Area;
typedef struct Tag Tag;
+typedef struct Area Area;
+typedef struct Frame Frame;
typedef struct Client Client;
struct Area {
unsigned short id;
- Client **client;
+ Frame **frame;
Tag *tag;
- unsigned int clientsz;
+ unsigned int framesz;
unsigned int sel;
- unsigned int nclient;
+ unsigned int nframe;
int mode;
XRectangle rect;
};
@@ -89,21 +90,26 @@ struct Tag {
unsigned int sel;
};
-struct Client {
+struct Frame {
+ Area *area;
unsigned short id;
+ XRectangle rect;
+ Client *client;
+};
+
+struct Client {
char name[256];
int proto;
unsigned int border;
Bool destroyed;
- Area *area;
Window win;
Window trans;
XRectangle rect;
XSizeHints size;
Window framewin;
- XRectangle frect;
GC gc;
Cursor cursor;
+ Frame *frame;
};
typedef struct Key Key;
@@ -227,8 +233,8 @@ Client *sel_client_of_tag(Tag *t);
void focus_client(Client *c);
Client *win2clientframe(Window w);
void resize_client(Client *c, XRectangle *r, XPoint *pt, Bool ignore_xcall);
-int cid2index(Area *a, unsigned short id);
-int client2index(Client *c);
+int frid2index(Area *a, unsigned short id);
+int frame2index(Frame *f);
void select_client(Client *c, char *arg);
void sendtotag_client(Client *c, char *arg);
void sendtoarea_client(Client *c, char *arg);