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