/* wmdelete.c (emx+gcc) -- Copyright (c) 1987-1994 by Eberhard Mattes */

#include <stdlib.h>
#include <sys/winmgr.h>
#include "winmgr2.h"


void wm_delete (wm_handle wh)
{
  int i, idx;

  if (wh->used != WM_USED)
    return;
  idx = _wm_idx1 (wh);
  if (idx < 0)
    return;
  --_wm_count;
  for (i = idx; i < _wm_count; ++i)
    _wm_idx[i] = _wm_idx[i+1];
  _tfree (wh->data);
  free (wh->mask);
  wh->used = 0;
  if (_wm_cursor == wh)
    {
      _wm_cursor = NULL;
      _wm_cursor1 ();
    }
}
