void nxmu_requestbkgd(FAR struct nxfe_conn_s *conn, FAR struct nxbe_state_s *be, FAR const struct nx_callback_s *cb, FAR void *arg) { #ifdef CONFIG_DEBUG if (!conn || !be || !cb) { errno = EINVAL; } #endif /* Set the client's callback vtable and and replace the server * connection with the clients connection. */ be->bkgd.cb = cb; be->bkgd.arg = arg; be->bkgd.conn = conn; /* 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 */ #ifdef CONFIG_NX_XYINPUT nxmu_mousereport(&be->bkgd); #endif }
void nxbe_raise(FAR struct nxbe_window_s *wnd) { FAR struct nxbe_state_s *be = wnd->be; /* If this window is already at the top of the display, then do nothing */ if (!wnd->above) { return; } /* Remove window from the list. Note that there is always * some below this window (it may only be the background window) */ wnd->above->below = wnd->below; wnd->below->above = wnd->above; /* Then put it back in the list at the top */ wnd->above = NULL; wnd->below = be->topwnd; be->topwnd->above = wnd; be->topwnd = wnd; /* This window is now at the top of the display, we know, therefore, that * it is not obscured by another window */ nxfe_redrawreq(wnd, &wnd->bounds); }
int nxtk_opentoolbar(NXTKWINDOW hfwnd, nxgl_coord_t height, FAR const struct nx_callback_s *cb, FAR void *arg) { FAR struct nxtk_framedwindow_s *fwnd = (FAR struct nxtk_framedwindow_s *)hfwnd; #ifdef CONFIG_DEBUG if (!hfwnd || !cb) { errno = EINVAL; return ERROR; } #endif /* Initialize the toolbar info */ fwnd->tbheight = height; fwnd->tbcb = cb; fwnd->tbarg = arg; /* Calculate the new dimensions of the toolbar and client windows */ nxtk_setsubwindows(fwnd); /* Then redraw the entire window, even the client window must be * redraw because it has changed its vertical position and size. */ nxfe_redrawreq(&fwnd->wnd, &fwnd->wnd.bounds); /* Return the initialized toolbar reference */ return OK; }
static void nxbe_clipredraw(FAR struct nxbe_clipops_s *cops, FAR struct nxbe_plane_s *plane, FAR const struct nxgl_rect_s *rect) { FAR struct nxbe_window_s *wnd = ((struct nxbe_redraw_s *)cops)->wnd; if (wnd) { nxfe_redrawreq(wnd, rect); } }
static void nxbe_clipmoveobscured(FAR struct nxbe_clipops_s *cops, FAR struct nxbe_plane_s *plane, FAR const struct nxgl_rect_s *rect) { struct nxbe_move_s *info = (struct nxbe_move_s *)cops; struct nxgl_rect_s dst; nxgl_rectoffset(&dst, rect, info->offset.x, info->offset.y); nxfe_redrawreq(info->wnd, &dst); }
static void nxbe_clipmovedest(FAR struct nxbe_clipops_s *cops, FAR struct nxbe_plane_s *plane, FAR const struct nxgl_rect_s *rect) { struct nxbe_move_s *dstdata = (struct nxbe_move_s *)cops; struct nxbe_window_s *wnd = dstdata->wnd; struct nxgl_point_s offset = dstdata->offset; struct nxgl_rect_s src; struct nxgl_rect_s tmprect1; struct nxgl_rect_s tmprect2; struct nxgl_rect_s nonintersecting[4]; int i; /* Redraw dest regions where the source is outside of the bounds of the * background window */ nxgl_rectoffset(&tmprect1, &dstdata->srcrect, offset.x, offset.y); nxgl_rectintersect(&tmprect2, &tmprect1, &wnd->be->bkgd.bounds); nxgl_nonintersecting(nonintersecting, rect, &tmprect2); for (i = 0; i < 4; i++) { if (!nxgl_nullrect(&nonintersecting[i])) { nxfe_redrawreq(dstdata->wnd, &nonintersecting[i]); } } /* Clip to determine what is inside the bounds */ nxgl_rectintersect(&src, rect, &dstdata->srcrect); if (!nxgl_nullrect(&src)) { struct nxbe_move_s srcinfo; srcinfo.cops.visible = nxbe_clipmovesrc; srcinfo.cops.obscured = nxbe_clipmoveobscured; srcinfo.offset = offset; srcinfo.wnd = wnd; nxbe_clipper(dstdata->wnd->above, &src, dstdata->order, &srcinfo.cops, plane); } }
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; }
int nxtk_closetoolbar(NXTKWINDOW hfwnd) { FAR struct nxtk_framedwindow_s *fwnd = (FAR struct nxtk_framedwindow_s *)hfwnd; /* Un-initialize the toolbar info */ fwnd->tbheight = 0; fwnd->tbcb = NULL; fwnd->tbarg = NULL; /* Calculate the new dimensions of the client window */ nxtk_setsubwindows(fwnd); /* Then redraw the entire window, even the client window must be * redraw because it has changed its vertical position and size. */ nxfe_redrawreq(&fwnd->wnd, &fwnd->wnd.bounds); return OK; }
int nx_releasebkgd(NXWINDOW hwnd) { FAR struct nxbe_window_s *bkgd = (FAR struct nxbe_window_s *)hwnd; #ifdef CONFIG_DEBUG if (!bkgd) { errno = EINVAL; return ERROR; } #endif /* Restore the NX background window callbacks */ bkgd->cb = &g_bkgdcb; bkgd->arg = NULL; /* Redraw the background window */ nxfe_redrawreq(bkgd, &bkgd->bounds); return OK; }
void nxmu_releasebkgd(FAR struct nxfe_state_s *fe) { FAR struct nxbe_state_s *be = &fe->be; #ifdef CONFIG_DEBUG if (!fe) { return; } #endif /* Destroy the client window callbacks* and restore the server * connection. */ be->bkgd.cb = NULL; be->bkgd.arg = NULL; be->bkgd.conn = &fe->conn; /* Redraw the background window */ nxfe_redrawreq(&be->bkgd, &be->bkgd.bounds); }
int nx_releasebkgd(NXWINDOW hwnd) { FAR struct nxfe_state_s *fe = (FAR struct nxfe_state_s *)hwnd; FAR struct nxbe_state_s *be = &fe->be; #ifdef CONFIG_DEBUG if (!fe) { errno = EINVAL; return ERROR; } #endif /* Restore the NX background window callbacks */ be->bkgd.cb = &g_bkgdcb; be->bkgd.arg = NULL; /* Redraw the background window */ nxfe_redrawreq(&be->bkgd, &be->bkgd.bounds); return OK; }
int nx_runinstance(FAR const char *mqname, FAR NX_DRIVERTYPE *dev) { struct nxfe_state_s fe; FAR struct nxsvrmsg_s *msg; uint8_t buffer[NX_MXSVRMSGLEN]; int nbytes; int ret; /* Initialization *********************************************************/ /* Sanity checking */ #ifdef CONFIG_DEBUG if (!mqname || !dev) { errno = EINVAL; return ERROR; } #endif /* Initialize and configure the server */ ret = nxmu_setup(mqname, dev, &fe); if (ret < 0) { return ret; /* nxmu_setup sets errno */ } /* Produce the initial, background display */ nxbe_redraw(&fe.be, &fe.be.bkgd, &fe.be.bkgd.bounds); /* Message Loop ***********************************************************/ /* Then loop forever processing incoming messages */ for (;;) { /* Receive the next server message */ nbytes = mq_receive(fe.conn.crdmq, buffer, NX_MXSVRMSGLEN, 0); if (nbytes < 0) { if (errno != EINTR) { gdbg("mq_receive failed: %d\n", errno); goto errout; /* mq_receive sets errno */ } continue; } /* Dispatch the message appropriately */ DEBUGASSERT(nbytes >= sizeof(struct nxsvrmsg_s)); msg = (FAR struct nxsvrmsg_s *)buffer; gvdbg("Received opcode=%d nbytes=%d\n", msg->msgid, nbytes); switch (msg->msgid) { /* Messages sent from clients to the NX server *********************/ case NX_SVRMSG_CONNECT: /* Establish connection with new NX server client */ { FAR struct nxsvrmsg_s *connmsg = (FAR struct nxsvrmsg_s *)buffer; nxmu_connect(connmsg->conn); } break; case NX_SVRMSG_DISCONNECT: /* Tear down connection with terminating client */ { FAR struct nxsvrmsg_s *disconnmsg = (FAR struct nxsvrmsg_s *)buffer; nxmu_disconnect(disconnmsg->conn); } break; case NX_SVRMSG_OPENWINDOW: /* Create a new window */ { FAR struct nxsvrmsg_openwindow_s *openmsg = (FAR struct nxsvrmsg_openwindow_s *)buffer; nxmu_openwindow(&fe.be, openmsg->wnd); } break; case NX_SVRMSG_CLOSEWINDOW: /* Close an existing window */ { FAR struct nxsvrmsg_closewindow_s *closemsg = (FAR struct nxsvrmsg_closewindow_s *)buffer; nxbe_closewindow(closemsg->wnd); } break; case NX_SVRMSG_BLOCKED: /* Block messsages to a window */ { FAR struct nxsvrmsg_blocked_s *blocked = (FAR struct nxsvrmsg_blocked_s *)buffer; nxmu_blocked(blocked->wnd, blocked->arg); } break; case NX_SVRMSG_REQUESTBKGD: /* Give access to the background window */ { FAR struct nxsvrmsg_requestbkgd_s *rqbgmsg = (FAR struct nxsvrmsg_requestbkgd_s *)buffer; nxmu_requestbkgd(rqbgmsg->conn, &fe.be, rqbgmsg->cb, rqbgmsg->arg); } break; case NX_SVRMSG_RELEASEBKGD: /* End access to the background window */ { nxmu_releasebkgd(&fe); } break; case NX_SVRMSG_SETPOSITION: /* Change window position */ { FAR struct nxsvrmsg_setposition_s *setposmsg = (FAR struct nxsvrmsg_setposition_s *)buffer; nxbe_setposition(setposmsg->wnd, &setposmsg->pos); } break; case NX_SVRMSG_SETSIZE: /* Change window size */ { FAR struct nxsvrmsg_setsize_s *setsizemsg = (FAR struct nxsvrmsg_setsize_s *)buffer; nxbe_setsize(setsizemsg->wnd, &setsizemsg->size); } break; case NX_SVRMSG_GETPOSITION: /* Get the window size/position */ { FAR struct nxsvrmsg_getposition_s *getposmsg = (FAR struct nxsvrmsg_getposition_s *)buffer; nxfe_reportposition(getposmsg->wnd); } break; case NX_SVRMSG_RAISE: /* Move the window to the top of the display */ { FAR struct nxsvrmsg_raise_s *raisemsg = (FAR struct nxsvrmsg_raise_s *)buffer; nxbe_raise(raisemsg->wnd); } break; case NX_SVRMSG_LOWER: /* Lower the window to the bottom of the display */ { FAR struct nxsvrmsg_lower_s *lowermsg = (FAR struct nxsvrmsg_lower_s *)buffer; nxbe_lower(lowermsg->wnd); } break; case NX_SVRMSG_SETPIXEL: /* Set a single pixel in the window with a color */ { FAR struct nxsvrmsg_setpixel_s *setmsg = (FAR struct nxsvrmsg_setpixel_s *)buffer; nxbe_setpixel(setmsg->wnd, &setmsg->pos, setmsg->color); } break; case NX_SVRMSG_FILL: /* Fill a rectangular region in the window with a color */ { FAR struct nxsvrmsg_fill_s *fillmsg = (FAR struct nxsvrmsg_fill_s *)buffer; nxbe_fill(fillmsg->wnd, &fillmsg->rect, fillmsg->color); } break; case NX_SVRMSG_GETRECTANGLE: /* Get a rectangular region from the window */ { FAR struct nxsvrmsg_getrectangle_s *getmsg = (FAR struct nxsvrmsg_getrectangle_s *)buffer; nxbe_getrectangle(getmsg->wnd, &getmsg->rect, getmsg->plane, getmsg->dest, getmsg->deststride); if (getmsg->sem_done) { sem_post(getmsg->sem_done); } } break; case NX_SVRMSG_FILLTRAP: /* Fill a trapezoidal region in the window with a color */ { FAR struct nxsvrmsg_filltrapezoid_s *trapmsg = (FAR struct nxsvrmsg_filltrapezoid_s *)buffer; nxbe_filltrapezoid(trapmsg->wnd, &trapmsg->clip, &trapmsg->trap, trapmsg->color); } break; case NX_SVRMSG_MOVE: /* Move a rectangular region within the window */ { FAR struct nxsvrmsg_move_s *movemsg = (FAR struct nxsvrmsg_move_s *)buffer; nxbe_move(movemsg->wnd, &movemsg->rect, &movemsg->offset); } break; case NX_SVRMSG_BITMAP: /* Copy a rectangular bitmap into the window */ { FAR struct nxsvrmsg_bitmap_s *bmpmsg = (FAR struct nxsvrmsg_bitmap_s *)buffer; nxbe_bitmap(bmpmsg->wnd, &bmpmsg->dest, bmpmsg->src, &bmpmsg->origin, bmpmsg->stride); if (bmpmsg->sem_done) { sem_post(bmpmsg->sem_done); } } break; case NX_SVRMSG_SETBGCOLOR: /* Set the color of the background */ { FAR struct nxsvrmsg_setbgcolor_s *bgcolormsg = (FAR struct nxsvrmsg_setbgcolor_s *)buffer; /* Has the background color changed? */ if (!nxgl_colorcmp(fe.be.bgcolor, bgcolormsg->color)) { /* Yes.. fill the background */ nxgl_colorcopy(fe.be.bgcolor, bgcolormsg->color); nxbe_fill(&fe.be.bkgd, &fe.be.bkgd.bounds, bgcolormsg->color); } } break; #ifdef CONFIG_NX_XYINPUT case NX_SVRMSG_MOUSEIN: /* New mouse report from mouse client */ { FAR struct nxsvrmsg_mousein_s *mousemsg = (FAR struct nxsvrmsg_mousein_s *)buffer; nxmu_mousein(&fe, &mousemsg->pt, mousemsg->buttons); } break; #endif #ifdef CONFIG_NX_KBD case NX_SVRMSG_KBDIN: /* New keyboard report from keyboard client */ { FAR struct nxsvrmsg_kbdin_s *kbdmsg = (FAR struct nxsvrmsg_kbdin_s *)buffer; nxmu_kbdin(&fe, kbdmsg->nch, kbdmsg->ch); } break; #endif case NX_SVRMSG_REDRAWREQ: /* Request re-drawing of rectangular region */ { FAR struct nxsvrmsg_redrawreq_s *redrawmsg = (FAR struct nxsvrmsg_redrawreq_s *)buffer; nxfe_redrawreq(redrawmsg->wnd, &redrawmsg->rect); } break; /* Messages sent to the background window **************************/ case NX_CLIMSG_REDRAW: /* Re-draw the background window */ { FAR struct nxclimsg_redraw_s *redraw = (FAR struct nxclimsg_redraw_s *)buffer; DEBUGASSERT(redraw->wnd == &fe.be.bkgd); gvdbg("Re-draw background rect={(%d,%d),(%d,%d)}\n", redraw->rect.pt1.x, redraw->rect.pt1.y, redraw->rect.pt2.x, redraw->rect.pt2.y); nxbe_fill(&fe.be.bkgd, &redraw->rect, fe.be.bgcolor); } break; case NX_CLIMSG_MOUSEIN: /* Ignored */ case NX_CLIMSG_KBDIN: break; case NX_CLIMSG_CONNECTED: /* Shouldn't happen */ case NX_CLIMSG_DISCONNECTED: default: gdbg("Unrecognized command: %d\n", msg->msgid); break; } } errout: nxmu_shutdown(&fe); return OK; }
void nx_redrawreq(NXWINDOW hwnd, FAR const struct nxgl_rect_s *rect) { nxfe_redrawreq((FAR struct nxbe_window_s *)hwnd, rect); }