main.c
changeset 969 50fb50842dbc
parent 968 ce9a5452ac8c
child 971 b2a0dfa22b1d
--- a/main.c	Sun Aug 19 11:00:47 2007 +0200
+++ b/main.c	Sun Aug 19 18:39:54 2007 +0200
@@ -111,6 +111,24 @@
 	dc.font.height = dc.font.ascent + dc.font.descent;
 }
 
+static long
+getstate(Window w) {
+	int format, status;
+	long result = -1;
+	unsigned char *p = NULL;
+	unsigned long n, extra;
+	Atom real;
+
+	status = XGetWindowProperty(dpy, w, wmatom[WMState], 0L, 2L, False, wmatom[WMState],
+			&real, &format, &n, &extra, (unsigned char **)&p);
+	if(status != Success)
+		return -1;
+	if(n != 0)
+		result = *p;
+	XFree(p);
+	return result;
+}
+
 static void
 scan(void) {
 	unsigned int i, num;
@@ -123,7 +141,14 @@
 			if(!XGetWindowAttributes(dpy, wins[i], &wa)
 			|| wa.override_redirect || XGetTransientForHint(dpy, wins[i], &d1))
 				continue;
-			if(wa.map_state == IsViewable)
+			if(wa.map_state == IsViewable || getstate(wins[i]) == IconicState)
+				manage(wins[i], &wa);
+		}
+		for(i = 0; i < num; i++) { /* now the transients */
+			if(!XGetWindowAttributes(dpy, wins[i], &wa))
+				continue;
+			if(XGetTransientForHint(dpy, wins[i], &d1)
+			&& (wa.map_state == IsViewable || getstate(wins[i]) == IconicState))
 				manage(wins[i], &wa);
 		}
 	}