+ x += col->width + MARGIN;
+ }
+}
+
+static void cut_window(win_t *win)
+{
+ list_t *lrow = win->wm->row;
+ list_t *lcol = win->wm->col;
+ col_t *col = lcol->data;
+
+ col->focus = lrow->prev ? lrow->prev->data :
+ lrow->next ? lrow->next->data : NULL;
+
+ wm_focus = col->focus ? col->focus :
+ lcol->prev ? ((col_t*)lcol->prev->data)->focus :
+ lcol->next ? ((col_t*)lcol->next->data)->focus : NULL;
+
+ col->rows = list_remove(col->rows, win->wm->row);
+ if (col->rows == NULL)
+ wm_cols = list_remove(wm_cols, lcol);
+}
+
+static void put_window(win_t *win, list_t *lcol)
+{
+ col_t *col = lcol->data;
+ col->rows = list_insert(col->rows, win);
+ win->wm->row = col->rows;
+ win->wm->col = lcol;
+ col->focus = win;
+ wm_focus = win;
+
+ int nrows = list_length(col->rows);
+ win->h = wm_root->h / MAX(nrows-1,1);
+ if (nrows == 1) { // new column
+ int ncols = list_length(wm_cols);
+ col->width = wm_root->w / MAX(ncols-1,1);