Layout: Add mirror_vertical and mirror_horizontal!
This commit is contained in:
26
src/init.c
26
src/init.c
@@ -160,18 +160,20 @@ init_layout(void)
|
|||||||
|
|
||||||
const func_name_list_t layout_list_tmp[] =
|
const func_name_list_t layout_list_tmp[] =
|
||||||
{
|
{
|
||||||
{"tile_right", tile },
|
{"tile_right", tile },
|
||||||
{"tile_left", tile_left },
|
{"tile_left", tile_left },
|
||||||
{"tile_top", tile_top },
|
{"tile_top", tile_top },
|
||||||
{"tile_bottom", tile_bottom },
|
{"tile_bottom", tile_bottom },
|
||||||
{"tile_grid", grid },
|
{"tile_grid", grid },
|
||||||
{"grid", grid },
|
{"grid", grid },
|
||||||
{"mirror", mirror },
|
{"mirror_vertical", mirror_vertical },
|
||||||
{"tile_mirror", mirror },
|
{"tile_mirror_vertical", mirror_vertical },
|
||||||
{"max", maxlayout },
|
{"mirror_horizontal", mirror_horizontal },
|
||||||
{"maxlayout", maxlayout },
|
{"tile_mirror_horizontal", mirror_horizontal },
|
||||||
{"freelayout", freelayout },
|
{"max", maxlayout },
|
||||||
{"free", freelayout }
|
{"maxlayout", maxlayout },
|
||||||
|
{"freelayout", freelayout },
|
||||||
|
{"free", freelayout }
|
||||||
};
|
};
|
||||||
|
|
||||||
layout_list = emalloc(LEN(layout_list_tmp), sizeof(func_name_list_t));
|
layout_list = emalloc(LEN(layout_list_tmp), sizeof(func_name_list_t));
|
||||||
|
|||||||
142
src/layout.c
142
src/layout.c
@@ -399,14 +399,14 @@ multi_tile(int screen, Position type)
|
|||||||
* \param screen Screen to execute this function
|
* \param screen Screen to execute this function
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
mirror(int screen)
|
mirror(int screen, Bool horizontal)
|
||||||
{
|
{
|
||||||
Client *c;
|
Client *c;
|
||||||
XRectangle sg = sgeo[screen];
|
XRectangle sg = sgeo[screen];
|
||||||
XRectangle mastergeo = {sg.x, sg.y, sg.width - (BORDH * 2), sg.height - BORDH};
|
XRectangle mastergeo = {sg.x, sg.y, sg.width, sg.height};
|
||||||
XRectangle cgeo = {sg.x, sg.y , sg.width, sg.height};
|
XRectangle cgeo = {sg.x, sg.y , sg.width, sg.height};
|
||||||
XRectangle nextg[2] = { {0} };
|
XRectangle nextg[2] = { {0} };
|
||||||
uint i, n, tilewidth, mwfact;
|
uint i, n, tilesize, mwfact;
|
||||||
uint nmaster = tags[screen][seltag[screen]].nmaster;
|
uint nmaster = tags[screen][seltag[screen]].nmaster;
|
||||||
int pa, imp;
|
int pa, imp;
|
||||||
Bool isp = 0;
|
Bool isp = 0;
|
||||||
@@ -421,23 +421,50 @@ mirror(int screen)
|
|||||||
pa = ((n - (nmaster - 1)) / 2) - (((n - (nmaster - 1)) % 2) ? 0 : 1);
|
pa = ((n - (nmaster - 1)) / 2) - (((n - (nmaster - 1)) % 2) ? 0 : 1);
|
||||||
|
|
||||||
/* Set mwfact */
|
/* Set mwfact */
|
||||||
if(tags[screen][seltag[screen]].mwfact < 0.51)
|
if(tags[screen][seltag[screen]].mwfact < 0.55)
|
||||||
tags[screen][seltag[screen]].mwfact = 0.51;
|
tags[screen][seltag[screen]].mwfact = 0.55;
|
||||||
mwfact = tags[screen][seltag[screen]].mwfact * sg.width;
|
|
||||||
|
mwfact = tags[screen][seltag[screen]].mwfact * ((horizontal) ? sg.height : sg.width);
|
||||||
|
|
||||||
/* Master size */
|
/* Master size */
|
||||||
mastergeo.height = (sg.height / nmaster) - (TBARH + (BORDH * 2));
|
if(horizontal)
|
||||||
|
{
|
||||||
|
mastergeo.width = (sg.width / nmaster) - (BORDH * 2);
|
||||||
|
mastergeo.height -= BORDH;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
mastergeo.width -= BORDH * 2;
|
||||||
|
mastergeo.height = (sg.height / nmaster) - (TBARH + (BORDH * 2));
|
||||||
|
}
|
||||||
|
|
||||||
if(n == nmaster + 1)
|
if(n == nmaster + 1)
|
||||||
{
|
{
|
||||||
mastergeo.width = mwfact - (BORDH * 3);
|
if(horizontal)
|
||||||
tilewidth = (sg.width - mastergeo.width) - (BORDH * 4);
|
{
|
||||||
|
mastergeo.height = mwfact - ((BORDH * 2) + TBARH);
|
||||||
|
tilesize = (sg.height - mastergeo.height) - ((BORDH * 2) + TBARH);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
mastergeo.width = mwfact - (BORDH * 3);
|
||||||
|
tilesize = (sg.width - mastergeo.width) - (BORDH * 4);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if(n > nmaster + 1)
|
if(n > nmaster + 1)
|
||||||
{
|
{
|
||||||
mastergeo.x = (sg.x + (sg.width - mwfact)) + BORDH;
|
if(horizontal)
|
||||||
mastergeo.width = ((2 * mwfact - sg.width) - (BORDH * 4));
|
{
|
||||||
tilewidth = (mwfact - mastergeo.width) - ((BORDH * 4) + BORDH);
|
mastergeo.y = (sg.y + (sg.height - mwfact)) + TBARH + BORDH;
|
||||||
|
mastergeo.height = (2 * mwfact - sg.height) - ((BORDH * 3) + (TBARH * 2));
|
||||||
|
tilesize = (mwfact - mastergeo.height) - ((BORDH * 3) + (TBARH * 2));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
mastergeo.x = (sg.x + (sg.width - mwfact)) + BORDH;
|
||||||
|
mastergeo.width = ((2 * mwfact - sg.width) - (BORDH * 4));
|
||||||
|
tilesize = (mwfact - mastergeo.width) - (BORDH * 5);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for(i = 0, c = tiled_client(screen, clients); c; c = tiled_client(screen, c->next), ++i)
|
for(i = 0, c = tiled_client(screen, clients); c; c = tiled_client(screen, c->next), ++i)
|
||||||
@@ -452,28 +479,59 @@ mirror(int screen)
|
|||||||
|
|
||||||
/* Master remainder */
|
/* Master remainder */
|
||||||
if(i + 1 == nmaster)
|
if(i + 1 == nmaster)
|
||||||
cgeo.height = (sg.y + sg.height) - (cgeo.y + BORDH);
|
{
|
||||||
|
if(horizontal)
|
||||||
|
cgeo.width = (sg.x + sg.width) - (cgeo.x + (BORDH * 2));
|
||||||
|
else
|
||||||
|
cgeo.height = (sg.y + sg.height) - (cgeo.y + BORDH);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
cgeo.width = tilewidth;
|
if(horizontal)
|
||||||
|
cgeo.height = tilesize;
|
||||||
|
else
|
||||||
|
cgeo.width = tilesize;
|
||||||
|
|
||||||
if((i + nmaster) % 2)
|
if((i + nmaster) % 2)
|
||||||
{
|
{
|
||||||
isp = 1;
|
isp = 1;
|
||||||
cgeo.x = sg.x;
|
|
||||||
cgeo.height = (sg.height / pa) - (TBARH + (BORDH * 2));
|
if(horizontal)
|
||||||
|
{
|
||||||
|
cgeo.y = sg.y;
|
||||||
|
cgeo.width = (sg.width / pa) - (BORDH * 2);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
cgeo.x = sg.x;
|
||||||
|
cgeo.height = (sg.height / pa) - (TBARH + (BORDH * 2));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
isp = 0;
|
isp = 0;
|
||||||
cgeo.x = (sg.x + mwfact) - BORDH;
|
|
||||||
cgeo.height = (sg.height / imp) - (TBARH + (BORDH * 2));
|
if(horizontal)
|
||||||
|
{
|
||||||
|
cgeo.y = (sg.y + mwfact) - BORDH;
|
||||||
|
cgeo.width = (sg.width / imp) - (BORDH * 2);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
cgeo.x = (sg.x + mwfact) - BORDH;
|
||||||
|
cgeo.height = (sg.height / imp) - (TBARH + (BORDH * 2));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Remainder */
|
/* Remainder */
|
||||||
if(i + 1 == n || i + 1 == n - 1)
|
if(i + 1 == n || i + 1 == n - 1)
|
||||||
cgeo.height = (sg.y + sg.height) - (cgeo.y + BORDH);
|
{
|
||||||
|
if(horizontal)
|
||||||
|
cgeo.width = (sg.x + sg.width) - (cgeo.x + (BORDH * 2));
|
||||||
|
else
|
||||||
|
cgeo.height = (sg.y + sg.height) - (cgeo.y + BORDH);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
client_moveresize(c, cgeo, tags[screen][seltag[screen]].resizehint);
|
client_moveresize(c, cgeo, tags[screen][seltag[screen]].resizehint);
|
||||||
@@ -481,16 +539,31 @@ mirror(int screen)
|
|||||||
if(i >= nmaster)
|
if(i >= nmaster)
|
||||||
nextg[!isp] = c->geo;
|
nextg[!isp] = c->geo;
|
||||||
|
|
||||||
/* Next y position */
|
/* Next y/x position */
|
||||||
if(i >= nmaster - 1)
|
if(i >= nmaster - 1)
|
||||||
{
|
{
|
||||||
if(i == nmaster || i == nmaster - 1)
|
if(horizontal)
|
||||||
cgeo.y = sg.y;
|
{
|
||||||
|
if(i == nmaster || i == nmaster - 1)
|
||||||
|
cgeo.x = sg.x;
|
||||||
|
else
|
||||||
|
cgeo.x = nextg[isp].x + nextg[isp].width + BORDH * 2;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
cgeo.y = nextg[isp].y + nextg[isp].height + BORDH + TBARH;
|
{
|
||||||
|
if(i == nmaster || i == nmaster - 1)
|
||||||
|
cgeo.y = sg.y;
|
||||||
|
else
|
||||||
|
cgeo.y = nextg[isp].y + nextg[isp].height + BORDH + TBARH;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (i <= nmaster - 1)
|
else if (i <= nmaster - 1)
|
||||||
mastergeo.y = c->geo.y + c->geo.height + BORDH + TBARH;
|
{
|
||||||
|
if(horizontal)
|
||||||
|
mastergeo.x = c->geo.x + c->geo.width + BORDH * 2;
|
||||||
|
else
|
||||||
|
mastergeo.y = c->geo.y + c->geo.height + BORDH + TBARH;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -529,7 +602,6 @@ tile_top(int screen)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/** Tile Bottom function
|
/** Tile Bottom function
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
@@ -540,6 +612,26 @@ tile_bottom(int screen)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Mirror tile vertical function
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
mirror_vertical(int screen)
|
||||||
|
{
|
||||||
|
mirror(screen, False);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Mirror tile horizontal function
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
mirror_horizontal(int screen)
|
||||||
|
{
|
||||||
|
mirror(screen, True);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
/** Put the selected client to the master postion
|
/** Put the selected client to the master postion
|
||||||
* \param cmd uicb_t type unused
|
* \param cmd uicb_t type unused
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -37,7 +37,7 @@
|
|||||||
|
|
||||||
#define NBUTTON 8
|
#define NBUTTON 8
|
||||||
#define MAXTAG 36
|
#define MAXTAG 36
|
||||||
#define NUM_OF_LAYOUT 8
|
#define NUM_OF_LAYOUT 9
|
||||||
|
|
||||||
/* Typedef */
|
/* Typedef */
|
||||||
typedef const char* uicb_t;
|
typedef const char* uicb_t;
|
||||||
|
|||||||
@@ -264,10 +264,11 @@ Client *tiled_client(int screen, Client *c);
|
|||||||
/* tile {{{ */
|
/* tile {{{ */
|
||||||
void grid(int screen);
|
void grid(int screen);
|
||||||
void tile(int screen);
|
void tile(int screen);
|
||||||
void mirror(int screen);
|
|
||||||
void tile_left(int screen);
|
void tile_left(int screen);
|
||||||
void tile_top(int screen);
|
void tile_top(int screen);
|
||||||
void tile_bottom(int screen);
|
void tile_bottom(int screen);
|
||||||
|
void mirror_vertical(int screen);
|
||||||
|
void mirror_horizontal(int screen);
|
||||||
/* }}} */
|
/* }}} */
|
||||||
void uicb_tile_switch(uicb_t);
|
void uicb_tile_switch(uicb_t);
|
||||||
void uicb_togglemax(uicb_t);
|
void uicb_togglemax(uicb_t);
|
||||||
|
|||||||
13
wmfsrc
13
wmfsrc
@@ -34,12 +34,13 @@ layouts
|
|||||||
system = "menu"
|
system = "menu"
|
||||||
|
|
||||||
# Tiling layouts.
|
# Tiling layouts.
|
||||||
layout { type = "tile_right" symbol = "RIGHT" }
|
layout { type = "tile_right" symbol = "RIGHT" }
|
||||||
layout { type = "tile_left" symbol = "LEFT" }
|
layout { type = "tile_left" symbol = "LEFT" }
|
||||||
layout { type = "tile_top" symbol = "TOP" }
|
layout { type = "tile_top" symbol = "TOP" }
|
||||||
layout { type = "tile_bottom" symbol = "BOTTOM" }
|
layout { type = "tile_bottom" symbol = "BOTTOM" }
|
||||||
layout { type = "tile_grid" symbol = "GRID" }
|
layout { type = "tile_grid" symbol = "GRID" }
|
||||||
layout { type = "tile_mirror" symbol = "MIRROR" }
|
layout { type = "mirror_vertical" symbol = "MIRROR_V" }
|
||||||
|
layout { type = "mirror_horizontal" symbol = "MIRROR_H" }
|
||||||
|
|
||||||
# Other.
|
# Other.
|
||||||
layout { type = "max" symbol = "MAX" }
|
layout { type = "max" symbol = "MAX" }
|
||||||
|
|||||||
Reference in New Issue
Block a user