config/screen: Multi-Head support: Add screen option in tag {} in the configuration file, Improved other things...

This commit is contained in:
Martin Duquesnoy 2008-12-01 01:37:34 +01:00
parent e9b2219566
commit 077d60c3d4
8 changed files with 57 additions and 51 deletions

View File

@ -99,8 +99,7 @@ pkg_check_modules(wmfs_required
x11
libconfuse
freetype2
xft
xinerama)
xft)
# Find exterbal programs
macro(a_find_program var prg req)

View File

@ -63,7 +63,7 @@ static cfg_opt_t bar_opts[] =
static cfg_opt_t mouse_button_opts[] =
{
CFG_INT("tag", -1, CFGF_NONE),
CFG_INT("tag", 0, CFGF_NONE),
CFG_STR("button", "Button1", CFGF_NONE),
CFG_STR("func", "", CFGF_NONE),
CFG_STR("cmd", "", CFGF_NONE),
@ -115,6 +115,7 @@ static cfg_opt_t layouts_opts[] =
static cfg_opt_t tag_opts[] =
{
CFG_INT("screen", 0, CFGF_NONE),
CFG_STR("name", "", CFGF_NONE),
CFG_FLOAT("mwfact", 0.65, CFGF_NONE),
CFG_INT("nmaster", 1, CFGF_NONE),
@ -449,50 +450,52 @@ init_conf(void)
}
}
/* tag
* if there is no tag in the conf or more than
/* Tag
* If there is no tag in the conf or more than
* MAXTAG (32) print an error and create only one.
*/
conf.colors.tagselfg = strdup(var_to_str(cfg_getstr(cfg_tags, "sel_fg")));
conf.colors.tagselbg = getcolor(var_to_str(cfg_getstr(cfg_tags, "sel_bg")));
conf.colors.tagbord = getcolor(var_to_str(cfg_getstr(cfg_tags, "border")));
conf.ntag = cfg_size(cfg_tags, "tag");
if(!conf.ntag || conf.ntag > MAXTAG)
/* Alloc all */
conf.ntag = emalloc(screen_count(), sizeof(int));
tags = emalloc(screen_count(), sizeof(Tag*));
for(i = 0; i < screen_count(); ++i)
tags[i] = emalloc(cfg_size(cfg_tags, "tag") + 1, sizeof(Tag));
for(i = 0; i < cfg_size(cfg_tags, "tag"); ++i)
{
fprintf(stderr, "WMFS Configuration: Too many or no tag"
" (%d) in the configration file\n", conf.ntag);
conf.ntag = 1;
conf.tag[0].name = strdup("WMFS");
conf.tag[0].mwfact = 0.65;
conf.tag[0].nmaster = 1;
conf.tag[0].resizehint = False;
conf.tag[0].layout = layout_name_to_struct(conf.layout, "tile_right", conf.nlayout);
}
else
{
for(i = 0; i < conf.ntag; ++i)
{
cfgtmp = cfg_getnsec(cfg_tags, "tag", i);
if(strlen(strdup(cfg_getstr(cfgtmp, "name"))) > 256)
fprintf(stderr, "WMFS Configuration: name of tag %d too long !\n", i);
conf.tag[i].name = strdup(cfg_getstr(cfgtmp, "name"));
conf.tag[i].mwfact = cfg_getfloat(cfgtmp, "mwfact");
conf.tag[i].nmaster = cfg_getint(cfgtmp, "nmaster");
conf.tag[i].resizehint = cfg_getbool(cfgtmp, "resizehint");
conf.tag[i].layout = layout_name_to_struct(conf.layout, cfg_getstr(cfgtmp, "layout"), conf.nlayout);
}
cfgtmp = cfg_getnsec(cfg_tags, "tag", i);
j = cfg_getint(cfgtmp, "screen");
if(j < 0 || j > screen_count() - 1)
j = 0;
++conf.ntag[j];
tags[j][conf.ntag[j]].name = strdup(cfg_getstr(cfgtmp, "name"));
tags[j][conf.ntag[j]].mwfact = cfg_getfloat(cfgtmp, "mwfact");
tags[j][conf.ntag[j]].nmaster = cfg_getint(cfgtmp, "nmaster");
tags[j][conf.ntag[j]].resizehint = cfg_getbool(cfgtmp, "resizehint");
tags[j][conf.ntag[j]].layout = layout_name_to_struct(conf.layout, cfg_getstr(cfgtmp, "layout"), conf.nlayout);
}
for(i = 0; i < screen_count(); ++i)
if(!conf.ntag[i] || conf.ntag[i] > MAXTAG)
{
fprintf(stderr, "WMFS Configuration: Too many or no tag"
" (%d) in the screen %d\n", conf.ntag[i], i);
conf.ntag[i] = 1;
tags[i][1].name = strdup("WMFS");
tags[i][1].mwfact = 0.50;
tags[i][1].nmaster = 1;
tags[i][1].resizehint = False;
tags[i][1].layout = layout_name_to_struct(conf.layout, "tile_right", conf.nlayout);
}
seltag = emalloc(screen_count(), sizeof(int));
tags = emalloc(screen_count(), sizeof(Tag*));
for(j = 0; j < screen_count(); ++j)
{
tags[j] = emalloc(conf.ntag + 1, sizeof(Tag));
seltag[j] = 1;
for(i = 0; i < conf.ntag; ++i)
tags[j][i + 1] = conf.tag[i];
}
/* keybind */
conf.nkeybind = cfg_size(cfg_keys, "key");

