wmii

git clone git://oldgit.suckless.org/wmii/
Log | Files | Refs | README | LICENSE

commit ff6540925f4ff4dedd04032c7f2f56e9782a9922
parent ca4cffaeedcf1788ee8048735b832c16a94c8d29
Author: Kris Maglione <jg@suckless.org>
Date:   Fri,  9 Feb 2007 22:06:07 -0500

Unmap and set Iconic state of iconic or out-of-view windows


Diffstat:
client.c | 48++++++++++++++++++++++++++++--------------------
event.c | 3++-
view.c | 9++++++---
wmii.h | 4+++-
4 files changed, 39 insertions(+), 25 deletions(-)

diff --git a/client.c b/client.c @@ -155,14 +155,6 @@ update_client_grab(Client *c) { } void -set_client_state(Client * c, int state) -{ - long data[] = { state, None }; - XChangeProperty(blz.dpy, c->win, wm_atom[WMState], wm_atom[WMState], 32, - PropModeReplace, (unsigned char *) data, 2); -} - -void focus_client(Client *c, Bool restack) { Client *old_in_area; Client *old; @@ -213,19 +205,31 @@ focus_client(Client *c, Bool restack) { } void +set_client_state(Client * c, int state) +{ + long data[] = { state, None }; + XChangeProperty(blz.dpy, c->win, wm_atom[WMState], wm_atom[WMState], 32, + PropModeReplace, (unsigned char *) data, 2); +} + +void map_client(Client *c) { XSelectInput(blz.dpy, c->win, CLIENT_MASK & ~StructureNotifyMask); XMapWindow(blz.dpy, c->win); XSelectInput(blz.dpy, c->win, CLIENT_MASK); set_client_state(c, NormalState); + c->mapped = 1; } void -unmap_client(Client *c) { +unmap_client(Client *c, int state) { XSelectInput(blz.dpy, c->win, CLIENT_MASK & ~StructureNotifyMask); XUnmapWindow(blz.dpy, c->win); XSelectInput(blz.dpy, c->win, CLIENT_MASK); - set_client_state(c, WithdrawnState); + set_client_state(c, state); + c->mapped = 0; + /* Always set this, since we don't care anymore once it's been destroyed */ + c->unmapped++; } void @@ -399,14 +403,15 @@ destroy_client(Client *c) { c->rect.x = c->sel->rect.x; c->rect.y = c->sel->rect.y; } + for(tc=&client; *tc && *tc != c; tc=&(*tc)->next) + if(*tc == c) break; + assert(*tc == c); + *tc = c->next; update_client_views(c, &dummy); - unmap_client(c); + unmap_client(c, WithdrawnState); reparent_client(c, blz.root, c->rect.x, c->rect.y); XFreeGC(blz.dpy, c->gc); XDestroyWindow(blz.dpy, c->framewin); - for(tc=&client; *tc && *tc != c; tc=&(*tc)->next); - assert(*tc == c); - *tc = c->next; update_views(); free(c); XSync(blz.dpy, False); @@ -502,19 +507,22 @@ resize_client(Client *c, XRectangle *r) { if(f->area->view == screen->sel) XMoveResizeWindow(blz.dpy, c->framewin, f->rect.x, f->rect.y, f->rect.width, f->rect.height); - else - XMoveResizeWindow(blz.dpy, c->framewin, 2 * screen->rect.width + f->rect.x, - f->rect.y, f->rect.width, f->rect.height); + else { + unmap_client(c, IconicState); + XUnmapWindow(blz.dpy, c->framewin); + } c->rect.x = def.border; c->rect.y = labelh(&def.font); if((f->area->sel == f) || (f->area->mode != Colstack)) { + if(!c->mapped) + map_client(c); c->rect.width = f->rect.width - 2 * def.border; c->rect.height = f->rect.height - def.border - labelh(&def.font); - } - - XMoveResizeWindow(blz.dpy, c->win, c->rect.x, c->rect.y, + XMoveResizeWindow(blz.dpy, c->win, c->rect.x, c->rect.y, c->rect.width, c->rect.height); + }else + unmap_client(c, IconicState); configure_client(c); } diff --git a/event.c b/event.c @@ -262,7 +262,8 @@ unmapnotify(XEvent *e) { XUnmapEvent *ev = &e->xunmap; if((c = client_of_win(ev->window))) - destroy_client(c); + if(!c->unmapped--) + destroy_client(c); } void (*handler[LASTEvent]) (XEvent *) = { diff --git a/view.c b/view.c @@ -116,11 +116,14 @@ focus_view(WMScreen *s, View *v) { for(c=client; c; c=c->next) if((f = c->sel)) { if(f->view == v) { + map_client(c); + XMapWindow(blz.dpy, c->framewin); resize_client(c, &f->rect); update_client_grab(c); - }else - XMoveWindow(blz.dpy, c->framewin, 2 * s->rect.width + f->rect.x, - f->rect.y); + } else { + XUnmapWindow(blz.dpy, c->framewin); + unmap_client(c, IconicState); + } } if((c = sel_client())) focus_client(c, True); diff --git a/wmii.h b/wmii.h @@ -144,6 +144,8 @@ struct Client { Bool floating; Bool fixedsize; Bool urgent; + Bool mapped; + int unmapped; Window win; Window trans; Window framewin; @@ -270,7 +272,7 @@ extern void configure_client(Client *c); extern void prop_client(Client *c, XPropertyEvent *e); extern void kill_client(Client *c); extern void gravitate_client(Client *c, Bool invert); -extern void unmap_client(Client *c); +extern void unmap_client(Client *c, int state); extern void map_client(Client *c); extern void reparent_client(Client *c, Window w, int x, int y); extern void manage_client(Client *c);