Refactor the focus.c interface to use globalconf.
This commit is contained in:
parent
b6bfd1a4d0
commit
d5fd96dbd2
|
@ -333,7 +333,7 @@ main(int argc, char *argv[])
|
|||
XSync(dpy, False);
|
||||
|
||||
globalconf.screens = p_new(VirtScreen, get_screen_count(dpy));
|
||||
focus_add_client(&globalconf.focus, NULL);
|
||||
focus_add_client(NULL);
|
||||
/* store display */
|
||||
globalconf.display = dpy;
|
||||
config_parse(confpath);
|
||||
|
|
4
client.c
4
client.c
|
@ -224,7 +224,7 @@ focus(Client *c, Bool selscreen, int screen)
|
|||
return;
|
||||
|
||||
/* save old sel in focus history */
|
||||
focus_add_client(&globalconf.focus, c);
|
||||
focus_add_client(c);
|
||||
|
||||
statusbar_draw(screen);
|
||||
|
||||
|
@ -493,7 +493,7 @@ client_unmanage(Client *c, long state)
|
|||
client_detach(c);
|
||||
if(globalconf.focus->client == c)
|
||||
focus(NULL, True, c->screen);
|
||||
focus_delete_client(&globalconf.focus, c);
|
||||
focus_delete_client(c);
|
||||
for(tag = globalconf.screens[c->screen].tags; tag; tag = tag->next)
|
||||
untag_client(c, tag, c->screen);
|
||||
XUngrabButton(c->display, AnyButton, AnyModifier, c->win);
|
||||
|
|
36
focus.c
36
focus.c
|
@ -27,11 +27,11 @@
|
|||
extern awesome_config globalconf;
|
||||
|
||||
static FocusList *
|
||||
focus_get_node_by_client(FocusList *head, Client *c)
|
||||
focus_get_node_by_client(Client *c)
|
||||
{
|
||||
FocusList *fh;
|
||||
|
||||
for(fh = head; fh; fh = fh->prev)
|
||||
for(fh = globalconf.focus; fh; fh = fh->prev)
|
||||
if(fh->client == c)
|
||||
return fh;
|
||||
|
||||
|
@ -39,15 +39,15 @@ focus_get_node_by_client(FocusList *head, Client *c)
|
|||
}
|
||||
|
||||
static FocusList *
|
||||
focus_detach_node(FocusList **head, FocusList *fl)
|
||||
focus_detach_node(FocusList *fl)
|
||||
{
|
||||
FocusList *tmp;
|
||||
|
||||
if(*head == fl)
|
||||
*head = fl->prev;
|
||||
if(globalconf.focus == fl)
|
||||
globalconf.focus = fl->prev;
|
||||
else
|
||||
{
|
||||
for(tmp = *head; tmp && tmp->prev != fl; tmp = tmp->prev);
|
||||
for(tmp = globalconf.focus; tmp && tmp->prev != fl; tmp = tmp->prev);
|
||||
tmp->prev = fl->prev;
|
||||
}
|
||||
|
||||
|
@ -55,51 +55,51 @@ focus_detach_node(FocusList **head, FocusList *fl)
|
|||
}
|
||||
|
||||
static FocusList *
|
||||
focus_attach_node(FocusList **head, FocusList *fl)
|
||||
focus_attach_node(FocusList *fl)
|
||||
{
|
||||
FocusList *old_head;
|
||||
|
||||
old_head = *head;
|
||||
*head = fl;
|
||||
old_head = globalconf.focus;
|
||||
globalconf.focus = fl;
|
||||
fl->prev = old_head;
|
||||
|
||||
return fl;
|
||||
}
|
||||
|
||||
void
|
||||
focus_add_client(FocusList **head, Client *c)
|
||||
focus_add_client(Client *c)
|
||||
{
|
||||
FocusList *new_fh;
|
||||
|
||||
/* if we don't find this node, create a new one */
|
||||
if(!(new_fh = focus_get_node_by_client(*head, c)))
|
||||
if(!(new_fh = focus_get_node_by_client(c)))
|
||||
{
|
||||
new_fh = p_new(FocusList, 1);
|
||||
new_fh->client = c;
|
||||
}
|
||||
else /* if we've got a node, detach it */
|
||||
focus_detach_node(head, new_fh);
|
||||
focus_detach_node(new_fh);
|
||||
|
||||
focus_attach_node(head, new_fh);
|
||||
focus_attach_node(new_fh);
|
||||
}
|
||||
|
||||
void
|
||||
focus_delete_client(FocusList **head, Client *c)
|
||||
focus_delete_client(Client *c)
|
||||
{
|
||||
FocusList *fc = focus_get_node_by_client(*head, c), *target;
|
||||
FocusList *fc = focus_get_node_by_client(c), *target;
|
||||
if (fc)
|
||||
{
|
||||
target = focus_detach_node(head, fc);
|
||||
target = focus_detach_node(fc);
|
||||
p_delete(&target);
|
||||
}
|
||||
}
|
||||
|
||||
Client *
|
||||
focus_get_latest_client_for_tag(FocusList *head, int screen, Tag *t)
|
||||
focus_get_latest_client_for_tag(int screen, Tag *t)
|
||||
{
|
||||
FocusList *fl;
|
||||
|
||||
for(fl = head; fl; fl = fl->prev)
|
||||
for(fl = globalconf.focus; fl; fl = fl->prev)
|
||||
if(is_client_tagged(fl->client, t, screen))
|
||||
return fl->client;
|
||||
|
||||
|
|
6
focus.h
6
focus.h
|
@ -24,9 +24,9 @@
|
|||
|
||||
#include "config.h"
|
||||
|
||||
void focus_add_client(FocusList **, Client *);
|
||||
void focus_delete_client(FocusList **, Client *);
|
||||
Client * focus_get_latest_client_for_tag(FocusList *, int, Tag *);
|
||||
void focus_add_client(Client *);
|
||||
void focus_delete_client(Client *);
|
||||
Client * focus_get_latest_client_for_tag(int, Tag *);
|
||||
|
||||
UICB_PROTO(uicb_focus_history);
|
||||
|
||||
|
|
2
layout.c
2
layout.c
|
@ -83,7 +83,7 @@ arrange(int screen)
|
|||
}
|
||||
|
||||
curtag->layout->arrange(screen);
|
||||
focus(focus_get_latest_client_for_tag(globalconf.focus, screen, curtag),
|
||||
focus(focus_get_latest_client_for_tag(screen, curtag),
|
||||
True, screen);
|
||||
restack(screen);
|
||||
}
|
||||
|
|
4
screen.c
4
screen.c
|
@ -262,9 +262,7 @@ uicb_screen_focus(int screen, char *arg)
|
|||
if (new_screen > (numscreens - 1))
|
||||
new_screen = 0;
|
||||
|
||||
focus(focus_get_latest_client_for_tag(globalconf.focus,
|
||||
new_screen,
|
||||
get_current_tag(new_screen)),
|
||||
focus(focus_get_latest_client_for_tag(new_screen, get_current_tag(new_screen)),
|
||||
True, new_screen);
|
||||
|
||||
move_mouse_pointer_to_screen(globalconf.display, new_screen);
|
||||
|
|
|
@ -10,8 +10,7 @@ static int
|
|||
focustitle_draw(Widget *widget, DrawCtx *ctx, int offset, int used)
|
||||
{
|
||||
VirtScreen vscreen = globalconf.screens[widget->statusbar->screen];
|
||||
Client *sel = focus_get_latest_client_for_tag(globalconf.focus,
|
||||
widget->statusbar->screen,
|
||||
Client *sel = focus_get_latest_client_for_tag(widget->statusbar->screen,
|
||||
get_current_tag(widget->statusbar->screen));
|
||||
int location = calculate_offset(vscreen.statusbar.width,
|
||||
0,
|
||||
|
|
Loading…
Reference in New Issue