Remember the focused window on tag changes
a. Adds a get_current_tag_number function to allow for above updates and teaches get_current_layout(...) and arrange(...) to use it. b. Adds an extra client_sel entry in struct Tag, updated on focus(...), manage(...), and unmanage(...), and used in arrange(...).
This commit is contained in:
parent
dd5387e25e
commit
4db1146f6c
12
client.c
12
client.c
|
@ -349,6 +349,7 @@ 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;
|
||||||
/* 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);
|
||||||
|
@ -374,6 +375,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)
|
||||||
|
*awesomeconf->tags[tag].client_sel = c;
|
||||||
drawstatusbar(awesomeconf);
|
drawstatusbar(awesomeconf);
|
||||||
if(*awesomeconf->client_sel)
|
if(*awesomeconf->client_sel)
|
||||||
{
|
{
|
||||||
|
@ -425,7 +428,7 @@ loadprops(Client *c, int ntags)
|
||||||
void
|
void
|
||||||
manage(Window w, XWindowAttributes *wa, awesome_config *awesomeconf)
|
manage(Window w, XWindowAttributes *wa, awesome_config *awesomeconf)
|
||||||
{
|
{
|
||||||
int i;
|
int i, tag;
|
||||||
Client *c, *t = NULL;
|
Client *c, *t = NULL;
|
||||||
Window trans;
|
Window trans;
|
||||||
Status rettrans;
|
Status rettrans;
|
||||||
|
@ -526,6 +529,9 @@ 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)
|
||||||
|
*awesomeconf->tags[tag].client_sel = c;
|
||||||
|
|
||||||
/* rearrange to display new window */
|
/* rearrange to display new window */
|
||||||
arrange(awesomeconf);
|
arrange(awesomeconf);
|
||||||
}
|
}
|
||||||
|
@ -649,6 +655,7 @@ void
|
||||||
unmanage(Client *c, long state, awesome_config *awesomeconf)
|
unmanage(Client *c, long state, awesome_config *awesomeconf)
|
||||||
{
|
{
|
||||||
XWindowChanges wc;
|
XWindowChanges wc;
|
||||||
|
int tag;
|
||||||
|
|
||||||
client_untab(c);
|
client_untab(c);
|
||||||
wc.border_width = c->oldborder;
|
wc.border_width = c->oldborder;
|
||||||
|
@ -658,6 +665,9 @@ unmanage(Client *c, long state, awesome_config *awesomeconf)
|
||||||
client_detach(awesomeconf->clients, c);
|
client_detach(awesomeconf->clients, c);
|
||||||
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++)
|
||||||
|
if(*awesomeconf->tags[tag].client_sel == c)
|
||||||
|
*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);
|
||||||
|
|
1
config.c
1
config.c
|
@ -362,6 +362,7 @@ 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))
|
||||||
|
|
28
config.h
28
config.h
|
@ -80,19 +80,6 @@ typedef struct
|
||||||
int screen;
|
int screen;
|
||||||
} Statusbar;
|
} Statusbar;
|
||||||
|
|
||||||
/** Tag type */
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
/** Tag name */
|
|
||||||
char *name;
|
|
||||||
/** True if selected */
|
|
||||||
Bool selected;
|
|
||||||
/** True if was selected before selecting others tags */
|
|
||||||
Bool was_selected;
|
|
||||||
/** Current tag layout */
|
|
||||||
Layout *layout;
|
|
||||||
} Tag;
|
|
||||||
|
|
||||||
typedef struct Client Client;
|
typedef struct Client Client;
|
||||||
struct Client
|
struct Client
|
||||||
{
|
{
|
||||||
|
@ -141,6 +128,21 @@ struct Client
|
||||||
int phys_screen;
|
int phys_screen;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/** Tag type */
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
/** Tag name */
|
||||||
|
char *name;
|
||||||
|
/** True if selected */
|
||||||
|
Bool selected;
|
||||||
|
/** True if was selected before selecting others tags */
|
||||||
|
Bool was_selected;
|
||||||
|
/** Current tag layout */
|
||||||
|
Layout *layout;
|
||||||
|
/** Selected client on this tag */
|
||||||
|
Client **client_sel;
|
||||||
|
} Tag;
|
||||||
|
|
||||||
/** Main configuration structure */
|
/** Main configuration structure */
|
||||||
struct awesome_config
|
struct awesome_config
|
||||||
{
|
{
|
||||||
|
|
32
layout.c
32
layout.c
|
@ -29,6 +29,22 @@
|
||||||
#include "statusbar.h"
|
#include "statusbar.h"
|
||||||
#include "layouts/floating.h"
|
#include "layouts/floating.h"
|
||||||
|
|
||||||
|
/** 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
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
get_current_tag_number(Tag *tags, int ntags)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for(i = 0; i < ntags; i++)
|
||||||
|
if(tags[i].selected == True)
|
||||||
|
return i;
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
/** Arrange windows following current selected layout
|
/** Arrange windows following current selected layout
|
||||||
* \param disp display ref
|
* \param disp display ref
|
||||||
* \param awesomeconf awesome config
|
* \param awesomeconf awesome config
|
||||||
|
@ -37,6 +53,7 @@ void
|
||||||
arrange(awesome_config *awesomeconf)
|
arrange(awesome_config *awesomeconf)
|
||||||
{
|
{
|
||||||
Client *c;
|
Client *c;
|
||||||
|
int curtag;
|
||||||
|
|
||||||
for(c = *awesomeconf->clients; c; c = c->next)
|
for(c = *awesomeconf->clients; c; c = c->next)
|
||||||
{
|
{
|
||||||
|
@ -46,20 +63,23 @@ arrange(awesome_config *awesomeconf)
|
||||||
else if(c->screen == awesomeconf->screen)
|
else if(c->screen == awesomeconf->screen)
|
||||||
ban(c);
|
ban(c);
|
||||||
}
|
}
|
||||||
get_current_layout(awesomeconf->tags, awesomeconf->ntags)->arrange(awesomeconf);
|
if ((curtag = get_current_tag_number(awesomeconf->tags, awesomeconf->ntags)) >= 0)
|
||||||
|
{
|
||||||
|
awesomeconf->tags[curtag].layout->arrange(awesomeconf);
|
||||||
|
focus(*awesomeconf->tags[curtag].client_sel, True, awesomeconf);
|
||||||
|
}
|
||||||
|
else
|
||||||
focus(NULL, True, awesomeconf);
|
focus(NULL, True, awesomeconf);
|
||||||
restack(awesomeconf);
|
restack(awesomeconf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Layout *
|
Layout *
|
||||||
get_current_layout(Tag *tags, int ntags)
|
get_current_layout(Tag *tags, int ntags)
|
||||||
{
|
{
|
||||||
int i;
|
int curtag;
|
||||||
|
|
||||||
for(i = 0; i < ntags; i++)
|
if ((curtag = get_current_tag_number(tags, ntags)) >= 0)
|
||||||
if(tags[i].selected)
|
return tags[curtag].layout;
|
||||||
return tags[i].layout;
|
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
1
layout.h
1
layout.h
|
@ -28,6 +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);
|
||||||
void restack(awesome_config *);
|
void restack(awesome_config *);
|
||||||
void loadawesomeprops(awesome_config *);
|
void loadawesomeprops(awesome_config *);
|
||||||
void saveawesomeprops(awesome_config *);
|
void saveawesomeprops(awesome_config *);
|
||||||
|
|
Loading…
Reference in New Issue