From c7e05fced8d96cd8c68329bb89f4e62d5927e928 Mon Sep 17 00:00:00 2001 From: Martin Duquesnoy Date: Tue, 1 Nov 2011 15:16:41 +0100 Subject: [PATCH] Work on reload.. --- src/client.c | 31 ++++++++++++++++++++----------- src/client.h | 7 ++++++- src/layout.c | 2 +- src/layout.h | 1 + src/tag.c | 2 +- src/wmfs.c | 49 +++++++++++++++++++++++++++---------------------- wmfsrc2 | 2 +- 7 files changed, 57 insertions(+), 37 deletions(-) diff --git a/src/client.c b/src/client.c index d093903..82ac60d 100644 --- a/src/client.c +++ b/src/client.c @@ -583,21 +583,30 @@ client_new(Window w, XWindowAttributes *wa, bool scan) } void -client_update_props(struct client *c) +client_update_props(struct client *c, Flags f) { - long g[4] = { c->geo.x, c->geo.y, c->geo.w, c->geo.h }; + if(f & CPROP_LOC) + { + XChangeProperty(W->dpy, c->win, ATOM("_WMFS_TAG"), XA_CARDINAL, 32, + PropModeReplace, (unsigned char*)&(c->tag->id), 1); - XChangeProperty(W->dpy, c->win, ATOM("_WMFS_TAG"), XA_CARDINAL, 32, - PropModeReplace, (unsigned char*)&(c->tag->id), 1); + XChangeProperty(W->dpy, c->win, ATOM("_WMFS_SCREEN"), XA_CARDINAL, 32, + PropModeReplace, (unsigned char*)&(c->screen->id), 1); + } - XChangeProperty(W->dpy, c->win, ATOM("_WMFS_SCREEN"), XA_CARDINAL, 32, - PropModeReplace, (unsigned char*)&(c->screen->id), 1); + if(f & CPROP_FLAG) + XChangeProperty(W->dpy, c->win, ATOM("_WMFS_FLAGS"), XA_CARDINAL, 32, + PropModeReplace, (unsigned char*)&(c->flags), 1); - XChangeProperty(W->dpy, c->win, ATOM("_WMFS_FLAGS"), XA_CARDINAL, 32, - PropModeReplace, (unsigned char*)&(c->flags), 1); + if(f & CPROP_GEO) + { + long g[4] = { (long)c->geo.x, (long)c->geo.y, (long)c->geo.w, (long)c->geo.h }; - XChangeProperty(W->dpy, c->win, ATOM("_WMFS_GEO"), XA_CARDINAL, 32, - PropModeReplace, (unsigned char*)g, 4); + XChangeProperty(W->dpy, c->win, ATOM("_WMFS_GEO"), XA_CARDINAL, 32, + PropModeReplace, (unsigned char*)g, 4); + putchar(' '); + DGEO(c->geo); + } } static void @@ -695,7 +704,7 @@ client_moveresize(struct client *c, struct geo *g) c->flags &= ~CLIENT_DID_WINSIZE; client_frame_update(c, CCOL(c)); - client_update_props(c); + client_update_props(c, CPROP_GEO); client_configure(c); } diff --git a/src/client.h b/src/client.h index 88b4b39..d55f16c 100644 --- a/src/client.h +++ b/src/client.h @@ -30,7 +30,12 @@ void client_remove(struct client *c); void client_free(void); void _fac_resize(struct client *c, enum position p, int fac); void client_apply_tgeo(struct tag *t); -void client_update_props(struct client *c); + +#define CPROP_LOC 0x01 +#define CPROP_FLAG 0x02 +#define CPROP_GEO 0x04 +void client_update_props(struct client *c, Flags f); + inline void client_fac_hint(struct client *c); /* Generated */ diff --git a/src/layout.c b/src/layout.c index 270b6eb..3fa635e 100644 --- a/src/layout.c +++ b/src/layout.c @@ -404,7 +404,7 @@ layout_split_integrate(struct client *c, struct client *sc) * |_____|----'| -> |_____|__v__| * ^^^ void */ -static inline void +inline void layout_fix_hole(struct client *c) { struct client *cr = client_next_with_pos(c, Right); diff --git a/src/layout.h b/src/layout.h index 2df3a8a..a03148a 100644 --- a/src/layout.h +++ b/src/layout.h @@ -33,6 +33,7 @@ void layout_save_set(struct tag *t); void layout_free_set(struct tag *t); void layout_split_integrate(struct client *c, struct client *sc); void layout_split_arrange_closed(struct client *ghost); +inline void layout_fix_hole(struct client *c); void uicb_layout_vmirror(Uicb cmd); void uicb_layout_hmirror(Uicb cmd); void uicb_layout_rotate_left(Uicb cmd); diff --git a/src/tag.c b/src/tag.c index 4d6d1df..5ed2a90 100644 --- a/src/tag.c +++ b/src/tag.c @@ -106,7 +106,7 @@ tag_client(struct tag *t, struct client *c) ewmh_set_wm_state(c->win, IconicState); } - client_update_props(c); + client_update_props(c, CPROP_LOC); /* * Insert in new tag list before diff --git a/src/wmfs.c b/src/wmfs.c index f206579..d51d45c 100644 --- a/src/wmfs.c +++ b/src/wmfs.c @@ -181,16 +181,17 @@ wmfs_grab_keys(void) static void wmfs_scan(void) { - XWindowAttributes wa; - Window usl, usl2, *w = NULL; - Atom rt; struct geo g; struct tag *t; struct client *c; struct screen *s; - int i, n, rf, tag = -1, screen = -1, flags = -1; + int i, n, rf; + int tag = -1, screen = -1, flags = -1; unsigned long ir, il; long *ret; + XWindowAttributes wa; + Window usl, usl2, *w = NULL; + Atom rt; SLIST_INIT(&W->h.client); @@ -201,19 +202,6 @@ wmfs_scan(void) if(!wa.override_redirect && wa.map_state == IsViewable) { - if(XGetWindowProperty(W->dpy, w[i], ATOM("_WMFS_GEO"), 0, 32, - False, XA_CARDINAL, &rt, &rf, &ir, &il, - (unsigned char**)&ret) - == Success && ret) - { - g.x = ret[0]; - g.y = ret[1]; - g.w = ret[2]; - g.h = ret[3]; - - XFree(ret); - } - if(XGetWindowProperty(W->dpy, w[i], ATOM("_WMFS_TAG"), 0, 32, False, XA_CARDINAL, &rt, &rf, &ir, &il, (unsigned char**)&ret) @@ -241,23 +229,36 @@ wmfs_scan(void) XFree(ret); } + if(XGetWindowProperty(W->dpy, w[i], ATOM("_WMFS_GEO"), 0, 32, + False, XA_CARDINAL, &rt, &rf, &ir, &il, + (unsigned char**)&ret) + == Success && ret) + { + g.x = ret[0]; + g.y = ret[1]; + g.w = ret[2]; + g.h = ret[3]; + + DGEO(g); + XFree(ret); + } + c = client_new(w[i], &wa, true); - - c->tgeo = g; - if(flags != -1) c->flags = flags; if(tag != -1 && screen != -1) { c->screen = screen_gb_id(screen); + TAILQ_FOREACH(t, &c->screen->tags, next) if(t->id == tag) { c->flags |= CLIENT_IGNORE_LAYOUT; tag_client(t, c); + client_moveresize(c, &g); client_get_name(c); - client_focus(c); + /*client_focus(c);*/ break; } } @@ -265,7 +266,10 @@ wmfs_scan(void) } /*SLIST_FOREACH(c, &W->h.client, next) - client_moveresize(c, &c->tgeo);*/ + client_moveresize(c, &c->tgeo); + + SLIST_FOREACH(c, &W->h.client, next) + layout_fix_hole(c);*/ XFree(w); } @@ -336,6 +340,7 @@ wmfs_quit(void) while(!SLIST_EMPTY(&W->h.client)) { c = SLIST_FIRST(&W->h.client); + client_update_props(c, CPROP_LOC | CPROP_FLAG | CPROP_GEO); client_remove(c); } diff --git a/wmfsrc2 b/wmfsrc2 index d72a5ea..bd88f50 100644 --- a/wmfsrc2 +++ b/wmfsrc2 @@ -106,7 +106,7 @@ [key] mod = {"Super"} key = "Return" func = "spawn" cmd = "xterm" [/key] [key] mod = {"Control", "Alt"} key = "q" func = "quit" [/key] - [key] mod = {"Control", "Alt"} key = "r" func = " reload" [/key] + [key] mod = {"Control", "Alt"} key = "r" func = "reload" [/key] [key] mod = {"Super"} key = "1" func = "tag_set" cmd = "1" [/key] [key] mod = {"Super"} key = "2" func = "tag_set" cmd = "2" [/key] [key] mod = {"Super"} key = "3" func = "tag_set" cmd = "3" [/key]