rewrite get_current_tag_number() in get_current_tag()

This commit is contained in:
Julien Danjou 2007-10-26 22:11:02 +02:00
parent 8b7561cb89
commit 9d507dc50c
5 changed files with 24 additions and 23 deletions

View File

@ -176,7 +176,8 @@ client_detach(Client **head, Client *c)
void void
focus(Client *c, Bool selscreen, awesome_config *awesomeconf) 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 is NULL or invisible, take next client in the stack */
if((!c && selscreen) || (c && !isvisible(c, awesomeconf->screen, awesomeconf->tags, awesomeconf->ntags))) 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); 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) if(!selscreen)
return; return;
*awesomeconf->client_sel = c; *awesomeconf->client_sel = c;
if ((tag = get_current_tag_number(awesomeconf->tags, awesomeconf->ntags)) >= 0) if((tag = get_current_tag(awesomeconf->tags, awesomeconf->ntags)))
*awesomeconf->tags[tag].client_sel = c; tag->client_sel = c;
drawstatusbar(awesomeconf); drawstatusbar(awesomeconf);
if(*awesomeconf->client_sel) if(*awesomeconf->client_sel)
{ {
@ -259,7 +260,8 @@ loadprops(Client *c, int ntags)
void void
client_manage(Window w, XWindowAttributes *wa, awesome_config *awesomeconf) client_manage(Window w, XWindowAttributes *wa, awesome_config *awesomeconf)
{ {
int i, tag; int i;
Tag *tag;
Client *c, *t = NULL; Client *c, *t = NULL;
Window trans; Window trans;
Status rettrans; Status rettrans;
@ -361,8 +363,8 @@ client_manage(Window w, XWindowAttributes *wa, awesome_config *awesomeconf)
/* some windows require this */ /* some windows require this */
XMoveResizeWindow(c->display, c->win, c->x, c->y, c->w, c->h); XMoveResizeWindow(c->display, c->win, c->x, c->y, c->w, c->h);
if((tag = get_current_tag_number(awesomeconf->tags, awesomeconf->ntags)) >= 0) if((tag = get_current_tag(awesomeconf->tags, awesomeconf->ntags)))
*awesomeconf->tags[tag].client_sel = c; tag->client_sel = c;
/* rearrange to display new window */ /* rearrange to display new window */
arrange(awesomeconf); arrange(awesomeconf);
@ -498,8 +500,8 @@ client_unmanage(Client *c, long state, awesome_config *awesomeconf)
if(*awesomeconf->client_sel == c) if(*awesomeconf->client_sel == c)
focus(NULL, True, awesomeconf); focus(NULL, True, awesomeconf);
for(tag = 0; tag < awesomeconf->ntags; tag++) for(tag = 0; tag < awesomeconf->ntags; tag++)
if(*awesomeconf->tags[tag].client_sel == c) if(awesomeconf->tags[tag].client_sel == c)
*awesomeconf->tags[tag].client_sel = NULL; awesomeconf->tags[tag].client_sel = NULL;
XUngrabButton(c->display, AnyButton, AnyModifier, c->win); XUngrabButton(c->display, AnyButton, AnyModifier, c->win);
window_setstate(c->display, c->win, state); window_setstate(c->display, c->win, state);
XSync(c->display, False); XSync(c->display, False);

View File

@ -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].name = a_strdup(cfg_title(cfgsectmp));
awesomeconf->tags[i].selected = False; awesomeconf->tags[i].selected = False;
awesomeconf->tags[i].was_selected = False; awesomeconf->tags[i].was_selected = False;
awesomeconf->tags[i].client_sel = p_new(Client *, 1);
tmp = cfg_getstr(cfgsectmp, "layout"); tmp = cfg_getstr(cfgsectmp, "layout");
for(k = 0; k < awesomeconf->nlayouts; k++) for(k = 0; k < awesomeconf->nlayouts; k++)
if(awesomeconf->layouts[k].arrange == name_func_lookup(tmp, LayoutsList)) if(awesomeconf->layouts[k].arrange == name_func_lookup(tmp, LayoutsList))

View File

@ -140,7 +140,7 @@ typedef struct
/** Current tag layout */ /** Current tag layout */
Layout *layout; Layout *layout;
/** Selected client on this tag */ /** Selected client on this tag */
Client **client_sel; Client *client_sel;
} Tag; } Tag;
/** Main configuration structure */ /** Main configuration structure */

View File

@ -32,18 +32,18 @@
/** Find the index of the first currently selected tag /** Find the index of the first currently selected tag
* \param tags the array of tags to search * \param tags the array of tags to search
* \param ntags number of elements in above array * \param ntags number of elements in above array
* \return tag number * \return tag
*/ */
int Tag *
get_current_tag_number(Tag *tags, int ntags) get_current_tag(Tag *tags, int ntags)
{ {
int i; int i;
for(i = 0; i < ntags; i++) for(i = 0; i < ntags; i++)
if(tags[i].selected == True) if(tags[i].selected == True)
return i; return &tags[i];
return -1; return NULL;
} }
/** Arrange windows following current selected layout /** Arrange windows following current selected layout
@ -54,7 +54,7 @@ void
arrange(awesome_config *awesomeconf) arrange(awesome_config *awesomeconf)
{ {
Client *c; Client *c;
int curtag; Tag *curtag;
for(c = *awesomeconf->clients; c; c = c->next) for(c = *awesomeconf->clients; c; c = c->next)
{ {
@ -64,10 +64,10 @@ arrange(awesome_config *awesomeconf)
else if(c->screen == awesomeconf->screen) else if(c->screen == awesomeconf->screen)
client_ban(c); 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); curtag->layout->arrange(awesomeconf);
focus(*awesomeconf->tags[curtag].client_sel, True, awesomeconf); focus(curtag->client_sel, True, awesomeconf);
} }
else else
focus(NULL, True, awesomeconf); focus(NULL, True, awesomeconf);
@ -77,10 +77,10 @@ arrange(awesome_config *awesomeconf)
Layout * Layout *
get_current_layout(Tag *tags, int ntags) get_current_layout(Tag *tags, int ntags)
{ {
int curtag; Tag *curtag;
if ((curtag = get_current_tag_number(tags, ntags)) >= 0) if ((curtag = get_current_tag(tags, ntags)))
return tags[curtag].layout; return curtag->layout;
return NULL; return NULL;
} }

View File

@ -28,7 +28,7 @@
void arrange(awesome_config *); void arrange(awesome_config *);
Layout * get_current_layout(Tag *, int); Layout * get_current_layout(Tag *, int);
int get_current_tag_number(Tag *, int); Tag * get_current_tag(Tag *, int);
void restack(awesome_config *); void restack(awesome_config *);
void loadawesomeprops(awesome_config *); void loadawesomeprops(awesome_config *);
void saveawesomeprops(awesome_config *); void saveawesomeprops(awesome_config *);