nmaster is now configurable per tag

This commit is contained in:
Julien Danjou 2007-11-11 11:53:10 +01:00
parent 32b098796e
commit 59f377526f
4 changed files with 15 additions and 14 deletions

View File

@ -34,6 +34,7 @@ screen 0
} }
tag 2 tag 2
{ {
nmaster = 2
layout = "tile" layout = "tile"
} }
tag 3 tag 3
@ -70,7 +71,6 @@ screen 0
layouts layouts
{ {
nmaster = 1
ncol = 1 ncol = 1
layout tile layout tile
{ {

View File

@ -176,6 +176,7 @@ parse_config(const char *confpatharg, awesome_config *awesomeconf)
{ {
CFG_STR((char *) "layout", (char *) "tile", CFGF_NONE), CFG_STR((char *) "layout", (char *) "tile", CFGF_NONE),
CFG_FLOAT((char *) "mwfact", 0.5, CFGF_NONE), CFG_FLOAT((char *) "mwfact", 0.5, CFGF_NONE),
CFG_INT((char *) "nmaster", 1, CFGF_NONE),
CFG_END() CFG_END()
}; };
static cfg_opt_t tags_opts[] = static cfg_opt_t tags_opts[] =
@ -191,7 +192,6 @@ parse_config(const char *confpatharg, awesome_config *awesomeconf)
static cfg_opt_t layouts_opts[] = static cfg_opt_t layouts_opts[] =
{ {
CFG_SEC((char *) "layout", layout_opts, CFGF_TITLE | CFGF_MULTI), CFG_SEC((char *) "layout", layout_opts, CFGF_TITLE | CFGF_MULTI),
CFG_INT((char *) "nmaster", 1, CFGF_NONE),
CFG_INT((char *) "ncol", 1, CFGF_NONE), CFG_INT((char *) "ncol", 1, CFGF_NONE),
CFG_END() CFG_END()
}; };
@ -337,7 +337,6 @@ parse_config(const char *confpatharg, awesome_config *awesomeconf)
awesomeconf->layouts[i].symbol = a_strdup(cfg_getstr(cfgsectmp, "symbol")); awesomeconf->layouts[i].symbol = a_strdup(cfg_getstr(cfgsectmp, "symbol"));
} }
awesomeconf->nmaster = cfg_getint(cfg_layouts, "nmaster");
awesomeconf->ncol = cfg_getint(cfg_layouts, "ncol"); awesomeconf->ncol = cfg_getint(cfg_layouts, "ncol");
if(!awesomeconf->nlayouts) if(!awesomeconf->nlayouts)
@ -377,6 +376,7 @@ parse_config(const char *confpatharg, awesome_config *awesomeconf)
k = 0; k = 0;
awesomeconf->tags[i].layout = &awesomeconf->layouts[k]; awesomeconf->tags[i].layout = &awesomeconf->layouts[k];
awesomeconf->tags[i].mwfact = cfg_getfloat(cfgsectmp, "mwfact"); awesomeconf->tags[i].mwfact = cfg_getfloat(cfgsectmp, "mwfact");
awesomeconf->tags[i].nmaster = cfg_getint(cfgsectmp, "nmaster");
} }

View File

@ -134,6 +134,8 @@ typedef struct
Client *client_sel; Client *client_sel;
/** Master width factor */ /** Master width factor */
double mwfact; double mwfact;
/** Number of master windows */
int nmaster;
} Tag; } Tag;
/** Main configuration structure */ /** Main configuration structure */
@ -169,8 +171,6 @@ struct awesome_config
int borderpx; int borderpx;
/** Number of pixels to snap windows */ /** Number of pixels to snap windows */
int snap; int snap;
/** Number of master windows */
int nmaster;
/** Number of columns in tile layout */ /** Number of columns in tile layout */
int ncol; int ncol;
/** Transparency of unfocused clients */ /** Transparency of unfocused clients */

View File

