diff --git a/client.c b/client.c index f7846b3e..b1f1d560 100644 --- a/client.c +++ b/client.c @@ -176,7 +176,8 @@ client_detach(Client **head, Client *c) void focus(Client *c, Bool selscreen, awesome_config *awesomeconf) { - int tag; + Tag *tag; + /* if c is NULL or invisible, take next client in the stack */ if((!c && selscreen) || (c && !isvisible(c, awesomeconf->screen, awesomeconf->tags, awesomeconf->ntags))) for(c = *awesomeconf->clients; c && !isvisible(c, awesomeconf->screen, awesomeconf->tags, awesomeconf->ntags); c = c->next); @@ -206,8 +207,8 @@ focus(Client *c, Bool selscreen, awesome_config *awesomeconf) if(!selscreen) return; *awesomeconf->client_sel = c; - if ((tag = get_current_tag_number(awesomeconf->tags, awesomeconf->ntags)) >= 0) - *awesomeconf->tags[tag].client_sel = c; + if((tag = get_current_tag(awesomeconf->tags, awesomeconf->ntags))) + tag->client_sel = c; drawstatusbar(awesomeconf); if(*awesomeconf->client_sel) { @@ -259,7 +260,8 @@ loadprops(Client *c, int ntags) void client_manage(Window w, XWindowAttributes *wa, awesome_config *awesomeconf) { - int i, tag; + int i; + Tag *tag; Client *c, *t = NULL; Window trans; Status rettrans; @@ -361,8 +363,8 @@ client_manage(Window w, XWindowAttributes *wa, awesome_config *awesomeconf) /* some windows require this */ XMoveResizeWindow(c->display, c->win, c->x, c->y, c->w, c->h); - if((tag = get_current_tag_number(awesomeconf->tags, awesomeconf->ntags)) >= 0) - *awesomeconf->tags[tag].client_sel = c; + if((tag = get_current_tag(awesomeconf->tags, awesomeconf->ntags))) + tag->client_sel = c; /* rearrange to display new window */ arrange(awesomeconf); @@ -498,8 +500,8 @@ client_unmanage(Client *c, long state, awesome_config *awesomeconf) if(*awesomeconf->client_sel == c) focus(NULL, True, awesomeconf); for(tag = 0; tag < awesomeconf->ntags; tag++) - if(*awesomeconf->tags[tag].client_sel == c) - *awesomeconf->tags[tag].client_sel = NULL; + if(awesomeconf->tags[tag].client_sel == c) + awesomeconf->tags[tag].client_sel = NULL; XUngrabButton(c->display, AnyButton, AnyModifier, c->win); window_setstate(c->display, c->win, state); XSync(c->display, False); diff --git a/config.c b/config.c index a4a4b1a2..01a3e1de 100644 --- a/config.c +++ b/config.c @@ -362,7 +362,6 @@ parse_config(Display * disp, int scr,const char *confpatharg, awesome_config *aw awesomeconf->tags[i].name = a_strdup(cfg_title(cfgsectmp)); awesomeconf->tags[i].selected = False; awesomeconf->tags[i].was_selected = False; - awesomeconf->tags[i].client_sel = p_new(Client *, 1); tmp = cfg_getstr(cfgsectmp, "layout"); for(k = 0; k < awesomeconf->nlayouts; k++) if(awesomeconf->layouts[k].arrange == name_func_lookup(tmp, LayoutsList)) diff --git a/config.h b/config.h index 6fe6e8e2..b8757d4a 100644 --- a/config.h +++ b/config.h @@ -140,7 +140,7 @@ typedef struct /** Current tag layout */ Layout *layout; /** Selected client on this tag */ - Client **client_sel; + Client *client_sel; } Tag; /** Main configuration structure */ diff --git a/layout.c b/layout.c index 11f45372..1c3a89bb 100644 --- a/layout.c +++ b/layout.c @@ -32,18 +32,18 @@ /** Find the index of the first currently selected tag * \param tags the array of tags to search * \param ntags number of elements in above array - * \return tag number + * \return tag */ -int -get_current_tag_number(Tag *tags, int ntags) +Tag * +get_current_tag(Tag *tags, int ntags) { int i; for(i = 0; i < ntags; i++) if(tags[i].selected == True) - return i; + return &tags[i]; - return -1; + return NULL; } /** Arrange windows following current selected layout @@ -54,7 +54,7 @@ void arrange(awesome_config *awesomeconf) { Client *c; - int curtag; + Tag *curtag; for(c = *awesomeconf->clients; c; c = c->next) { @@ -64,10 +64,10 @@ arrange(awesome_config *awesomeconf) else if(c->screen == awesomeconf->screen) client_ban(c); } - if ((curtag = get_current_tag_number(awesomeconf->tags, awesomeconf->ntags)) >= 0) + if ((curtag = get_current_tag(awesomeconf->tags, awesomeconf->ntags))) { - awesomeconf->tags[curtag].layout->arrange(awesomeconf); - focus(*awesomeconf->tags[curtag].client_sel, True, awesomeconf); + curtag->layout->arrange(awesomeconf); + focus(curtag->client_sel, True, awesomeconf); } else focus(NULL, True, awesomeconf); @@ -77,10 +77,10 @@ arrange(awesome_config *awesomeconf) Layout * get_current_layout(Tag *tags, int ntags) { - int curtag; + Tag *curtag; - if ((curtag = get_current_tag_number(tags, ntags)) >= 0) - return tags[curtag].layout; + if ((curtag = get_current_tag(tags, ntags))) + return curtag->layout; return NULL; } diff --git a/layout.h b/layout.h index c4911989..b975433c 100644 --- a/layout.h +++ b/layout.h @@ -28,7 +28,7 @@ void arrange(awesome_config *); Layout * get_current_layout(Tag *, int); -int get_current_tag_number(Tag *, int); +Tag * get_current_tag(Tag *, int); void restack(awesome_config *); void loadawesomeprops(awesome_config *); void saveawesomeprops(awesome_config *);