示例#1
0
int nx_mousein(NXHANDLE handle, nxgl_coord_t x, nxgl_coord_t y, uint8_t buttons)
{
  FAR struct nxfe_state_s *fe = (FAR struct nxfe_state_s *)handle;
  struct nxbe_window_s *wnd;
  int ret;

  /* Clip x and y to within the bounding rectangle */

  if (x < 0)
    {
      x = 0;
    }
  else if (x >= g_mrange.x)
    {
      x = g_mrange.x - 1;
    }

  if (y < 0)
    {
      y = 0;
    }
  else if (y >= g_mrange.y)
    {
      y = g_mrange.y - 1;
    }

 /* Look any change in values */

  if (x != g_mpos.x || y != g_mpos.y || buttons != g_mbutton)
    {
      /* Update the mouse value */

      g_mpos.x  = x;
      g_mpos.y  = y;
      g_mbutton = buttons;

      /* Pick the window to receive the mouse event.  Start with
       * the top window and go down.  Step with the first window
       * that gets the mouse report
       */

      for (wnd = fe->be.topwnd; wnd; wnd = wnd->below)
        {
          ret = nxsu_mousereport(wnd);
          if (ret == 0)
            {
              break;
            }
        }
    }
  return OK;
}
int nx_constructwindow(NXHANDLE handle, NXWINDOW hwnd,
                       FAR const struct nx_callback_s *cb, FAR void *arg)
{
  FAR struct nxfe_state_s *fe = (FAR struct nxfe_state_s *)handle;
  FAR struct nxbe_window_s *wnd = (FAR struct nxbe_window_s *)hwnd;
  FAR struct nxbe_state_s *be = &fe->be;

#ifdef CONFIG_DEBUG
  if (!wnd)
    {
      set_errno(EINVAL);
      return ERROR;
    }

  if (!fe || !cb)
    {
      kufree(wnd);
      errno = EINVAL;
      return ERROR;
    }
#endif

  /* Initialize the window structure */

  wnd->be           = be;
  wnd->cb           = cb;
  wnd->arg          = arg;

  /* Insert the new window at the top on the display.  topwnd is
   * never NULL (it may point only at the background window, however)
   */

  wnd->above        = NULL;
  wnd->below        = be->topwnd;

  be->topwnd->above = wnd;
  be->topwnd        = wnd;

  /* Report the initialize size/position of the window */

  nxfe_reportposition((NXWINDOW)wnd);

  /* Provide the initial mouse settings */

#ifdef CONFIG_NX_XYINPUT
  nxsu_mousereport(wnd);
#endif

  return OK;
}
int nx_requestbkgd(NXHANDLE handle, FAR const struct nx_callback_s *cb,
                   FAR void *arg)
{
    FAR struct nxfe_state_s *fe = (FAR struct nxfe_state_s *)handle;
    FAR struct nxbe_state_s *be = &fe->be;

#ifdef CONFIG_DEBUG
    if (!fe || !cb)
    {
        errno = EINVAL;
        return ERROR;
    }
#endif

    /* Replace the NX background windo callbacks with the client's callbacks */

    be->bkgd.cb  = cb;
    be->bkgd.arg = arg;

    /* Report the size/position of the background window to the client */

    nxfe_reportposition((NXWINDOW)&be->bkgd);

    /* Redraw the background window */

    nxfe_redrawreq(&be->bkgd, &be->bkgd.bounds);

    /* Provide the mouse settings to the client */

#ifdef CONFIG_NX_XYINPUT
    nxsu_mousereport(&be->bkgd);
#endif

    /* In this single-user mode, we could return the background window
     * handle here.  However, we cannot do that in the multi-user case
     * because that handle is known only to the server.  Instead, the
     * background window handle is returned to the client via a redraw
     * callback.  So we will do the same in the single-user case for
     * compatibility.
     */

    return OK;
}