remove nlayouts
This commit is contained in:
parent
b9320be372
commit
b03cdbd877
11
awesome.c
11
awesome.c
|
@ -67,6 +67,7 @@ cleanup_buttons(Button *buttons)
|
||||||
void
|
void
|
||||||
cleanup_screen(awesome_config *awesomeconf, int screen)
|
cleanup_screen(awesome_config *awesomeconf, int screen)
|
||||||
{
|
{
|
||||||
|
Layout *l, *ln;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
XftFontClose(awesomeconf->display, awesomeconf->screens[screen].font);
|
XftFontClose(awesomeconf->display, awesomeconf->screens[screen].font);
|
||||||
|
@ -76,8 +77,12 @@ cleanup_screen(awesome_config *awesomeconf, int screen)
|
||||||
for(i = 0; i < awesomeconf->screens[screen].ntags; i++)
|
for(i = 0; i < awesomeconf->screens[screen].ntags; i++)
|
||||||
p_delete(&awesomeconf->screens[screen].tags[i].name);
|
p_delete(&awesomeconf->screens[screen].tags[i].name);
|
||||||
|
|
||||||
for(i = 0; i < awesomeconf->screens[screen].nlayouts; i++)
|
for(l = awesomeconf->screens[screen].layouts; l; l = ln)
|
||||||
p_delete(&awesomeconf->screens[screen].layouts[i].symbol);
|
{
|
||||||
|
ln = l->next;
|
||||||
|
p_delete(&l->symbol);
|
||||||
|
p_delete(&l);
|
||||||
|
}
|
||||||
|
|
||||||
p_delete(&awesomeconf->screens[screen].tags);
|
p_delete(&awesomeconf->screens[screen].tags);
|
||||||
p_delete(&awesomeconf->screens[screen].layouts);
|
p_delete(&awesomeconf->screens[screen].layouts);
|
||||||
|
@ -219,7 +224,7 @@ setup_screen(awesome_config *awesomeconf, int screen)
|
||||||
setup(awesomeconf, screen);
|
setup(awesomeconf, screen);
|
||||||
initstatusbar(awesomeconf->display, screen, &awesomeconf->screens[screen].statusbar,
|
initstatusbar(awesomeconf->display, screen, &awesomeconf->screens[screen].statusbar,
|
||||||
awesomeconf->cursor[CurNormal], awesomeconf->screens[screen].font,
|
awesomeconf->cursor[CurNormal], awesomeconf->screens[screen].font,
|
||||||
awesomeconf->screens[screen].layouts, awesomeconf->screens[screen].nlayouts, &awesomeconf->screens[screen].padding);
|
awesomeconf->screens[screen].layouts, &awesomeconf->screens[screen].padding);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Startup Error handler to check if another window manager
|
/** Startup Error handler to check if another window manager
|
||||||
|
|
46
config.c
46
config.c
|
@ -383,12 +383,13 @@ parse_config(const char *confpatharg, awesome_config *awesomeconf)
|
||||||
};
|
};
|
||||||
cfg_t *cfg, *cfg_general, *cfg_colors, *cfg_screen, *cfg_statusbar, *cfg_tags,
|
cfg_t *cfg, *cfg_general, *cfg_colors, *cfg_screen, *cfg_statusbar, *cfg_tags,
|
||||||
*cfg_layouts, *cfg_rules, *cfg_keys, *cfg_mouse, *cfgsectmp, *cfg_padding;
|
*cfg_layouts, *cfg_rules, *cfg_keys, *cfg_mouse, *cfgsectmp, *cfg_padding;
|
||||||
int i = 0, k = 0, ret, screen;
|
int i = 0, ret, screen;
|
||||||
unsigned int j = 0;
|
unsigned int j = 0;
|
||||||
const char *tmp, *homedir;
|
const char *tmp, *homedir;
|
||||||
char *confpath, buf[2];
|
char *confpath, buf[2];
|
||||||
ssize_t confpath_len;
|
ssize_t confpath_len;
|
||||||
Rule *rule = NULL;
|
Rule *rule = NULL;
|
||||||
|
Layout *layout = NULL;
|
||||||
FILE *defconfig = NULL;
|
FILE *defconfig = NULL;
|
||||||
|
|
||||||
if(confpatharg)
|
if(confpatharg)
|
||||||
|
@ -471,22 +472,28 @@ parse_config(const char *confpatharg, awesome_config *awesomeconf)
|
||||||
get_statusbar_position_from_str(cfg_getstr(cfg_statusbar, "position"));
|
get_statusbar_position_from_str(cfg_getstr(cfg_statusbar, "position"));
|
||||||
|
|
||||||
/* Layouts */
|
/* Layouts */
|
||||||
awesomeconf->screens[screen].nlayouts = cfg_size(cfg_layouts, "layout");
|
if(cfg_size(cfg_layouts, "layout"))
|
||||||
awesomeconf->screens[screen].layouts = p_new(Layout, awesomeconf->screens[screen].nlayouts);
|
|
||||||
for(i = 0; i < awesomeconf->screens[screen].nlayouts; i++)
|
|
||||||
{
|
{
|
||||||
cfgsectmp = cfg_getnsec(cfg_layouts, "layout", i);
|
awesomeconf->screens[screen].layouts = layout = p_new(Layout, 1);
|
||||||
awesomeconf->screens[screen].layouts[i].arrange = name_func_lookup(cfg_title(cfgsectmp), LayoutsList);
|
for(j = 0; j < cfg_size(cfg_layouts, "layout"); j++)
|
||||||
if(!awesomeconf->screens[screen].layouts[i].arrange)
|
{
|
||||||
|
cfgsectmp = cfg_getnsec(cfg_layouts, "layout", j);
|
||||||
|
layout->arrange = name_func_lookup(cfg_title(cfgsectmp), LayoutsList);
|
||||||
|
if(!layout->arrange)
|
||||||
{
|
{
|
||||||
warn("unknown layout %s in configuration file\n", cfg_title(cfgsectmp));
|
warn("unknown layout %s in configuration file\n", cfg_title(cfgsectmp));
|
||||||
awesomeconf->screens[screen].layouts[i].symbol = NULL;
|
layout->symbol = NULL;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
awesomeconf->screens[screen].layouts[i].symbol = a_strdup(cfg_getstr(cfgsectmp, "symbol"));
|
layout->symbol = a_strdup(cfg_getstr(cfgsectmp, "symbol"));
|
||||||
}
|
|
||||||
|
|
||||||
if(!awesomeconf->screens[screen].nlayouts)
|
if(j < cfg_size(cfg_layouts, "layout") - 1)
|
||||||
|
layout = layout->next = p_new(Layout, 1);
|
||||||
|
else
|
||||||
|
layout->next = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
eprint("fatal: no default layout available\n");
|
eprint("fatal: no default layout available\n");
|
||||||
|
|
||||||
/* Tags */
|
/* Tags */
|
||||||
|
@ -499,12 +506,12 @@ parse_config(const char *confpatharg, awesome_config *awesomeconf)
|
||||||
awesomeconf->screens[screen].tags[i].selected = False;
|
awesomeconf->screens[screen].tags[i].selected = False;
|
||||||
awesomeconf->screens[screen].tags[i].was_selected = False;
|
awesomeconf->screens[screen].tags[i].was_selected = False;
|
||||||
tmp = cfg_getstr(cfgsectmp, "layout");
|
tmp = cfg_getstr(cfgsectmp, "layout");
|
||||||
for(k = 0; k < awesomeconf->screens[screen].nlayouts; k++)
|
for(layout = awesomeconf->screens[screen].layouts;
|
||||||
if(awesomeconf->screens[screen].layouts[k].arrange == name_func_lookup(tmp, LayoutsList))
|
layout && layout->arrange != name_func_lookup(tmp, LayoutsList); layout = layout->next);
|
||||||
break;
|
if(!layout)
|
||||||
if(k == awesomeconf->screens[screen].nlayouts)
|
awesomeconf->screens[screen].tags[i].layout = awesomeconf->screens[screen].layouts;
|
||||||
k = 0;
|
else
|
||||||
awesomeconf->screens[screen].tags[i].layout = &awesomeconf->screens[screen].layouts[k];
|
awesomeconf->screens[screen].tags[i].layout = layout;
|
||||||
awesomeconf->screens[screen].tags[i].mwfact = cfg_getfloat(cfgsectmp, "mwfact");
|
awesomeconf->screens[screen].tags[i].mwfact = cfg_getfloat(cfgsectmp, "mwfact");
|
||||||
awesomeconf->screens[screen].tags[i].nmaster = cfg_getint(cfgsectmp, "nmaster");
|
awesomeconf->screens[screen].tags[i].nmaster = cfg_getint(cfgsectmp, "nmaster");
|
||||||
awesomeconf->screens[screen].tags[i].ncol = cfg_getint(cfgsectmp, "ncol");
|
awesomeconf->screens[screen].tags[i].ncol = cfg_getint(cfgsectmp, "ncol");
|
||||||
|
@ -546,10 +553,7 @@ parse_config(const char *confpatharg, awesome_config *awesomeconf)
|
||||||
rule->screen = 0;
|
rule->screen = 0;
|
||||||
|
|
||||||
if(j < cfg_size(cfg_rules, "rule") - 1)
|
if(j < cfg_size(cfg_rules, "rule") - 1)
|
||||||
{
|
rule = rule->next = p_new(Rule, 1);
|
||||||
rule->next = p_new(Rule, 1);
|
|
||||||
rule = rule->next;
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
rule->next = NULL;
|
rule->next = NULL;
|
||||||
}
|
}
|
||||||
|
|
7
config.h
7
config.h
|
@ -50,11 +50,13 @@ struct Rule
|
||||||
|
|
||||||
typedef struct awesome_config awesome_config;
|
typedef struct awesome_config awesome_config;
|
||||||
|
|
||||||
typedef struct
|
typedef struct Layout Layout;
|
||||||
|
struct Layout
|
||||||
{
|
{
|
||||||
char *symbol;
|
char *symbol;
|
||||||
void (*arrange) (awesome_config *, int);
|
void (*arrange) (awesome_config *, int);
|
||||||
} Layout;
|
Layout *next;
|
||||||
|
};
|
||||||
|
|
||||||
typedef struct Key Key;
|
typedef struct Key Key;
|
||||||
struct Key
|
struct Key
|
||||||
|
@ -200,7 +202,6 @@ typedef struct
|
||||||
TagClientLink *tclink;
|
TagClientLink *tclink;
|
||||||
/** Layout list */
|
/** Layout list */
|
||||||
Layout *layouts;
|
Layout *layouts;
|
||||||
int nlayouts;
|
|
||||||
/** Status bar */
|
/** Status bar */
|
||||||
Statusbar statusbar;
|
Statusbar statusbar;
|
||||||
/** Padding */
|
/** Padding */
|
||||||
|
|
25
layout.c
25
layout.c
|
@ -203,25 +203,24 @@ uicb_tag_setlayout(awesome_config * awesomeconf,
|
||||||
int screen,
|
int screen,
|
||||||
const char *arg)
|
const char *arg)
|
||||||
{
|
{
|
||||||
int i, j;
|
Layout *l = awesomeconf->screens[screen].layouts;
|
||||||
|
int i;
|
||||||
|
|
||||||
if(arg)
|
if(arg)
|
||||||
{
|
{
|
||||||
/* compute current index */
|
for(i = 0; l && l != get_current_layout(awesomeconf->screens[screen]); i++, l = l->next);
|
||||||
for(i = 0; i < awesomeconf->screens[screen].nlayouts &&
|
if(!l)
|
||||||
&awesomeconf->screens[screen].layouts[i] != get_current_layout(awesomeconf->screens[screen]); i++);
|
|
||||||
i = compute_new_value_from_arg(arg, (double) i);
|
|
||||||
if(i >= awesomeconf->screens[screen].nlayouts)
|
|
||||||
i = 0;
|
i = 0;
|
||||||
else if(i < 0)
|
for(i = compute_new_value_from_arg(arg, (double) i),
|
||||||
i = awesomeconf->screens[screen].nlayouts - 1;
|
l = awesomeconf->screens[screen].layouts; l && i > 0; i--)
|
||||||
|
l = l->next;
|
||||||
|
if(!l)
|
||||||
|
l = awesomeconf->screens[screen].layouts;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
i = 0;
|
|
||||||
|
|
||||||
for(j = 0; j < awesomeconf->screens[screen].ntags; j++)
|
for(i = 0; i < awesomeconf->screens[screen].ntags; i++)
|
||||||
if (awesomeconf->screens[screen].tags[j].selected)
|
if (awesomeconf->screens[screen].tags[i].selected)
|
||||||
awesomeconf->screens[screen].tags[j].layout = &awesomeconf->screens[screen].layouts[i];
|
awesomeconf->screens[screen].tags[i].layout = l;
|
||||||
|
|
||||||
if(get_current_tag(awesomeconf->screens[screen])->client_sel)
|
if(get_current_tag(awesomeconf->screens[screen])->client_sel)
|
||||||
arrange(awesomeconf, screen);
|
arrange(awesomeconf, screen);
|
||||||
|
|
|
@ -203,10 +203,11 @@ drawstatusbar(awesome_config *awesomeconf, int screen)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
initstatusbar(Display *disp, int screen, Statusbar *statusbar, Cursor cursor, XftFont *font, Layout *layouts, int nlayouts, Padding *padding)
|
initstatusbar(Display *disp, int screen, Statusbar *statusbar, Cursor cursor, XftFont *font, Layout *layouts, Padding *padding)
|
||||||
{
|
{
|
||||||
|
Layout *l;
|
||||||
XSetWindowAttributes wa;
|
XSetWindowAttributes wa;
|
||||||
int i, phys_screen = get_phys_screen(disp, screen);
|
int phys_screen = get_phys_screen(disp, screen);
|
||||||
ScreenInfo *si = get_screen_info(disp, screen, NULL, padding);
|
ScreenInfo *si = get_screen_info(disp, screen, NULL, padding);
|
||||||
|
|
||||||
statusbar->height = font->height * 1.5;
|
statusbar->height = font->height * 1.5;
|
||||||
|
@ -244,9 +245,9 @@ initstatusbar(Display *disp, int screen, Statusbar *statusbar, Cursor cursor, Xf
|
||||||
updatebarpos(disp, *statusbar, padding);
|
updatebarpos(disp, *statusbar, padding);
|
||||||
XMapRaised(disp, statusbar->window);
|
XMapRaised(disp, statusbar->window);
|
||||||
|
|
||||||
for(i = 0; i < nlayouts; i++)
|
for(l = layouts ; l; l = l->next)
|
||||||
statusbar->txtlayoutwidth = MAX(statusbar->txtlayoutwidth,
|
statusbar->txtlayoutwidth = MAX(statusbar->txtlayoutwidth,
|
||||||
(textwidth(disp, font, layouts[i].symbol)));
|
(textwidth(disp, font, l->symbol)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
|
|
||||||
void initstatusbar(Display *, int, Statusbar *, Cursor, XftFont *, Layout *, int, Padding *);
|
void initstatusbar(Display *, int, Statusbar *, Cursor, XftFont *, Layout *, Padding *);
|
||||||
void drawstatusbar(awesome_config *, int);
|
void drawstatusbar(awesome_config *, int);
|
||||||
int get_statusbar_position_from_str(const char *);
|
int get_statusbar_position_from_str(const char *);
|
||||||
void updatebarpos(Display *, Statusbar, Padding *);
|
void updatebarpos(Display *, Statusbar, Padding *);
|
||||||
|
|
Loading…
Reference in New Issue