nxmu_server.c 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588
  1. /****************************************************************************
  2. * graphics/nxmu/nxmu_server.c
  3. *
  4. * Copyright (C) 2008-2012, 2017, 2019 Gregory Nutt. All rights reserved.
  5. * Author: Gregory Nutt <gnutt@nuttx.org>
  6. *
  7. * Redistribution and use in source and binary forms, with or without
  8. * modification, are permitted provided that the following conditions
  9. * are met:
  10. *
  11. * 1. Redistributions of source code must retain the above copyright
  12. * notice, this list of conditions and the following disclaimer.
  13. * 2. Redistributions in binary form must reproduce the above copyright
  14. * notice, this list of conditions and the following disclaimer in
  15. * the documentation and/or other materials provided with the
  16. * distribution.
  17. * 3. Neither the name NuttX nor the names of its contributors may be
  18. * used to endorse or promote products derived from this software
  19. * without specific prior written permission.
  20. *
  21. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  22. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  23. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
  24. * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
  25. * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  26. * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
  27. * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
  28. * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
  29. * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  30. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
  31. * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  32. * POSSIBILITY OF SUCH DAMAGE.
  33. *
  34. ****************************************************************************/
  35. /****************************************************************************
  36. * Included Files
  37. ****************************************************************************/
  38. #include <nuttx/config.h>
  39. #include <stdint.h>
  40. #include <stdio.h>
  41. #include <string.h>
  42. #include <mqueue.h>
  43. #include <fcntl.h>
  44. #include <assert.h>
  45. #include <errno.h>
  46. #include <debug.h>
  47. #include <nuttx/mqueue.h>
  48. #include <nuttx/nx/nx.h>
  49. #include "nxmu.h"
  50. /****************************************************************************
  51. * Private Functions
  52. ****************************************************************************/
  53. /****************************************************************************
  54. * Name: nxmu_disconnect
  55. ****************************************************************************/
  56. static inline void nxmu_disconnect(FAR struct nxmu_conn_s *conn)
  57. {
  58. struct nxclimsg_disconnected_s outmsg;
  59. int ret;
  60. /* Send the handshake message back to the client */
  61. outmsg.msgid = NX_CLIMSG_DISCONNECTED;
  62. ret = nxmu_sendclient(conn, &outmsg, sizeof(struct nxclimsg_disconnected_s));
  63. if (ret < 0)
  64. {
  65. gerr("ERROR: nxmu_sendclient failed: %d\n", ret);
  66. }
  67. /* Close the outgoing client message queue */
  68. mq_close(conn->swrmq);
  69. }
  70. /****************************************************************************
  71. * Name: nxmu_connect
  72. ****************************************************************************/
  73. static inline void nxmu_connect(FAR struct nxmu_conn_s *conn)
  74. {
  75. char mqname[NX_CLIENT_MXNAMELEN];
  76. struct nxclimsg_connected_s outmsg;
  77. int ret;
  78. /* Create the client MQ name */
  79. sprintf(mqname, NX_CLIENT_MQNAMEFMT, conn->cid);
  80. /* Open the client MQ -- this should have already been created by the client */
  81. conn->swrmq = mq_open(mqname, O_WRONLY);
  82. if (conn->swrmq == (mqd_t)-1)
  83. {
  84. gerr("ERROR: mq_open(%s) failed: %d\n", mqname, errno);
  85. outmsg.msgid = NX_CLIMSG_DISCONNECTED;
  86. }
  87. /* Send the handshake message back to the client */
  88. outmsg.msgid = NX_CLIMSG_CONNECTED;
  89. ret = nxmu_sendclient(conn, &outmsg, sizeof(struct nxclimsg_connected_s));
  90. if (ret < 0)
  91. {
  92. gerr("ERROR: nxmu_sendclient failed: %d\n", ret);
  93. }
  94. }
  95. /****************************************************************************
  96. * Name: nxmu_shutdown
  97. ****************************************************************************/
  98. static inline void nxmu_shutdown(FAR struct nxmu_state_s *nxmu)
  99. {
  100. FAR struct nxbe_window_s *wnd;
  101. /* Inform all of the clients in the window list that the server is
  102. * exit-ting. Notes: (1) that the following loop will probably attempt to
  103. * disconnect clients multiple times because one client may have multiple
  104. * windows: The first disconnect will fail; subsequent will return errors
  105. * that are ignored. (2) The final window to be disconnected will be the
  106. * background window, thus close all of the servers message queues.
  107. */
  108. for (wnd = nxmu->be.topwnd; wnd; wnd = wnd->below)
  109. {
  110. nxmu_disconnect(wnd->conn);
  111. }
  112. }
  113. /****************************************************************************
  114. * Name: nxmu_event
  115. ****************************************************************************/
  116. static void nxmu_event(FAR struct nxbe_window_s *wnd, enum nx_event_e event,
  117. FAR void *arg)
  118. {
  119. struct nxclimsg_event_s outmsg;
  120. int ret;
  121. outmsg.msgid = NX_CLIMSG_EVENT;
  122. outmsg.wnd = wnd;
  123. outmsg.arg = arg;
  124. outmsg.event = event;
  125. ret = nxmu_sendclient(wnd->conn, &outmsg,
  126. sizeof(struct nxclimsg_event_s));
  127. if (ret < 0)
  128. {
  129. gerr("ERROR: nxmu_sendclient failed: %d\n", ret);
  130. }
  131. }
  132. /****************************************************************************
  133. * Name: nxmu_setup
  134. ****************************************************************************/
  135. static inline int nxmu_setup(FAR const char *mqname, FAR NX_DRIVERTYPE *dev,
  136. FAR struct nxmu_state_s *nxmu)
  137. {
  138. struct mq_attr attr;
  139. int ret;
  140. memset(nxmu, 0, sizeof(struct nxmu_state_s));
  141. /* Configure the framebuffer/LCD device */
  142. ret = nxbe_configure(dev, &nxmu->be);
  143. if (ret < 0)
  144. {
  145. gerr("ERROR: nxbe_configure failed: %d\n", ret);
  146. return ret;
  147. }
  148. #ifdef CONFIG_FB_CMAP
  149. ret = nxbe_colormap(dev);
  150. if (ret < 0)
  151. {
  152. gerr("ERROR: nxbe_colormap failed: %d\n", ret);
  153. return ret;
  154. }
  155. #endif /* CONFIG_FB_CMAP */
  156. /* Initialize the non-NULL elements of the server connection structure.
  157. * Oddly, this structure represents the connection between the server and
  158. * itself.
  159. *
  160. * Open the incoming server MQ. The server receives messages on the
  161. * background window's incoming message queue.
  162. */
  163. attr.mq_maxmsg = CONFIG_NX_MXSERVERMSGS;
  164. attr.mq_msgsize = NX_MXSVRMSGLEN;
  165. attr.mq_flags = 0;
  166. nxmu->conn.crdmq = mq_open(mqname, O_RDONLY | O_CREAT, 0666, &attr);
  167. if (nxmu->conn.crdmq == (mqd_t)-1)
  168. {
  169. int errcode = get_errno();
  170. gerr("ERROR: mq_open(%s) failed: %d\n", mqname, errcode);
  171. return -errcode;
  172. }
  173. /* NOTE that the outgoing client MQ (cwrmq) is not initialized. The
  174. * background window never initiates messages.
  175. */
  176. /* Open the outgoing server MQ. This is used to send messages to the
  177. * background window which will, of course, be received and handled by
  178. * the server message loop.
  179. */
  180. nxmu->conn.swrmq = mq_open(mqname, O_WRONLY);
  181. if (nxmu->conn.swrmq == (mqd_t)-1)
  182. {
  183. int errcode = get_errno();
  184. gerr("ERROR: mq_open(%s) failed: %d\n", mqname, errcode);
  185. mq_close(nxmu->conn.crdmq);
  186. return -errcode;
  187. }
  188. /* The server is now "connected" to itself via the background window */
  189. nxmu->conn.state = NX_CLISTATE_CONNECTED;
  190. /* Initialize the non-NULL elements of the background window */
  191. nxmu->be.bkgd.conn = &nxmu->conn;
  192. nxmu->be.bkgd.be = (FAR struct nxbe_state_s *)nxmu;
  193. nxmu->be.bkgd.bounds.pt2.x = nxmu->be.vinfo.xres - 1;
  194. nxmu->be.bkgd.bounds.pt2.y = nxmu->be.vinfo.yres - 1;
  195. /* Complete initialization of the server state structure. The
  196. * window list contains only one element: The background window
  197. * with nothing else above or below it
  198. */
  199. nxmu->be.topwnd = &nxmu->be.bkgd;
  200. /* Initialize the mouse position */
  201. #ifdef CONFIG_NX_XYINPUT
  202. nxmu_mouseinit(nxmu->be.vinfo.xres, nxmu->be.vinfo.yres);
  203. #endif
  204. return OK;
  205. }
  206. /****************************************************************************
  207. * Public Functions
  208. ****************************************************************************/
  209. /****************************************************************************
  210. * Name: nx_runinstance
  211. *
  212. * Description:
  213. * This is the server entry point. It does not return; the calling thread
  214. * is dedicated to supporting NX server.
  215. *
  216. * NOTE that multiple instances of the NX server may run at the same time,
  217. * each with different callback and message queue names.
  218. *
  219. * Input Parameters:
  220. * mqname - The name for the server incoming message queue
  221. * dev - Vtable "object" of the framebuffer/LCD "driver" to use
  222. *
  223. * Returned Value:
  224. * This function usually does not return. If it does return, it will
  225. * return a negated errno value indicating the cause of the failure.
  226. *
  227. ****************************************************************************/
  228. int nx_runinstance(FAR const char *mqname, FAR NX_DRIVERTYPE *dev)
  229. {
  230. struct nxmu_state_s nxmu;
  231. FAR struct nxsvrmsg_s *msg;
  232. char buffer[NX_MXSVRMSGLEN];
  233. int nbytes;
  234. int ret;
  235. /* Initialization *********************************************************/
  236. DEBUGASSERT(mqname != NULL || dev != NULL);
  237. /* Initialize and configure the server */
  238. ret = nxmu_setup(mqname, dev, &nxmu);
  239. if (ret < 0)
  240. {
  241. return ret;
  242. }
  243. /* Produce the initial, background display */
  244. nxbe_redraw(&nxmu.be, &nxmu.be.bkgd, &nxmu.be.bkgd.bounds);
  245. /* Message Loop ***********************************************************/
  246. /* Then loop forever processing incoming messages */
  247. for (; ; )
  248. {
  249. /* Receive the next server message */
  250. nbytes = nxmq_receive(nxmu.conn.crdmq, buffer, NX_MXSVRMSGLEN, 0);
  251. if (nbytes < 0)
  252. {
  253. if (nbytes != -EINTR)
  254. {
  255. gerr("ERROR: nxmq_receive() failed: %d\n", nbytes);
  256. ret = nbytes;
  257. goto errout;
  258. }
  259. continue;
  260. }
  261. /* Dispatch the message appropriately */
  262. DEBUGASSERT(nbytes >= sizeof(struct nxsvrmsg_releasebkgd_s));
  263. msg = (FAR struct nxsvrmsg_s *)buffer;
  264. ginfo("Received opcode=%d nbytes=%d\n", msg->msgid, nbytes);
  265. switch (msg->msgid)
  266. {
  267. /* Messages sent from clients to the NX server *********************/
  268. case NX_SVRMSG_CONNECT: /* Establish connection with new NX server client */
  269. {
  270. FAR struct nxsvrmsg_s *connmsg = (FAR struct nxsvrmsg_s *)buffer;
  271. nxmu_connect(connmsg->conn);
  272. }
  273. break;
  274. case NX_SVRMSG_DISCONNECT: /* Tear down connection with terminating client */
  275. {
  276. FAR struct nxsvrmsg_s *disconnmsg = (FAR struct nxsvrmsg_s *)buffer;
  277. nxmu_disconnect(disconnmsg->conn);
  278. }
  279. break;
  280. case NX_SVRMSG_OPENWINDOW: /* Create a new window */
  281. {
  282. FAR struct nxsvrmsg_openwindow_s *openmsg = (FAR struct nxsvrmsg_openwindow_s *)buffer;
  283. nxmu_openwindow(&nxmu.be, openmsg->wnd);
  284. }
  285. break;
  286. case NX_SVRMSG_CLOSEWINDOW: /* Close an existing window */
  287. {
  288. FAR struct nxsvrmsg_closewindow_s *closemsg = (FAR struct nxsvrmsg_closewindow_s *)buffer;
  289. nxbe_closewindow(closemsg->wnd);
  290. }
  291. break;
  292. case NX_SVRMSG_BLOCKED: /* Block messages to a window */
  293. {
  294. FAR struct nxsvrmsg_blocked_s *blocked = (FAR struct nxsvrmsg_blocked_s *)buffer;
  295. nxmu_event(blocked->wnd, NXEVENT_BLOCKED, blocked->arg);
  296. }
  297. break;
  298. case NX_SVRMSG_SYNCH: /* Synchronization request */
  299. {
  300. FAR struct nxsvrmsg_synch_s *synch = (FAR struct nxsvrmsg_synch_s *)buffer;
  301. nxmu_event(synch->wnd, NXEVENT_SYNCHED, synch->arg);
  302. }
  303. break;
  304. #if defined(CONFIG_NX_SWCURSOR) || defined(CONFIG_NX_HWCURSOR)
  305. case NX_SVRMSG_CURSOR_ENABLE: /* Enable/disable cursor */
  306. {
  307. FAR struct nxsvrmsg_curenable_s *enabmsg = (FAR struct nxsvrmsg_curenable_s *)buffer;
  308. nxbe_cursor_enable(&nxmu.be, enabmsg->enable);
  309. }
  310. break;
  311. #if defined(CONFIG_NX_HWCURSORIMAGE) || defined(CONFIG_NX_SWCURSOR)
  312. case NX_SVRMSG_CURSOR_IMAGE: /* Set cursor image */
  313. {
  314. FAR struct nxsvrmsg_curimage_s *imgmsg = (FAR struct nxsvrmsg_curimage_s *)buffer;
  315. nxbe_cursor_setimage(&nxmu.be, &imgmsg->image);
  316. }
  317. break;
  318. #endif
  319. case NX_SVRMSG_CURSOR_SETPOS: /* Set cursor position */
  320. {
  321. FAR struct nxsvrmsg_curpos_s *posmsg = (FAR struct nxsvrmsg_curpos_s *)buffer;
  322. nxbe_cursor_setposition(&nxmu.be, &posmsg->pos);
  323. }
  324. break;
  325. #endif
  326. case NX_SVRMSG_REQUESTBKGD: /* Give access to the background window */
  327. {
  328. FAR struct nxsvrmsg_requestbkgd_s *rqbgmsg = (FAR struct nxsvrmsg_requestbkgd_s *)buffer;
  329. nxmu_requestbkgd(rqbgmsg->conn, &nxmu.be, rqbgmsg->cb, rqbgmsg->arg);
  330. }
  331. break;
  332. case NX_SVRMSG_RELEASEBKGD: /* End access to the background window */
  333. {
  334. nxmu_releasebkgd(&nxmu);
  335. }
  336. break;
  337. case NX_SVRMSG_SETPOSITION: /* Change window position */
  338. {
  339. FAR struct nxsvrmsg_setposition_s *setposmsg = (FAR struct nxsvrmsg_setposition_s *)buffer;
  340. nxbe_setposition(setposmsg->wnd, &setposmsg->pos);
  341. }
  342. break;
  343. case NX_SVRMSG_SETSIZE: /* Change window size */
  344. {
  345. FAR struct nxsvrmsg_setsize_s *setsizemsg = (FAR struct nxsvrmsg_setsize_s *)buffer;
  346. nxbe_setsize(setsizemsg->wnd, &setsizemsg->size);
  347. }
  348. break;
  349. case NX_SVRMSG_GETPOSITION: /* Get the window size/position */
  350. {
  351. FAR struct nxsvrmsg_getposition_s *getposmsg = (FAR struct nxsvrmsg_getposition_s *)buffer;
  352. nxmu_reportposition(getposmsg->wnd);
  353. }
  354. break;
  355. case NX_SVRMSG_RAISE: /* Move the window to the top of the display */
  356. {
  357. FAR struct nxsvrmsg_raise_s *raisemsg = (FAR struct nxsvrmsg_raise_s *)buffer;
  358. nxbe_raise(raisemsg->wnd);
  359. }
  360. break;
  361. case NX_SVRMSG_LOWER: /* Lower the window to the bottom of the display */
  362. {
  363. FAR struct nxsvrmsg_lower_s *lowermsg = (FAR struct nxsvrmsg_lower_s *)buffer;
  364. nxbe_lower(lowermsg->wnd);
  365. }
  366. break;
  367. case NX_SVRMSG_MODAL: /* Select/De-select window modal state */
  368. {
  369. FAR struct nxsvrmsg_modal_s *modalmsg = (FAR struct nxsvrmsg_modal_s *)buffer;
  370. nxbe_modal(modalmsg->wnd, modalmsg->modal);
  371. }
  372. break;
  373. case NX_SVRMSG_SETVISIBILITY: /* Show or hide a window */
  374. {
  375. FAR struct nxsvrmsg_setvisibility_s *vismsg =
  376. (FAR struct nxsvrmsg_setvisibility_s *)buffer;
  377. nxbe_setvisibility(vismsg->wnd, vismsg->hide);
  378. }
  379. break;
  380. case NX_SVRMSG_SETPIXEL: /* Set a single pixel in the window with a color */
  381. {
  382. FAR struct nxsvrmsg_setpixel_s *setmsg = (FAR struct nxsvrmsg_setpixel_s *)buffer;
  383. nxbe_setpixel(setmsg->wnd, &setmsg->pos, setmsg->color);
  384. }
  385. break;
  386. case NX_SVRMSG_FILL: /* Fill a rectangular region in the window with a color */
  387. {
  388. FAR struct nxsvrmsg_fill_s *fillmsg = (FAR struct nxsvrmsg_fill_s *)buffer;
  389. nxbe_fill(fillmsg->wnd, &fillmsg->rect, fillmsg->color);
  390. }
  391. break;
  392. case NX_SVRMSG_GETRECTANGLE: /* Get a rectangular region from the window */
  393. {
  394. FAR struct nxsvrmsg_getrectangle_s *getmsg = (FAR struct nxsvrmsg_getrectangle_s *)buffer;
  395. nxbe_getrectangle(getmsg->wnd, &getmsg->rect, getmsg->plane, getmsg->dest, getmsg->deststride);
  396. if (getmsg->sem_done)
  397. {
  398. nxsem_post(getmsg->sem_done);
  399. }
  400. }
  401. break;
  402. case NX_SVRMSG_FILLTRAP: /* Fill a trapezoidal region in the window with a color */
  403. {
  404. FAR struct nxsvrmsg_filltrapezoid_s *trapmsg = (FAR struct nxsvrmsg_filltrapezoid_s *)buffer;
  405. nxbe_filltrapezoid(trapmsg->wnd, &trapmsg->clip, &trapmsg->trap, trapmsg->color);
  406. }
  407. break;
  408. case NX_SVRMSG_MOVE: /* Move a rectangular region within the window */
  409. {
  410. FAR struct nxsvrmsg_move_s *movemsg = (FAR struct nxsvrmsg_move_s *)buffer;
  411. nxbe_move(movemsg->wnd, &movemsg->rect, &movemsg->offset);
  412. }
  413. break;
  414. case NX_SVRMSG_BITMAP: /* Copy a rectangular bitmap into the window */
  415. {
  416. FAR struct nxsvrmsg_bitmap_s *bmpmsg = (FAR struct nxsvrmsg_bitmap_s *)buffer;
  417. nxbe_bitmap(bmpmsg->wnd, &bmpmsg->dest, bmpmsg->src, &bmpmsg->origin, bmpmsg->stride);
  418. if (bmpmsg->sem_done)
  419. {
  420. nxsem_post(bmpmsg->sem_done);
  421. }
  422. }
  423. break;
  424. case NX_SVRMSG_SETBGCOLOR: /* Set the color of the background */
  425. {
  426. FAR struct nxsvrmsg_setbgcolor_s *bgcolormsg =
  427. (FAR struct nxsvrmsg_setbgcolor_s *)buffer;
  428. /* Has the background color changed? */
  429. if (!nxgl_colorcmp(nxmu.be.bgcolor, bgcolormsg->color))
  430. {
  431. /* Yes.. fill the background */
  432. nxgl_colorcopy(nxmu.be.bgcolor, bgcolormsg->color);
  433. nxbe_fill(&nxmu.be.bkgd, &nxmu.be.bkgd.bounds, bgcolormsg->color);
  434. }
  435. }
  436. break;
  437. #ifdef CONFIG_NX_XYINPUT
  438. case NX_SVRMSG_MOUSEIN: /* New mouse report from mouse client */
  439. {
  440. FAR struct nxsvrmsg_mousein_s *mousemsg = (FAR struct nxsvrmsg_mousein_s *)buffer;
  441. nxmu_mousein(&nxmu, &mousemsg->pt, mousemsg->buttons);
  442. }
  443. break;
  444. #endif
  445. #ifdef CONFIG_NX_KBD
  446. case NX_SVRMSG_KBDIN: /* New keyboard report from keyboard client */
  447. {
  448. FAR struct nxsvrmsg_kbdin_s *kbdmsg = (FAR struct nxsvrmsg_kbdin_s *)buffer;
  449. nxmu_kbdin(&nxmu, kbdmsg->nch, kbdmsg->ch);
  450. }
  451. break;
  452. #endif
  453. case NX_SVRMSG_REDRAWREQ: /* Request re-drawing of rectangular region */
  454. {
  455. FAR struct nxsvrmsg_redrawreq_s *redrawmsg = (FAR struct nxsvrmsg_redrawreq_s *)buffer;
  456. nxmu_redraw(redrawmsg->wnd, &redrawmsg->rect);
  457. }
  458. break;
  459. /* Messages sent to the background window **************************/
  460. case NX_CLIMSG_REDRAW: /* Re-draw the background window */
  461. {
  462. FAR struct nxclimsg_redraw_s *redraw = (FAR struct nxclimsg_redraw_s *)buffer;
  463. DEBUGASSERT(redraw->wnd == &nxmu.be.bkgd);
  464. ginfo("Re-draw background rect={(%d,%d),(%d,%d)}\n",
  465. redraw->rect.pt1.x, redraw->rect.pt1.y,
  466. redraw->rect.pt2.x, redraw->rect.pt2.y);
  467. nxbe_fill(&nxmu.be.bkgd, &redraw->rect, nxmu.be.bgcolor);
  468. }
  469. break;
  470. case NX_CLIMSG_MOUSEIN: /* Ignored */
  471. case NX_CLIMSG_KBDIN:
  472. break;
  473. case NX_CLIMSG_CONNECTED: /* Shouldn't happen */
  474. case NX_CLIMSG_DISCONNECTED:
  475. default:
  476. gerr("ERROR: Unrecognized command: %d\n", msg->msgid);
  477. break;
  478. }
  479. }
  480. nxmu_shutdown(&nxmu);
  481. return OK;
  482. errout:
  483. nxmu_shutdown(&nxmu);
  484. return ret;
  485. }