diff --git a/awesome.c b/awesome.c index cfdb399e..c923e661 100644 --- a/awesome.c +++ b/awesome.c @@ -101,30 +101,6 @@ cleanup(awesome_config *awesomeconf) p_delete(&awesomeconf); } -/** Get a window state (WM_STATE) - * \param disp Display ref - * \param w Client window - * \return state - */ -static long -getstate(Display *disp, Window w) -{ - int format, status; - long result = -1; - unsigned char *p = NULL; - unsigned long n, extra; - Atom real; - status = XGetWindowProperty(disp, w, XInternAtom(disp, "WM_STATE", False), - 0L, 2L, False, XInternAtom(disp, "WM_STATE", False), - &real, &format, &n, &extra, (unsigned char **) &p); - if(status != Success) - return -1; - if(n != 0) - result = *p; - p_delete(&p); - return result; -} - /** Scan X to find windows to manage * \param screen Screen number * \param awesomeconf awesome config @@ -148,7 +124,7 @@ scan(awesome_config *awesomeconf) || wa.override_redirect || XGetTransientForHint(awesomeconf->display, wins[i], &d1)) continue; - if(wa.map_state == IsViewable || getstate(awesomeconf->display, wins[i]) == IconicState) + if(wa.map_state == IsViewable || window_getstate(awesomeconf->display, wins[i]) == IconicState) { if(screen == 0) real_screen = get_screen_bycoord(awesomeconf->display, wa.x, wa.y); @@ -161,7 +137,7 @@ scan(awesome_config *awesomeconf) if(!XGetWindowAttributes(awesomeconf->display, wins[i], &wa)) continue; if(XGetTransientForHint(awesomeconf->display, wins[i], &d1) - && (wa.map_state == IsViewable || getstate(awesomeconf->display, wins[i]) == IconicState)) + && (wa.map_state == IsViewable || window_getstate(awesomeconf->display, wins[i]) == IconicState)) { if(screen == 0) real_screen = get_screen_bycoord(awesomeconf->display, wa.x, wa.y); diff --git a/client.c b/client.c index 9a4b706d..21bf70a2 100644 --- a/client.c +++ b/client.c @@ -243,7 +243,6 @@ ban(Client * c) { XUnmapWindow(c->display, c->win); window_setstate(c->display, c->win, IconicState); - c->unmapped = True; } /** Configure client @@ -268,6 +267,30 @@ window_configure(Display *disp, Window win, int x, int y, int w, int h, int bord XSendEvent(disp, win, False, StructureNotifyMask, (XEvent *) & ce); } +/** Get a window state (WM_STATE) + * \param disp Display ref + * \param w Client window + * \return state + */ +long +window_getstate(Display *disp, Window w) +{ + int format, status; + long result = -1; + unsigned char *p = NULL; + unsigned long n, extra; + Atom real; + status = XGetWindowProperty(disp, w, XInternAtom(disp, "WM_STATE", False), + 0L, 2L, False, XInternAtom(disp, "WM_STATE", False), + &real, &format, &n, &extra, (unsigned char **) &p); + if(status != Success) + return -1; + if(n != 0) + result = *p; + p_delete(&p); + return result; +} + /** Attach client after another one * \param client to attach to * \param c the client @@ -613,7 +636,6 @@ unban(Client *c) { XMapWindow(c->display, c->win); window_setstate(c->display, c->win, NormalState); - c->unmapped = False; } void @@ -622,7 +644,6 @@ unmanage(Client *c, long state, awesome_config *awesomeconf) XWindowChanges wc; client_untab(c); - c->unmapped = True; wc.border_width = c->oldborder; /* The server grab construct avoids race conditions. */ XGrabServer(c->display); diff --git a/client.h b/client.h index f8af0691..6ee0bcc4 100644 --- a/client.h +++ b/client.h @@ -34,6 +34,7 @@ inline void client_detach(Client **, Client *); void client_reattach_after(Client *, Client *); void ban(Client *); /* bans c */ void window_configure(Display *, Window, int, int, int, int, int); +long window_getstate(Display *, Window); void focus(Client *, Bool, awesome_config *); void manage(Window, XWindowAttributes *, awesome_config *); void resize(Client *, int, int, int, int, awesome_config *, Bool); /* resize with given coordinates c */ diff --git a/config.h b/config.h index 2e3d271c..bc78fe70 100644 --- a/config.h +++ b/config.h @@ -104,8 +104,6 @@ struct Client int rx, ry, rw, rh; int basew, baseh, incw, inch, maxw, maxh, minw, minh; int minax, maxax, minay, maxay; - /** True if client is unmapped */ - Bool unmapped; long flags; int border, oldborder; /** Store previous floating state before maximizing */ diff --git a/event.c b/event.c index 84cde26c..2752b9db 100644 --- a/event.c +++ b/event.c @@ -501,7 +501,8 @@ handle_event_unmapnotify(XEvent * e, awesome_config *awesomeconf) XUnmapEvent *ev = &e->xunmap; if((c = get_client_bywin(*awesomeconf->clients, ev->window)) - && ev->event == RootWindow(e->xany.display, c->phys_screen) && (ev->send_event || !c->unmapped)) + && ev->event == RootWindow(e->xany.display, c->phys_screen) + && ev->send_event && window_getstate(c->display, c->win) == NormalState) unmanage(c, WithdrawnState, &awesomeconf[c->screen]); }