minimized movement overhead on attaching/sendtopage through a saner attach_client_to_page function

This commit is contained in:
Anselm R. Garbe 2006-02-27 16:09:13 +01:00
parent 5704f29b69
commit c3b5fb7619
3 changed files with 33 additions and 24 deletions

View File

@ -362,17 +362,14 @@ gravitate(Client * c, unsigned int tabh, unsigned int bw, int invert)
}
void
attach_client(Client *c)
attach_client_to_page(Page *p, Client *c)
{
Page *p;
if(!page)
p = alloc_page();
else
p = page[sel];
Area *a = p->area[p->sel];
int pi = page_to_index(p);
int px = sel * rect.width;
reparent_client(c, c->frame.win, c->rect.x, c->rect.y);
Area *a = p->area[p->sel];
a->client = (Client **)cext_array_attach((void **)a->client, c,
sizeof(Client *), &a->clientsz);
a->nclient++;
@ -381,8 +378,22 @@ attach_client(Client *c)
arrange_column(a);
else /* normal mode */
resize_client(c, &c->frame.rect, nil);
XMoveWindow(dpy, c->frame.win,
px - (pi * rect.width) + c->frame.rect.x, c->frame.rect.y);
map_client(c);
XMapWindow(dpy, c->frame.win);
}
void
attach_client(Client *c)
{
Page *p;
if(!page)
p = alloc_page();
else
p = page[sel];
attach_client_to_page(p, c);
focus_client(c, True);
}
@ -577,24 +588,19 @@ select_client(Client *c, char *arg)
void
sendtopage_client(Client *c, char *arg) {
const char *errstr;
Page *p;
Page *selp = page[sel];
int i;
if(!strncmp(arg, "new", 4))
p = alloc_page();
else {
i = cext_strtonum(arg, 1, npage, &errstr);
const char *errstr;
int i = cext_strtonum(arg, 1, npage, &errstr);
if(errstr)
return;
p = page[i - 1];
}
detach_client(c, False);
focus_page(p);
attach_client(c);
focus_page(selp);
attach_client_to_page(p, c);
}
void

View File

@ -68,21 +68,23 @@ focus_page(Page *p)
Page *old = page ? page[sel] : nil;
char buf[16];
Client *c;
int i = page_to_index(p);
int i, pi = page_to_index(p);
int px;
if(!npage || (i == -1))
if(!npage || (pi == -1))
return;
if(old && old != p)
p->revert = old;
sel = i;
sel = pi;
px = sel * rect.width;
for(i = 0; i < nclient; i++) {
c = client[i];
if(old && (old != p) && (c->area && c->area->page == old))
XMoveWindow(dpy, c->frame.win, 2 * rect.width, 2 * rect.height);
else if(c->area && c->area->page == p) {
XMoveWindow(dpy, c->frame.win, c->frame.rect.x, c->frame.rect.y);
draw_client(c);
if(c->area) {
pi = page_to_index(c->area->page);
XMoveWindow(dpy, c->frame.win, px - (pi * rect.width) + c->frame.rect.x, c->frame.rect.y);
if(c->area->page == p)
draw_client(c);
}
}
if((c = sel_client_of_page(p)))

View File

@ -213,6 +213,7 @@ void unmap_client(Client *c);
void map_client(Client *c);
void reparent_client(Client *c, Window w, int x, int y);
void attach_client(Client *c);
void attach_client_to_page(Page *p, Client *c);
void detach_client(Client *c, Bool unmap);
Client *sel_client();
Client *sel_client_of_page(Page *p);