From 8e10f82c23e327b33f541b8466fbb6b5240b7b19 Mon Sep 17 00:00:00 2001 From: Martin Duquesnoy Date: Thu, 23 Apr 2009 17:16:16 +0200 Subject: [PATCH] Scan: Check _WMFS_TAG and _WMFS_SCREEN when scan() to place correctly every client. --- src/client.c | 8 +++++--- src/wmfs.c | 49 +++++++++++++++++++++++++++++++++++++------------ src/wmfs.h | 2 +- 3 files changed, 43 insertions(+), 16 deletions(-) diff --git a/src/client.c b/src/client.c index 90e2eed..be31a81 100644 --- a/src/client.c +++ b/src/client.c @@ -402,8 +402,9 @@ client_map(Client *c) /** Manage a client with a window and his attributes * \param w Cient's futur Window * \param wa XWindowAttributes pointer, Window w attributes + * \return The managed client */ -void +Client* client_manage(Window w, XWindowAttributes *wa) { Client *c, *t = NULL; @@ -476,11 +477,12 @@ client_manage(Window w, XWindowAttributes *wa) setwinstate(c->win, NormalState); ewmh_get_client_list(); ewmh_manage_window_type(c); - arrange(c->screen); client_set_wanted_tag(c); client_update_attributes(c); - return; + arrange(c->screen); + + return c; } /** Move and Resize a client diff --git a/src/wmfs.c b/src/wmfs.c index 92cebc5..0d22b18 100644 --- a/src/wmfs.c +++ b/src/wmfs.c @@ -192,13 +192,38 @@ scan(void) uint i, n; XWindowAttributes wa; Window usl, usl2, *w = NULL; + Atom rt; + int rf, tag = -1, screen = -1; + ulong ir, il; + uchar *ret; + Client *c; if(XQueryTree(dpy, ROOT, &usl, &usl2, &w, &n)) for(i = 0; i < n; ++i) if(XGetWindowAttributes(dpy, w[i], &wa) && !(wa.override_redirect || XGetTransientForHint(dpy, w[i], &usl)) && wa.map_state == IsViewable) - client_manage(w[i], &wa); + { + if(XGetWindowProperty(dpy, w[i], ATOM("_WMFS_TAG"), 0, 32, + False, XA_CARDINAL, &rt, &rf, &ir, &il, &ret) == Success) + tag = *ret; + + if(XGetWindowProperty(dpy, w[i], ATOM("_WMFS_SCREEN"), 0, 32, + False, XA_CARDINAL, &rt, &rf, &ir, &il, &ret) == Success) + screen = *ret; + + c = client_manage(w[i], &wa); + + if(tag != -1) + c->tag = tag; + if(screen != -1) + c->screen = screen; + + arrange(c->screen); + } + + if(ret) + XFree(ret); XFree(w); arrange(screen_get_sel()); @@ -212,12 +237,12 @@ scan(void) void uicb_reload(uicb_t cmd) { + XSetErrorHandler(errorhandlerdummy); XftFontClose(dpy, font); infobar_destroy(); - init_conf(); init(); scan(); @@ -240,21 +265,21 @@ check_wmfs_running(void) ulong ir, il; uchar *ret; - XGetWindowProperty(dpy, ROOT, ATOM("_WMFS_RUNNING"), 0L, 4096, - False, XA_CARDINAL, &rt, &rf, &ir, &il, &ret); + XGetWindowProperty(dpy, ROOT, ATOM("_WMFS_RUNNING"), 0L, 4096, + False, XA_CARDINAL, &rt, &rf, &ir, &il, &ret); - if(!ret) - { - XFree(ret); + if(!ret) + { + XFree(ret); - fprintf(stderr, "Wmfs is not running. ( _WMFS_RUNNING not present)\n"); + fprintf(stderr, "Wmfs is not running. ( _WMFS_RUNNING not present)\n"); - return False; - } + return False; + } - XFree(ret); + XFree(ret); - return True; + return True; } /** Execute an uicb function diff --git a/src/wmfs.h b/src/wmfs.h index c417945..383582e 100644 --- a/src/wmfs.h +++ b/src/wmfs.h @@ -141,7 +141,7 @@ void client_hide(Client *c); void client_kill(Client *c); Bool ishide(Client *c, int screen); void client_map(Client *c); -void client_manage(Window w, XWindowAttributes *wa); +Client* client_manage(Window w, XWindowAttributes *wa); void client_moveresize(Client *c, XRectangle geo, Bool r); void client_maximize(Client *c); void client_size_hints(Client *c);