-horizontal_stack(struct workspace *ws, struct swm_geometry *g) {
- XWindowChanges wc;
- struct swm_geometry gg = *g;
- struct ws_win *win, *winfocus;
- int i, hrw, winno, main_height;
- unsigned int mask;
-
- DNPRINTF(SWM_D_STACK, "horizontal_stack: workspace: %d\n", ws->idx);
-
- if ((winno = count_win(ws, 0)) == 0)
- return;
-
- if (ws->focus == NULL)
- ws->focus = TAILQ_FIRST(&ws->winlist);
- winfocus = cur_focus ? cur_focus : ws->focus;
-
- if (winno > 1) {
- main_height = (g->h / SWM_H_SLICE) *
- ws->l_state.horizontal_msize;
- gg.h = main_height;
- }
-
- if (winno > 2)
- hrw = g->w / (winno - 1);
- else
- hrw = 0;
-
- i = 0;
- TAILQ_FOREACH(win, &ws->winlist, entry) {
- if (i == 1) {
- gg.y += main_height + 2;
- gg.h = g->h - (main_height + 2);
- }
- if (i != 0 && hrw != 0) {
- /* correct the last window for lost pixels */
- if (win == TAILQ_LAST(&ws->winlist, ws_win_list)) {
- gg.w = hrw + (g->w - (i * hrw));
- gg.x += hrw;
- } else {
- gg.w = hrw - 2;
- /* leave first bottom window at x = 0 */
- if (i > 1)
- gg.x += gg.w + 2;
- }
- }
-
- if (win->transient != 0 || win->floating != 0)
- stack_floater(win, ws->r);
- else {
- bzero(&wc, sizeof wc);
- wc.border_width = 1;
- win->g.x = wc.x = gg.x;
- win->g.y = wc.y = gg.y;
- win->g.w = wc.width = gg.w;
- win->g.h = wc.height = gg.h;
- mask = CWX | CWY | CWWidth | CWHeight | CWBorderWidth;
- XConfigureWindow(display, win->id, mask, &wc);
- }
-
- XMapRaised(display, win->id);
- i++;
- }