diff --git a/app/cwm/calmwm.h b/app/cwm/calmwm.h index 65e05f604..76461418e 100644 --- a/app/cwm/calmwm.h +++ b/app/cwm/calmwm.h @@ -15,7 +15,7 @@ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * - * $OpenBSD: calmwm.h,v 1.256 2014/02/02 16:29:04 okan Exp $ + * $OpenBSD: calmwm.h,v 1.257 2014/02/03 20:20:39 okan Exp $ */ #ifndef _CALMWM_H_ @@ -383,7 +383,7 @@ void client_map(struct client_ctx *); void client_maximize(struct client_ctx *); void client_msg(struct client_ctx *, Atom, Time); void client_move(struct client_ctx *); -struct client_ctx *client_init(Window, struct screen_ctx *, int); +struct client_ctx *client_init(Window, struct screen_ctx *); void client_ptrsave(struct client_ctx *); void client_ptrwarp(struct client_ctx *); void client_raise(struct client_ctx *); diff --git a/app/cwm/client.c b/app/cwm/client.c index 23af4b2db..684dacd97 100644 --- a/app/cwm/client.c +++ b/app/cwm/client.c @@ -15,7 +15,7 @@ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * - * $OpenBSD: client.c,v 1.170 2014/02/02 21:34:05 okan Exp $ + * $OpenBSD: client.c,v 1.171 2014/02/03 20:20:39 okan Exp $ */ #include @@ -55,18 +55,26 @@ client_find(Window win) } struct client_ctx * -client_init(Window win, struct screen_ctx *sc, int mapped) +client_init(Window win, struct screen_ctx *sc) { struct client_ctx *cc; XWindowAttributes wattr; long state; + int mapped; if (win == None) return (NULL); if (!XGetWindowAttributes(X_Dpy, win, &wattr)) return (NULL); - if (sc == NULL) + + if (sc == NULL) { sc = screen_fromroot(wattr.root); + mapped = 1; + } else { + if (wattr.override_redirect || wattr.map_state != IsViewable) + return (NULL); + mapped = wattr.map_state != IsUnmapped; + } cc = xcalloc(1, sizeof(*cc)); diff --git a/app/cwm/screen.c b/app/cwm/screen.c index 37cb5c3ae..735ff8420 100644 --- a/app/cwm/screen.c +++ b/app/cwm/screen.c @@ -15,7 +15,7 @@ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * - * $OpenBSD: screen.c,v 1.57 2014/02/02 16:29:04 okan Exp $ + * $OpenBSD: screen.c,v 1.58 2014/02/03 20:20:39 okan Exp $ */ #include @@ -35,7 +35,6 @@ screen_init(int which) { struct screen_ctx *sc; Window *wins, w0, w1; - XWindowAttributes winattr; XSetWindowAttributes rootattr; unsigned int nwins, i; @@ -62,17 +61,12 @@ screen_init(int which) CWEventMask|CWCursor, &rootattr); /* Deal with existing clients. */ - XQueryTree(X_Dpy, sc->rootwin, &w0, &w1, &wins, &nwins); - for (i = 0; i < nwins; i++) { - XGetWindowAttributes(X_Dpy, wins[i], &winattr); - if (winattr.override_redirect || - winattr.map_state != IsViewable) - continue; - (void)client_init(wins[i], sc, winattr.map_state != IsUnmapped); - } - if (wins) - XFree(wins); + if (XQueryTree(X_Dpy, sc->rootwin, &w0, &w1, &wins, &nwins)) { + for (i = 0; i < nwins; i++) + (void)client_init(wins[i], sc); + XFree(wins); + } screen_updatestackingorder(sc); if (HasRandr) diff --git a/app/cwm/xevents.c b/app/cwm/xevents.c index 82dfeddd5..c9c48d1ff 100644 --- a/app/cwm/xevents.c +++ b/app/cwm/xevents.c @@ -15,7 +15,7 @@ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * - * $OpenBSD: xevents.c,v 1.110 2014/02/02 21:34:05 okan Exp $ + * $OpenBSD: xevents.c,v 1.111 2014/02/03 20:20:39 okan Exp $ */ /* @@ -80,7 +80,7 @@ xev_handle_maprequest(XEvent *ee) client_ptrsave(old_cc); if ((cc = client_find(e->window)) == NULL) - cc = client_init(e->window, NULL, 1); + cc = client_init(e->window, NULL); if ((cc != NULL) && ((cc->flags & CLIENT_IGNORE) == 0)) client_ptrwarp(cc);