Works on reload/previous session properties

This commit is contained in:
Martin Duquesnoy 2011-10-30 21:38:09 +01:00
parent 2abbd8ca98
commit aef863b066
6 changed files with 117 additions and 42 deletions

View File

@ -526,7 +526,7 @@ client_frame_new(struct client *c)
}
struct client*
client_new(Window w, XWindowAttributes *wa)
client_new(Window w, XWindowAttributes *wa, bool scan)
{
struct client *c = xcalloc(1, sizeof(struct client));
@ -558,7 +558,9 @@ client_new(Window w, XWindowAttributes *wa)
/* Set tag */
client_get_sizeh(c);
tag_client(W->screen->seltag, c);
if(!scan)
tag_client(W->screen->seltag, c);
/* X window attributes */
XSelectInput(W->dpy, w, EnterWindowMask | LeaveWindowMask | StructureNotifyMask | PropertyChangeMask);
@ -568,20 +570,36 @@ client_new(Window w, XWindowAttributes *wa)
/* Attach */
SLIST_INSERT_HEAD(&W->h.client, c, next);
/* Map */
WIN_STATE(c->frame, Map);
if(c->titlebar)
barwin_map(c->titlebar);
ewmh_set_wm_state(w, NormalState);
client_get_name(c);
client_focus(c);
client_configure(c);
if(!scan)
{
client_get_name(c);
client_focus(c);
client_configure(c);
}
return c;
}
void
client_update_props(struct client *c)
{
long g[4] = { c->geo.x, c->geo.y, c->geo.w, c->geo.h };
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_FLAGS"), XA_CARDINAL, 32,
PropModeReplace, (unsigned char*)&(c->flags), 1);
XChangeProperty(W->dpy, c->win, ATOM("_WMFS_GEO"), XA_CARDINAL, 32,
PropModeReplace, (unsigned char*)g, 4);
}
static void
client_geo_hints(struct geo *g, int *s)
{
@ -677,6 +695,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_configure(c);
}

View File

@ -20,7 +20,7 @@ void client_focus(struct client *c);
void client_get_name(struct client *c);
void client_close(struct client *c);
void uicb_client_close(Uicb cmd);
struct client *client_new(Window w, XWindowAttributes *wa);
struct client *client_new(Window w, XWindowAttributes *wa, bool scan);
bool client_winsize(struct client *c, struct geo *geo);
void client_moveresize(struct client *c, struct geo *g);
void client_maximize(struct client *c);
@ -30,6 +30,7 @@ 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);
inline void client_fac_hint(struct client *c);
/* Generated */

View File

@ -128,7 +128,7 @@ event_maprequest(XEvent *e)
return;
if(!client_gb_win(ev->window))
client_new(ev->window, &at);
client_new(ev->window, &at, false);
}
static void

View File

@ -17,15 +17,19 @@
struct tag*
tag_new(struct screen *s, char *name)
{
struct tag *t;
struct tag *t, *l;
t = xcalloc(1, sizeof(struct tag));
t->screen = s;
t->name = xstrdup(name);
t->flags = 0;
t->id = 0;
t->sel = NULL;
if((l = TAILQ_LAST(&s->tags, tsub)))
t->id = l->id + 1;
SLIST_INIT(&t->clients);
TAILQ_INIT(&t->sets);
@ -90,13 +94,30 @@ tag_client(struct tag *t, struct client *c)
c->tag = t;
/* Map / Unmap client */
if(t == W->screen->seltag)
{
WIN_STATE(c->frame, Map);
ewmh_set_wm_state(c->win, NormalState);
}
else
{
WIN_STATE(c->frame, Unmap);
ewmh_set_wm_state(c->win, IconicState);
}
client_update_props(c);
/*
* Insert in new tag list before
* layout_split_integrate, because of set historic.
*/
SLIST_INSERT_HEAD(&t->clients, c, tnext);
layout_split_integrate(c, t->sel);
if(c->flags & CLIENT_IGNORE_LAYOUT)
c->flags ^= CLIENT_IGNORE_LAYOUT;
else
layout_split_integrate(c, t->sel);
}
void

View File

@ -181,60 +181,92 @@ wmfs_grab_keys(void)
static void
wmfs_scan(void)
{
int i, n;
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;
unsigned long ir, il;
long *ret;
SLIST_INIT(&W->h.client);
/*
Atom rt;
int s, rf, tag = -1, screen = -1, flags = -1, i;
ulong ir, il;
uchar *ret;
*/
if(XQueryTree(W->dpy, W->root, &usl, &usl2, &w, (unsigned int*)&n))
for(i = n - 1; i != -1; --i)
{
XGetWindowAttributes(W->dpy, w[i], &wa);
if(!wa.override_redirect && wa.map_state == IsViewable)
{/*
if(XGetWindowProperty(dpy, w[i], ATOM("_WMFS_TAG"), 0, 32,
False, XA_CARDINAL, &rt, &rf, &ir, &il, &ret) == Success && 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];
XFree(ret);
}
if(XGetWindowProperty(W->dpy, w[i], ATOM("_WMFS_TAG"), 0, 32,
False, XA_CARDINAL, &rt, &rf, &ir, &il,
(unsigned char**)&ret)
== Success && ret)
{
tag = *ret;
XFree(ret);
}
if(XGetWindowProperty(dpy, w[i], ATOM("_WMFS_SCREEN"), 0, 32,
False, XA_CARDINAL, &rt, &rf, &ir, &il, &ret) == Success && ret)
if(XGetWindowProperty(W->dpy, w[i], ATOM("_WMFS_SCREEN"), 0, 32,
False, XA_CARDINAL, &rt, &rf, &ir, &il,
(unsigned char**)&ret)
== Success && ret)
{
screen = *ret;
XFree(ret);
}
if(XGetWindowProperty(dpy, w[i], ATOM("_WMFS_FLAGS"), 0, 32,
False, XA_CARDINAL, &rt, &rf, &ir, &il, &ret) == Success && ret)
if(XGetWindowProperty(W->dpy, w[i], ATOM("_WMFS_FLAGS"), 0, 32,
False, XA_CARDINAL, &rt, &rf, &ir, &il,
(unsigned char**)&ret)
== Success && ret)
{
flags = *ret;
XFree(ret);
}
*/
/*c = */ client_new(w[i], &wa);
}
c = client_new(w[i], &wa, true);
c->tgeo = g;
/*
if(tag != -1)
c->tag = tag;
if(screen != -1)
c->screen = screen;
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_get_name(c);
client_focus(c);
break;
}
}
}
}
/*SLIST_FOREACH(c, &W->h.client, next)
client_moveresize(c, &c->tgeo);*/
XFree(w);
}

View File

@ -132,6 +132,7 @@ struct tag
struct client *sel;
struct client *prevsel;
char *name;
int id;
Flags flags;
SLIST_HEAD(, client) clients;
TAILQ_HEAD(ssub, layout_set) sets;
@ -148,10 +149,11 @@ struct client
int sizeh[SHLAST];
char *title;
int border, tbarw;
#define CLIENT_HINT_FLAG 0x01
#define CLIENT_IGNORE_ENTER 0x02
#define CLIENT_DID_WINSIZE 0x04
#define CLIENT_FAC_APPLIED 0x08
#define CLIENT_HINT_FLAG 0x01
#define CLIENT_IGNORE_ENTER 0x02
#define CLIENT_DID_WINSIZE 0x04
#define CLIENT_FAC_APPLIED 0x08
#define CLIENT_IGNORE_LAYOUT 0x10
Flags flags;
Window win, frame;
SLIST_ENTRY(client) next; /* Global list */