commit 9ef8acd057e36fdcfe5434dca46a70663443f2a6
parent d564fe9b171fcf922b540558c091bbc77013a238
Author: Anselm R. Garbe <garbeam@wmii.de>
Date: Mon, 23 Jan 2006 21:00:25 +0200
removed Frame->clients and Frame->nclients, changed it to Frame->client instead (only first step)
Diffstat:
6 files changed, 58 insertions(+), 112 deletions(-)
diff --git a/cmd/wm/client.c b/cmd/wm/client.c
@@ -194,32 +194,25 @@ destroy_client(Client * c)
/* speed reasoned function for client property change */
void
-draw_client(Client * client)
+draw_client(Client *c)
{
- Frame *f = client->frame;
- unsigned int i = 0, tw, tabh = tab_height(f);
+ Frame *f = c->frame;
+ unsigned int tabh = tab_height(f);
Draw d = { 0 };
- Client *c;
if(!tabh)
return;
- tw = f->rect.width / f->nclients;
- for(c = f->clients; c && c != client; c = c->next)
- i++;
-
d.drawable = f->win;
d.gc = f->gc;
- d.rect.x = i * tw;
+ d.rect.x = 0;
d.rect.y = 0;
- d.rect.width = tw;
- if(i && (i == f->nclients - 1))
- d.rect.width = f->rect.width - d.rect.x;
+ d.rect.width = f->rect.width;
d.rect.height = tabh;
d.data = c->name;
d.font = font;
- if((f == sel_frame()) && (c == f->sel)) {
+ if(f == sel_frame()) {
d.bg = blitz_loadcolor(dpy, screen_num, def[WM_SEL_BG_COLOR]->content);
d.fg = blitz_loadcolor(dpy, screen_num, def[WM_SEL_FG_COLOR]->content);
d.border = blitz_loadcolor(dpy, screen_num, def[WM_SEL_BORDER_COLOR]->content);
@@ -233,14 +226,6 @@ draw_client(Client * client)
}
void
-draw_clients(Frame * f)
-{
- Client *c;
- for(c = f->clients; c; c = c->next)
- draw_client(c);
-}
-
-void
gravitate(Client * c, unsigned int tabh, unsigned int bw, int invert)
{
int dx = 0, dy = 0;
diff --git a/cmd/wm/frame.c b/cmd/wm/frame.c
@@ -168,7 +168,7 @@ resize_frame(Frame * f, XRectangle * r, XPoint * pt)
Layout *l = f->layout;
unsigned int tabh = tab_height(f);
unsigned int bw = border_width(f);
- Client *c;
+ Client *c = f->client;
l->def->resize(f, r, pt);
@@ -182,15 +182,15 @@ resize_frame(Frame * f, XRectangle * r, XPoint * pt)
XMoveResizeWindow(dpy, f->win, f->rect.x, f->rect.y, f->rect.width,
f->rect.height);
- for(c = f->clients; c; c = c->next) {
- c->rect.x = bw;
- c->rect.y = tabh ? tabh : bw;
- c->rect.width = c->frame->rect.width - 2 * bw;
- c->rect.height = c->frame->rect.height - bw - (tabh ? tabh : bw);
- XMoveResizeWindow(dpy, c->win, c->rect.x, c->rect.y, c->rect.width,
- c->rect.height);
- configure_client(c);
- }
+ if(f->client) {
+ c->rect.x = bw;
+ c->rect.y = tabh ? tabh : bw;
+ c->rect.width = c->frame->rect.width - 2 * bw;
+ c->rect.height = c->frame->rect.height - bw - (tabh ? tabh : bw);
+ XMoveResizeWindow(dpy, c->win, c->rect.x, c->rect.y, c->rect.width,
+ c->rect.height);
+ configure_client(c);
+ }
}
/**
@@ -238,7 +238,7 @@ draw_frame(Frame * f)
blitz_drawlabel(dpy, &d);
}
- draw_clients(f);
+ draw_client(f->client);
XSync(dpy, False);
}
@@ -246,9 +246,7 @@ void
handle_frame_buttonpress(XButtonEvent * e, Frame * f)
{
Align align;
- int bindex, cindex = e->x / (f->rect.width / f->nclients);
- Client *new = clientat(f->clients, cindex);
- f->layout->def->focus(f->layout, new, False);
+ int bindex;
if(e->button == Button1) {
align = cursor_to_align(f->cursor);
if(align == CENTER)
@@ -264,24 +262,13 @@ handle_frame_buttonpress(XButtonEvent * e, Frame * f)
}
void
-attach_client_to_frame(Frame * f, Client * client)
+attach_client_to_frame(Frame * f, Client * c)
{
- Client *c;
- for(c = f->clients; c && c->next; c = c->next);
- if(!c) {
- f->clients = client;
- client->prev = client->next = nil;
- } else {
- client->prev = c;
- client->next = nil;
- c->next = client;
- }
- /*f->sel = client;*/
- f->nclients++;
- client->frame = f;
+ f->client = c;
+ c->frame = f;
resize_frame(f, &f->rect, 0);
- reparent_client(client, f->win, client->rect.x, client->rect.y);
- map_client(client);
+ reparent_client(c, f->win, c->rect.x, c->rect.y);
+ map_client(c);
}
void
@@ -293,17 +280,7 @@ detach_client_from_frame(Client * c, Bool unmap)
if(f->sel == c)
f->sel = nil;
- if(f->clients == c) {
- if(c->next)
- c->next->prev = nil;
- f->clients = c->next;
- } else {
- c->prev->next = c->next;
- if(c->next)
- c->next->prev = c->prev;
- }
-
- f->nclients--;
+ f->client = nil;
if(!c->destroyed) {
if(!unmap) {
diff --git a/cmd/wm/layout_column.c b/cmd/wm/layout_column.c
@@ -197,17 +197,16 @@ deinit_column(Layout *l)
Column *column = acme->columns;
while((f = acme->frames)) {
- while((cl = f->clients)) {
- detach_client_from_frame(cl, False);
- cl->prev = cl->next = 0;
- if(!c)
- res = c = cl;
- else {
- c->next = cl;
- cl->prev = c;
- c = cl;
- }
- }
+ cl = f->client;
+ detach_client_from_frame(cl, False);
+ cl->prev = cl->next = 0;
+ if(!c)
+ res = c = cl;
+ else {
+ c->next = cl;
+ cl->prev = c;
+ c = cl;
+ }
detach_frame(l, f);
destroy_frame(f);
}
@@ -273,11 +272,8 @@ detach_column(Layout *l, Client * c, Bool unmap)
Column *column = old->column;
detach_client_from_frame(c, unmap);
- if(!f->clients) {
- detach_frame(l, f);
- destroy_frame(f);
- } else
- return;
+ detach_frame(l, f);
+ destroy_frame(f);
if(column->cells) {
if(column->sel == old)
column->sel = column->cells;
diff --git a/cmd/wm/layout_float.c b/cmd/wm/layout_float.c
@@ -123,17 +123,16 @@ deinit_float(Layout *l)
Frame *f;
while((f = fl->frames)) {
- while((cl = f->clients)) {
- detach_client_from_frame(cl, False);
- cl->prev = cl->next = 0;
- if(!res)
- res = c = cl;
- else {
- c->next = cl;
- cl->prev = c;
- c = cl;
- }
- }
+ cl = f->client;
+ detach_client_from_frame(cl, False);
+ cl->prev = cl->next = 0;
+ if(!res)
+ res = c = cl;
+ else {
+ c->next = cl;
+ cl->prev = c;
+ c = cl;
+ }
detach_frame(l, f);
destroy_frame(f);
}
@@ -168,10 +167,8 @@ detach_float(Layout *l, Client * c, Bool unmap)
{
Frame *f = c->frame;
detach_client_from_frame(c, unmap);
- if(!f->clients) {
- detach_frame(l, f);
- destroy_frame(f);
- }
+ detach_frame(l, f);
+ destroy_frame(f);
}
static void
diff --git a/cmd/wm/wm.c b/cmd/wm/wm.c
@@ -466,14 +466,12 @@ win_to_client(Window w)
Frame *f;
if(p->managed->def)
for(f = p->managed->def->frames(p->managed); f; f = f->next) {
- for(c = f->clients; c; c = c->next)
- if(c->win == w)
- return c;
+ if(f->client->win == w)
+ return f->client;
}
for(f = p->floating->def->frames(p->floating); f; f = f->next) {
- for(c = f->clients; c; c = c->next)
- if(c->win == w)
- return c;
+ if(f->client->win == w)
+ return f->client;
}
}
return nil;
@@ -774,17 +772,12 @@ static void
cleanup()
{
Page *p;
- Client *c;
for(p = pages; p; p = p->next) {
Frame *f;
- for(f = p->managed->def->frames(p->managed); f; f = f->next) {
- while((c = f->clients))
- detach_client_from_frame(c, False);
- }
- for(f = p->floating->def->frames(p->floating); f; f = f->next) {
- while((c = f->clients))
- detach_client_from_frame(c, False);
- }
+ for(f = p->managed->def->frames(p->managed); f; f = f->next)
+ detach_client_from_frame(f->client, False);
+ for(f = p->floating->def->frames(p->floating); f; f = f->next)
+ detach_client_from_frame(f->client, False);
}
XSetInputFocus(dpy, PointerRoot, RevertToPointerRoot, CurrentTime);
XSync(dpy, False);
diff --git a/cmd/wm/wm.h b/cmd/wm/wm.h
@@ -136,8 +136,7 @@ struct Frame {
Layout *layout;
Window win;
Client *sel;
- Client *clients;
- size_t nclients;
+ Client *client;
Bool maximized;
XRectangle old;
GC gc;
@@ -221,7 +220,6 @@ void configure_client(Client * c);
void handle_client_property(Client * c, XPropertyEvent * e);
void close_client(Client * c);
void draw_client(Client * client);
-void draw_clients(Frame * f);
void gravitate(Client * c, unsigned int tabh, unsigned int bw, int invert);
void grab_client(Client * c, unsigned long mod, unsigned int button);
void ungrab_client(Client * c, unsigned long mod, unsigned int button);
@@ -243,7 +241,7 @@ void destroy_frame(Frame * f);
void resize_frame(Frame * f, XRectangle * r, XPoint * pt);
void draw_frame(Frame * f);
void handle_frame_buttonpress(XButtonEvent * e, Frame * f);
-void attach_client_to_frame(Frame * f, Client * client);
+void attach_client_to_frame(Frame * f, Client * c);
void detach_client_from_frame(Client * client, Bool unmap);
unsigned int tab_height(Frame * f);
unsigned int border_width(Frame * f);