2008-11-28 15:42:52 +01:00
|
|
|
/****************************************************************************
|
|
|
|
* graphics/nxmu/nxmu_server.c
|
|
|
|
*
|
2024-09-10 09:30:58 +02:00
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
*
|
2021-02-05 11:12:53 +01:00
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
* contributor license agreements. See the NOTICE file distributed with
|
|
|
|
* this work for additional information regarding copyright ownership. The
|
|
|
|
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
|
|
|
* "License"); you may not use this file except in compliance with the
|
|
|
|
* License. You may obtain a copy of the License at
|
2008-11-28 15:42:52 +01:00
|
|
|
*
|
2021-02-05 11:12:53 +01:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
2008-11-28 15:42:52 +01:00
|
|
|
*
|
2021-02-05 11:12:53 +01:00
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
|
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
|
|
* License for the specific language governing permissions and limitations
|
|
|
|
* under the License.
|
2008-11-28 15:42:52 +01:00
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Included Files
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#include <nuttx/config.h>
|
|
|
|
|
2020-11-20 12:35:12 +01:00
|
|
|
#include <inttypes.h>
|
2009-12-15 19:12:29 +01:00
|
|
|
#include <stdint.h>
|
2008-11-28 15:42:52 +01:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <mqueue.h>
|
|
|
|
#include <fcntl.h>
|
2018-01-31 00:23:10 +01:00
|
|
|
#include <assert.h>
|
2008-11-28 15:42:52 +01:00
|
|
|
#include <errno.h>
|
|
|
|
#include <debug.h>
|
|
|
|
|
2017-10-10 17:57:40 +02:00
|
|
|
#include <nuttx/mqueue.h>
|
2011-07-24 22:49:01 +02:00
|
|
|
#include <nuttx/nx/nx.h>
|
2017-10-10 17:57:40 +02:00
|
|
|
|
2019-03-13 16:16:30 +01:00
|
|
|
#include "nxmu.h"
|
2008-11-28 15:42:52 +01:00
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Private Functions
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Name: nxmu_disconnect
|
|
|
|
****************************************************************************/
|
|
|
|
|
2019-03-13 16:16:30 +01:00
|
|
|
static inline void nxmu_disconnect(FAR struct nxmu_conn_s *conn)
|
2008-11-28 15:42:52 +01:00
|
|
|
{
|
2008-11-29 21:26:18 +01:00
|
|
|
struct nxclimsg_disconnected_s outmsg;
|
|
|
|
int ret;
|
2008-11-28 15:42:52 +01:00
|
|
|
|
|
|
|
/* Send the handshake message back to the client */
|
|
|
|
|
|
|
|
outmsg.msgid = NX_CLIMSG_DISCONNECTED;
|
|
|
|
|
2020-11-20 12:33:38 +01:00
|
|
|
ret = nxmu_sendclient(conn, &outmsg,
|
|
|
|
sizeof(struct nxclimsg_disconnected_s));
|
2008-11-28 15:42:52 +01:00
|
|
|
if (ret < 0)
|
|
|
|
{
|
2019-03-17 18:34:45 +01:00
|
|
|
gerr("ERROR: nxmu_sendclient failed: %d\n", ret);
|
2008-11-28 15:42:52 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Close the outgoing client message queue */
|
|
|
|
|
2020-05-02 16:30:58 +02:00
|
|
|
nxmq_close(conn->swrmq);
|
2008-11-28 15:42:52 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Name: nxmu_connect
|
|
|
|
****************************************************************************/
|
|
|
|
|
2019-03-13 16:16:30 +01:00
|
|
|
static inline void nxmu_connect(FAR struct nxmu_conn_s *conn)
|
2008-11-28 15:42:52 +01:00
|
|
|
{
|
2008-11-29 21:26:18 +01:00
|
|
|
char mqname[NX_CLIENT_MXNAMELEN];
|
|
|
|
struct nxclimsg_connected_s outmsg;
|
|
|
|
int ret;
|
2008-11-28 15:42:52 +01:00
|
|
|
|
|
|
|
/* Create the client MQ name */
|
|
|
|
|
2023-03-05 15:34:33 +01:00
|
|
|
snprintf(mqname, sizeof(mqname), NX_CLIENT_MQNAMEFMT, conn->cid);
|
2008-11-28 15:42:52 +01:00
|
|
|
|
2020-11-20 12:33:38 +01:00
|
|
|
/* Open the client MQ -- this should have already been created by the
|
|
|
|
* client
|
|
|
|
*/
|
2008-11-28 15:42:52 +01:00
|
|
|
|
2021-02-15 04:34:04 +01:00
|
|
|
conn->swrmq = nxmq_open(mqname, O_WRONLY);
|
|
|
|
if (conn->swrmq < 0)
|
2008-11-28 15:42:52 +01:00
|
|
|
{
|
2021-02-15 04:34:04 +01:00
|
|
|
gerr("ERROR: nxmq_open(%s) failed: %d\n", mqname, conn->swrmq);
|
2008-11-28 15:42:52 +01:00
|
|
|
outmsg.msgid = NX_CLIMSG_DISCONNECTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Send the handshake message back to the client */
|
|
|
|
|
2008-11-29 21:26:18 +01:00
|
|
|
outmsg.msgid = NX_CLIMSG_CONNECTED;
|
2012-05-17 21:32:48 +02:00
|
|
|
ret = nxmu_sendclient(conn, &outmsg, sizeof(struct nxclimsg_connected_s));
|
2008-11-28 15:42:52 +01:00
|
|
|
if (ret < 0)
|
|
|
|
{
|
2019-03-17 18:34:45 +01:00
|
|
|
gerr("ERROR: nxmu_sendclient failed: %d\n", ret);
|
2008-11-28 15:42:52 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Name: nxmu_shutdown
|
|
|
|
****************************************************************************/
|
|
|
|
|
2019-04-05 16:24:46 +02:00
|
|
|
static inline void nxmu_shutdown(FAR struct nxmu_state_s *nxmu)
|
2008-11-28 15:42:52 +01:00
|
|
|
{
|
|
|
|
FAR struct nxbe_window_s *wnd;
|
|
|
|
|
|
|
|
/* Inform all of the clients in the window list that the server is
|
|
|
|
* exit-ting. Notes: (1) that the following loop will probably attempt to
|
|
|
|
* disconnect clients multiple times because one client may have multiple
|
|
|
|
* windows: The first disconnect will fail; subsequent will return errors
|
|
|
|
* that are ignored. (2) The final window to be disconnected will be the
|
|
|
|
* background window, thus close all of the servers message queues.
|
|
|
|
*/
|
|
|
|
|
2019-04-05 16:24:46 +02:00
|
|
|
for (wnd = nxmu->be.topwnd; wnd; wnd = wnd->below)
|
2008-11-28 15:42:52 +01:00
|
|
|
{
|
2020-01-02 17:49:34 +01:00
|
|
|
nxmu_disconnect(wnd->conn);
|
2008-11-28 15:42:52 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-05-18 00:16:02 +02:00
|
|
|
/****************************************************************************
|
2019-03-25 20:00:13 +01:00
|
|
|
* Name: nxmu_event
|
2012-05-18 00:16:02 +02:00
|
|
|
****************************************************************************/
|
|
|
|
|
2019-03-25 20:48:27 +01:00
|
|
|
static void nxmu_event(FAR struct nxbe_window_s *wnd, enum nx_event_e event,
|
|
|
|
FAR void *arg)
|
2012-05-18 00:16:02 +02:00
|
|
|
{
|
2019-03-25 20:00:13 +01:00
|
|
|
struct nxclimsg_event_s outmsg;
|
2012-05-18 00:16:02 +02:00
|
|
|
int ret;
|
|
|
|
|
2019-03-25 20:00:13 +01:00
|
|
|
outmsg.msgid = NX_CLIMSG_EVENT;
|
2012-05-18 00:16:02 +02:00
|
|
|
outmsg.wnd = wnd;
|
2012-05-19 03:01:00 +02:00
|
|
|
outmsg.arg = arg;
|
2019-03-25 20:00:13 +01:00
|
|
|
outmsg.event = event;
|
2012-05-18 00:16:02 +02:00
|
|
|
|
2019-03-17 18:34:45 +01:00
|
|
|
ret = nxmu_sendclient(wnd->conn, &outmsg,
|
2019-03-25 20:00:13 +01:00
|
|
|
sizeof(struct nxclimsg_event_s));
|
2012-05-18 00:16:02 +02:00
|
|
|
if (ret < 0)
|
|
|
|
{
|
2019-03-17 18:34:45 +01:00
|
|
|
gerr("ERROR: nxmu_sendclient failed: %d\n", ret);
|
2012-05-18 00:16:02 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-11-28 15:42:52 +01:00
|
|
|
/****************************************************************************
|
|
|
|
* Name: nxmu_setup
|
|
|
|
****************************************************************************/
|
|
|
|
|
2012-03-28 19:19:17 +02:00
|
|
|
static inline int nxmu_setup(FAR const char *mqname, FAR NX_DRIVERTYPE *dev,
|
2019-04-05 16:24:46 +02:00
|
|
|
FAR struct nxmu_state_s *nxmu)
|
2008-11-28 15:42:52 +01:00
|
|
|
{
|
|
|
|
struct mq_attr attr;
|
|
|
|
int ret;
|
|
|
|
|
2019-04-05 16:24:46 +02:00
|
|
|
memset(nxmu, 0, sizeof(struct nxmu_state_s));
|
2008-11-28 15:42:52 +01:00
|
|
|
|
2010-04-17 05:08:30 +02:00
|
|
|
/* Configure the framebuffer/LCD device */
|
2008-11-28 15:42:52 +01:00
|
|
|
|
2019-04-05 16:24:46 +02:00
|
|
|
ret = nxbe_configure(dev, &nxmu->be);
|
2008-11-28 15:42:52 +01:00
|
|
|
if (ret < 0)
|
|
|
|
{
|
2019-03-17 18:34:45 +01:00
|
|
|
gerr("ERROR: nxbe_configure failed: %d\n", ret);
|
|
|
|
return ret;
|
2008-11-28 15:42:52 +01:00
|
|
|
}
|
|
|
|
|
2015-09-01 15:04:09 +02:00
|
|
|
#ifdef CONFIG_FB_CMAP
|
2010-04-17 05:08:30 +02:00
|
|
|
ret = nxbe_colormap(dev);
|
2008-11-28 15:42:52 +01:00
|
|
|
if (ret < 0)
|
|
|
|
{
|
2019-03-17 18:34:45 +01:00
|
|
|
gerr("ERROR: nxbe_colormap failed: %d\n", ret);
|
|
|
|
return ret;
|
2008-11-28 15:42:52 +01:00
|
|
|
}
|
2010-04-17 05:08:30 +02:00
|
|
|
#endif /* CONFIG_FB_CMAP */
|
2008-11-28 15:42:52 +01:00
|
|
|
|
|
|
|
/* Initialize the non-NULL elements of the server connection structure.
|
2020-02-23 09:50:23 +01:00
|
|
|
* Oddly, this structure represents the connection between the server and
|
2008-11-28 15:42:52 +01:00
|
|
|
* itself.
|
|
|
|
*
|
|
|
|
* Open the incoming server MQ. The server receives messages on the
|
|
|
|
* background window's incoming message queue.
|
|
|
|
*/
|
|
|
|
|
|
|
|
attr.mq_maxmsg = CONFIG_NX_MXSERVERMSGS;
|
|
|
|
attr.mq_msgsize = NX_MXSVRMSGLEN;
|
|
|
|
attr.mq_flags = 0;
|
|
|
|
|
2021-02-15 04:34:04 +01:00
|
|
|
nxmu->conn.crdmq = nxmq_open(mqname, O_RDONLY | O_CREAT, 0666, &attr);
|
|
|
|
if (nxmu->conn.crdmq < 0)
|
2008-11-28 15:42:52 +01:00
|
|
|
{
|
2021-02-15 04:34:04 +01:00
|
|
|
gerr("ERROR: nxmq_open(%s) failed: %d\n", mqname, nxmu->conn.crdmq);
|
|
|
|
return nxmu->conn.crdmq;
|
2008-11-28 15:42:52 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* NOTE that the outgoing client MQ (cwrmq) is not initialized. The
|
|
|
|
* background window never initiates messages.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* Open the outgoing server MQ. This is used to send messages to the
|
|
|
|
* background window which will, of course, be received and handled by
|
|
|
|
* the server message loop.
|
|
|
|
*/
|
|
|
|
|
2021-02-15 04:34:04 +01:00
|
|
|
nxmu->conn.swrmq = nxmq_open(mqname, O_WRONLY);
|
|
|
|
if (nxmu->conn.swrmq < 0)
|
2008-11-28 15:42:52 +01:00
|
|
|
{
|
2021-02-15 04:34:04 +01:00
|
|
|
gerr("ERROR: nxmq_open(%s) failed: %d\n", mqname, nxmu->conn.swrmq);
|
2021-02-15 17:45:31 +01:00
|
|
|
nxmq_close(nxmu->conn.crdmq);
|
2021-02-15 04:34:04 +01:00
|
|
|
return nxmu->conn.swrmq;
|
2008-11-28 15:42:52 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* The server is now "connected" to itself via the background window */
|
|
|
|
|
2019-04-05 16:24:46 +02:00
|
|
|
nxmu->conn.state = NX_CLISTATE_CONNECTED;
|
2008-11-28 15:42:52 +01:00
|
|
|
|
|
|
|
/* Initialize the non-NULL elements of the background window */
|
|
|
|
|
2019-04-05 16:24:46 +02:00
|
|
|
nxmu->be.bkgd.conn = &nxmu->conn;
|
|
|
|
nxmu->be.bkgd.be = (FAR struct nxbe_state_s *)nxmu;
|
2008-11-28 15:42:52 +01:00
|
|
|
|
2019-04-05 16:24:46 +02:00
|
|
|
nxmu->be.bkgd.bounds.pt2.x = nxmu->be.vinfo.xres - 1;
|
|
|
|
nxmu->be.bkgd.bounds.pt2.y = nxmu->be.vinfo.yres - 1;
|
2008-11-28 15:42:52 +01:00
|
|
|
|
|
|
|
/* Complete initialization of the server state structure. The
|
|
|
|
* window list contains only one element: The background window
|
|
|
|
* with nothing else above or below it
|
|
|
|
*/
|
|
|
|
|
2019-04-05 16:24:46 +02:00
|
|
|
nxmu->be.topwnd = &nxmu->be.bkgd;
|
2008-11-28 15:42:52 +01:00
|
|
|
|
|
|
|
/* Initialize the mouse position */
|
|
|
|
|
2014-07-17 00:31:31 +02:00
|
|
|
#ifdef CONFIG_NX_XYINPUT
|
2019-04-05 16:24:46 +02:00
|
|
|
nxmu_mouseinit(nxmu->be.vinfo.xres, nxmu->be.vinfo.yres);
|
2008-11-28 15:42:52 +01:00
|
|
|
#endif
|
|
|
|
return OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Public Functions
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Name: nx_runinstance
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* This is the server entry point. It does not return; the calling thread
|
|
|
|
* is dedicated to supporting NX server.
|
|
|
|
*
|
|
|
|
* NOTE that multiple instances of the NX server may run at the same time,
|
|
|
|
* each with different callback and message queue names.
|
|
|
|
*
|
|
|
|
* Input Parameters:
|
|
|
|
* mqname - The name for the server incoming message queue
|
2010-04-17 05:08:30 +02:00
|
|
|
* dev - Vtable "object" of the framebuffer/LCD "driver" to use
|
2008-11-28 15:42:52 +01:00
|
|
|
*
|
2018-02-01 17:00:02 +01:00
|
|
|
* Returned Value:
|
2008-11-28 15:42:52 +01:00
|
|
|
* This function usually does not return. If it does return, it will
|
2019-03-17 18:34:45 +01:00
|
|
|
* return a negated errno value indicating the cause of the failure.
|
2008-11-28 15:42:52 +01:00
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
2010-04-17 05:08:30 +02:00
|
|
|
int nx_runinstance(FAR const char *mqname, FAR NX_DRIVERTYPE *dev)
|
2008-11-28 15:42:52 +01:00
|
|
|
{
|
2019-04-05 16:24:46 +02:00
|
|
|
struct nxmu_state_s nxmu;
|
2008-11-28 15:42:52 +01:00
|
|
|
FAR struct nxsvrmsg_s *msg;
|
2015-05-13 16:56:03 +02:00
|
|
|
char buffer[NX_MXSVRMSGLEN];
|
2008-11-28 15:42:52 +01:00
|
|
|
int nbytes;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
/* Initialization *********************************************************/
|
|
|
|
|
2018-01-31 00:23:10 +01:00
|
|
|
DEBUGASSERT(mqname != NULL || dev != NULL);
|
2008-11-28 15:42:52 +01:00
|
|
|
|
|
|
|
/* Initialize and configure the server */
|
|
|
|
|
2019-04-05 16:24:46 +02:00
|
|
|
ret = nxmu_setup(mqname, dev, &nxmu);
|
2008-11-28 15:42:52 +01:00
|
|
|
if (ret < 0)
|
|
|
|
{
|
2019-03-17 18:34:45 +01:00
|
|
|
return ret;
|
2008-11-28 15:42:52 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Produce the initial, background display */
|
|
|
|
|
2019-04-05 16:24:46 +02:00
|
|
|
nxbe_redraw(&nxmu.be, &nxmu.be.bkgd, &nxmu.be.bkgd.bounds);
|
2008-11-28 15:42:52 +01:00
|
|
|
|
|
|
|
/* Message Loop ***********************************************************/
|
|
|
|
|
|
|
|
/* Then loop forever processing incoming messages */
|
|
|
|
|
2015-10-08 17:10:22 +02:00
|
|
|
for (; ; )
|
2008-11-28 15:42:52 +01:00
|
|
|
{
|
2020-11-20 12:33:38 +01:00
|
|
|
/* Receive the next server message */
|
|
|
|
|
|
|
|
nbytes = nxmq_receive(nxmu.conn.crdmq, buffer, NX_MXSVRMSGLEN, 0);
|
|
|
|
if (nbytes < 0)
|
|
|
|
{
|
|
|
|
if (nbytes != -EINTR)
|
|
|
|
{
|
|
|
|
gerr("ERROR: nxmq_receive() failed: %d\n", nbytes);
|
|
|
|
ret = nbytes;
|
|
|
|
goto errout;
|
|
|
|
}
|
|
|
|
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Dispatch the message appropriately */
|
|
|
|
|
|
|
|
DEBUGASSERT(nbytes >= sizeof(struct nxsvrmsg_releasebkgd_s));
|
|
|
|
msg = (FAR struct nxsvrmsg_s *)buffer;
|
|
|
|
|
2020-11-20 12:35:12 +01:00
|
|
|
ginfo("Received opcode=%" PRId32 " nbytes=%d\n", msg->msgid, nbytes);
|
2020-11-20 12:33:38 +01:00
|
|
|
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(&nxmu.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 messages to a window */
|
|
|
|
{
|
|
|
|
FAR struct nxsvrmsg_blocked_s *blocked =
|
|
|
|
(FAR struct nxsvrmsg_blocked_s *)buffer;
|
|
|
|
nxmu_event(blocked->wnd, NXEVENT_BLOCKED, blocked->arg);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NX_SVRMSG_SYNCH: /* Synchronization request */
|
|
|
|
{
|
|
|
|
FAR struct nxsvrmsg_synch_s *synch =
|
|
|
|
(FAR struct nxsvrmsg_synch_s *)buffer;
|
|
|
|
nxmu_event(synch->wnd, NXEVENT_SYNCHED, synch->arg);
|
|
|
|
}
|
|
|
|
break;
|
2019-03-25 20:48:27 +01:00
|
|
|
|
2019-04-06 22:34:56 +02:00
|
|
|
#if defined(CONFIG_NX_SWCURSOR) || defined(CONFIG_NX_HWCURSOR)
|
2020-11-20 12:33:38 +01:00
|
|
|
case NX_SVRMSG_CURSOR_ENABLE: /* Enable/disable cursor */
|
|
|
|
{
|
|
|
|
FAR struct nxsvrmsg_curenable_s *enabmsg =
|
|
|
|
(FAR struct nxsvrmsg_curenable_s *)buffer;
|
|
|
|
nxbe_cursor_enable(&nxmu.be, enabmsg->enable);
|
|
|
|
}
|
|
|
|
break;
|
2019-04-06 22:34:56 +02:00
|
|
|
|
|
|
|
#if defined(CONFIG_NX_HWCURSORIMAGE) || defined(CONFIG_NX_SWCURSOR)
|
2020-11-20 12:33:38 +01:00
|
|
|
case NX_SVRMSG_CURSOR_IMAGE: /* Set cursor image */
|
|
|
|
{
|
|
|
|
FAR struct nxsvrmsg_curimage_s *imgmsg =
|
|
|
|
(FAR struct nxsvrmsg_curimage_s *)buffer;
|
|
|
|
nxbe_cursor_setimage(&nxmu.be, &imgmsg->image);
|
|
|
|
}
|
|
|
|
break;
|
2019-04-06 22:34:56 +02:00
|
|
|
#endif
|
2020-11-20 12:33:38 +01:00
|
|
|
case NX_SVRMSG_CURSOR_SETPOS: /* Set cursor position */
|
|
|
|
{
|
|
|
|
FAR struct nxsvrmsg_curpos_s *posmsg =
|
|
|
|
(FAR struct nxsvrmsg_curpos_s *)buffer;
|
|
|
|
nxbe_cursor_setposition(&nxmu.be, &posmsg->pos);
|
|
|
|
}
|
|
|
|
break;
|
2019-04-06 22:34:56 +02:00
|
|
|
#endif
|
|
|
|
|
2020-11-20 12:33:38 +01:00
|
|
|
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, &nxmu.be, rqbgmsg->cb,
|
|
|
|
rqbgmsg->arg);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NX_SVRMSG_RELEASEBKGD: /* End access to the background window */
|
|
|
|
{
|
|
|
|
nxmu_releasebkgd(&nxmu);
|
|
|
|
}
|
|
|
|
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;
|
|
|
|
nxmu_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_MODAL: /* Select/De-select window modal state */
|
|
|
|
{
|
|
|
|
FAR struct nxsvrmsg_modal_s *modalmsg =
|
|
|
|
(FAR struct nxsvrmsg_modal_s *)buffer;
|
|
|
|
nxbe_modal(modalmsg->wnd, modalmsg->modal);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NX_SVRMSG_SETVISIBILITY: /* Show or hide a window */
|
|
|
|
{
|
|
|
|
FAR struct nxsvrmsg_setvisibility_s *vismsg =
|
2019-05-05 23:18:31 +02:00
|
|
|
(FAR struct nxsvrmsg_setvisibility_s *)buffer;
|
2020-11-20 12:33:38 +01:00
|
|
|
nxbe_setvisibility(vismsg->wnd, vismsg->hide);
|
|
|
|
}
|
|
|
|
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)
|
|
|
|
{
|
|
|
|
nxsem_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)
|
|
|
|
{
|
|
|
|
nxsem_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(nxmu.be.bgcolor, bgcolormsg->color))
|
|
|
|
{
|
|
|
|
/* Yes.. fill the background */
|
|
|
|
|
|
|
|
nxgl_colorcopy(nxmu.be.bgcolor, bgcolormsg->color);
|
|
|
|
nxbe_fill(&nxmu.be.bkgd, &nxmu.be.bkgd.bounds,
|
|
|
|
bgcolormsg->color);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2008-11-28 15:42:52 +01:00
|
|
|
|
2014-07-17 00:31:31 +02:00
|
|
|
#ifdef CONFIG_NX_XYINPUT
|
2020-11-20 12:33:38 +01:00
|
|
|
case NX_SVRMSG_MOUSEIN: /* New mouse report from mouse client */
|
|
|
|
{
|
|
|
|
FAR struct nxsvrmsg_mousein_s *mousemsg =
|
|
|
|
(FAR struct nxsvrmsg_mousein_s *)buffer;
|
|
|
|
nxmu_mousein(&nxmu, &mousemsg->pt, mousemsg->buttons);
|
|
|
|
}
|
|
|
|
break;
|
2008-11-28 15:42:52 +01:00
|
|
|
#endif
|
|
|
|
#ifdef CONFIG_NX_KBD
|
2020-11-20 12:33:38 +01:00
|
|
|
case NX_SVRMSG_KBDIN: /* New keyboard report from keyboard client */
|
|
|
|
{
|
|
|
|
FAR struct nxsvrmsg_kbdin_s *kbdmsg =
|
|
|
|
(FAR struct nxsvrmsg_kbdin_s *)buffer;
|
|
|
|
nxmu_kbdin(&nxmu, kbdmsg->nch, kbdmsg->ch);
|
|
|
|
}
|
|
|
|
break;
|
2008-11-28 15:42:52 +01:00
|
|
|
#endif
|
|
|
|
|
2020-11-20 12:33:38 +01:00
|
|
|
case NX_SVRMSG_REDRAWREQ: /* Request re-drawing of rectangular region */
|
|
|
|
{
|
|
|
|
FAR struct nxsvrmsg_redrawreq_s *redrawmsg =
|
|
|
|
(FAR struct nxsvrmsg_redrawreq_s *)buffer;
|
|
|
|
nxmu_redraw(redrawmsg->wnd, &redrawmsg->rect);
|
|
|
|
}
|
|
|
|
break;
|
2013-12-28 18:33:21 +01:00
|
|
|
|
2020-11-20 12:33:38 +01:00
|
|
|
/* Messages sent to the background window *************************/
|
2008-11-28 15:42:52 +01:00
|
|
|
|
2020-11-20 12:33:38 +01:00
|
|
|
case NX_CLIMSG_REDRAW: /* Re-draw the background window */
|
2008-11-29 00:04:54 +01:00
|
|
|
{
|
2020-11-20 12:33:38 +01:00
|
|
|
FAR struct nxclimsg_redraw_s *redraw =
|
|
|
|
(FAR struct nxclimsg_redraw_s *)buffer;
|
2019-04-05 16:24:46 +02:00
|
|
|
DEBUGASSERT(redraw->wnd == &nxmu.be.bkgd);
|
2016-06-11 19:59:51 +02:00
|
|
|
ginfo("Re-draw background rect={(%d,%d),(%d,%d)}\n",
|
2008-11-29 00:04:54 +01:00
|
|
|
redraw->rect.pt1.x, redraw->rect.pt1.y,
|
|
|
|
redraw->rect.pt2.x, redraw->rect.pt2.y);
|
2019-04-05 16:24:46 +02:00
|
|
|
nxbe_fill(&nxmu.be.bkgd, &redraw->rect, nxmu.be.bgcolor);
|
2008-11-29 00:04:54 +01:00
|
|
|
}
|
2020-11-20 12:33:38 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case NX_CLIMSG_MOUSEIN: /* Ignored */
|
|
|
|
case NX_CLIMSG_KBDIN:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NX_CLIMSG_CONNECTED: /* Shouldn't happen */
|
|
|
|
case NX_CLIMSG_DISCONNECTED:
|
|
|
|
default:
|
2020-11-20 12:35:12 +01:00
|
|
|
gerr("ERROR: Unrecognized command: %" PRId32 "\n", msg->msgid);
|
2020-11-20 12:33:38 +01:00
|
|
|
break;
|
|
|
|
}
|
2008-11-28 15:42:52 +01:00
|
|
|
}
|
|
|
|
|
2019-04-05 16:24:46 +02:00
|
|
|
nxmu_shutdown(&nxmu);
|
2008-11-28 15:42:52 +01:00
|
|
|
return OK;
|
2017-10-10 17:57:40 +02:00
|
|
|
|
|
|
|
errout:
|
2019-04-05 16:24:46 +02:00
|
|
|
nxmu_shutdown(&nxmu);
|
2019-03-17 18:34:45 +01:00
|
|
|
return ret;
|
2008-11-28 15:42:52 +01:00
|
|
|
}
|