simplify sel handling

This commit is contained in:
Julien Danjou 2007-12-27 19:57:46 +01:00
parent 50e7595a0c
commit 5f92667773
7 changed files with 17 additions and 20 deletions

4
ewmh.c
View File

@ -176,9 +176,7 @@ void
ewmh_update_net_active_window(int phys_screen)
{
Window win;
Tag **curtags = get_current_tags(phys_screen);
Client *sel = focus_get_latest_client_for_tags(phys_screen, curtags);
p_delete(&curtags);
Client *sel = focus_get_current_client(phys_screen);
win = sel ? sel->win : None;

12
focus.c
View File

@ -94,7 +94,7 @@ focus_delete_client(Client *c)
}
}
Client *
static Client *
focus_get_latest_client_for_tags(int screen, Tag **t)
{
FocusList *fl;
@ -107,6 +107,16 @@ focus_get_latest_client_for_tags(int screen, Tag **t)
return NULL;
}
Client *
focus_get_current_client(int screen)
{
Tag **curtags = get_current_tags(screen);
Client *sel = focus_get_latest_client_for_tags(screen, curtags);
p_delete(&curtags);
return sel;
}
/** Jump in focus history stack
* \param screen Screen ID
* \param arg Integer argument

View File

@ -26,7 +26,7 @@
void focus_add_client(Client *);
void focus_delete_client(Client *);
Client * focus_get_latest_client_for_tags(int, Tag **);
Client * focus_get_current_client(int);
UICB_PROTO(uicb_focus_history);
UICB_PROTO(uicb_focus_client_byname);

View File

@ -67,8 +67,7 @@ arrange(int screen)
}
curtags[0]->layout->arrange(screen);
focus(focus_get_latest_client_for_tags(screen, curtags),
True, screen);
focus(focus_get_current_client(screen), True, screen);
p_delete(&curtags);
restack(screen);
}

View File

@ -252,7 +252,6 @@ void
uicb_screen_focus(int screen, char *arg)
{
int new_screen, numscreens = get_screen_count();
Tag **curtags = get_current_tags(screen);
if(arg)
new_screen = compute_new_value_from_arg(arg, screen);
@ -264,10 +263,7 @@ uicb_screen_focus(int screen, char *arg)
if (new_screen > (numscreens - 1))
new_screen = 0;
focus(focus_get_latest_client_for_tags(new_screen, curtags),
True, new_screen);
p_delete(&curtags);
focus(focus_get_current_client(new_screen), True, new_screen);
move_mouse_pointer_to_screen(new_screen);
}

View File

@ -34,10 +34,7 @@ static int
focustitle_draw(Widget *widget, DrawCtx *ctx, int offset, int used)
{
VirtScreen vscreen = globalconf.screens[widget->statusbar->screen];
Tag **curtags = get_current_tags(widget->statusbar->screen);
Client *sel = focus_get_latest_client_for_tags(widget->statusbar->screen, curtags);
p_delete(&curtags);
Client *sel = focus_get_current_client(widget->statusbar->screen);
widget->location = widget_calculate_offset(vscreen.statusbar->width,
0,

View File

@ -38,10 +38,7 @@ netwmicon_draw(Widget *widget, DrawCtx *ctx, int offset,
int format, width, height, size, i;
unsigned long items, rest;
unsigned char *image, *imgdata;
Tag **curtags = get_current_tags(widget->statusbar->screen);
Client *sel = focus_get_latest_client_for_tags(widget->statusbar->screen, curtags);
p_delete(&curtags);
Client *sel = focus_get_current_client(widget->statusbar->screen);
if(!sel)
return 0;