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
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);

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].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))

View File

@ -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 */

View File

@ -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;
}

View File

@ -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 *);