{
struct ws_win *win;
int count = 0;
- int state;
-
- /*
- * Under stress conditions windows sometimes do not get removed from
- * the managed list quickly enough. Use a very large hammer to get rid
- * of them. A smaller hammer would be nice.
- */
- TAILQ_FOREACH(win, &ws->winlist, entry) {
- state = getstate(win->id);
- if (state == -1) {
- DNPRINTF(SWM_D_MISC, "count_win:removing: %lu\n",
- win->id);
- unmanage_window(win);
- }
- }
TAILQ_FOREACH(win, &ws->winlist, entry) {
if (count_transient == 0 && win->floating)
}
}
+Bool
+destroy_notify_cb(Display *d, XEvent *e, char *arg)
+{
+ struct ws_win *win = (struct ws_win *)arg;
+ if (win && win->id == e->xany.window && e->xany.type == DestroyNotify)
+ return (True);
+ return (False);
+}
+
void
expose(XEvent *e)
{
void
destroynotify(XEvent *e)
{
- struct ws_win *win, *winfocus = NULL;
+ struct ws_win *win, *w, *winfocus = NULL;
struct workspace *ws;
struct ws_win_list *wl;
XDestroyWindowEvent *ev = &e->xdestroywindow;
+ XEvent de;
DNPRINTF(SWM_D_EVENT, "destroynotify: window %lu\n", ev->window);
}
unmanage_window(win);
+ /*
+ * Under stress conditions windows sometimes do not get removed
+ * from the managed list. Use a very large hammer to get rid
+ * of them. A smaller hammer would be nice.
+ */
+ TAILQ_FOREACH(w, &ws->winlist, entry) {
+ if (win == w)
+ continue; /* can't happen but oh well */
+
+ if (getstate(w->id) != -1)
+ continue;
+
+ /* see if we have a destroy event */
+ if (XCheckIfEvent(display, &de, destroy_notify_cb,
+ (char *)w) == False)
+ unmanage_window(w); /* no event, help it */
+ else
+ XPutBackEvent(display, &de); /* oops */
+ }
+
ignore_enter = 1;
stack();
if (winfocus)
struct passwd *pwd;
struct swm_region *r, *rr;
struct ws_win *winfocus = NULL;
+ struct timeval tv;
char conf[PATH_MAX], *cfile = NULL;
struct stat sb;
XEvent e;
FD_ZERO(&rd);
FD_SET(xfd, &rd);
- if (select(xfd + 1, &rd, NULL, NULL, NULL) == -1)
+ tv.tv_sec = 1;
+ tv.tv_usec = 0;
+ if (select(xfd + 1, &rd, NULL, NULL, &tv) == -1)
if (errno != EINTR)
DNPRINTF(SWM_D_MISC, "select failed");
if (running == 0)