@ -32,13 +32,14 @@ void
uicb_setnmaster(awesome_config *awesomeconf, uicb_setnmaster(awesome_config *awesomeconf,
const char * arg) const char * arg)
{ {
Layout *curlay = get_current_layout(awesomeconf->tags, awesomeconf->ntags); Tag *curtag = get_current_tag(awesomeconf->tags, awesomeconf->ntags);
Layout *curlay = curtag->layout;
if(!arg || (curlay->arrange != layout_tile && curlay->arrange != layout_tileleft)) if(!arg || (curlay->arrange != layout_tile && curlay->arrange != layout_tileleft))
return; return;
if((awesomeconf->nmaster = (int) compute_new_value_from_arg(arg, (double) awesomeconf->nmaster)) < 0) if((curtag->nmaster = (int) compute_new_value_from_arg(arg, (double) curtag->nmaster)) < 0)
awesomeconf->nmaster = 0; curtag->nmaster = 0;
arrange(awesomeconf); arrange(awesomeconf);
} }
@ -113,14 +114,14 @@ _tile(awesome_config *awesomeconf, const Bool right)
wax = screens_info[awesomeconf->screen].x_org; wax = screens_info[awesomeconf->screen].x_org;
way = screens_info[awesomeconf->screen].y_org; way = screens_info[awesomeconf->screen].y_org;
masterwin = MIN(n, awesomeconf->nmaster); masterwin = MIN(n, curtag->nmaster);
otherwin = n - masterwin; otherwin = n - masterwin;
if(otherwin < 0) if(otherwin < 0)
otherwin = 0; otherwin = 0;
if(awesomeconf->nmaster) if(curtag->nmaster)
{ {
mh = masterwin ? wah / masterwin : waw; mh = masterwin ? wah / masterwin : waw;
mw = otherwin ? waw * curtag->mwfact : waw; mw = otherwin ? waw * curtag->mwfact : waw;
@ -136,7 +137,7 @@ _tile(awesome_config *awesomeconf, const Bool right)
continue; continue;
c->ismax = False; c->ismax = False;
if(i < awesomeconf->nmaster) if(i < curtag->nmaster)
{ /* master */ { /* master */
ny = way + i * mh; ny = way + i * mh;
nx = wax + (right ? 0 : waw - mw); nx = wax + (right ? 0 : waw - mw);
@ -147,7 +148,7 @@ _tile(awesome_config *awesomeconf, const Bool right)
if(real_ncol) if(real_ncol)
win_by_col = otherwin / real_ncol; win_by_col = otherwin / real_ncol;
if((i - awesomeconf->nmaster) && (i - awesomeconf->nmaster) % win_by_col == 0 && current_col < real_ncol - 1) if((i - curtag->nmaster) && (i - curtag->nmaster) % win_by_col == 0 && current_col < real_ncol - 1)
current_col++; current_col++;
if(current_col == real_ncol - 1) if(current_col == real_ncol - 1)
@ -160,10 +161,10 @@ _tile(awesome_config *awesomeconf, const Bool right)
nw = (waw - mw) / real_ncol - 2 * c->border; nw = (waw - mw) / real_ncol - 2 * c->border;
if(i == awesomeconf->nmaster || otherwin <= real_ncol || (i - awesomeconf->nmaster) % win_by_col == 0) if(i == curtag->nmaster || otherwin <= real_ncol || (i - curtag->nmaster) % win_by_col == 0)
ny = way; ny = way;
else else
ny = way + ((i - awesomeconf->nmaster) % win_by_col) * (nh + 2 * c->border); ny = way + ((i - curtag->nmaster) % win_by_col) * (nh + 2 * c->border);
nx = wax + current_col * (nw + 2 * c->border) + (right ? mw : 0); nx = wax + current_col * (nw + 2 * c->border) + (right ? mw : 0);
client_resize(c, nx, ny, nw, nh, awesomeconf, awesomeconf->resize_hints, False); client_resize(c, nx, ny, nw, nh, awesomeconf, awesomeconf->resize_hints, False);