--- dwm.c.orig 2012-03-15 20:02:26.714393218 +0100
+++ src/dwm-6.0/dwm.c 2012-03-15 20:02:12.317726810 +0100
@@ -175,6 +175,7 @@
static void attach(Client *c);
static void attachstack(Client *c);
static void buttonpress(XEvent *e);
+static void chat(Monitor *m);
static void checkotherwm(void);
static void cleanup(void);
static void cleanupmon(Monitor *mon);
@@ -2271,6 +2272,56 @@
}
}
+void
+chat(Monitor *m) {
+ unsigned int n, cols, rows, cn, rn, i, cx, cy, cw, ch, ww;
+ Client *c, *bl = NULL;
+
+ for(n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++)
+ if(strstr(c->name, "emesene"))
+ bl = c;
+ if(n == 0)
+ return;
+
+ /* buddy list */
+ ww = (bl ? m->mfacts[m->curtag] * m->ww : m->ww);
+ if(bl) {
+ resize(bl, m->wx + ww, m->wy, m->ww - ww - 2 * bl->bw, m->wh - 2 * bl->bw, False);
+ if(--n == 0)
+ return;
+ }
+
+ /* grid dimensions */
+ for(cols = 0; cols <= n/2; cols++)
+ if(cols*cols >= n)
+ break;
+ if(n == 5) /* set layout against the general calculation: not 1:2:2, but 2:3 */
+ cols = 2;
+ rows = n/cols;
+
+ /* window geometries */
+ cw = cols ? ww / cols : ww;
+ cn = 0; /* current column number */
+ rn = 0; /* current row number */
+ for(i = 0, c = nexttiled(m->clients); c; i++, c = nexttiled(c->next)) {
+ if(c == bl) {
+ --i;
+ continue;
+ }
+ if(i/rows + 1 > cols - n%cols)
+ rows = n/cols + 1;
+ ch = rows ? m->wh / rows : m->wh;
+ cx = m->wx + cn*cw;
+ cy = m->wy + rn*ch;
+ resize(c, cx, cy, cw - 2 * c->bw, ch - 2 * c->bw, False);
+ rn++;
+ if(rn >= rows) {
+ rn = 0;
+ cn++;
+ }
+ }
+}
+
int
main(int argc, char *argv[]) {
if(argc == 2 && !strcmp("-v", argv[1]))