diff --git a/ewmh.c b/ewmh.c index 85c3b8b89..a9d6b9529 100644 --- a/ewmh.c +++ b/ewmh.c @@ -265,6 +265,12 @@ void ewmh_process_client_message(XClientMessageEvent *ev) { Client *c; + int screen; + + if(ev->message_type == net_current_desktop) + for(screen = 0; screen < ScreenCount(globalconf.display); screen++) + if(ev->window == RootWindow(globalconf.display, screen)) + tag_view(screen, ev->data.l[0]); if(ev->message_type == net_close_window) { diff --git a/tag.c b/tag.c index 9ebc87ab8..2908567f3 100644 --- a/tag.c +++ b/tag.c @@ -301,6 +301,27 @@ uicb_tag_toggleview(int screen, char *arg) ewmh_update_net_current_desktop(get_phys_screen(screen)); } +void +tag_view(int screen, int dindex) +{ + Tag *target_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)); +} + /** View tag * \param screen Screen ID * \param arg tag to view @@ -309,28 +330,13 @@ uicb_tag_toggleview(int screen, char *arg) void uicb_tag_view(int screen, char *arg) { - int i; - Tag *tag, *target_tag; + Tag *tag; if(arg) - { - i = atoi(arg) - 1; - for(target_tag = globalconf.screens[screen].tags; target_tag && i > 0; - target_tag = target_tag->next, i--); - if(target_tag) - { - for(tag = globalconf.screens[screen].tags; tag; tag = tag->next) - tag->selected = False; - target_tag->selected = True; - } - } + tag_view(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)); } /** View previously selected tags diff --git a/tag.h b/tag.h index 202de20e6..1af98a74e 100644 --- a/tag.h +++ b/tag.h @@ -33,6 +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(int, int); UICB_PROTO(uicb_client_tag); UICB_PROTO(uicb_client_togglefloating);