aboutsummaryrefslogtreecommitdiff
path: root/monsterwm.c
diff options
context:
space:
mode:
authorIvan Kanakarakis <ivan.kanak@gmail.com>2011-12-26 16:34:05 +0200
committerIvan Kanakarakis <ivan.kanak@gmail.com>2011-12-26 16:34:05 +0200
commitdc5a7cd0eee456ce9f8ce3cf76eb1c2dbb83398f (patch)
treeb1aede7fe06502fba5c762db57908a4f9ac6e035 /monsterwm.c
parent679c87981a36d52026060921ea6511cd05e370d6 (diff)
output desktops window information
Diffstat (limited to 'monsterwm.c')
-rw-r--r--monsterwm.c24
1 files changed, 17 insertions, 7 deletions
diff --git a/monsterwm.c b/monsterwm.c
index af734fa..81d0593 100644
--- a/monsterwm.c
+++ b/monsterwm.c
@@ -75,6 +75,7 @@ static void cleanup(void);
static void client_to_desktop(const Arg *arg);
static void configurerequest(XEvent *e);
static void deletewindow(Window w);
+static void desktopinfo(void);
static void destroynotify(XEvent *e);
static void die(const char* errstr, ...);
static void enternotify(XEvent *e);
@@ -145,10 +146,8 @@ static void (*events[LASTEvent])(XEvent *e) = {
void add_window(Window w) {
client *c;
-
if(!(c = (client *)calloc(1, sizeof(client))))
die("error: could not calloc() %u bytes\n", sizeof(client));
-
if(!head) {
head = c;
head->prev = head;
@@ -165,8 +164,8 @@ void add_window(Window w) {
c->win = w;
current = c;
save_desktop(current_desktop);
-
if(FOLLOW_MOUSE) XSelectInput(dis, c->win, EnterWindowMask);
+ desktopinfo();
}
void buttonpressed(XEvent *e) {
@@ -207,12 +206,9 @@ void cleanup(void) {
unsigned int nchildren;
XUngrabKey(dis, AnyKey, AnyModifier, root);
-
XQueryTree(dis, root, &root_return, &parent_return, &children, &nchildren);
- for(unsigned int i = 0; i < nchildren; i++)
- deletewindow(children[i]);
+ for(unsigned int i = 0; i<nchildren; i++) deletewindow(children[i]);
if(children) XFree(children);
-
XSync(dis, False);
XSetInputFocus(dis, PointerRoot, RevertToPointerRoot, CurrentTime);
}
@@ -266,11 +262,24 @@ void deletewindow(Window w) {
XSendEvent(dis, w, False, NoEventMask, &ev);
}
+void desktopinfo(void) {
+ int cd = current_desktop;
+ save_desktop(cd);
+ for(int n=0, d=0; d<DESKTOPS; d++, n=0) {
+ select_desktop(d);
+ for(client *c=head; c; c=c->next, ++n);
+ printf("%d:%d%c", d, n, d+1==DESKTOPS?'\n':' ');
+ }
+ fflush(stdout);
+ select_desktop(cd);
+}
+
void destroynotify(XEvent *e) {
XDestroyWindowEvent *ev = &e->xdestroywindow;
client *c;
if((c = wintoclient(ev->window)))
removeclient(c);
+ desktopinfo();
}
void die(const char *errstr, ...) {
@@ -682,6 +691,7 @@ int main(int argc, char *argv[]) {
if(!(dis = XOpenDisplay(NULL)))
die("error: cannot open display\n");
setup();
+ desktopinfo(); /* zero out every desktop on (re)start */
run();
cleanup();
XCloseDisplay(dis);