diff --git a/ewmh.c b/ewmh.c index aa4e5eecb..28f3d4c5c 100644 --- a/ewmh.c +++ b/ewmh.c @@ -310,7 +310,7 @@ ewmh_process_client_message(XClientMessageEvent *ev) if(ev->message_type == net_current_desktop) for(screen = 0; screen < ScreenCount(globalconf.display); screen++) if(ev->window == RootWindow(globalconf.display, screen)) - tag_view_byindex(screen, ev->data.l[0]); + tag_view_only_byindex(screen, ev->data.l[0]); if(ev->message_type == net_close_window) { diff --git a/tag.c b/tag.c index 898425400..e2287f1f1 100644 --- a/tag.c +++ b/tag.c @@ -272,26 +272,29 @@ uicb_tag_toggleview(int screen, char *arg) widget_invalidate_cache(screen, WIDGET_CACHE_TAGS); } -void -tag_view_byindex(int screen, int dindex) +static void +tag_view_only(int screen, Tag *target) { - Tag *target_tag, *tag; + Tag *tag; + + if(!target) return; + + for(tag = globalconf.screens[screen].tags; tag; tag = tag->next) + tag->selected = False; + target->selected = True; +} + +void +tag_view_only_byindex(int screen, int dindex) +{ + Tag *tag; if(dindex < 0) return; - for(target_tag = globalconf.screens[screen].tags; target_tag && dindex > 0; - target_tag = target_tag->next, dindex--); - if(target_tag) - { - for(tag = globalconf.screens[screen].tags; tag; tag = tag->next) - tag->selected = False; - target_tag->selected = True; - } - saveawesomeprops(screen); - arrange(screen); - ewmh_update_net_current_desktop(get_phys_screen(screen)); - widget_invalidate_cache(screen, WIDGET_CACHE_TAGS); + for(tag = globalconf.screens[screen].tags; tag && dindex > 0; + tag = tag->next, dindex--); + tag_view_only(screen, tag); } /** View tag @@ -305,16 +308,15 @@ uicb_tag_view(int screen, char *arg) Tag *tag; if(arg) - tag_view_byindex(screen, atoi(arg) - 1); + tag_view_only_byindex(screen, atoi(arg) - 1); else - { for(tag = globalconf.screens[screen].tags; tag; tag = tag->next) tag->selected = True; - saveawesomeprops(screen); - arrange(screen); - ewmh_update_net_current_desktop(get_phys_screen(screen)); - widget_invalidate_cache(screen, WIDGET_CACHE_TAGS); - } + + saveawesomeprops(screen); + arrange(screen); + ewmh_update_net_current_desktop(get_phys_screen(screen)); + widget_invalidate_cache(screen, WIDGET_CACHE_TAGS); } /** View previously selected tags @@ -334,6 +336,7 @@ uicb_tag_prev_selected(int screen, char *arg __attribute__ ((unused))) tag->selected = tag->was_selected; tag->was_selected = t; } + saveawesomeprops(screen); arrange(screen); ewmh_update_net_current_desktop(get_phys_screen(screen)); widget_invalidate_cache(screen, WIDGET_CACHE_TAGS); @@ -382,6 +385,7 @@ uicb_tag_viewprev(int screen, char *arg __attribute__ ((unused))) arrange(screen); } p_delete(&curtags); + saveawesomeprops(screen); ewmh_update_net_current_desktop(get_phys_screen(screen)); widget_invalidate_cache(screen, WIDGET_CACHE_TAGS); } diff --git a/tag.h b/tag.h index d0e8c0d0c..7ada98b05 100644 --- a/tag.h +++ b/tag.h @@ -33,7 +33,7 @@ void untag_client(Client *, Tag *); Bool is_client_tagged(Client *, Tag *); void tag_client_with_current_selected(Client *); void tag_client_with_rules(Client *); -void tag_view_byindex(int, int); +void tag_view_only_byindex(int, int); Uicb uicb_client_tag; Uicb uicb_client_toggletag; diff --git a/widgets/tasklist.c b/widgets/tasklist.c index 10c4e1b8a..8cb87b268 100644 --- a/widgets/tasklist.c +++ b/widgets/tasklist.c @@ -190,7 +190,7 @@ tasklist_button_press(Widget *widget, XButtonPressedEvent *ev) if(!client_isvisible(c, widget->statusbar->screen)) for(i = 0, tag = globalconf.screens[c->screen].tags; tag; tag = tag->next, i++) if(is_client_tagged(c, tag)) - tag_view_byindex(c->screen, i); + tag_view_only_byindex(c->screen, i); focus(c, True, widget->statusbar->screen); }