View File

@ -72,10 +72,10 @@ buttonpress(XButtonEvent *ev)
conf.root.mouse[i].func(conf.root.mouse[i].cmd);
/* Tag */
for(i = 1; i < conf.ntag + 1; ++i)
for(i = 1; i < conf.ntag[screen_get_sel()]+ 1; ++i)
{
ITOA(s, i);
if(ev->window == infobar[screen_get_sel()].tags[i]->win)
if(ev->window == infobar[selscreen].tags[i]->win)
{
if(ev->button == Button1)
uicb_tag(s);
@ -89,7 +89,7 @@ buttonpress(XButtonEvent *ev)
}
/* Layout button */
if(ev->window == infobar[screen_get_sel()].layout_button->win)
if(ev->window == infobar[selscreen].layout_button->win)
{
if(ev->button == Button1
|| ev->button == Button4)
@ -213,7 +213,7 @@ expose(XExposeEvent *ev)
barwin_refresh(infobar[sc].bar);
if(ev->window == infobar[sc].layout_button->win)
barwin_refresh(infobar[sc].layout_button);
for(i = 1; i < conf.ntag + 1; ++i)
for(i = 1; i < conf.ntag[sc] + 1; ++i)
if(ev->window == infobar[sc].tags[i]->win)
barwin_refresh(infobar[sc].tags[i]);
}

View File

@ -55,7 +55,7 @@ infobar_init(void)
screen_get_geo(sc).width, infobar[sc].geo.height, conf.colors.bar, False);
/* Create tags window */
for(i = 1; i < conf.ntag + 1; ++i)
for(i = 1; i < conf.ntag[sc] + 1; ++i)
{
infobar[sc].tags[i] = barwin_create(infobar[sc].bar->win, j, 0, textw(tags[sc][i].name) + PAD,
infobar[sc].geo.height, conf.colors.bar, False);
@ -110,6 +110,7 @@ infobar_draw_layout(int sc)
{
barwin_resize(infobar[sc].layout_button, textw(tags[sc][seltag[sc]].layout.symbol) + PAD, infobar[sc].geo.height);
barwin_refresh_color(infobar[sc].layout_button);
if(tags[sc][seltag[sc]].layout.symbol)
draw_text(infobar[sc].layout_button->dr, PAD / 2, font->height,
conf.colors.layout_fg, 0, tags[sc][seltag[sc]].layout.symbol);
barwin_refresh(infobar[sc].layout_button);
@ -124,12 +125,17 @@ infobar_draw_taglist(int sc)
{
int i;
for(i = 1; i < conf.ntag + 1; ++i)
for(i = 1; i < conf.ntag[sc] + 1; ++i)
{
infobar[sc].tags[i]->color = ((i == seltag[sc]) ? conf.colors.tagselbg : conf.colors.bar);
barwin_refresh_color(infobar[sc].tags[i]);
draw_text(infobar[sc].tags[i]->dr, PAD / 2, font->height,
((i == seltag[sc]) ? conf.colors.tagselfg : conf.colors.text), 0, tags[sc][i].name);
if(tags[sc][i].name)
draw_text(infobar[sc].tags[i]->dr,
PAD / 2,
font->height,
((i == seltag[sc]) ? conf.colors.tagselfg : conf.colors.text),
0,
tags[sc][i].name);
barwin_refresh(infobar[sc].tags[i]);
}
@ -147,7 +153,7 @@ infobar_destroy(void)
{
barwin_delete(infobar[sc].layout_button);
barwin_delete_subwin(infobar[sc].layout_button);
for(i = 1; i < conf.ntag + 1; ++i)
for(i = 1; i < conf.ntag[sc] + 1; ++i)
{
barwin_delete_subwin(infobar[sc].tags[i]);
barwin_delete(infobar[sc].tags[i]);

View File

@ -51,9 +51,7 @@ arrange(void)
}
tags[selscreen][seltag[selscreen]].layout.func();
client_focus(NULL);
infobar_draw(selscreen);
return;

View File

@ -70,12 +70,12 @@ screen_get_geo(int s)
geo.height = xsi[s].height - INFOBARH - TBARH;
geo.width = xsi[s].width;
free(xsi);
XFree(xsi);
}
else
{
geo.x = BORDH;
geo.y = (conf.bartop) ? INFOBARH + TBARH : TBARH; ;
geo.y = (conf.bartop) ? INFOBARH + TBARH : TBARH;
geo.height = MAXH - INFOBARH - TBARH;
geo.width = MAXW;
}

View File

@ -203,7 +203,7 @@ typedef struct
} titlebar;
Tag tag[MAXTAG];
Layout layout[NUM_OF_LAYOUT];
int ntag;
int *ntag;
int nkeybind;
int nbutton;
int nlayout;

View File

@ -48,14 +48,14 @@ uicb_tag(uicb_t cmd)
if(cmd[0] == '+' || cmd[0] == '-')
{
if(tmp + seltag[selscreen] < 1
|| tmp + seltag[selscreen] > conf.ntag)
|| tmp + seltag[selscreen] > conf.ntag[selscreen])
return;
seltag[selscreen] += tmp;
}
else
{
if(tmp == seltag[selscreen]
|| tmp > conf.ntag)
|| tmp > conf.ntag[selscreen])
return;
seltag[selscreen] = tmp;
}