Answer: You can look at the WM_STATE property, but this breaks ICCCM guidelines. ICCCM compliant window managers will map windows in changing them to normal state and unmap them in changing them to iconic state. Look for StructureNotify events and check the event type: XtAddEventHandler (toplevel_widget, StructureNotifyMask, False, StateWatcher, (Opaque) NULL); .... void StateWatcher (w, unused, event) Widget w; caddr_t unused; XEvent *event; { if (event->type == MapNotify) printf ("normal\n"); else if (event->type == UnmapNotify) printf ("iconified\n"); else printf ("other event\n"); } If you insist on looking at WM_STATE, here is some code (from Ken Sall) to do it: /* ------------------------------------------------------------------ Try a function such as CheckWinMgrState below which returns one of IconicState | NormalState | WithdrawnState | NULL : ------------------------------------------------------------------ */ #define WM_STATE_ELEMENTS 1 unsigned long *CheckWinMgrState (dpy, window) Display *dpy; Window window; { unsigned long *property = NULL; unsigned long nitems; unsigned long leftover; Atom xa_WM_STATE, actual_type; int actual_format; int status; xa_WM_STATE = XInternAtom (dpy, "WM_STATE", False); status = XGetWindowProperty (dpy, window, xa_WM_STATE, 0L, WM_STATE_ELEMENTS, False, xa_WM_STATE, &actual_type, &actual_format, &nitems, &leftover, (unsigned char **)&property); if ( ! ((status == Success) && (actual_type == xa_WM_STATE) && (nitems == WM_STATE_ELEMENTS))) { if (property) { XFree ((char *)property); property = NULL; } } return (property); } /* end CheckWinMgrState */Go Back Up