Make layout fancier by adding master_grow, master_shrink, master_add,

master_del, stack_inc and stack_del to the format string.
This commit is contained in:
Marco Peereboom 2011-06-23 18:56:39 +00:00
parent 2a8d7bafe3
commit 014589e605
3 changed files with 50 additions and 9 deletions

View file

@ -122,14 +122,30 @@ This ratio is the screen size to what they will be resized.
For example, 0.6 is 60% of the physical screen size. For example, 0.6 is 60% of the physical screen size.
.It Cm layout .It Cm layout
select layout to use at start-of-day. select layout to use at start-of-day.
Defined in the format ws[<idx>]:<layout>, e.g. ws[2]:horizontal sets worskspace Defined in the format ws[idx]:master_grow:master_add:stack_inc:layout, e.g.
2 to the horizontal stack mode. ws[2]:-4:0:1:horizontal sets worskspace 2 to the horizontal stack mode and
This setting is not retained at restart. shrinks the master area by 4 ticks and adds one window to the stack.
Possible values are Possible layout values are
.Pa vertical , .Pa vertical ,
.Pa horizontal .Pa horizontal
and and
.Pa fullscreen . .Pa fullscreen .
.Pp
See
.Pa master_grow ,
.Pa master_shrink ,
.Pa master_add ,
.Pa master_del ,
.Pa stack_inc ,
and
.Pa stack_del
for more information.
Note that the stacking options are complicated and have side-effects.
One should familiarize oneself with these commands before experimenting with the
.Pa layout
option.
.Pp
This setting is not retained at restart.
.It Cm region .It Cm region
Allocates a custom region, removing any autodetected regions which occupy the same Allocates a custom region, removing any autodetected regions which occupy the same
space on the screen. space on the screen.

View file

@ -4589,7 +4589,7 @@ setautorun(char *selector, char *value, int flags)
int int
setlayout(char *selector, char *value, int flags) setlayout(char *selector, char *value, int flags)
{ {
int ws_id, st, i; int ws_id, st, i, x, mg, ma, si;
char s[1024]; char s[1024];
struct workspace *ws; struct workspace *ws;
@ -4597,7 +4597,8 @@ setlayout(char *selector, char *value, int flags)
return (0); return (0);
bzero(s, sizeof s); bzero(s, sizeof s);
if (sscanf(value, "ws[%d]:%1023c", &ws_id, s) != 2) if (sscanf(value, "ws[%d]:%d:%d:%d:%1023c",
&ws_id, &mg, &ma, &si, s) != 5)
errx(1, "invalid layout entry, should be 'ws[<idx>]:<type>'\n"); errx(1, "invalid layout entry, should be 'ws[<idx>]:<type>'\n");
ws_id--; ws_id--;
if (ws_id < 0 || ws_id >= SWM_WS_MAX) if (ws_id < 0 || ws_id >= SWM_WS_MAX)
@ -4615,6 +4616,30 @@ setlayout(char *selector, char *value, int flags)
for (i = 0; i < ScreenCount(display); i++) { for (i = 0; i < ScreenCount(display); i++) {
ws = (struct workspace *)&screens[i].ws; ws = (struct workspace *)&screens[i].ws;
ws[ws_id].cur_layout = &layouts[st]; ws[ws_id].cur_layout = &layouts[st];
if (st == SWM_MAX_STACK)
continue;
/* master grow */
for (x = 0; x < abs(mg); x++) {
ws[ws_id].cur_layout->l_config(&ws[ws_id],
mg >= 0 ? SWM_ARG_ID_MASTERGROW :
SWM_ARG_ID_MASTERSHRINK);
stack();
}
/* master add */
for (x = 0; x < abs(ma); x++) {
ws[ws_id].cur_layout->l_config(&ws[ws_id],
ma >= 0 ? SWM_ARG_ID_MASTERADD :
SWM_ARG_ID_MASTERDEL);
stack();
}
/* stack inc */
for (x = 0; x < abs(si); x++) {
ws[ws_id].cur_layout->l_config(&ws[ws_id],
si >= 0 ? SWM_ARG_ID_STACKINC :
SWM_ARG_ID_STACKDEC);
stack();
}
} }
return (0); return (0);

View file

@ -46,9 +46,9 @@ dialog_ratio = 0.6
# autorun = ws[2]:xxxterm http://www.openbsd.org # autorun = ws[2]:xxxterm http://www.openbsd.org
# workspace layout # workspace layout
# layout = ws[1]:vertical # layout = ws[1]:4:0:0:vertical
# layout = ws[2]:horizontal # layout = ws[2]:0:0:0:horizontal
# layout = ws[3]:fullscreen # layout = ws[3]:0:0:0:fullscreen
# mod key, (windows key is Mod4) (apple key on OSX is Mod2) # mod key, (windows key is Mod4) (apple key on OSX is Mod2)
# modkey = Mod1 # modkey = Mod1