+}
+
+void
+horizontal_init(void)
+{
+ DNPRINTF(SWM_D_EVENT, "horizontal_init: workspace: %d\n", current_ws);
+}
+
+void
+horizontal_stack(void) {
+ XWindowChanges wc;
+ struct ws_win wf, *win, *winfocus = &wf;
+ int i, h, w, x, y, hrw, winno;
+ int floater = 0;
+ unsigned int mask;
+
+ DNPRINTF(SWM_D_EVENT, "horizontal_stack: workspace: %d\n", current_ws);
+
+ winfocus->id = root;
+
+ winno = count_win(current_ws, 0);
+ if (winno == 0)
+ return;
+
+ if (winno > 1)
+ h = height / 2;
+ else
+ h = height;
+
+ if (winno > 2)
+ hrw = width / (winno - 1);
+ else
+ hrw = 0;
+
+ x = 0;
+ y = bar_enabled ? bar_height : 0;
+ w = width;
+ i = 0;
+ TAILQ_FOREACH (win, &ws[current_ws].winlist, entry) {
+ if (i == 1) {
+ y += h + 2;
+ h -= 2;
+ }
+ if (i != 0 && hrw != 0) {
+ /* correct the last window for lost pixels */
+ if (win == TAILQ_LAST(&ws[current_ws].winlist,
+ ws_win_list)) {
+ w = width - (i * hrw);
+ if (w == 0)
+ w = hrw;
+ else
+ w += hrw;
+ x += hrw;
+ } else {
+ w = hrw - 2;
+ /* leave first bottom window at x = 0 */
+ if (i > 1)
+ x += w + 2;
+ }
+ }
+
+ if (win->transient != 0 || win->floating != 0)
+ floater = 1;
+ else
+ floater = 0;
+
+ bzero(&wc, sizeof wc);
+ wc.border_width = 1;
+ if (floater == 0) {
+ win->x = wc.x = x;
+ win->y = wc.y = y;
+ win->width = wc.width = w;
+ win->height = wc.height = h;
+ mask = CWX | CWY | CWWidth | CWHeight | CWBorderWidth;
+ } else {
+ /* make sure we don't clobber the screen */
+ if (win->wa.width > width)
+ win->wa.width = width;
+ if (win->wa.height > height)
+ win->wa.width = height;
+ win->x = wc.x = (width - win->wa.width) / 2;
+ win->y = wc.y = (height - win->wa.height) / 2;
+ mask = CWX | CWY | CWBorderWidth;
+ }
+ XConfigureWindow(display, win->id, mask, &wc);
+
+ if (win == ws[current_ws].focus)
+ winfocus = win;
+ else
+ unfocus_win(win);
+ XMapRaised(display, win->id);
+ i++;
+ }
+
+ focus_win(winfocus); /* this has to be done outside of the loop */
+}
+
+/* fullscreen view */
+void
+max_init(void)
+{
+ DNPRINTF(SWM_D_EVENT, "max_init: workspace: %d\n", current_ws);
+}
+
+void
+max_stack(void) {
+ XWindowChanges wc;
+ struct ws_win wf, *win, *winfocus = &wf;
+ int i, h, w, x, y, winno;
+ unsigned int mask;
+
+ DNPRINTF(SWM_D_EVENT, "max_stack: workspace: %d\n", current_ws);
+
+ winfocus->id = root;
+
+ winno = count_win(current_ws, 0);
+ if (winno == 0)
+ return;
+
+ x = 0;
+ y = bar_enabled ? bar_height : 0;
+ TAILQ_FOREACH (win, &ws[current_ws].winlist, entry) {
+ if (i == 1 && win->transient == 0 && win->floating != 0) {
+ h = height - 2;
+ w = width - 2;
+
+ winfocus = win;
+
+ bzero(&wc, sizeof wc);
+ wc.border_width = 1;
+ win->x = wc.x = x;
+ win->y = wc.y = y;
+ win->width = wc.width = w;
+ win->height = wc.height = h;
+ mask = CWX | CWY | CWWidth | CWHeight | CWBorderWidth;
+ XConfigureWindow(display, win->id, mask, &wc);
+
+ XMapRaised(display, win->id);
+ } else {
+ /* hide all but the master window */
+ XUnmapWindow(display, win->id);
+ }
+ i++;
+ }
+
+ focus_win(winfocus); /* this has to be done outside of the loop */