+#define GUTTER_PX 4
+#define TAB_HEIGHT (bh / 2 - GUTTER_PX)
+#define TAB_PAD GUTTER_PX
+
+void
+jason_layout(Monitor *m) {
+ unsigned int i, tiled_count, mw, right_width, tab_counts[2] = {0,0}, cur_tab = 0, *tab_count;
+ int tab_top;
+ Client *c, *vis_slave = 0, *base = 0;
+
+ tab_count = &(tab_counts[0]);
+
+ for(tiled_count = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), tiled_count++) {
+ if (tiled_count == 0) { // master
+ if (c->next) {
+ if (m->sel && (m->sel == c || m->sel->isfloating || !ISVISIBLE(m->sel))) {
+ vis_slave = nexttiled(c->next);
+ } else {
+ vis_slave = m->sel;
+ }
+ }
+ } else {
+ if (c == vis_slave) {
+ tab_count = &(tab_counts[1]);
+ } else {
+ (*tab_count) += 1;
+ }
+ }
+ }
+ if(tiled_count == 0) {
+ return;
+ }
+
+ if(tiled_count > 1 || (tiled_count == 1 && !nexttiled(m->clients)->screen_hog)) {
+ mw = m->ww * m->mfact;
+ } else {
+ mw = m->ww;
+ }
+ right_width = m->ww - mw - GUTTER_PX;
+ tab_count = &(tab_counts[0]);
+ tab_top = m->my - m->wh + TAB_HEIGHT;
+ for (i = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) {
+ if (i == 0) {
+ resize(c, m->wx, m->wy, mw, m->wh, False, 0);
+ } else {
+ if (c == vis_slave) {
+ resize(c,
+ m->wx + mw + GUTTER_PX,
+ m->my + TAB_HEIGHT + TAB_PAD,
+ right_width,
+ m->wh,
+ False,
+ base
+ );
+ tab_count = &(tab_counts[1]);
+ tab_top = m->my + m->mh - TAB_HEIGHT;
+ cur_tab = 0;
+ } else {
+ // this function does not get called when focus changes
+ // resize(c, m->wx + m->ww, m->wy, m->ww - mw, m->wh, False);
+ resize(c,
+ m->wx + mw + GUTTER_PX + right_width * cur_tab / (*tab_count),
+ tab_top,
+ right_width,
+ m->wh,
+ False,
+ base
+ );
+ cur_tab += 1;
+ }
+ }
+ base = c;
+ }
+}
+