if (winfocus == winlostfocus)
return;
+ XMapRaised(display, winfocus->id);
focus_win(winfocus);
XSync(display, False);
}
XConfigureWindow(display, win->id, mask, &wc);
}
+#define SWAPXY(g) do { \
+ int tmp; \
+ tmp = (g)->y; (g)->y = (g)->x; (g)->x = tmp; \
+ tmp = (g)->h; (g)->h = (g)->w; (g)->w = tmp; \
+} while (0);
void
-vertical_config(struct workspace *ws, int id)
+stack_master(struct workspace *ws, struct swm_geometry *g, int rot, int flip)
{
- DNPRINTF(SWM_D_STACK, "vertical_resize: workspace: %d\n", ws->idx);
-
- switch (id) {
- case SWM_ARG_ID_STACKRESET:
- case SWM_ARG_ID_STACKINIT:
- ws->l_state.vertical_msize = SWM_V_SLICE / 2;
- ws->l_state.vertical_mwin = 1;
- break;
- case SWM_ARG_ID_MASTERSHRINK:
- if (ws->l_state.vertical_msize > 1)
- ws->l_state.vertical_msize--;
- break;
- case SWM_ARG_ID_MASTERGROW:
- if (ws->l_state.vertical_msize < SWM_V_SLICE - 1)
- ws->l_state.vertical_msize++;
- break;
- case SWM_ARG_ID_MASTERADD:
- ws->l_state.vertical_mwin++;
- break;
- case SWM_ARG_ID_MASTERDEL:
- if (ws->l_state.vertical_mwin > 0)
- ws->l_state.vertical_mwin--;
- break;
- default:
- return;
- }
-}
-
-void
-vertical_stack(struct workspace *ws, struct swm_geometry *g) {
XWindowChanges wc;
- struct swm_geometry gg = *g;
+ struct swm_geometry win_g, r_g = *g;
struct ws_win *win, *winfocus;
- int i, j, split, colno, hrh, winno, main_width;
+ int i, j;
+ int split, colno, hrh, winno, mwin, msize, mscale;
unsigned int mask;
- DNPRINTF(SWM_D_STACK, "vertical_stack: workspace: %d\n", ws->idx);
+ DNPRINTF(SWM_D_STACK, "stack_master: workspace: %d\n rot=%s flip=%s",
+ ws->idx, rot ? "yes" : "no", flip ? "yes" : "no");
if ((winno = count_win(ws, 0)) == 0)
return;
ws->focus = TAILQ_FIRST(&ws->winlist);
winfocus = cur_focus ? cur_focus : ws->focus;
- if (ws->l_state.vertical_mwin &&
- winno > ws->l_state.vertical_mwin) {
- split = ws->l_state.vertical_mwin;
+ if (rot) {
+ mwin = ws->l_state.horizontal_mwin;
+ mscale = ws->l_state.horizontal_msize;
+ SWAPXY(&r_g);
+ } else {
+ mwin = ws->l_state.vertical_mwin;
+ mscale = ws->l_state.vertical_msize;
+ }
+ win_g = r_g;
+
+ if (mwin && winno > mwin) {
+ split = mwin;
colno = split;
- main_width = (g->w / SWM_V_SLICE) *
- ws->l_state.vertical_msize;
- gg.w = main_width;
+ msize = (r_g.w / SWM_V_SLICE) * mscale;
+ win_g.w = msize;
+ if (flip)
+ win_g.x += r_g.w - msize;
} else {
colno = winno;
split = 0;
}
- hrh = g->h / colno;
- gg.h = hrh - 2;
+ hrh = r_g.h / colno;
+ win_g.h = hrh - 2;
i = j = 0;
TAILQ_FOREACH(win, &ws->winlist, entry) {
if (split && i == split) {
colno = winno - split;
- hrh = (g->h / colno);
- gg.x += main_width + 2;
- gg.w = g->w - (main_width + 2);
- gg.h = hrh - 2;
+ hrh = (r_g.h / colno);
+ if (flip)
+ win_g.x = r_g.x;
+ else
+ win_g.x += msize + 2;
+ win_g.w = r_g.w - (msize + 2);
+ win_g.h = hrh - 2;
j = 0;
}
if (j == colno - 1)
- gg.h = (hrh + (g->h - (colno * hrh)));
+ win_g.h = (hrh + (r_g.h - (colno * hrh)));
if (j == 0)
- gg.y = g->y;
+ win_g.y = r_g.y;
else
- gg.y += hrh;
+ win_g.y += hrh;
if (win->transient != 0 || win->floating != 0)
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;
+ if (rot) {
+ win->g.x = wc.x = win_g.y;
+ win->g.y = wc.y = win_g.x;
+ win->g.w = wc.width = win_g.h;
+ win->g.h = wc.height = win_g.w;
+ } else {
+ win->g.x = wc.x = win_g.x;
+ win->g.y = wc.y = win_g.y;
+ win->g.w = wc.width = win_g.w;
+ win->g.h = wc.height = win_g.h;
+ }
mask = CWX | CWY | CWWidth | CWHeight | CWBorderWidth;
XConfigureWindow(display, win->id, mask, &wc);
/*
}
void
+vertical_config(struct workspace *ws, int id)
+{
+ DNPRINTF(SWM_D_STACK, "vertical_resize: workspace: %d\n", ws->idx);
+
+ switch (id) {
+ case SWM_ARG_ID_STACKRESET:
+ case SWM_ARG_ID_STACKINIT:
+ ws->l_state.vertical_msize = SWM_V_SLICE / 2;
+ ws->l_state.vertical_mwin = 1;
+ break;
+ case SWM_ARG_ID_MASTERSHRINK:
+ if (ws->l_state.vertical_msize > 1)
+ ws->l_state.vertical_msize--;
+ break;
+ case SWM_ARG_ID_MASTERGROW:
+ if (ws->l_state.vertical_msize < SWM_V_SLICE - 1)
+ ws->l_state.vertical_msize++;
+ break;
+ case SWM_ARG_ID_MASTERADD:
+ ws->l_state.vertical_mwin++;
+ break;
+ case SWM_ARG_ID_MASTERDEL:
+ if (ws->l_state.vertical_mwin > 0)
+ ws->l_state.vertical_mwin--;
+ break;
+ default:
+ return;
+ }
+}
+
+void
+vertical_stack(struct workspace *ws, struct swm_geometry *g)
+{
+ DNPRINTF(SWM_D_STACK, "vertical_stack: workspace: %d\n", ws->idx);
+
+ stack_master(ws, g, 0, 0);
+}
+
+void
horizontal_config(struct workspace *ws, int id)
{
DNPRINTF(SWM_D_STACK, "horizontal_config: workspace: %d\n", ws->idx);
}
void
-horizontal_stack(struct workspace *ws, struct swm_geometry *g) {
- XWindowChanges wc;
- struct swm_geometry gg = *g;
- struct ws_win *win, *winfocus;
- int i, j, split, rowno, 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 (ws->l_state.horizontal_mwin &&
- winno > ws->l_state.horizontal_mwin) {
- split = ws->l_state.horizontal_mwin;
- rowno = split;
- main_height = (g->h / SWM_V_SLICE) *
- ws->l_state.horizontal_msize;
- gg.h = main_height;
- } else {
- rowno = winno;
- split = 0;
- }
- hrw = g->w / rowno;
- gg.w = hrw - 2;
-
- i = j = 0;
- TAILQ_FOREACH(win, &ws->winlist, entry) {
- if (split && i == split) {
- rowno = winno - split;
- hrw = (g->w / rowno);
- gg.y += main_height + 2;
- gg.h = g->h - (main_height + 2);
- gg.w = hrw - 2;
- j = 0;
- }
- if (j == rowno - 1)
- gg.w = (hrw + (g->w - (rowno * hrw)));
-
- if (j == 0)
- gg.x = g->x;
- else
- gg.x += hrw;
-
- 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);
- j++;
- i++;
- }
+horizontal_stack(struct workspace *ws, struct swm_geometry *g)
+{
+ DNPRINTF(SWM_D_STACK, "vertical_stack: workspace: %d\n", ws->idx);
- if (winfocus)
- focus_win(winfocus); /* this has to be done outside of the loop */
+ stack_master(ws, g, 1, 0);
}
/* fullscreen view */