wmii

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

commit 54b7d6dd2a3dfe24d619914b179a96a8bc129c43
parent 0a144ff452a2586ddce39f78d155896d9d83f9d8
Author: Anselm R. Garbe <garbeam@wmii.de>
Date:   Sun,  5 Mar 2006 00:25:49 +0100

removed Client.Frame


Diffstat:
cmd/wm/area.c | 96++++++++++++++++++++++++++++++++++++++++----------------------------------------
cmd/wm/client.c | 74+++++++++++++++++++++++++++++++++++++-------------------------------------
cmd/wm/event.c | 20++++++++++----------
cmd/wm/fs.c | 12++++++------
cmd/wm/mouse.c | 24++++++++++++------------
cmd/wm/tag.c | 2+-
cmd/wm/wm.c | 2+-
cmd/wm/wm.h | 10++++------
8 files changed, 119 insertions(+), 121 deletions(-)

diff --git a/cmd/wm/area.c b/cmd/wm/area.c @@ -120,7 +120,7 @@ attach_toarea(Area *a, Client *c) if(area2index(a)) /* column */ arrange_area(a); else /* floating */ - resize_client(c, &c->frame.rect, nil, False); + resize_client(c, &c->frect, nil, False); } void @@ -178,21 +178,21 @@ relax_area(Area *a) for(i = 0; i < a->nclient; i++) { Client *c = a->client[i]; if(a->mode == Colmax) { - if(h < c->frame.rect.height) - h = c->frame.rect.height; + if(h < c->frect.height) + h = c->frect.height; } else - h += c->frame.rect.height; + h += c->frect.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->frame.rect.height; - c->frame.rect.height += (a->rect.height - h); - resize_client(c, &c->frame.rect, 0, True); - h += (c->frame.rect.height - tmp); + 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); } } @@ -200,11 +200,11 @@ relax_area(Area *a) yoff = a->rect.y + hdiff / 2; for(i = 0; i < a->nclient; i++) { Client *c = a->client[i]; - c->frame.rect.x = a->rect.x + (a->rect.width - c->frame.rect.width) / 2; - c->frame.rect.y = yoff; + c->frect.x = a->rect.x + (a->rect.width - c->frect.width) / 2; + c->frect.y = yoff; if(a->mode != Colmax) - yoff = c->frame.rect.y + c->frame.rect.height + hdiff; - resize_client(c, &c->frame.rect, 0, False); + yoff = c->frect.y + c->frect.height + hdiff; + resize_client(c, &c->frect, 0, False); } } @@ -222,14 +222,14 @@ arrange_area(Area *a) h /= a->nclient; for(i = 0; i < a->nclient; i++) { Client *c = a->client[i]; - c->frame.rect = a->rect; - c->frame.rect.y += i * h; + c->frect = a->rect; + c->frect.y += i * h; if(i + 1 < a->nclient) - c->frame.rect.height = h; + c->frect.height = h; else - c->frame.rect.height = - a->rect.height - c->frame.rect.y + a->rect.y; - resize_client(c, &c->frame.rect, 0, True); + c->frect.height = + a->rect.height - c->frect.y + a->rect.y; + resize_client(c, &c->frect, 0, True); } break; case Colstack: @@ -237,21 +237,21 @@ arrange_area(Area *a) h = a->rect.height - (a->nclient - 1) * bar_height(); for(i = 0; i < a->nclient; i++) { Client *c = a->client[i]; - c->frame.rect = a->rect; - c->frame.rect.y = yoff; + c->frect = a->rect; + c->frect.y = yoff; if(i == a->sel) - c->frame.rect.height = h; + c->frect.height = h; else - c->frame.rect.height = bar_height(); - yoff += c->frame.rect.height; - resize_client(c, &c->frame.rect, 0, True); + c->frect.height = bar_height(); + yoff += c->frect.height; + resize_client(c, &c->frect, 0, True); } break; case Colmax: for(i = 0; i < a->nclient; i++) { Client *c = a->client[i]; - c->frame.rect = a->rect; - resize_client(c, &c->frame.rect, 0, True); + c->frect = a->rect; + resize_client(c, &c->frect, 0, True); } break; default: @@ -289,9 +289,9 @@ match_horiz(Area *a, XRectangle *r) for(i = 0; i < a->nclient; i++) { Client *c = a->client[i]; - c->frame.rect.x = r->x; - c->frame.rect.width = r->width; - resize_client(c, &c->frame.rect, nil, False); + c->frect.x = r->x; + c->frect.width = r->width; + resize_client(c, &c->frect, nil, False); } } @@ -313,15 +313,15 @@ drop_resize(Client *c, XRectangle *new) south = i + 1 < a->nclient ? a->client[i + 1] : nil; /* horizontal resize */ - if(west && (new->x != c->frame.rect.x)) { + if(west && (new->x != c->frect.x)) { west->rect.width = new->x - west->rect.x; - a->rect.width += c->frame.rect.x - new->x; + a->rect.width += c->frect.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->frame.rect.x + c->frame.rect.width)) { + if(east && (new->x + new->width != c->frect.x + c->frect.width)) { east->rect.width -= new->x + new->width - east->rect.x; east->rect.x = new->x + new->width; a->rect.x = new->x; @@ -332,20 +332,20 @@ drop_resize(Client *c, XRectangle *new) } /* vertical resize */ - if(north && (new->y != c->frame.rect.y)) { - north->frame.rect.height = new->y - north->frame.rect.y; - c->frame.rect.height += c->frame.rect.y - new->y; - c->frame.rect.y = new->y; - resize_client(north, &north->frame.rect, nil, False); - resize_client(c, &c->frame.rect, nil, False); + 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(south && (new->y + new->height != c->frame.rect.y + c->frame.rect.height)) { - south->frame.rect.height -= new->y + new->height - south->frame.rect.y; - south->frame.rect.y = new->y + new->height; - c->frame.rect.y = new->y; - c->frame.rect.height = new->height; - resize_client(c, &c->frame.rect, nil, False); - resize_client(south, &south->frame.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); } relax_area(a); } @@ -369,7 +369,7 @@ drop_moving(Client *c, XRectangle *new, XPoint * pt) } else { for(i = 0; (i < src->nclient) && !blitz_ispointinrect( - pt->x, pt->y, &src->client[i]->frame.rect); i++); + 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]; @@ -385,8 +385,8 @@ drop_moving(Client *c, XRectangle *new, XPoint * pt) void resize_area(Client *c, XRectangle *r, XPoint *pt) { - if((c->frame.rect.width == r->width) - && (c->frame.rect.height == r->height)) + if((c->frect.width == r->width) + && (c->frect.height == r->height)) drop_moving(c, r, pt); else drop_resize(c, r); diff --git a/cmd/wm/client.c b/cmd/wm/client.c @@ -44,17 +44,17 @@ alloc_client(Window w, XWindowAttributes *wa) fwa.event_mask = SubstructureRedirectMask | ExposureMask | ButtonPressMask | PointerMotionMask; bh = bar_height(); - c->frame.rect = c->rect; - c->frame.rect.width += 2 * bw; - c->frame.rect.height += bw + (bh ? bh : bw); - c->frame.win = XCreateWindow(dpy, root, c->frame.rect.x, c->frame.rect.y, - c->frame.rect.width, c->frame.rect.height, 0, + c->frect = c->rect; + c->frect.width += 2 * bw; + c->frect.height += bw + (bh ? bh : bw); + c->framewin = XCreateWindow(dpy, root, c->frect.x, c->frect.y, + c->frect.width, c->frect.height, 0, DefaultDepth(dpy, screen), CopyFromParent, DefaultVisual(dpy, screen), CWOverrideRedirect | CWBackPixmap | CWEventMask, &fwa); - c->frame.cursor = normal_cursor; - XDefineCursor(dpy, c->frame.win, c->frame.cursor); - c->frame.gc = XCreateGC(dpy, c->frame.win, 0, 0); + c->cursor = normal_cursor; + XDefineCursor(dpy, c->framewin, c->cursor); + c->gc = XCreateGC(dpy, c->framewin, 0, 0); XSync(dpy, False); client = (Client **)cext_array_attach((void **)client, c, sizeof(Client *), &clientsz); @@ -86,8 +86,8 @@ static void client_focus_event(Client *c) { char buf[256]; - 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); + snprintf(buf, sizeof(buf), "CF %d %d %d %d\n", c->frect.x, c->frect.y, + c->frect.width, c->frect.height); write_event(buf); } @@ -106,7 +106,7 @@ focus_client(Client *c) ungrab_mouse(c->win, AnyModifier, AnyButton); grab_mouse(c->win, Mod1Mask, Button1); grab_mouse(c->win, Mod1Mask, Button3); - XRaiseWindow(dpy, c->frame.win); + XRaiseWindow(dpy, c->framewin); XSetInputFocus(dpy, c->win, RevertToPointerRoot, CurrentTime); draw_client(c); XSync(dpy, False); @@ -153,8 +153,8 @@ configure_client(Client * c) e.x = c->rect.x; e.y = c->rect.y; if(c->area) { - e.x += c->frame.rect.x; - e.y += c->frame.rect.y; + e.x += c->frect.x; + e.y += c->frect.y; } e.width = c->rect.width; e.height = c->rect.height; @@ -229,8 +229,8 @@ handle_client_property(Client *c, XPropertyEvent *e) void destroy_client(Client * c) { - XFreeGC(dpy, c->frame.gc); - XDestroyWindow(dpy, c->frame.win); + XFreeGC(dpy, c->gc); + XDestroyWindow(dpy, c->framewin); cext_array_detach((void **)client, c, &clientsz); nclient--; free(c); @@ -246,9 +246,9 @@ draw_client(Client *c) XRectangle notch; d.align = WEST; - d.drawable = c->frame.win; + d.drawable = c->framewin; d.font = xfont; - d.gc = c->frame.gc; + d.gc = c->gc; if(c == sel_client()) d.color = def.sel; @@ -259,9 +259,9 @@ draw_client(Client *c) if(bw) { notch.x = bw; notch.y = bw; - notch.width = c->frame.rect.width - 2 * bw; - notch.height = c->frame.rect.height - 2 * bw; - d.rect = c->frame.rect; + notch.width = c->frect.width - 2 * bw; + notch.height = c->frect.height - 2 * bw; + d.rect = c->frect; d.rect.x = d.rect.y = 0; d.notch = &notch; @@ -275,7 +275,7 @@ draw_client(Client *c) d.rect.x = 0; d.rect.y = 0; - d.rect.width = c->frame.rect.width; + d.rect.width = c->frect.width; d.rect.height = bh; d.notch = nil; d.data = c->name; @@ -349,10 +349,10 @@ attach_totag(Tag *t, Client *c) { Area *a = t->area[t->sel]; - reparent_client(c, c->frame.win, c->rect.x, c->rect.y); + reparent_client(c, c->framewin, c->rect.x, c->rect.y); attach_toarea(a, c); map_client(c); - XMapWindow(dpy, c->frame.win); + XMapWindow(dpy, c->framewin); } void @@ -376,10 +376,10 @@ detach_client(Client *c, Bool unmap) if(!c->destroyed) { if(!unmap) unmap_client(c); - c->rect.x = c->frame.rect.x; - c->rect.y = c->frame.rect.y; + c->rect.x = c->frect.x; + c->rect.y = c->frect.y; reparent_client(c, root, c->rect.x, c->rect.y); - XUnmapWindow(dpy, c->frame.win); + XUnmapWindow(dpy, c->framewin); } detach_fromarea(c); } @@ -409,7 +409,7 @@ win2clientframe(Window w) { unsigned int i; for(i = 0; (i < clientsz) && client[i]; i++) - if(client[i]->frame.win == w) + if(client[i]->framewin == w) return client[i]; return nil; } @@ -444,13 +444,13 @@ match_sizehints(Client *c, unsigned int tabh, unsigned int bw) h = c->size.min_height; } /* client_width = base_width + i * c->size.width_inc for an integer i */ - w = c->frame.rect.width - 2 * bw - w; + w = c->frect.width - 2 * bw - w; if(s->width_inc > 0) - c->frame.rect.width -= w % s->width_inc; + c->frect.width -= w % s->width_inc; - h = c->frame.rect.height - bw - (tabh ? tabh : bw) - h; + h = c->frect.height - bw - (tabh ? tabh : bw) - h; if(s->height_inc > 0) - c->frame.rect.height -= h % s->height_inc; + c->frect.height -= h % s->height_inc; } } @@ -466,20 +466,20 @@ resize_client(Client *c, XRectangle *r, XPoint *pt, Bool ignore_xcall) if(area2index(c->area) > 0) resize_area(c, r, pt); else - c->frame.rect = *r; + c->frect = *r; if((c->area->mode != Colstack) || (c->area->sel == client2index(c))) match_sizehints(c, bh, bw); if(!ignore_xcall) - XMoveResizeWindow(dpy, c->frame.win, px - (pi * rect.width) + c->frame.rect.x, c->frame.rect.y, - c->frame.rect.width, c->frame.rect.height); + XMoveResizeWindow(dpy, c->framewin, px - (pi * rect.width) + c->frect.x, c->frect.y, + c->frect.width, c->frect.height); if((c->area->mode != Colstack) || (c->area->sel == client2index(c))) { c->rect.x = bw; c->rect.y = bh ? bh : bw; - c->rect.width = c->frame.rect.width - 2 * bw; - c->rect.height = c->frame.rect.height - bw - (bh ? bh : bw); + c->rect.width = c->frect.width - 2 * bw; + c->rect.height = c->frect.height - bw - (bh ? bh : bw); XMoveResizeWindow(dpy, c->win, c->rect.x, c->rect.y, c->rect.width, c->rect.height); configure_client(c); } @@ -601,7 +601,7 @@ resize_all_clients() unsigned int i; for(i = 0; i < nclient; i++) if(client[i]->area) - resize_client(client[i], &client[i]->frame.rect, 0, False); + resize_client(client[i], &client[i]->frect, 0, False); } /* convenience function */ diff --git a/cmd/wm/event.c b/cmd/wm/event.c @@ -78,7 +78,7 @@ handle_buttonpress(XEvent *e) focus(c); return; } - align = cursor2align(c->frame.cursor); + align = cursor2align(c->cursor); if(align == CENTER) mouse_move(c); else @@ -93,7 +93,7 @@ handle_buttonpress(XEvent *e) else if((c = win2client(ev->window))) { ev->state &= valid_mask; if(ev->state & Mod1Mask) { - XRaiseWindow(dpy, c->frame.win); + XRaiseWindow(dpy, c->framewin); switch (ev->button) { case Button1: focus(c); @@ -153,14 +153,14 @@ handle_configurerequest(XEvent *e) gravitate(c, bh ? bh : bw, bw, 0); if(c->area) { - c->frame.rect.x = wc.x = c->rect.x - bw; - c->frame.rect.y = wc.y = c->rect.y - (bh ? bh : bw); - c->frame.rect.width = wc.width = c->rect.width + 2 * bw; - c->frame.rect.height = wc.height = c->rect.height + bw + (bh ? bh : bw); + c->frect.x = wc.x = c->rect.x - bw; + c->frect.y = wc.y = c->rect.y - (bh ? bh : bw); + c->frect.width = wc.width = c->rect.width + 2 * bw; + c->frect.height = wc.height = c->rect.height + bw + (bh ? bh : bw); wc.border_width = 1; wc.sibling = None; wc.stack_mode = ev->detail; - XConfigureWindow(dpy, c->frame.win, ev->value_mask, &wc); + XConfigureWindow(dpy, c->framewin, ev->value_mask, &wc); configure_client(c); } } @@ -256,9 +256,9 @@ handle_motionnotify(XEvent *e) Client *c = win2clientframe(e->xmotion.window); if(c) { Cursor cursor = cursor_for_motion(c, e->xmotion.x, e->xmotion.y); - if(cursor != c->frame.cursor) { - c->frame.cursor = cursor; - XDefineCursor(dpy, c->frame.win, cursor); + if(cursor != c->cursor) { + c->cursor = cursor; + XDefineCursor(dpy, c->framewin, cursor); } } } diff --git a/cmd/wm/fs.c b/cmd/wm/fs.c @@ -539,8 +539,8 @@ type2stat(Stat *stat, char *wname, Qid *dir) break; case Fgeom: c = tag[dir_i1]->area[dir_i2]->client[dir_i3]; - snprintf(buf, sizeof(buf), "%d %d %d %d", c->frame.rect.x, c->frame.rect.y, - c->frame.rect.width, c->frame.rect.height); + snprintf(buf, sizeof(buf), "%d %d %d %d", c->frect.x, c->frect.y, + c->frect.width, c->frect.height); return mkstat(stat, dir, wname, strlen(buf), DMREAD | DMWRITE); break; case Fsnap: @@ -905,8 +905,8 @@ xread(IXPConn *c, Fcall *fcall) break; case Fgeom: client = tag[i1]->area[i2]->client[i3]; - snprintf(buf, sizeof(buf), "%d %d %d %d", client->frame.rect.x, client->frame.rect.y, - client->frame.rect.width, client->frame.rect.height); + snprintf(buf, sizeof(buf), "%d %d %d %d", client->frect.x, client->frect.y, + client->frect.width, client->frect.height); fcall->count = strlen(buf); memcpy(p, buf, fcall->count); break; @@ -1067,8 +1067,8 @@ xwrite(IXPConn *c, Fcall *fcall) return "geometry values out of range"; memcpy(buf, fcall->data, fcall->count); buf[fcall->count] = 0; - blitz_strtorect(&rect, &cl->frame.rect, buf); - resize_client(cl, &cl->frame.rect, 0, False); + blitz_strtorect(&rect, &cl->frect, buf); + resize_client(cl, &cl->frect, 0, False); break; case Fexpand: { diff --git a/cmd/wm/mouse.c b/cmd/wm/mouse.c @@ -23,14 +23,14 @@ cursor_for_motion(Client *c, int x, int y) /* rectangle attributes of client are used */ w = x < bw; - e = x >= c->frame.rect.width - bw; + e = x >= c->frect.width - bw; n = y < bw; - s = y >= c->frame.rect.height - bw; + s = y >= c->frect.height - bw; tw = x < (bh ? bh : 2 * bw); - te = x > c->frame.rect.width - (bh ? bh : 2 * bw); + te = x > c->frect.width - (bh ? bh : 2 * bw); tn = y < (bh ? bh : 2 * bw); - ts = s > c->frame.rect.height - (bh ? bh : 2 * bw); + ts = s > c->frect.height - (bh ? bh : 2 * bw); if((w && n) || (w && tn) || (n && tw)) return nw_cursor; @@ -309,11 +309,11 @@ mouse_move(Client *c) unsigned int num; unsigned int dmask; XRectangle *rects = rectangles(&num); - XRectangle frect = c->frame.rect; + XRectangle frect = c->frect; XPoint pt; - XQueryPointer(dpy, c->frame.win, &dummy, &dummy, &i, &i, &wex, &wey, &dmask); - XTranslateCoordinates(dpy, c->frame.win, root, wex, wey, &ex, &ey, &dummy); + XQueryPointer(dpy, c->framewin, &dummy, &dummy, &i, &i, &wex, &wey, &dmask); + XTranslateCoordinates(dpy, c->framewin, root, wex, wey, &ex, &ey, &dummy); pt.x = ex; pt.y = ey; XSync(dpy, False); @@ -346,7 +346,7 @@ mouse_move(Client *c) case MotionNotify: pt.x = ev.xmotion.x; pt.y = ev.xmotion.y; - XTranslateCoordinates(dpy, c->frame.win, root, ev.xmotion.x, + XTranslateCoordinates(dpy, c->framewin, root, ev.xmotion.x, ev.xmotion.y, &px, &py, &dummy); if(first) first = 0; @@ -554,14 +554,14 @@ mouse_resize(Client *c, Align align) unsigned int dmask; unsigned int num; XRectangle *rects = rectangles(&num); - XRectangle frect = c->frame.rect; + XRectangle frect = c->frect; XRectangle origin = frect; - XQueryPointer(dpy, c->frame.win, &dummy, &dummy, &i, &i, &ox, &oy, &dmask); + XQueryPointer(dpy, c->framewin, &dummy, &dummy, &i, &i, &ox, &oy, &dmask); XSync(dpy, False); XGrabServer(dpy); while(XGrabPointer - (dpy, c->frame.win, False, ButtonMotionMask | ButtonReleaseMask, + (dpy, c->framewin, False, ButtonMotionMask | ButtonReleaseMask, GrabModeAsync, GrabModeAsync, None, resize_cursor, CurrentTime) != GrabSuccess) usleep(20000); @@ -588,7 +588,7 @@ mouse_resize(Client *c, Align align) return; break; case MotionNotify: - XTranslateCoordinates(dpy, c->frame.win, root, ev.xmotion.x, + XTranslateCoordinates(dpy, c->framewin, root, ev.xmotion.x, ev.xmotion.y, &px, &py, &dummy); if(first) diff --git a/cmd/wm/tag.c b/cmd/wm/tag.c @@ -78,7 +78,7 @@ focus_tag(Tag *t) c = client[i]; if(c->area) { pi = tag2index(c->area->tag); - XMoveWindow(dpy, c->frame.win, px - (pi * rect.width) + c->frame.rect.x, c->frame.rect.y); + XMoveWindow(dpy, c->framewin, px - (pi * rect.width) + c->frect.x, c->frect.y); if(c->area->tag == t) draw_client(c); } 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->frame.rect.x, c->frame.rect.y); + reparent_client(c, root, c->frect.x, c->frect.y); } XSetInputFocus(dpy, PointerRoot, RevertToPointerRoot, CurrentTime); XSync(dpy, False); diff --git a/cmd/wm/wm.h b/cmd/wm/wm.h @@ -100,12 +100,10 @@ struct Client { Window trans; XRectangle rect; XSizeHints size; - struct Frame { - Window win; - XRectangle rect; - GC gc; - Cursor cursor; - } frame; + Window framewin; + XRectangle frect; + GC gc; + Cursor cursor; }; typedef struct Key Key;