/* wmfind.c (emx+gcc) -- Copyright (c) 1987-1995 by Eberhard Mattes */

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

wm_handle wm_find (int x, int y)
{
  int i;
  wm_handle wh;

  for (i = 0; i < _wm_count; ++i)
    {
      wh = _wm_idx[i];
      if (wh->open && x >= wh->bx0 && y >= wh->by0
          && x <= wh->bx1 && y <= wh->by1)
        if (wh->visible)
          return wh;
        else if (MASK (wh, x-wh->bx0, y-wh->by0))
          return wh;
    }
  return NULL;
}
