From 502f502e23b25020f4b505f21a13bd2c2a08b7c7 Mon Sep 17 00:00:00 2001 From: Julien Danjou Date: Thu, 27 Dec 2007 18:18:12 +0100 Subject: [PATCH] add support for _NET_NUMBER_OF_DESKTOPS --- awesome.c | 4 ++-- config.c | 3 +++ ewmh.c | 19 ++++++++++++++++++- ewmh.h | 1 + 4 files changed, 24 insertions(+), 3 deletions(-) diff --git a/awesome.c b/awesome.c index d615fb53..c37a5cca 100644 --- a/awesome.c +++ b/awesome.c @@ -331,6 +331,8 @@ main(int argc, char *argv[]) XSync(dpy, False); globalconf.display = dpy; + ewmh_init_atoms(); + globalconf.screens = p_new(VirtScreen, get_screen_count()); focus_add_client(NULL); /* store display */ @@ -344,8 +346,6 @@ main(int argc, char *argv[]) statusbar_draw(screen); } - ewmh_init_atoms(); - /* do this only for real screen */ for(screen = 0; screen < ScreenCount(dpy); screen++) { diff --git a/config.c b/config.c index 286360ab..5f43293f 100644 --- a/config.c +++ b/config.c @@ -32,6 +32,7 @@ #include "screen.h" #include "widget.h" #include "xutil.h" +#include "ewmh.h" #include "defconfig.h" #define AWESOME_CONFIG_FILE ".awesomerc" @@ -638,6 +639,8 @@ config_parse(const char *confpatharg) else eprint("fatal: no tags found in configuration file\n"); + ewmh_update_net_numbers_of_desktop(get_phys_screen(screen)); + /* select first tag by default */ virtscreen->tags[0].selected = True; virtscreen->tags[0].was_selected = True; diff --git a/ewmh.c b/ewmh.c index 74e8ad59..2f4aba4d 100644 --- a/ewmh.c +++ b/ewmh.c @@ -19,7 +19,8 @@ * */ -#include +#include +#include #include "ewmh.h" #include "util.h" @@ -28,6 +29,7 @@ extern AwesomeConf globalconf; static Atom net_supported; static Atom net_client_list; +static Atom net_number_of_desktops; static Atom net_wm_name; static Atom net_wm_icon; @@ -42,6 +44,7 @@ static AtomItem AtomNames[] = { { "_NET_SUPPORTED", &net_supported }, { "_NET_CLIENT_LIST", &net_client_list }, + { "_NET_NUMBER_OF_DESKTOPS", &net_number_of_desktops }, { "_NET_WM_NAME", &net_wm_name }, { "_NET_WM_ICON", &net_wm_icon }, @@ -71,6 +74,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_wm_name; atom[i++] = net_wm_icon; @@ -104,4 +108,17 @@ ewmh_update_net_client_list(int phys_screen) XFlush(globalconf.display); } +void +ewmh_update_net_numbers_of_desktop(int phys_screen) +{ + CARD32 count = 0; + Tag *tag; + + for(tag = globalconf.screens[phys_screen].tags; tag; tag = tag->next) + count++; + + XChangeProperty(globalconf.display, RootWindow(globalconf.display, phys_screen), + net_number_of_desktops, XA_CARDINAL, 32, PropModeReplace, (unsigned char *) &count, 1); +} + // vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80 diff --git a/ewmh.h b/ewmh.h index ee526e3b..b9bc5bf2 100644 --- a/ewmh.h +++ b/ewmh.h @@ -25,6 +25,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); #endif // vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80