Layout: Add nmaster support to new Mirror layout.
This commit is contained in:
parent
c1bcd7c405
commit
44aa82eb4e
@ -142,7 +142,7 @@ init_root(void)
|
|||||||
XChangeWindowAttributes(dpy, ROOT, CWEventMask | CWCursor, &at);
|
XChangeWindowAttributes(dpy, ROOT, CWEventMask | CWCursor, &at);
|
||||||
|
|
||||||
if(conf.root.background_command)
|
if(conf.root.background_command)
|
||||||
uicb_spawn(conf.root.background_command);
|
spawn(conf.root.background_command);
|
||||||
|
|
||||||
ewmh_init_hints();
|
ewmh_init_hints();
|
||||||
ewmh_get_number_of_desktop();
|
ewmh_get_number_of_desktop();
|
||||||
|
|||||||
98
src/layout.c
98
src/layout.c
@ -276,8 +276,7 @@ multi_tile(int screen, Position type)
|
|||||||
XRectangle sg = sgeo[screen];
|
XRectangle sg = sgeo[screen];
|
||||||
XRectangle mastergeo = {sg.x, sg.y, 0, 0};
|
XRectangle mastergeo = {sg.x, sg.y, 0, 0};
|
||||||
XRectangle cgeo = {sg.x, sg.y, 0, 0};
|
XRectangle cgeo = {sg.x, sg.y, 0, 0};
|
||||||
uint i , n, tilesize, mwfact, nmaster = tags[screen][seltag[screen]].nmaster;
|
uint i, n, tilesize, mwfact, nmaster = tags[screen][seltag[screen]].nmaster;
|
||||||
uint border = BORDH * 2;
|
|
||||||
|
|
||||||
for(n = 0, c = tiled_client(screen, clients); c; c = tiled_client(screen, c->next), ++n);
|
for(n = 0, c = tiled_client(screen, clients); c; c = tiled_client(screen, c->next), ++n);
|
||||||
CHECK(n);
|
CHECK(n);
|
||||||
@ -295,14 +294,14 @@ multi_tile(int screen, Position type)
|
|||||||
{
|
{
|
||||||
if(type == Top)
|
if(type == Top)
|
||||||
mastergeo.y = (n <= nmaster) ? sg.y : sg.y + (sg.height - mwfact) - BORDH;
|
mastergeo.y = (n <= nmaster) ? sg.y : sg.y + (sg.height - mwfact) - BORDH;
|
||||||
mastergeo.width = (sg.width / nmaster) - (border * 2);
|
mastergeo.width = (sg.width / nmaster) - (BORDH * 4);
|
||||||
mastergeo.height = (n <= nmaster) ? sg.height - BORDH : mwfact;
|
mastergeo.height = (n <= nmaster) ? sg.height - BORDH : mwfact;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if(type == Left)
|
if(type == Left)
|
||||||
mastergeo.x = (n <= nmaster) ? sg.x : (sg.x + sg.width) - mwfact - border;
|
mastergeo.x = (n <= nmaster) ? sg.x : (sg.x + sg.width) - mwfact - (BORDH * 2);
|
||||||
mastergeo.width = (n <= nmaster) ? sg.width - border : mwfact;
|
mastergeo.width = (n <= nmaster) ? sg.width - (BORDH * 2) : mwfact;
|
||||||
mastergeo.height = (sg.height / nmaster) - BORDH;
|
mastergeo.height = (sg.height / nmaster) - BORDH;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -310,9 +309,9 @@ multi_tile(int screen, Position type)
|
|||||||
if(n > nmaster)
|
if(n > nmaster)
|
||||||
{
|
{
|
||||||
if(type == Top || type == Bottom)
|
if(type == Top || type == Bottom)
|
||||||
tilesize = sg.width / (n - nmaster) - (border * 2);
|
tilesize = sg.width / (n - nmaster) - (BORDH * 4);
|
||||||
else
|
else
|
||||||
tilesize = sg.height / (n - nmaster) - (border + TBARH);
|
tilesize = sg.height / (n - nmaster) - ((BORDH * 2) + TBARH);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -355,7 +354,7 @@ multi_tile(int screen, Position type)
|
|||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
case Right:
|
case Right:
|
||||||
cgeo.x += mastergeo.width + border;
|
cgeo.x += mastergeo.width + (BORDH * 2);
|
||||||
cgeo.y = sg.y;
|
cgeo.y = sg.y;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -363,11 +362,11 @@ multi_tile(int screen, Position type)
|
|||||||
if(type == Top || type == Bottom)
|
if(type == Top || type == Bottom)
|
||||||
{
|
{
|
||||||
cgeo.width = tilesize;
|
cgeo.width = tilesize;
|
||||||
cgeo.height = sg.height - mastergeo.height - TBARH - border;
|
cgeo.height = sg.height - mastergeo.height - TBARH - (BORDH * 2);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
cgeo.width = sg.width - mastergeo.width - border * 2;
|
cgeo.width = sg.width - mastergeo.width - (BORDH * 4);
|
||||||
cgeo.height = tilesize;
|
cgeo.height = tilesize;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -376,7 +375,7 @@ multi_tile(int screen, Position type)
|
|||||||
if(i + 1 == n || i + 1 == (n < nmaster ? n : nmaster))
|
if(i + 1 == n || i + 1 == (n < nmaster ? n : nmaster))
|
||||||
{
|
{
|
||||||
if(type == Top || type == Bottom)
|
if(type == Top || type == Bottom)
|
||||||
cgeo.width = sg.width - (cgeo.x - (sg.x - border));
|
cgeo.width = sg.width - (cgeo.x - (sg.x - (BORDH * 2)));
|
||||||
else
|
else
|
||||||
cgeo.height = (sg.y + sg.height) - cgeo.y - BORDH;
|
cgeo.height = (sg.y + sg.height) - cgeo.y - BORDH;
|
||||||
}
|
}
|
||||||
@ -386,7 +385,7 @@ multi_tile(int screen, Position type)
|
|||||||
|
|
||||||
/* Set the position of the next client */
|
/* Set the position of the next client */
|
||||||
if(type == Top || type == Bottom)
|
if(type == Top || type == Bottom)
|
||||||
cgeo.x = c->geo.x + c->geo.width + border;
|
cgeo.x = c->geo.x + c->geo.width + (BORDH * 2);
|
||||||
else
|
else
|
||||||
cgeo.y = c->geo.y + c->geo.height + BORDH + TBARH;
|
cgeo.y = c->geo.y + c->geo.height + BORDH + TBARH;
|
||||||
}
|
}
|
||||||
@ -396,19 +395,21 @@ multi_tile(int screen, Position type)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Mirror layout function
|
||||||
|
* \param screen Screen to execute this function
|
||||||
|
*/
|
||||||
void
|
void
|
||||||
mirror(int screen)
|
mirror(int screen)
|
||||||
{
|
{
|
||||||
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 - (BORDH * 2), sg.height - BORDH};
|
||||||
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;
|
||||||
uint border = BORDH * 2;
|
int pa, imp;
|
||||||
int pa, imp, isp = 0;
|
Bool isp = 0;
|
||||||
|
|
||||||
for(n = 0, c = tiled_client(screen, clients); c; c = tiled_client(screen, c->next), ++n);
|
for(n = 0, c = tiled_client(screen, clients); c; c = tiled_client(screen, c->next), ++n);
|
||||||
CHECK(n);
|
CHECK(n);
|
||||||
@ -416,8 +417,8 @@ mirror(int screen)
|
|||||||
/* Fix nmaster */
|
/* Fix nmaster */
|
||||||
nmaster = (n < nmaster) ? n : nmaster;
|
nmaster = (n < nmaster) ? n : nmaster;
|
||||||
|
|
||||||
imp = (n / 2);
|
imp = ((n - (nmaster - 1)) / 2);
|
||||||
pa = (n / 2) - ((n % 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.51)
|
||||||
@ -425,17 +426,18 @@ mirror(int screen)
|
|||||||
mwfact = tags[screen][seltag[screen]].mwfact * sg.width;
|
mwfact = tags[screen][seltag[screen]].mwfact * sg.width;
|
||||||
|
|
||||||
/* Master size */
|
/* Master size */
|
||||||
if(n == 2)
|
mastergeo.height = (sg.height / nmaster) - (TBARH + (BORDH * 2));
|
||||||
|
|
||||||
|
if(n == nmaster + 1)
|
||||||
{
|
{
|
||||||
mastergeo.width = mwfact - (border + BORDH);
|
mastergeo.width = mwfact - (BORDH * 3);
|
||||||
tilesize = (sg.width - mastergeo.width) - border * 2;
|
tilewidth = (sg.width - mastergeo.width) - (BORDH * 4);
|
||||||
}
|
}
|
||||||
if(n > 2)
|
if(n > nmaster + 1)
|
||||||
{
|
{
|
||||||
mastergeo.x = (sg.x + (sg.width - mwfact)) + BORDH;
|
mastergeo.x = (sg.x + (sg.width - mwfact)) + BORDH;
|
||||||
mastergeo.y = sg.y;
|
mastergeo.width = ((2 * mwfact - sg.width) - (BORDH * 4));
|
||||||
mastergeo.width = ((2 * mwfact - sg.width) - (border * 2));
|
tilewidth = (mwfact - mastergeo.width) - ((BORDH * 4) + BORDH);
|
||||||
tilesize = (mwfact - mastergeo.width) - ((border * 2) + BORDH);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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)
|
||||||
@ -444,43 +446,55 @@ mirror(int screen)
|
|||||||
c->max = c->lmax = False;
|
c->max = c->lmax = False;
|
||||||
c->tile = True;
|
c->tile = True;
|
||||||
|
|
||||||
if(i < 1)
|
if(i < nmaster)
|
||||||
|
{
|
||||||
cgeo = mastergeo;
|
cgeo = mastergeo;
|
||||||
|
|
||||||
|
/* Master remainder */
|
||||||
|
if(i + 1 == nmaster)
|
||||||
|
cgeo.height = (sg.y + sg.height) - (cgeo.y + BORDH);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
cgeo.width = tilesize;
|
cgeo.width = tilewidth;
|
||||||
|
|
||||||
if((i + 1) % 2)
|
if((i + nmaster) % 2)
|
||||||
{
|
{
|
||||||
isp = 1;
|
isp = 1;
|
||||||
cgeo.x = sg.x;
|
cgeo.x = sg.x;
|
||||||
cgeo.height = (sg.height / pa) - (TBARH + border);
|
cgeo.height = (sg.height / pa) - (TBARH + (BORDH * 2));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
isp = 0;
|
isp = 0;
|
||||||
cgeo.x = (sg.x + mwfact) - BORDH;
|
cgeo.x = (sg.x + mwfact) - BORDH;
|
||||||
cgeo.height = (sg.height / imp) - (TBARH + border);
|
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);
|
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);
|
||||||
|
|
||||||
nextg[!isp] = c->geo;
|
if(i >= nmaster)
|
||||||
|
nextg[!isp] = c->geo;
|
||||||
|
|
||||||
if(i >= 2)
|
/* Next y position */
|
||||||
cgeo.y = nextg[isp].y + nextg[isp].height + BORDH + TBARH;
|
if(i >= nmaster - 1)
|
||||||
|
{
|
||||||
/*
|
if(i == nmaster || i == nmaster - 1)
|
||||||
else if (i < nmaster)
|
cgeo.y = sg.y;
|
||||||
|
else
|
||||||
|
cgeo.y = nextg[isp].y + nextg[isp].height + BORDH + TBARH;
|
||||||
|
}
|
||||||
|
else if (i <= nmaster - 1)
|
||||||
mastergeo.y = c->geo.y + c->geo.height + BORDH + TBARH;
|
mastergeo.y = c->geo.y + c->geo.height + BORDH + TBARH;
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ewmh_get_current_layout();
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user