add support for _NET_CURRENT_DESKTOP

This commit is contained in:
Julien Danjou 2007-12-27 18:42:20 +01:00
parent 502f502e23
commit 3de4814910
5 changed files with 30 additions and 0 deletions

View File

@ -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;

19
ewmh.c
View File

@ -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

1
ewmh.h
View File

@ -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

View File

@ -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

6
tag.c
View File

@ -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