/* wmclose.c (emx+gcc) -- Copyright (c) 1987-1993 by Eberhard Mattes */

#include <stdlib.h>
#include <sys/winmgr.h>
#include "winmgr2.h"

void wm_close (wm_handle wh)
{
  int i;
  wm_handle p;

  if (wh->used != WM_USED)
    return;
  if (wh->open)
    {
      _wm_unhide1 (wh, NULL);
      wh->open = FALSE;
      wh->display = FALSE;
      _wm_hide1 ();
      for (i = 0; i < _wm_count; ++i)
        {
          p = _wm_idx[i];
          if (p == wh)
            break;
          if (p->open && _wm_jam1 (p, wh))
            _wm_put1 (p);
        }
      wh->visible = FALSE;
      _wm_cursor1 ();
    }
}
