From 5f92667773a93b3b7fe93a3578dfb3a0f2d59b77 Mon Sep 17 00:00:00 2001 From: Julien Danjou Date: Thu, 27 Dec 2007 19:57:46 +0100 Subject: [PATCH] simplify sel handling --- ewmh.c | 4 +--- focus.c | 12 +++++++++++- focus.h | 2 +- layout.c | 3 +-- screen.c | 6 +----- widgets/focustitle.c | 5 +---- widgets/netwmicon.c | 5 +---- 7 files changed, 17 insertions(+), 20 deletions(-) diff --git a/ewmh.c b/ewmh.c index 2e788a59f..02380a151 100644 --- a/ewmh.c +++ b/ewmh.c @@ -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; diff --git a/focus.c b/focus.c index 5fb65def2..88f7041b3 100644 --- a/focus.c +++ b/focus.c @@ -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 diff --git a/focus.h b/focus.h index 7946b8bca..85ec45249 100644 --- a/focus.h +++ b/focus.h @@ -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); diff --git a/layout.c b/layout.c index d0b8d34b1..7d3cb839f 100644 --- a/layout.c +++ b/layout.c @@ -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); } diff --git a/screen.c b/screen.c index 39e91f40d..ff2032c88 100644 --- a/screen.c +++ b/screen.c @@ -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); } diff --git a/widgets/focustitle.c b/widgets/focustitle.c index 778b39d91..af8219d45 100644 --- a/widgets/focustitle.c +++ b/widgets/focustitle.c @@ -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, diff --git a/widgets/netwmicon.c b/widgets/netwmicon.c index 20308e471..6da4720b3 100644 --- a/widgets/netwmicon.c +++ b/widgets/netwmicon.c @@ -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;