diff --git a/config.c b/config.c index 5f43293f..4f2c3364 100644 --- a/config.c +++ b/config.c @@ -640,6 +640,7 @@ config_parse(const char *confpatharg) eprint("fatal: no tags found in configuration file\n"); ewmh_update_net_numbers_of_desktop(get_phys_screen(screen)); + ewmh_update_net_current_desktop(get_phys_screen(screen)); /* select first tag by default */ virtscreen->tags[0].selected = True; diff --git a/ewmh.c b/ewmh.c index 2f4aba4d..988ff61b 100644 --- a/ewmh.c +++ b/ewmh.c @@ -24,12 +24,14 @@ #include "ewmh.h" #include "util.h" +#include "tag.h" extern AwesomeConf globalconf; static Atom net_supported; static Atom net_client_list; static Atom net_number_of_desktops; +static Atom net_current_desktop; static Atom net_wm_name; static Atom net_wm_icon; @@ -45,6 +47,7 @@ static AtomItem AtomNames[] = { "_NET_SUPPORTED", &net_supported }, { "_NET_CLIENT_LIST", &net_client_list }, { "_NET_NUMBER_OF_DESKTOPS", &net_number_of_desktops }, + { "_NET_CURRENT_DESKTOP", &net_current_desktop }, { "_NET_WM_NAME", &net_wm_name }, { "_NET_WM_ICON", &net_wm_icon }, @@ -75,6 +78,7 @@ ewmh_set_supported_hints(int phys_screen) atom[i++] = net_supported; atom[i++] = net_client_list; atom[i++] = net_number_of_desktops; + atom[i++] = net_current_desktop; atom[i++] = net_wm_name; atom[i++] = net_wm_icon; @@ -121,4 +125,19 @@ ewmh_update_net_numbers_of_desktop(int phys_screen) net_number_of_desktops, XA_CARDINAL, 32, PropModeReplace, (unsigned char *) &count, 1); } +void +ewmh_update_net_current_desktop(int phys_screen) +{ + CARD32 count = 0; + Tag *tag, **curtags = get_current_tags(phys_screen); + + for(tag = globalconf.screens[phys_screen].tags; tag != curtags[0]; tag = tag->next) + count++; + + XChangeProperty(globalconf.display, RootWindow(globalconf.display, phys_screen), + net_current_desktop, XA_CARDINAL, 32, PropModeReplace, (unsigned char *) &count, 1); + + p_delete(&curtags); +} + // vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80 diff --git a/ewmh.h b/ewmh.h index b9bc5bf2..7754ea16 100644 --- a/ewmh.h +++ b/ewmh.h @@ -26,6 +26,7 @@ void ewmh_init_atoms(void); void ewmh_set_supported_hints(int); void ewmh_update_net_client_list(int); void ewmh_update_net_numbers_of_desktop(int); +void ewmh_update_net_current_desktop(int); #endif // vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80 diff --git a/layout.c b/layout.c index 7ccf05ac..f937deb3 100644 --- a/layout.c +++ b/layout.c @@ -29,6 +29,7 @@ #include "xutil.h" #include "focus.h" #include "statusbar.h" +#include "ewmh.h" #include "layouts/tile.h" #include "layouts/max.h" #include "layouts/fibonacci.h" @@ -141,6 +142,8 @@ loadawesomeprops(int screen) tag->selected = False; p_delete(&prop); + + ewmh_update_net_current_desktop(get_phys_screen(screen)); } void diff --git a/tag.c b/tag.c index faa337a1..2172cc64 100644 --- a/tag.c +++ b/tag.c @@ -27,6 +27,7 @@ #include "tag.h" #include "util.h" #include "rules.h" +#include "ewmh.h" extern AwesomeConf globalconf; @@ -296,6 +297,7 @@ uicb_tag_toggleview(int screen, char *arg) saveawesomeprops(screen); arrange(screen); + ewmh_update_net_current_desktop(get_phys_screen(screen)); } /** View tag @@ -327,6 +329,7 @@ uicb_tag_view(int screen, char *arg) saveawesomeprops(screen); arrange(screen); + ewmh_update_net_current_desktop(get_phys_screen(screen)); } /** View previously selected tags @@ -347,6 +350,7 @@ uicb_tag_prev_selected(int screen, char *arg __attribute__ ((unused))) tag->was_selected = t; } arrange(screen); + ewmh_update_net_current_desktop(get_phys_screen(screen)); } /** View next tag @@ -369,6 +373,7 @@ uicb_tag_viewnext(int screen, char *arg __attribute__ ((unused))) saveawesomeprops(screen); arrange(screen); + ewmh_update_net_current_desktop(get_phys_screen(screen)); } /** View previous tag @@ -390,5 +395,6 @@ uicb_tag_viewprev(int screen, char *arg __attribute__ ((unused))) arrange(screen); } p_delete(&curtags); + ewmh_update_net_current_desktop(get_phys_screen(screen)); } // vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80