commit c3b5fb7619fc8a86d376dce9f4fddbd71770fc5e
parent 5704f29b691cae0c532506c912532bf6a686f90a
Author: Anselm R. Garbe <garbeam@wmii.de>
Date: Mon, 27 Feb 2006 16:09:13 +0100
minimized movement overhead on attaching/sendtopage through a saner attach_client_to_page function
Diffstat:
3 files changed, 33 insertions(+), 24 deletions(-)
diff --git a/cmd/wm/client.c b/cmd/wm/client.c
@@ -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];
+ reparent_client(c, c->frame.win, c->rect.x, c->rect.y);
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
diff --git a/cmd/wm/page.c b/cmd/wm/page.c
@@ -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)))
diff --git a/cmd/wm/wm.h b/cmd/wm/wm.h
@@ -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);