public void scan_children () {
    // query all top-level windows
    Window[] children = root.tree ().children ();
    for (Window w : children) {
      Client client = (Client) Client.intern (display, w.id);

      // get override_redirect and map_state
      client.attributes = client.attributes ();

      /* Children of root to be managed: (1) not override redirect (pop-up
       * and transient windows). (2) VIEWABLE (previously mapped)
       */
      if (client.attributes.override_redirect ()
	|| client.attributes.map_state ()
        != Window.AttributesReply.VIEWABLE)

	continue;		// not managed


      int wm_state = client.wm_state ();
      if (wm_state != -1 && wm_state == Window.WMState.ICONIC) {
    	  hide (client);		// respect its iconic state

      } else {
	// maintain our state variable
	client.state = NORMAL;
	// in case someone screws this up
	client.set_wm_state (Window.WMState.NORMAL);
      }


      if (client.state == NORMAL || client.state == HIDDEN)
	manage (client);
    }
  }