diff --git a/src/init.c b/src/init.c index 8f2365e..392a449 100644 --- a/src/init.c +++ b/src/init.c @@ -166,6 +166,8 @@ init_layout(void) {"tile_bottom", tile_bottom }, {"tile_grid", grid }, {"grid", grid }, + {"mirror", mirror }, + {"tile_mirror", mirror }, {"max", maxlayout }, {"maxlayout", maxlayout }, {"freelayout", freelayout }, diff --git a/src/layout.c b/src/layout.c index e55cbb8..1bc7906 100644 --- a/src/layout.c +++ b/src/layout.c @@ -396,6 +396,95 @@ multi_tile(int screen, Position type) return; } +void +mirror(int screen) +{ + Client *c; + XRectangle sg = sgeo[screen]; + XRectangle mastergeo = {sg.x, sg.y, sg.width - (BORDH * 2), sg.height - BORDH}; + XRectangle cgeo = {sg.x, sg.y, sg.width, sg.height}; + XRectangle nextg[2] = { {0} }; + + uint i, n, tilesize, mwfact; + uint nmaster = tags[screen][seltag[screen]].nmaster; + uint border = BORDH * 2; + int pa, imp, isp = 0; + + for(n = 0, c = tiled_client(screen, clients); c; c = tiled_client(screen, c->next), ++n); + CHECK(n); + + /* Fix nmaster */ + nmaster = (n < nmaster) ? n : nmaster; + + imp = (n / 2); + pa = (n / 2) - ((n % 2) ? 0 : 1); + + /* Set mwfact */ + if(tags[screen][seltag[screen]].mwfact < 0.51) + tags[screen][seltag[screen]].mwfact = 0.51; + mwfact = tags[screen][seltag[screen]].mwfact * sg.width; + + /* Master size */ + if(n == 2) + { + mastergeo.width = mwfact - (border + BORDH); + tilesize = (sg.width - mastergeo.width) - border * 2; + } + if(n > 2) + { + mastergeo.x = (sg.x + (sg.width - mwfact)) + BORDH; + mastergeo.y = sg.y; + mastergeo.width = ((2 * mwfact - sg.width) - (border * 2)); + tilesize = (mwfact - mastergeo.width) - ((border * 2) + BORDH); + } + + for(i = 0, c = tiled_client(screen, clients); c; c = tiled_client(screen, c->next), ++i) + { + /* Set client property */ + c->max = c->lmax = False; + c->tile = True; + + if(i < 1) + cgeo = mastergeo; + else + { + cgeo.width = tilesize; + + if((i + 1) % 2) + { + isp = 1; + cgeo.x = sg.x; + cgeo.height = (sg.height / pa) - (TBARH + border); + } + else + { + isp = 0; + cgeo.x = (sg.x + mwfact) - BORDH; + cgeo.height = (sg.height / imp) - (TBARH + border); + } + } + + /* Remainder */ + if(i + 1 == n || i + 1 == n - 1) + cgeo.height = (sg.y + sg.height) - (cgeo.y + BORDH); + + client_moveresize(c, cgeo, tags[screen][seltag[screen]].resizehint); + + nextg[!isp] = c->geo; + + if(i >= 2) + cgeo.y = nextg[isp].y + nextg[isp].height + BORDH + TBARH; + + /* + else if (i < nmaster) + mastergeo.y = c->geo.y + c->geo.height + BORDH + TBARH; + */ + } + + + return; +} + /** Tile Right function */ void diff --git a/src/structs.h b/src/structs.h index fd84a1d..ccdaeb2 100644 --- a/src/structs.h +++ b/src/structs.h @@ -37,7 +37,7 @@ #define NBUTTON 8 #define MAXTAG 36 -#define NUM_OF_LAYOUT 7 +#define NUM_OF_LAYOUT 8 /* Typedef */ typedef const char* uicb_t; diff --git a/src/wmfs.h b/src/wmfs.h index c2881f9..5c62a91 100644 --- a/src/wmfs.h +++ b/src/wmfs.h @@ -264,6 +264,7 @@ Client *tiled_client(int screen, Client *c); /* tile {{{ */ void grid(int screen); void tile(int screen); + void mirror(int screen); void tile_left(int screen); void tile_top(int screen); void tile_bottom(int screen); diff --git a/wmfsrc b/wmfsrc index 68b8f92..301b01b 100644 --- a/wmfsrc +++ b/wmfsrc @@ -39,6 +39,7 @@ layouts layout { type = "tile_top" symbol = "TOP" } layout { type = "tile_bottom" symbol = "BOTTOM" } layout { type = "tile_grid" symbol = "GRID" } + layout { type = "tile_mirror" symbol = "MIRROR" } # Other. layout { type = "max" symbol = "MAX" }