make tags a linked list instead of array
This commit is contained in:
parent
b03cdbd877
commit
bb1381abc2
13
awesome.c
13
awesome.c
|
@ -68,14 +68,18 @@ void
|
|||
cleanup_screen(awesome_config *awesomeconf, int screen)
|
||||
{
|
||||
Layout *l, *ln;
|
||||
int i;
|
||||
Tag *t, *tn;
|
||||
|
||||
XftFontClose(awesomeconf->display, awesomeconf->screens[screen].font);
|
||||
XUngrabKey(awesomeconf->display, AnyKey, AnyModifier, RootWindow(awesomeconf->display, get_phys_screen(awesomeconf->display, screen)));
|
||||
XDestroyWindow(awesomeconf->display, awesomeconf->screens[screen].statusbar.window);
|
||||
|
||||
for(i = 0; i < awesomeconf->screens[screen].ntags; i++)
|
||||
p_delete(&awesomeconf->screens[screen].tags[i].name);
|
||||
for(t = awesomeconf->screens[screen].tags; t; t = tn)
|
||||
{
|
||||
tn = t;
|
||||
p_delete(&t->name);
|
||||
p_delete(&t);
|
||||
}
|
||||
|
||||
for(l = awesomeconf->screens[screen].layouts; l; l = ln)
|
||||
{
|
||||
|
@ -83,9 +87,6 @@ cleanup_screen(awesome_config *awesomeconf, int screen)
|
|||
p_delete(&l->symbol);
|
||||
p_delete(&l);
|
||||
}
|
||||
|
||||
p_delete(&awesomeconf->screens[screen].tags);
|
||||
p_delete(&awesomeconf->screens[screen].layouts);
|
||||
}
|
||||
|
||||
/** Cleanup everything on quit
|
||||
|
|
85
client.c
85
client.c
|
@ -43,24 +43,28 @@
|
|||
static Bool
|
||||
loadprops(Client * c, VirtScreen *scr)
|
||||
{
|
||||
int i;
|
||||
int i, ntags = 0;
|
||||
Tag *tag;
|
||||
char *prop;
|
||||
Bool result = False;
|
||||
|
||||
prop = p_new(char, scr->ntags + 2);
|
||||
for(tag = scr->tags; tag; tag = tag->next)
|
||||
ntags++;
|
||||
|
||||
if(xgettextprop(c->display, c->win, AWESOMEPROPS_ATOM(c->display), prop, scr->ntags + 2))
|
||||
prop = p_new(char, ntags + 2);
|
||||
|
||||
if(xgettextprop(c->display, c->win, AWESOMEPROPS_ATOM(c->display), prop, ntags + 2))
|
||||
{
|
||||
for(i = 0; i < scr->ntags && prop[i]; i++)
|
||||
for(i = 0, tag = scr->tags; tag && i < ntags && prop[i]; i++, tag = tag->next)
|
||||
if(prop[i] == '1')
|
||||
{
|
||||
tag_client(&scr->tclink, c, &scr->tags[i]);
|
||||
tag_client(&scr->tclink, c, tag);
|
||||
result = True;
|
||||
}
|
||||
else
|
||||
untag_client(&scr->tclink, c, &scr->tags[i]);
|
||||
untag_client(&scr->tclink, c, tag);
|
||||
|
||||
if(i <= scr->ntags && prop[i])
|
||||
if(i <= ntags && prop[i])
|
||||
c->isfloating = prop[i] == '1';
|
||||
}
|
||||
|
||||
|
@ -191,27 +195,23 @@ client_detach(Client **head, Client *c)
|
|||
void
|
||||
focus(Client *c, Bool selscreen, awesome_config *awesomeconf, int screen)
|
||||
{
|
||||
int i;
|
||||
Tag *tag = get_current_tag(awesomeconf->screens[screen]);
|
||||
Tag *tag, *curtag = get_current_tag(awesomeconf->screens[screen]);
|
||||
|
||||
/* if c is NULL or invisible, take next client in the stack */
|
||||
if((!c && selscreen) || (c && !client_isvisible(c, &awesomeconf->screens[screen], screen)))
|
||||
for(c = awesomeconf->clients; c && !client_isvisible(c, &awesomeconf->screens[screen], screen); c = c->next);
|
||||
|
||||
/* XXX unfocus other tags clients, this is a bit too much */
|
||||
for(i = 0; i < awesomeconf->screens[screen].ntags; i++)
|
||||
if(awesomeconf->screens[screen].tags[i].client_sel)
|
||||
for(tag = awesomeconf->screens[screen].tags; tag; tag = tag->next)
|
||||
if(tag->client_sel)
|
||||
{
|
||||
window_grabbuttons(awesomeconf->screens[screen].tags[i].client_sel->display,
|
||||
awesomeconf->screens[screen].tags[i].client_sel->phys_screen,
|
||||
awesomeconf->screens[screen].tags[i].client_sel->win,
|
||||
False, True, awesomeconf->buttons.root,
|
||||
window_grabbuttons(tag->client_sel->display, tag->client_sel->phys_screen,
|
||||
tag->client_sel->win, False, True, awesomeconf->buttons.root,
|
||||
awesomeconf->buttons.client, awesomeconf->numlockmask);
|
||||
XSetWindowBorder(awesomeconf->screens[screen].tags[i].client_sel->display,
|
||||
awesomeconf->screens[screen].tags[i].client_sel->win,
|
||||
XSetWindowBorder(tag->client_sel->display, tag->client_sel->win,
|
||||
awesomeconf->screens[screen].colors_normal[ColBorder].pixel);
|
||||
window_settrans(awesomeconf->screens[screen].tags[i].client_sel->display,
|
||||
awesomeconf->screens[screen].tags[i].client_sel->win, awesomeconf->screens[screen].opacity_unfocused);
|
||||
window_settrans(tag->client_sel->display, tag->client_sel->win,
|
||||
awesomeconf->screens[screen].opacity_unfocused);
|
||||
}
|
||||
if(c)
|
||||
{
|
||||
|
@ -222,15 +222,15 @@ focus(Client *c, Bool selscreen, awesome_config *awesomeconf, int screen)
|
|||
}
|
||||
if(!selscreen)
|
||||
return;
|
||||
tag->client_sel = c;
|
||||
curtag->client_sel = c;
|
||||
drawstatusbar(awesomeconf, screen);
|
||||
if(tag->client_sel)
|
||||
if(curtag->client_sel)
|
||||
{
|
||||
XSetInputFocus(tag->client_sel->display, tag->client_sel->win, RevertToPointerRoot, CurrentTime);
|
||||
XSetInputFocus(curtag->client_sel->display, curtag->client_sel->win, RevertToPointerRoot, CurrentTime);
|
||||
for(c = awesomeconf->clients; c; c = c->next)
|
||||
if(c != tag->client_sel)
|
||||
window_settrans(awesomeconf->display, tag->client_sel->win, awesomeconf->screens[screen].opacity_unfocused);
|
||||
window_settrans(awesomeconf->display, tag->client_sel->win, -1);
|
||||
if(c != curtag->client_sel)
|
||||
window_settrans(awesomeconf->display, curtag->client_sel->win, awesomeconf->screens[screen].opacity_unfocused);
|
||||
window_settrans(awesomeconf->display, curtag->client_sel->win, -1);
|
||||
}
|
||||
else
|
||||
XSetInputFocus(awesomeconf->display, RootWindow(awesomeconf->display, get_phys_screen(awesomeconf->display, screen)), RevertToPointerRoot, CurrentTime);
|
||||
|
@ -244,12 +244,12 @@ focus(Client *c, Bool selscreen, awesome_config *awesomeconf, int screen)
|
|||
void
|
||||
client_manage(Window w, XWindowAttributes *wa, awesome_config *awesomeconf, int screen)
|
||||
{
|
||||
int i;
|
||||
Client *c, *t = NULL;
|
||||
Window trans;
|
||||
Status rettrans;
|
||||
XWindowChanges wc;
|
||||
ScreenInfo *screen_info;
|
||||
Tag *tag;
|
||||
|
||||
c = p_new(Client, 1);
|
||||
|
||||
|
@ -330,9 +330,9 @@ client_manage(Window w, XWindowAttributes *wa, awesome_config *awesomeconf, int
|
|||
/* check for transient and set tags like its parent */
|
||||
if((rettrans = XGetTransientForHint(c->display, w, &trans) == Success)
|
||||
&& (t = get_client_bywin(awesomeconf->clients, trans)))
|
||||
for(i = 0; i < awesomeconf->screens[c->screen].ntags; i++)
|
||||
if(is_client_tagged(awesomeconf->screens[c->screen].tclink, t, &awesomeconf->screens[c->screen].tags[i]))
|
||||
tag_client(&awesomeconf->screens[c->screen].tclink, c, &awesomeconf->screens[c->screen].tags[i]);
|
||||
for(tag = awesomeconf->screens[c->screen].tags; tag; tag = tag->next)
|
||||
if(is_client_tagged(awesomeconf->screens[c->screen].tclink, t, tag))
|
||||
tag_client(&awesomeconf->screens[c->screen].tclink, c, tag);
|
||||
|
||||
/* should be floating if transsient or fixed) */
|
||||
if(!c->isfloating)
|
||||
|
@ -445,15 +445,19 @@ client_resize(Client *c, int x, int y, int w, int h, awesome_config *awesomeconf
|
|||
void
|
||||
client_saveprops(Client * c, VirtScreen *scr)
|
||||
{
|
||||
int i;
|
||||
int i = 0, ntags = 0;
|
||||
char *prop;
|
||||
Tag *tag;
|
||||
|
||||
prop = p_new(char, scr->ntags + 2);
|
||||
for(tag = scr->tags; tag; tag = tag->next)
|
||||
ntags++;
|
||||
|
||||
for(i = 0; i < scr->ntags; i++)
|
||||
prop[i] = is_client_tagged(scr->tclink, c, &scr->tags[i]) ? '1' : '0';
|
||||
prop = p_new(char, ntags + 2);
|
||||
|
||||
if(i <= scr->ntags)
|
||||
for(tag = scr->tags; tag; tag = tag->next, i++)
|
||||
prop[i] = is_client_tagged(scr->tclink, c, tag) ? '1' : '0';
|
||||
|
||||
if(i <= ntags)
|
||||
prop[i] = c->isfloating ? '1' : '0';
|
||||
|
||||
prop[++i] = '\0';
|
||||
|
@ -475,7 +479,7 @@ void
|
|||
client_unmanage(Client *c, long state, awesome_config *awesomeconf)
|
||||
{
|
||||
XWindowChanges wc;
|
||||
int tag;
|
||||
Tag *tag;
|
||||
|
||||
wc.border_width = c->oldborder;
|
||||
/* The server grab construct avoids race conditions. */
|
||||
|
@ -484,9 +488,8 @@ client_unmanage(Client *c, long state, awesome_config *awesomeconf)
|
|||
client_detach(&awesomeconf->clients, c);
|
||||
if(get_current_tag(awesomeconf->screens[c->screen])->client_sel == c)
|
||||
focus(NULL, True, awesomeconf, c->screen);
|
||||
for(tag = 0; tag < awesomeconf->screens[c->screen].ntags; tag++)
|
||||
untag_client(&awesomeconf->screens[c->screen].tclink, c,
|
||||
&awesomeconf->screens[c->screen].tags[tag]);
|
||||
for(tag = awesomeconf->screens[c->screen].tags; tag; tag = tag->next)
|
||||
untag_client(&awesomeconf->screens[c->screen].tclink, c, tag);
|
||||
XUngrabButton(c->display, AnyButton, AnyModifier, c->win);
|
||||
window_setstate(c->display, c->win, state);
|
||||
XSync(c->display, False);
|
||||
|
@ -568,13 +571,13 @@ client_updatesizehints(Client *c)
|
|||
Bool
|
||||
client_isvisible(Client *c, VirtScreen *scr, int screen)
|
||||
{
|
||||
int i;
|
||||
Tag *tag;
|
||||
|
||||
if(c->screen != screen)
|
||||
return False;
|
||||
|
||||
for(i = 0; i < scr->ntags; i++)
|
||||
if(is_client_tagged(scr->tclink, c, &scr->tags[i]) && scr->tags[i].selected)
|
||||
for(tag = scr->tags; tag; tag = tag->next)
|
||||
if(tag->selected && is_client_tagged(scr->tclink, c, tag))
|
||||
return True;
|
||||
return False;
|
||||
}
|
||||
|
|
61
config.c
61
config.c
|
@ -383,13 +383,14 @@ parse_config(const char *confpatharg, awesome_config *awesomeconf)
|
|||
};
|
||||
cfg_t *cfg, *cfg_general, *cfg_colors, *cfg_screen, *cfg_statusbar, *cfg_tags,
|
||||
*cfg_layouts, *cfg_rules, *cfg_keys, *cfg_mouse, *cfgsectmp, *cfg_padding;
|
||||
int i = 0, ret, screen;
|
||||
unsigned int j = 0;
|
||||
int ret, screen;
|
||||
unsigned int i = 0;
|
||||
const char *tmp, *homedir;
|
||||
char *confpath, buf[2];
|
||||
ssize_t confpath_len;
|
||||
Rule *rule = NULL;
|
||||
Layout *layout = NULL;
|
||||
Tag *tag = NULL;
|
||||
FILE *defconfig = NULL;
|
||||
|
||||
if(confpatharg)
|
||||
|
@ -475,9 +476,9 @@ parse_config(const char *confpatharg, awesome_config *awesomeconf)
|
|||
if(cfg_size(cfg_layouts, "layout"))
|
||||
{
|
||||
awesomeconf->screens[screen].layouts = layout = p_new(Layout, 1);
|
||||
for(j = 0; j < cfg_size(cfg_layouts, "layout"); j++)
|
||||
for(i = 0; i < cfg_size(cfg_layouts, "layout"); i++)
|
||||
{
|
||||
cfgsectmp = cfg_getnsec(cfg_layouts, "layout", j);
|
||||
cfgsectmp = cfg_getnsec(cfg_layouts, "layout", i);
|
||||
layout->arrange = name_func_lookup(cfg_title(cfgsectmp), LayoutsList);
|
||||
if(!layout->arrange)
|
||||
{
|
||||
|
@ -487,7 +488,7 @@ parse_config(const char *confpatharg, awesome_config *awesomeconf)
|
|||
}
|
||||
layout->symbol = a_strdup(cfg_getstr(cfgsectmp, "symbol"));
|
||||
|
||||
if(j < cfg_size(cfg_layouts, "layout") - 1)
|
||||
if(i < cfg_size(cfg_layouts, "layout") - 1)
|
||||
layout = layout->next = p_new(Layout, 1);
|
||||
else
|
||||
layout->next = NULL;
|
||||
|
@ -497,27 +498,33 @@ parse_config(const char *confpatharg, awesome_config *awesomeconf)
|
|||
eprint("fatal: no default layout available\n");
|
||||
|
||||
/* Tags */
|
||||
awesomeconf->screens[screen].ntags = cfg_size(cfg_tags, "tag");
|
||||
awesomeconf->screens[screen].tags = p_new(Tag, awesomeconf->screens[screen].ntags);
|
||||
for(i = 0; i < awesomeconf->screens[screen].ntags; i++)
|
||||
if(cfg_size(cfg_tags, "tag"))
|
||||
{
|
||||
cfgsectmp = cfg_getnsec(cfg_tags, "tag", i);
|
||||
awesomeconf->screens[screen].tags[i].name = a_strdup(cfg_title(cfgsectmp));
|
||||
awesomeconf->screens[screen].tags[i].selected = False;
|
||||
awesomeconf->screens[screen].tags[i].was_selected = False;
|
||||
tmp = cfg_getstr(cfgsectmp, "layout");
|
||||
for(layout = awesomeconf->screens[screen].layouts;
|
||||
layout && layout->arrange != name_func_lookup(tmp, LayoutsList); layout = layout->next);
|
||||
if(!layout)
|
||||
awesomeconf->screens[screen].tags[i].layout = awesomeconf->screens[screen].layouts;
|
||||
else
|
||||
awesomeconf->screens[screen].tags[i].layout = layout;
|
||||
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].ncol = cfg_getint(cfgsectmp, "ncol");
|
||||
awesomeconf->screens[screen].tags = tag = p_new(Tag, 1);
|
||||
for(i = 0; i < cfg_size(cfg_tags, "tag"); i++)
|
||||
{
|
||||
cfgsectmp = cfg_getnsec(cfg_tags, "tag", i);
|
||||
tag->name = a_strdup(cfg_title(cfgsectmp));
|
||||
tag->selected = False;
|
||||
tag->was_selected = False;
|
||||
tmp = cfg_getstr(cfgsectmp, "layout");
|
||||
for(layout = awesomeconf->screens[screen].layouts;
|
||||
layout && layout->arrange != name_func_lookup(tmp, LayoutsList); layout = layout->next);
|
||||
if(!layout)
|
||||
tag->layout = awesomeconf->screens[screen].layouts;
|
||||
else
|
||||
tag->layout = layout;
|
||||
tag->mwfact = cfg_getfloat(cfgsectmp, "mwfact");
|
||||
tag->nmaster = cfg_getint(cfgsectmp, "nmaster");
|
||||
tag->ncol = cfg_getint(cfgsectmp, "ncol");
|
||||
|
||||
if(i < cfg_size(cfg_tags, "tag") - 1)
|
||||
tag = tag->next = p_new(Tag, 1);
|
||||
else
|
||||
tag->next = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if(!awesomeconf->screens[screen].ntags)
|
||||
else
|
||||
eprint("fatal: no tags found in configuration file\n");
|
||||
|
||||
/* select first tag by default */
|
||||
|
@ -540,9 +547,9 @@ parse_config(const char *confpatharg, awesome_config *awesomeconf)
|
|||
if(cfg_size(cfg_rules, "rule"))
|
||||
{
|
||||
awesomeconf->rules = rule = p_new(Rule, 1);
|
||||
for(j = 0; j < cfg_size(cfg_rules, "rule"); j++)
|
||||
for(i = 0; i < cfg_size(cfg_rules, "rule"); i++)
|
||||
{
|
||||
cfgsectmp = cfg_getnsec(cfg_rules, "rule", j);
|
||||
cfgsectmp = cfg_getnsec(cfg_rules, "rule", i);
|
||||
rule->prop = a_strdup(cfg_getstr(cfgsectmp, "name"));
|
||||
rule->tags = a_strdup(cfg_getstr(cfgsectmp, "tags"));
|
||||
if(!a_strlen(rule->tags))
|
||||
|
@ -552,7 +559,7 @@ parse_config(const char *confpatharg, awesome_config *awesomeconf)
|
|||
if(rule->screen >= get_screen_count(awesomeconf->display))
|
||||
rule->screen = 0;
|
||||
|
||||
if(j < cfg_size(cfg_rules, "rule") - 1)
|
||||
if(i < cfg_size(cfg_rules, "rule") - 1)
|
||||
rule = rule->next = p_new(Rule, 1);
|
||||
else
|
||||
rule->next = NULL;
|
||||
|
|
9
config.h
9
config.h
|
@ -133,7 +133,8 @@ struct Client
|
|||
};
|
||||
|
||||
/** Tag type */
|
||||
typedef struct
|
||||
typedef struct Tag Tag;
|
||||
struct Tag
|
||||
{
|
||||
/** Tag name */
|
||||
char *name;
|
||||
|
@ -151,7 +152,9 @@ typedef struct
|
|||
int nmaster;
|
||||
/** Number of columns in tile layout */
|
||||
int ncol;
|
||||
} Tag;
|
||||
/** Next tag */
|
||||
Tag *next;
|
||||
};
|
||||
|
||||
/** TagClientLink type */
|
||||
typedef struct TagClientLink TagClientLink;
|
||||
|
@ -197,8 +200,6 @@ typedef struct
|
|||
XColor colors_selected[ColLast];
|
||||
/** Tag list */
|
||||
Tag *tags;
|
||||
/** Number of tags in **tags */
|
||||
int ntags;
|
||||
TagClientLink *tclink;
|
||||
/** Layout list */
|
||||
Layout *layouts;
|
||||
|
|
7
event.c
7
event.c
|
@ -65,21 +65,22 @@ handle_event_buttonpress(XEvent * e, awesome_config *awesomeconf)
|
|||
Client *c;
|
||||
Window wdummy;
|
||||
char arg[256];
|
||||
Tag *tag;
|
||||
XButtonPressedEvent *ev = &e->xbutton;
|
||||
|
||||
for(screen = 0; screen < get_screen_count(e->xany.display); screen++)
|
||||
if(awesomeconf->screens[screen].statusbar.window == ev->window)
|
||||
{
|
||||
for(i = 0; i < awesomeconf->screens[screen].ntags; i++)
|
||||
for(i = 1, tag = awesomeconf->screens[screen].tags; tag; tag = tag->next, i++)
|
||||
{
|
||||
x += textwidth(e->xany.display, awesomeconf->screens[screen].font, awesomeconf->screens[screen].tags[i].name);
|
||||
x += textwidth(e->xany.display, awesomeconf->screens[screen].font, tag->name);
|
||||
if(((awesomeconf->screens[screen].statusbar.position == BarTop
|
||||
|| awesomeconf->screens[screen].statusbar.position == BarBot)
|
||||
&& ev->x < x)
|
||||
|| (awesomeconf->screens[screen].statusbar.position == BarRight && ev->y < x)
|
||||
|| (awesomeconf->screens[screen].statusbar.position == BarLeft && ev->y > awesomeconf->screens[screen].statusbar.width - x))
|
||||
{
|
||||
snprintf(arg, sizeof(arg), "%d", i + 1);
|
||||
snprintf(arg, sizeof(arg), "%d", i);
|
||||
handle_mouse_button_press(awesomeconf, screen, ev->button, ev->state,
|
||||
awesomeconf->buttons.tag, arg);
|
||||
return;
|
||||
|
|
53
layout.c
53
layout.c
|
@ -37,11 +37,11 @@
|
|||
Tag *
|
||||
get_current_tag(VirtScreen screen)
|
||||
{
|
||||
int i;
|
||||
Tag *tag;
|
||||
|
||||
for(i = 0; i < screen.ntags; i++)
|
||||
if(screen.tags[i].selected == True)
|
||||
return &screen.tags[i];
|
||||
for(tag = screen.tags; tag; tag = tag->next)
|
||||
if(tag->selected)
|
||||
return tag;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
@ -123,20 +123,25 @@ uicb_client_focusprev(awesome_config *awesomeconf,
|
|||
}
|
||||
|
||||
void
|
||||
loadawesomeprops(awesome_config * awesomeconf, int screen)
|
||||
loadawesomeprops(awesome_config *awesomeconf, int screen)
|
||||
{
|
||||
int i;
|
||||
int i, ntags = 0;
|
||||
char *prop;
|
||||
Tag *tag;
|
||||
|
||||
prop = p_new(char, awesomeconf->screens[screen].ntags + 1);
|
||||
for(tag = awesomeconf->screens[screen].tags; tag; tag = tag->next)
|
||||
ntags++;
|
||||
|
||||
if(xgettextprop(awesomeconf->display, RootWindow(awesomeconf->display, get_phys_screen(awesomeconf->display, screen)),
|
||||
AWESOMEPROPS_ATOM(awesomeconf->display), prop, awesomeconf->screens[screen].ntags + 1))
|
||||
for(i = 0; i < awesomeconf->screens[screen].ntags && prop[i]; i++)
|
||||
prop = p_new(char, ntags + 1);
|
||||
|
||||
if(xgettextprop(awesomeconf->display,
|
||||
RootWindow(awesomeconf->display, get_phys_screen(awesomeconf->display, screen)),
|
||||
AWESOMEPROPS_ATOM(awesomeconf->display), prop, ntags + 1))
|
||||
for(i = 0, tag = awesomeconf->screens[screen].tags; tag && prop[i]; i++, tag = tag->next)
|
||||
if(prop[i] == '1')
|
||||
awesomeconf->screens[screen].tags[i].selected = True;
|
||||
tag->selected = True;
|
||||
else
|
||||
awesomeconf->screens[screen].tags[i].selected = False;
|
||||
tag->selected = False;
|
||||
|
||||
p_delete(&prop);
|
||||
}
|
||||
|
@ -185,14 +190,21 @@ restack(awesome_config *awesomeconf, int screen)
|
|||
void
|
||||
saveawesomeprops(awesome_config *awesomeconf, int screen)
|
||||
{
|
||||
int i;
|
||||
int i, ntags = 0;
|
||||
char *prop;
|
||||
Tag *tag;
|
||||
|
||||
for(tag = awesomeconf->screens[screen].tags; tag; tag = tag->next)
|
||||
ntags++;
|
||||
|
||||
prop = p_new(char, ntags + 1);
|
||||
|
||||
for(i = 0, tag = awesomeconf->screens[screen].tags; tag; tag = tag->next, i++)
|
||||
prop[i] = tag->selected ? '1' : '0';
|
||||
|
||||
prop = p_new(char, awesomeconf->screens[screen].ntags + 1);
|
||||
for(i = 0; i < awesomeconf->screens[screen].ntags; i++)
|
||||
prop[i] = awesomeconf->screens[screen].tags[i].selected ? '1' : '0';
|
||||
prop[i] = '\0';
|
||||
XChangeProperty(awesomeconf->display, RootWindow(awesomeconf->display, get_phys_screen(awesomeconf->display, screen)),
|
||||
XChangeProperty(awesomeconf->display,
|
||||
RootWindow(awesomeconf->display, get_phys_screen(awesomeconf->display, screen)),
|
||||
AWESOMEPROPS_ATOM(awesomeconf->display), XA_STRING, 8,
|
||||
PropModeReplace, (unsigned char *) prop, i);
|
||||
p_delete(&prop);
|
||||
|
@ -204,6 +216,7 @@ uicb_tag_setlayout(awesome_config * awesomeconf,
|
|||
const char *arg)
|
||||
{
|
||||
Layout *l = awesomeconf->screens[screen].layouts;
|
||||
Tag *tag;
|
||||
int i;
|
||||
|
||||
if(arg)
|
||||
|
@ -218,9 +231,9 @@ uicb_tag_setlayout(awesome_config * awesomeconf,
|
|||
l = awesomeconf->screens[screen].layouts;
|
||||
}
|
||||
|
||||
for(i = 0; i < awesomeconf->screens[screen].ntags; i++)
|
||||
if (awesomeconf->screens[screen].tags[i].selected)
|
||||
awesomeconf->screens[screen].tags[i].layout = l;
|
||||
for(tag = awesomeconf->screens[screen].tags; tag; tag = tag->next)
|
||||
if(tag->selected)
|
||||
tag->layout = l;
|
||||
|
||||
if(get_current_tag(awesomeconf->screens[screen])->client_sel)
|
||||
arrange(awesomeconf, screen);
|
||||
|
|
9
screen.c
9
screen.c
|
@ -179,12 +179,11 @@ get_phys_screen(Display *disp, int screen)
|
|||
void
|
||||
move_client_to_screen(Client *c, awesome_config *awesomeconf, int new_screen, Bool doresize)
|
||||
{
|
||||
int i, old_screen = c->screen;
|
||||
Tag *tag;
|
||||
int old_screen = c->screen;
|
||||
|
||||
/* if the client was focused on an old screen tag, remove it */
|
||||
for(i = 0; i < awesomeconf->screens[old_screen].ntags; i++)
|
||||
if(awesomeconf->screens[old_screen].tags[i].client_sel == c)
|
||||
awesomeconf->screens[old_screen].tags[i].client_sel = NULL;
|
||||
for(tag = awesomeconf->screens[old_screen].tags; tag; tag = tag->next)
|
||||
untag_client(&awesomeconf->screens[old_screen].tclink, c, tag);
|
||||
|
||||
/* tag client with new screen tags */
|
||||
tag_client_with_current_selected(c, &awesomeconf->screens[new_screen]);
|
||||
|
|
26
statusbar.c
26
statusbar.c
|
@ -50,10 +50,11 @@ isoccupied(TagClientLink *tc, int screen, Client *head, Tag *t)
|
|||
void
|
||||
drawstatusbar(awesome_config *awesomeconf, int screen)
|
||||
{
|
||||
int z, i, x = 0, y = 0, w;
|
||||
int z, x = 0, y = 0, w;
|
||||
Client *sel = get_current_tag(awesomeconf->screens[screen])->client_sel;
|
||||
Drawable drawable;
|
||||
int phys_screen = get_phys_screen(awesomeconf->display, screen);
|
||||
Tag *tag;
|
||||
|
||||
/* don't waste our time */
|
||||
if(awesomeconf->screens[screen].statusbar.position == BarOff)
|
||||
|
@ -65,11 +66,10 @@ drawstatusbar(awesome_config *awesomeconf, int screen)
|
|||
awesomeconf->screens[screen].statusbar.height,
|
||||
DefaultDepth(awesomeconf->display, phys_screen));
|
||||
|
||||
for(i = 0; i < awesomeconf->screens[screen].ntags; i++)
|
||||
for(tag = awesomeconf->screens[screen].tags; tag; tag = tag->next)
|
||||
{
|
||||
w = textwidth(awesomeconf->display, awesomeconf->screens[screen].font,
|
||||
awesomeconf->screens[screen].tags[i].name);
|
||||
if(awesomeconf->screens[screen].tags[i].selected)
|
||||
w = textwidth(awesomeconf->display, awesomeconf->screens[screen].font, tag->name);
|
||||
if(tag->selected)
|
||||
{
|
||||
drawtext(awesomeconf->display, phys_screen,
|
||||
x, y, w,
|
||||
|
@ -78,9 +78,8 @@ drawstatusbar(awesome_config *awesomeconf, int screen)
|
|||
awesomeconf->screens[screen].statusbar.width,
|
||||
awesomeconf->screens[screen].statusbar.height,
|
||||
awesomeconf->screens[screen].font,
|
||||
awesomeconf->screens[screen].tags[i].name, awesomeconf->screens[screen].colors_selected);
|
||||
if(isoccupied(awesomeconf->screens[screen].tclink, screen, awesomeconf->clients,
|
||||
&awesomeconf->screens[screen].tags[i]))
|
||||
tag->name, awesomeconf->screens[screen].colors_selected);
|
||||
if(isoccupied(awesomeconf->screens[screen].tclink, screen, awesomeconf->clients, tag))
|
||||
drawrectangle(awesomeconf->display, phys_screen,
|
||||
x, y,
|
||||
(awesomeconf->screens[screen].font->height + 2) / 4,
|
||||
|
@ -88,8 +87,7 @@ drawstatusbar(awesome_config *awesomeconf, int screen)
|
|||
drawable,
|
||||
awesomeconf->screens[screen].statusbar.width,
|
||||
awesomeconf->screens[screen].statusbar.height,
|
||||
sel && is_client_tagged(awesomeconf->screens[screen].tclink, sel,
|
||||
&awesomeconf->screens[screen].tags[i]),
|
||||
sel && is_client_tagged(awesomeconf->screens[screen].tclink, sel, tag),
|
||||
awesomeconf->screens[screen].colors_selected[ColFG]);
|
||||
}
|
||||
else
|
||||
|
@ -101,9 +99,8 @@ drawstatusbar(awesome_config *awesomeconf, int screen)
|
|||
awesomeconf->screens[screen].statusbar.width,
|
||||
awesomeconf->screens[screen].statusbar.height,
|
||||
awesomeconf->screens[screen].font,
|
||||
awesomeconf->screens[screen].tags[i].name, awesomeconf->screens[screen].colors_normal);
|
||||
if(isoccupied(awesomeconf->screens[screen].tclink, screen,
|
||||
awesomeconf->clients, &awesomeconf->screens[screen].tags[i]))
|
||||
tag->name, awesomeconf->screens[screen].colors_normal);
|
||||
if(isoccupied(awesomeconf->screens[screen].tclink, screen, awesomeconf->clients, tag))
|
||||
drawrectangle(awesomeconf->display, phys_screen,
|
||||
x, y,
|
||||
(awesomeconf->screens[screen].font->height + 2) / 4,
|
||||
|
@ -111,8 +108,7 @@ drawstatusbar(awesome_config *awesomeconf, int screen)
|
|||
drawable,
|
||||
awesomeconf->screens[screen].statusbar.width,
|
||||
awesomeconf->screens[screen].statusbar.height,
|
||||
sel && is_client_tagged(awesomeconf->screens[screen].tclink, sel,
|
||||
&awesomeconf->screens[screen].tags[i]),
|
||||
sel && is_client_tagged(awesomeconf->screens[screen].tclink, sel, tag),
|
||||
awesomeconf->screens[screen].colors_normal[ColFG]);
|
||||
}
|
||||
x += w;
|
||||
|
|
179
tag.c
179
tag.c
|
@ -96,21 +96,21 @@ is_client_tagged(TagClientLink *head, Client *c, Tag *t)
|
|||
void
|
||||
tag_client_with_current_selected(Client *c, VirtScreen *screen)
|
||||
{
|
||||
int i;
|
||||
Tag *tag;
|
||||
|
||||
for(i = 0; i < screen->ntags; i++)
|
||||
if(screen->tags[i].selected)
|
||||
tag_client(&screen->tclink, c, &screen->tags[i]);
|
||||
for(tag = screen->tags; tag; tag = tag->next)
|
||||
if(tag->selected)
|
||||
tag_client(&screen->tclink, c, tag);
|
||||
else
|
||||
untag_client(&screen->tclink, c, &screen->tags[i]);
|
||||
untag_client(&screen->tclink, c, tag);
|
||||
}
|
||||
|
||||
void
|
||||
tag_client_with_rules(Client *c, awesome_config *awesomeconf)
|
||||
{
|
||||
Rule *r;
|
||||
Tag *tag;
|
||||
Bool matched = False;
|
||||
int i;
|
||||
|
||||
for(r = awesomeconf->rules; r; r = r->next)
|
||||
if(client_match_rule(c, r))
|
||||
|
@ -120,12 +120,11 @@ tag_client_with_rules(Client *c, awesome_config *awesomeconf)
|
|||
if(r->screen != RULE_NOSCREEN && r->screen != c->screen)
|
||||
move_client_to_screen(c, awesomeconf, r->screen, True);
|
||||
|
||||
for(i = 0; i < awesomeconf->screens[c->screen].ntags; i++)
|
||||
if(is_tag_match_rules(&awesomeconf->screens[c->screen].tags[i], r))
|
||||
for(tag = awesomeconf->screens[c->screen].tags; tag; tag = tag->next)
|
||||
if(is_tag_match_rules(tag, r))
|
||||
{
|
||||
matched = True;
|
||||
tag_client(&awesomeconf->screens[c->screen].tclink, c,
|
||||
&awesomeconf->screens[c->screen].tags[i]);
|
||||
tag_client(&awesomeconf->screens[c->screen].tclink, c, tag);
|
||||
}
|
||||
|
||||
if(!matched)
|
||||
|
@ -143,7 +142,8 @@ uicb_client_tag(awesome_config *awesomeconf,
|
|||
int screen,
|
||||
const char *arg)
|
||||
{
|
||||
int i, tag_id = -1;
|
||||
int tag_id = -1;
|
||||
Tag *tag, *target_tag;
|
||||
Client *sel = get_current_tag(awesomeconf->screens[screen])->client_sel;
|
||||
|
||||
if(!sel)
|
||||
|
@ -152,21 +152,21 @@ uicb_client_tag(awesome_config *awesomeconf,
|
|||
if(arg)
|
||||
{
|
||||
tag_id = atoi(arg) - 1;
|
||||
if(tag_id < 0 || tag_id >= awesomeconf->screens[screen].ntags)
|
||||
return;
|
||||
if(tag_id != -1)
|
||||
{
|
||||
for(target_tag = awesomeconf->screens[screen].tags; target_tag && tag_id > 0;
|
||||
target_tag = target_tag->next, tag_id--);
|
||||
if(target_tag)
|
||||
{
|
||||
for(tag = awesomeconf->screens[screen].tags; tag; tag = tag->next)
|
||||
untag_client(&awesomeconf->screens[screen].tclink, sel, tag);
|
||||
tag_client(&awesomeconf->screens[screen].tclink, sel, target_tag);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(arg)
|
||||
for(i = 0; i < awesomeconf->screens[screen].ntags; i++)
|
||||
untag_client(&awesomeconf->screens[screen].tclink, sel,
|
||||
&awesomeconf->screens[screen].tags[i]);
|
||||
else
|
||||
for(i = 0; i < awesomeconf->screens[screen].ntags; i++)
|
||||
tag_client(&awesomeconf->screens[screen].tclink, sel,
|
||||
&awesomeconf->screens[screen].tags[i]);
|
||||
if(tag_id != -1)
|
||||
tag_client(&awesomeconf->screens[screen].tclink, sel,
|
||||
&awesomeconf->screens[screen].tags[tag_id]);
|
||||
for(tag = awesomeconf->screens[screen].tags; tag; tag = tag->next)
|
||||
tag_client(&awesomeconf->screens[screen].tclink, sel, tag);
|
||||
|
||||
client_saveprops(sel, &awesomeconf->screens[screen]);
|
||||
arrange(awesomeconf, screen);
|
||||
|
@ -207,7 +207,8 @@ uicb_client_toggletag(awesome_config *awesomeconf,
|
|||
const char *arg)
|
||||
{
|
||||
Client *sel = get_current_tag(awesomeconf->screens[screen])->client_sel;
|
||||
int i, j;
|
||||
int i;
|
||||
Tag *tag, *target_tag;
|
||||
|
||||
if(!sel)
|
||||
return;
|
||||
|
@ -215,27 +216,29 @@ uicb_client_toggletag(awesome_config *awesomeconf,
|
|||
if(arg)
|
||||
{
|
||||
i = atoi(arg) - 1;
|
||||
|
||||
if(i < 0 || i >= awesomeconf->screens[screen].ntags)
|
||||
return;
|
||||
|
||||
if(is_client_tagged(awesomeconf->screens[screen].tclink, sel,
|
||||
&awesomeconf->screens[screen].tags[i]))
|
||||
untag_client(&awesomeconf->screens[screen].tclink, sel,&awesomeconf->screens[screen].tags[i]);
|
||||
else
|
||||
tag_client(&awesomeconf->screens[screen].tclink, sel,&awesomeconf->screens[screen].tags[i]);
|
||||
for(target_tag = awesomeconf->screens[screen].tags; target_tag && i > 0;
|
||||
target_tag = target_tag->next, i--);
|
||||
if(target_tag)
|
||||
{
|
||||
if(is_client_tagged(awesomeconf->screens[screen].tclink, sel, target_tag))
|
||||
untag_client(&awesomeconf->screens[screen].tclink, sel, target_tag);
|
||||
else
|
||||
tag_client(&awesomeconf->screens[screen].tclink, sel, target_tag);
|
||||
}
|
||||
|
||||
/* check that there's at least one tag selected for this client*/
|
||||
for(j = 0; j < awesomeconf->screens[screen].ntags
|
||||
&& !is_client_tagged(awesomeconf->screens[screen].tclink, sel,
|
||||
&awesomeconf->screens[screen].tags[j]); j++);
|
||||
for(tag = awesomeconf->screens[screen].tags; tag
|
||||
&& !is_client_tagged(awesomeconf->screens[screen].tclink, sel, tag); tag = tag->next)
|
||||
|
||||
if(j == awesomeconf->screens[screen].ntags)
|
||||
tag_client(&awesomeconf->screens[screen].tclink, sel,&awesomeconf->screens[screen].tags[i]);
|
||||
if(!tag)
|
||||
tag_client(&awesomeconf->screens[screen].tclink, sel, target_tag);
|
||||
}
|
||||
else
|
||||
for(i = 0; i < awesomeconf->screens[screen].ntags; i++)
|
||||
tag_client(&awesomeconf->screens[screen].tclink, sel,&awesomeconf->screens[screen].tags[i]);
|
||||
for(tag = awesomeconf->screens[screen].tags; tag; tag = tag->next)
|
||||
if(is_client_tagged(awesomeconf->screens[screen].tclink, sel, tag))
|
||||
tag_client(&awesomeconf->screens[screen].tclink, sel, tag);
|
||||
else
|
||||
untag_client(&awesomeconf->screens[screen].tclink, sel, tag);
|
||||
|
||||
client_saveprops(sel, &awesomeconf->screens[screen]);
|
||||
arrange(awesomeconf, screen);
|
||||
|
@ -250,19 +253,26 @@ uicb_tag_toggleview(awesome_config *awesomeconf,
|
|||
int screen,
|
||||
const char *arg)
|
||||
{
|
||||
int i, j;
|
||||
int i;
|
||||
Tag *tag, *target_tag;
|
||||
|
||||
i = arg ? atoi(arg) - 1: 0;
|
||||
if(arg)
|
||||
{
|
||||
i = atoi(arg) - 1;
|
||||
for(target_tag = awesomeconf->screens[screen].tags; target_tag && i > 0;
|
||||
target_tag = target_tag->next, i--);
|
||||
|
||||
if(i < 0 || i >= awesomeconf->screens[screen].ntags)
|
||||
return;
|
||||
if(target_tag)
|
||||
target_tag->selected = !target_tag->selected;
|
||||
|
||||
awesomeconf->screens[screen].tags[i].selected = !awesomeconf->screens[screen].tags[i].selected;
|
||||
|
||||
/* check that there's at least one tag selected */
|
||||
for(j = 0; j < awesomeconf->screens[screen].ntags && !awesomeconf->screens[screen].tags[j].selected; j++);
|
||||
if(j == awesomeconf->screens[screen].ntags)
|
||||
awesomeconf->screens[screen].tags[i].selected = True;
|
||||
/* check that there's at least one tag selected */
|
||||
for(tag = awesomeconf->screens[screen].tags; tag && !tag->selected; tag = tag->next);
|
||||
if(!tag)
|
||||
target_tag->selected = True;
|
||||
}
|
||||
else
|
||||
for(tag = awesomeconf->screens[screen].tags; tag; tag = tag->next)
|
||||
tag->selected = !tag->selected;
|
||||
|
||||
saveawesomeprops(awesomeconf, screen);
|
||||
arrange(awesomeconf, screen);
|
||||
|
@ -278,23 +288,24 @@ uicb_tag_view(awesome_config *awesomeconf,
|
|||
int screen,
|
||||
const char *arg)
|
||||
{
|
||||
int i, tag_id = -1;
|
||||
int i;
|
||||
Tag *tag, *target_tag;
|
||||
|
||||
if(arg)
|
||||
{
|
||||
tag_id = atoi(arg) - 1;
|
||||
if(tag_id < 0 || tag_id >= awesomeconf->screens[screen].ntags)
|
||||
return;
|
||||
i = atoi(arg) - 1;
|
||||
for(target_tag = awesomeconf->screens[screen].tags; target_tag && i > 0;
|
||||
target_tag = target_tag->next, i--);
|
||||
if(target_tag)
|
||||
{
|
||||
for(tag = awesomeconf->screens[screen].tags; tag; tag = tag->next)
|
||||
tag->selected = False;
|
||||
target_tag->selected = True;
|
||||
}
|
||||
}
|
||||
|
||||
for(i = 0; i < awesomeconf->screens[screen].ntags; i++)
|
||||
{
|
||||
awesomeconf->screens[screen].tags[i].was_selected = awesomeconf->screens[screen].tags[i].selected;
|
||||
awesomeconf->screens[screen].tags[i].selected = arg == NULL;
|
||||
}
|
||||
|
||||
if(tag_id != -1)
|
||||
awesomeconf->screens[screen].tags[tag_id].selected = True;
|
||||
else
|
||||
for(tag = awesomeconf->screens[screen].tags; tag; tag = tag->next)
|
||||
tag->selected = True;
|
||||
|
||||
saveawesomeprops(awesomeconf, screen);
|
||||
arrange(awesomeconf, screen);
|
||||
|
@ -310,14 +321,14 @@ uicb_tag_prev_selected(awesome_config *awesomeconf,
|
|||
int screen,
|
||||
const char *arg __attribute__ ((unused)))
|
||||
{
|
||||
int i;
|
||||
Tag *tag;
|
||||
Bool t;
|
||||
|
||||
for(i = 0; i < awesomeconf->screens[screen].ntags; i++)
|
||||
for(tag = awesomeconf->screens[screen].tags; tag; tag = tag->next)
|
||||
{
|
||||
t = awesomeconf->screens[screen].tags[i].selected;
|
||||
awesomeconf->screens[screen].tags[i].selected = awesomeconf->screens[screen].tags[i].was_selected;
|
||||
awesomeconf->screens[screen].tags[i].was_selected = t;
|
||||
t = tag->selected;
|
||||
tag->selected = tag->was_selected;
|
||||
tag->was_selected = t;
|
||||
}
|
||||
arrange(awesomeconf, screen);
|
||||
}
|
||||
|
@ -331,18 +342,11 @@ uicb_tag_viewnext(awesome_config *awesomeconf,
|
|||
int screen,
|
||||
const char *arg __attribute__ ((unused)))
|
||||
{
|
||||
int i;
|
||||
int firsttag = -1;
|
||||
Tag *curtag = get_current_tag(awesomeconf->screens[screen]);
|
||||
|
||||
curtag->selected = False;
|
||||
curtag->next->selected = True;
|
||||
|
||||
for(i = 0; i < awesomeconf->screens[screen].ntags; i++)
|
||||
{
|
||||
if(firsttag < 0 && awesomeconf->screens[screen].tags[i].selected)
|
||||
firsttag = i;
|
||||
awesomeconf->screens[screen].tags[i].selected = False;
|
||||
}
|
||||
if(++firsttag >= awesomeconf->screens[screen].ntags)
|
||||
firsttag = 0;
|
||||
awesomeconf->screens[screen].tags[firsttag].selected = True;
|
||||
saveawesomeprops(awesomeconf, screen);
|
||||
arrange(awesomeconf, screen);
|
||||
}
|
||||
|
@ -356,18 +360,15 @@ uicb_tag_viewprev(awesome_config *awesomeconf,
|
|||
int screen,
|
||||
const char *arg __attribute__ ((unused)))
|
||||
{
|
||||
int i;
|
||||
int firsttag = -1;
|
||||
Tag *tag, *curtag = get_current_tag(awesomeconf->screens[screen]);
|
||||
|
||||
for(i = awesomeconf->screens[screen].ntags - 1; i >= 0; i--)
|
||||
for(tag = awesomeconf->screens[screen].tags - 1; tag && tag->next != curtag; tag = tag->next);
|
||||
if(tag)
|
||||
{
|
||||
if(firsttag < 0 && awesomeconf->screens[screen].tags[i].selected)
|
||||
firsttag = i;
|
||||
awesomeconf->screens[screen].tags[i].selected = False;
|
||||
tag->selected = True;
|
||||
curtag->selected = False;
|
||||
}
|
||||
if(--firsttag < 0)
|
||||
firsttag = awesomeconf->screens[screen].ntags - 1;
|
||||
awesomeconf->screens[screen].tags[firsttag].selected = True;
|
||||
|
||||
saveawesomeprops(awesomeconf, screen);
|
||||
arrange(awesomeconf, screen);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue