+void wm_update(void)
+{
+ int x=0, y=0; // Current window top-left position
+ int tx=0, ty=0; // Total x/y size
+ int mx=0, my=0; // Maximum x/y size (screen size)
+ int sy=0; // Size of focused stack window
+
+ /* Scale horizontally */
+ x = wm_root->x;
+ mx = wm_root->w - (list_length(wm_cols)+1)*MARGIN;
+ for (list_t *lx = wm_cols; lx; lx = lx->next)
+ tx += ((col_t*)lx->data)->width;
+ for (list_t *lx = wm_cols; lx; lx = lx->next)
+ ((col_t*)lx->data)->width *= (float)mx / tx;
+
+ /* Scale each column vertically */
+ for (list_t *lx = wm_cols; lx; lx = lx->next) {
+ col_t *col = lx->data;
+ ty = 0;
+ for (list_t *ly = col->rows; ly; ly = ly->next)
+ ty += ((win_t*)ly->data)->h;
+ y = wm_root->y;
+ my = wm_root->h - (list_length(col->rows)+1)*MARGIN;
+ sy = my - (list_length(col->rows)-1)*STACK;
+ for (list_t *ly = col->rows; ly; ly = ly->next) {
+ win_t *win = ly->data;
+ int height = 0;
+ switch (col->mode) {
+ case split:
+ sys_move(win, x+MARGIN, y+MARGIN,
+ col->width, win->h * ((float)my / ty));
+ height = win->h;
+ break;
+ case stack:
+ height = col->focus == win ? sy : STACK;
+ sys_move(win, x+MARGIN, y+MARGIN,
+ col->width, height);
+ break;
+ case max:
+ case tab:
+ sys_move(win, x+MARGIN, 0+MARGIN,
+ col->width, wm_root->h-2*MARGIN);
+ if (col->focus == win)
+ sys_raise(win);
+ break;
+ }
+ y += height + MARGIN;
+ }
+ x += col->width + MARGIN;
+ }
+}
+