Squashed commit of the following:
libs/libnx/nxme: Add front-end, client, message handling needed for cursor support. Still actual cursor logic yet, just message handling.
graphics/nxmu and graphics/nxbe: Add back-end message handling needed for cursor support. No actual cursor logic yet, just message handling.
This commit is contained in:
parent
04b723e447
commit
42e2c9139c
11 changed files with 498 additions and 35 deletions
|
|
@ -44,6 +44,12 @@ ifeq ($(CONFIG_NX_RAMBACKED),y)
|
||||||
CSRCS += nxbe_flush.c
|
CSRCS += nxbe_flush.c
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
ifeq ($(CONFIG_NX_HWCURSOR),y)
|
||||||
|
CSRCS += nxbe_cursor.c
|
||||||
|
else ifeq ($(CONFIG_NX_SWCURSOR),y)
|
||||||
|
CSRCS += nxbe_cursor.c
|
||||||
|
endif
|
||||||
|
|
||||||
DEPPATH += --dep-path nxbe
|
DEPPATH += --dep-path nxbe
|
||||||
CFLAGS += ${shell $(INCDIR) $(INCDIROPT) "$(CC)" $(TOPDIR)/graphics/nxbe}
|
CFLAGS += ${shell $(INCDIR) $(INCDIROPT) "$(CC)" $(TOPDIR)/graphics/nxbe}
|
||||||
VPATH += :nxbe
|
VPATH += :nxbe
|
||||||
|
|
|
||||||
|
|
@ -188,12 +188,25 @@ struct nxbe_clipops_s
|
||||||
|
|
||||||
struct nxbe_state_s
|
struct nxbe_state_s
|
||||||
{
|
{
|
||||||
uint8_t flags; /* NXBE_STATE_* flags */
|
uint8_t flags; /* NXBE_STATE_* flags */
|
||||||
|
|
||||||
|
#if defined(CONFIG_NX_SWCURSOR) || defined(CONFIG_NX_HWCURSOR)
|
||||||
|
/* Cursor support */
|
||||||
|
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
bool visible; /* True: the cursor is visible */
|
||||||
|
struct cursor_pos_s pos; /* The current cursor position */
|
||||||
|
#ifdef CONFIG_NX_SWCURSOR
|
||||||
|
FAR struct cursor_image_s image; /* Cursor image */
|
||||||
|
#endif
|
||||||
|
} cursor;
|
||||||
|
#endif
|
||||||
|
|
||||||
/* The window list (with the background window always at the bottom) */
|
/* The window list (with the background window always at the bottom) */
|
||||||
|
|
||||||
FAR struct nxbe_window_s *topwnd; /* The window at the top of the display */
|
FAR struct nxbe_window_s *topwnd; /* The window at the top of the display */
|
||||||
struct nxbe_window_s bkgd; /* The background window is always at the bottom */
|
struct nxbe_window_s bkgd; /* The background window is always at the bottom */
|
||||||
|
|
||||||
/* At present, only a solid colored background is supported for refills. The
|
/* At present, only a solid colored background is supported for refills. The
|
||||||
* following provides the background color. It would be nice to support
|
* following provides the background color. It would be nice to support
|
||||||
|
|
@ -254,6 +267,65 @@ int nxbe_colormap(FAR NX_DRIVERTYPE *dev);
|
||||||
|
|
||||||
int nxbe_configure(FAR NX_DRIVERTYPE *dev, FAR struct nxbe_state_s *be);
|
int nxbe_configure(FAR NX_DRIVERTYPE *dev, FAR struct nxbe_state_s *be);
|
||||||
|
|
||||||
|
#if defined(CONFIG_NX_SWCURSOR) || defined(CONFIG_NX_HWCURSOR)
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: nxbe_cursor_enable
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Enable/disable presentation of the cursor
|
||||||
|
*
|
||||||
|
* Input Parameters:
|
||||||
|
* be - The back-end state structure instance
|
||||||
|
* enable - True: show the cursor, false: hide the cursor.
|
||||||
|
*
|
||||||
|
* Returned Value:
|
||||||
|
* None
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
void nxbe_cursor_enable(FAR struct nxbe_state_s *be, bool enable);
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: nxbe_cursor_setimage
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Set the cursor image
|
||||||
|
*
|
||||||
|
* Input Parameters:
|
||||||
|
* be - The back-end state structure instance
|
||||||
|
* image - Describes the cursor image in the expected format. For a
|
||||||
|
* software cursor, this is the format used with the display. The
|
||||||
|
* format may be different if a hardware cursor is used.
|
||||||
|
*
|
||||||
|
* Returned Value:
|
||||||
|
* None
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#if defined(CONFIG_NX_HWCURSORIMAGE) || defined(CONFIG_NX_SWCURSOR)
|
||||||
|
void nxbe_cursor_setimage(FAR struct nxbe_state_s *be,
|
||||||
|
FAR struct cursor_image_s *image);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: nxcursor_setposition
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Move the cursor to the specified position
|
||||||
|
*
|
||||||
|
* Input Parameters:
|
||||||
|
* be - The back-end state structure instance
|
||||||
|
* pos - The new cursor position
|
||||||
|
*
|
||||||
|
* Returned Value:
|
||||||
|
* None
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
void nxcursor_setposition(FAR struct nxbe_state_s *be,
|
||||||
|
FAR const struct cursor_pos_s *pos);
|
||||||
|
#endif /* CONFIG_NX_SWCURSOR || CONFIG_NX_HWCURSOR */
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: nxbe_closewindow
|
* Name: nxbe_closewindow
|
||||||
*
|
*
|
||||||
|
|
|
||||||
117
graphics/nxbe/nxbe_cursor.c
Normal file
117
graphics/nxbe/nxbe_cursor.c
Normal file
|
|
@ -0,0 +1,117 @@
|
||||||
|
/****************************************************************************
|
||||||
|
* graphics/nxbe/nxbe_cursor.c
|
||||||
|
*
|
||||||
|
* Copyright (C) 2019 Gregory Nutt. All rights reserved.
|
||||||
|
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
*
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in
|
||||||
|
* the documentation and/or other materials provided with the
|
||||||
|
* distribution.
|
||||||
|
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||||
|
* used to endorse or promote products derived from this software
|
||||||
|
* without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||||
|
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||||
|
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||||
|
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||||
|
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||||
|
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||||
|
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Included Files
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include <nuttx/config.h>
|
||||||
|
|
||||||
|
#include <assert.h>
|
||||||
|
|
||||||
|
#include "nxbe.h"
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Public Functions
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#if defined(CONFIG_NX_SWCURSOR) || defined(CONFIG_NX_HWCURSOR)
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: nxbe_cursor_enable
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Enable/disable presentation of the cursor
|
||||||
|
*
|
||||||
|
* Input Parameters:
|
||||||
|
* be - The back-end state structure instance
|
||||||
|
* enable - True: show the cursor, false: hide the cursor.
|
||||||
|
*
|
||||||
|
* Returned Value:
|
||||||
|
* None
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
void nxbe_cursor_enable(FAR struct nxbe_state_s *be, bool enable)
|
||||||
|
{
|
||||||
|
#warning Missing logic
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: nxbe_cursor_setimage
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Set the cursor image
|
||||||
|
*
|
||||||
|
* Input Parameters:
|
||||||
|
* be - The back-end state structure instance
|
||||||
|
* image - Describes the cursor image in the expected format. For a
|
||||||
|
* software cursor, this is the format used with the display. The
|
||||||
|
* format may be different if a hardware cursor is used.
|
||||||
|
*
|
||||||
|
* Returned Value:
|
||||||
|
* None
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#if defined(CONFIG_NX_HWCURSORIMAGE) || defined(CONFIG_NX_SWCURSOR)
|
||||||
|
void nxbe_cursor_setimage(FAR struct nxbe_state_s *be,
|
||||||
|
FAR struct cursor_image_s *image);
|
||||||
|
{
|
||||||
|
#warning Missing logic
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: nxcursor_setposition
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Move the cursor to the specified position
|
||||||
|
*
|
||||||
|
* Input Parameters:
|
||||||
|
* be - The back-end state structure instance
|
||||||
|
* pos - The new cursor position
|
||||||
|
*
|
||||||
|
* Returned Value:
|
||||||
|
* None
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
void nxcursor_setposition(FAR struct nxbe_state_s *be,
|
||||||
|
FAR const struct cursor_pos_s *pos)
|
||||||
|
{
|
||||||
|
#warning Missing logic
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* CONFIG_NX_SWCURSOR || CONFIG_NX_HWCURSOR */
|
||||||
|
|
@ -376,6 +376,30 @@ int nx_runinstance(FAR const char *mqname, FAR NX_DRIVERTYPE *dev)
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
#if defined(CONFIG_NX_SWCURSOR) || defined(CONFIG_NX_HWCURSOR)
|
||||||
|
case NX_SVRMSG_CURSOR_ENABLE: /* Enable/disable cursor */
|
||||||
|
{
|
||||||
|
FAR struct nxsvrmsg_curenable_s *enabmsg = (FAR struct nxsvrmsg_curenable_s *)buffer;
|
||||||
|
nxbe_cursor_enable(&nxwm.be, enabmsg->enable);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
#if defined(CONFIG_NX_HWCURSORIMAGE) || defined(CONFIG_NX_SWCURSOR)
|
||||||
|
case NX_SVRMSG_CURSOR_IMAGE: /* Set cursor image */
|
||||||
|
{
|
||||||
|
FAR struct nxsvrmsg_curimage_s *imgmsg = (FAR struct nxsvrmsg_curimage_s *)buffer;
|
||||||
|
nxbe_cursor_setimage(&nxwm.be, imgmsg->image);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
|
case NX_SVRMSG_CURSOR_SETPOS: /* Set cursor position */
|
||||||
|
{
|
||||||
|
FAR struct nxsvrmsg_curpos_s *posmsg = (FAR struct nxsvrmsg_curpos_s *)buffer;
|
||||||
|
nxbe_cursor_setposition(&nxwm.be, &posmsg->pos);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
|
|
||||||
case NX_SVRMSG_REQUESTBKGD: /* Give access to the background window */
|
case NX_SVRMSG_REQUESTBKGD: /* Give access to the background window */
|
||||||
{
|
{
|
||||||
FAR struct nxsvrmsg_requestbkgd_s *rqbgmsg = (FAR struct nxsvrmsg_requestbkgd_s *)buffer;
|
FAR struct nxsvrmsg_requestbkgd_s *rqbgmsg = (FAR struct nxsvrmsg_requestbkgd_s *)buffer;
|
||||||
|
|
|
||||||
|
|
@ -50,18 +50,6 @@
|
||||||
|
|
||||||
#ifndef defined(CONFIG_NX_SWCURSOR) || defined(CONFIG_NX_HWCURSOR)
|
#ifndef defined(CONFIG_NX_SWCURSOR) || defined(CONFIG_NX_HWCURSOR)
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Pre-processor Definitions
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Public Types
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Public Data
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
#undef EXTERN
|
#undef EXTERN
|
||||||
#if defined(__cplusplus)
|
#if defined(__cplusplus)
|
||||||
#define EXTERN extern "C"
|
#define EXTERN extern "C"
|
||||||
|
|
@ -86,17 +74,21 @@ extern "C"
|
||||||
* enable - True: show the cursor, false: hide the cursor.
|
* enable - True: show the cursor, false: hide the cursor.
|
||||||
*
|
*
|
||||||
* Returned Value:
|
* Returned Value:
|
||||||
* None
|
* OK on success; ERROR on failure with errno set appropriately
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
void nxcursor_enable(NXHANDLE hnd, bool enable);
|
int nxcursor_enable(NXHANDLE hnd, bool enable);
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: nxcursor_set_image
|
* Name: nxcursor_setimage
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* Set the cursor image
|
* Set the cursor image.
|
||||||
|
*
|
||||||
|
* NOTE: The NX logic will reference the user image buffer repeatedly.
|
||||||
|
* That image buffer must persist for as long as the NX server connection
|
||||||
|
* persists.
|
||||||
*
|
*
|
||||||
* Input Parameters:
|
* Input Parameters:
|
||||||
* hnd - The server handle returned by nx_connect()
|
* hnd - The server handle returned by nx_connect()
|
||||||
|
|
@ -105,30 +97,30 @@ void nxcursor_enable(NXHANDLE hnd, bool enable);
|
||||||
* format may be different if a hardware cursor is used.
|
* format may be different if a hardware cursor is used.
|
||||||
*
|
*
|
||||||
* Returned Value:
|
* Returned Value:
|
||||||
* None
|
* OK on success; ERROR on failure with errno set appropriately
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#if defined(CONFIG_NX_HWCURSORIMAGE) || defined(CONFIG_NX_SWCURSOR)
|
#if defined(CONFIG_NX_HWCURSORIMAGE) || defined(CONFIG_NX_SWCURSOR)
|
||||||
void nxcursor_set_image(NXHANDLE hnd, FAR struct cursor_image_s *image);
|
int nxcursor_setimage(NXHANDLE hnd, FAR struct cursor_image_s *image);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: nxcursor_set_position
|
* Name: nxcursor_setposition
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* Move the cursor to the specified position
|
* Move the cursor to the specified position
|
||||||
*
|
*
|
||||||
* Input Parameters:
|
* Input Parameters:
|
||||||
* hnd - The server handle returned by nx_connect()
|
* hnd - The server handle returned by nx_connect()
|
||||||
* pos -
|
* pos - The new cursor position
|
||||||
*
|
*
|
||||||
* Returned Value:
|
* Returned Value:
|
||||||
* None
|
* OK on success; ERROR on failure with errno set appropriately
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
void nxcursor_set_position(NXHANDLE hnd, FAR const struct cursor_pos_s *pos);
|
int nxcursor_setposition(NXHANDLE hnd, FAR const struct cursor_pos_s *pos);
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: nxcursor_get_position
|
* Name: nxcursor_get_position
|
||||||
|
|
@ -146,11 +138,11 @@ void nxcursor_set_position(NXHANDLE hnd, FAR const struct cursor_pos_s *pos);
|
||||||
* pos - The location to return the cursor position
|
* pos - The location to return the cursor position
|
||||||
*
|
*
|
||||||
* Returned Value:
|
* Returned Value:
|
||||||
* None
|
* OK on success; ERROR on failure with errno set appropriately
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
void nxcursor_get_position(NXHANDLE hnd, FAR struct cursor_pos_s *pos);
|
int nxcursor_get_position(NXHANDLE hnd, FAR struct cursor_pos_s *pos);
|
||||||
|
|
||||||
#undef EXTERN
|
#undef EXTERN
|
||||||
#if defined(__cplusplus)
|
#if defined(__cplusplus)
|
||||||
|
|
|
||||||
|
|
@ -140,6 +140,9 @@ enum nxmsg_e
|
||||||
NX_SVRMSG_CLOSEWINDOW, /* Close an existing window */
|
NX_SVRMSG_CLOSEWINDOW, /* Close an existing window */
|
||||||
NX_SVRMSG_BLOCKED, /* The window is blocked */
|
NX_SVRMSG_BLOCKED, /* The window is blocked */
|
||||||
NX_SVRMSG_SYNCH, /* Window syncrhonization request */
|
NX_SVRMSG_SYNCH, /* Window syncrhonization request */
|
||||||
|
NX_SVRMSG_CURSOR_ENABLE, /* Enable/disablel cursor presentation */
|
||||||
|
NX_SVRMSG_CURSOR_IMAGE, /* Set cursor image */
|
||||||
|
NX_SVRMSG_CURSOR_SETPOS, /* Set cursor position */
|
||||||
NX_SVRMSG_REQUESTBKGD, /* Open the background window */
|
NX_SVRMSG_REQUESTBKGD, /* Open the background window */
|
||||||
NX_SVRMSG_RELEASEBKGD, /* Release the background window */
|
NX_SVRMSG_RELEASEBKGD, /* Release the background window */
|
||||||
NX_SVRMSG_SETPOSITION, /* Window position has changed */
|
NX_SVRMSG_SETPOSITION, /* Window position has changed */
|
||||||
|
|
@ -295,6 +298,34 @@ struct nxsvrmsg_synch_s
|
||||||
FAR void *arg; /* User argument */
|
FAR void *arg; /* User argument */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#if defined(CONFIG_NX_SWCURSOR) || defined(CONFIG_NX_HWCURSOR)
|
||||||
|
/* Enable/disable cursor */
|
||||||
|
|
||||||
|
struct nxsvrmsg_curenable_s
|
||||||
|
{
|
||||||
|
uint32_t msgid; /* NX_SVRMSG_CURSOR_ENABLE */
|
||||||
|
bool enable; /* True: show the cursor, false: hide the cursor */
|
||||||
|
};
|
||||||
|
|
||||||
|
#if defined(CONFIG_NX_HWCURSORIMAGE) || defined(CONFIG_NX_SWCURSOR)
|
||||||
|
/* Set cursor image. */
|
||||||
|
|
||||||
|
struct nxsvrmsg_curimage_s
|
||||||
|
{
|
||||||
|
uint32_t msgid; /* NX_SVRMSG_CURSOR_IMAGE */
|
||||||
|
FAR struct cursor_image_s image /* True: show the cursor, false: hide the cursor */
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Set cursor position. */
|
||||||
|
|
||||||
|
struct nxsvrmsg_curpos_s
|
||||||
|
{
|
||||||
|
uint32_t msgid; /* NX_SVRMSG_CURSOR_SETPOS */
|
||||||
|
FAR struct cursor_pos_s pos; /* The new cursor position */
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
/* This message requests the server to create a new window */
|
/* This message requests the server to create a new window */
|
||||||
|
|
||||||
struct nxsvrmsg_requestbkgd_s
|
struct nxsvrmsg_requestbkgd_s
|
||||||
|
|
|
||||||
|
|
@ -34,8 +34,8 @@
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifndef __INCLUDE_NUTTX_VIDIO_CURSOR_H
|
#ifndef __INCLUDE_NUTTX_VIDEO_CURSOR_H
|
||||||
#define __INCLUDE_NUTTX_VIDIO_CURSOR_H
|
#define __INCLUDE_NUTTX_VIDEO_CURSOR_H
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Included Files
|
* Included Files
|
||||||
|
|
@ -69,7 +69,7 @@ struct cursor_image_s
|
||||||
{
|
{
|
||||||
cursor_coord_t width; /* Width of the cursor image in pixels */
|
cursor_coord_t width; /* Width of the cursor image in pixels */
|
||||||
cursor_coord_t height; /* Height of the cursor image in pixels */
|
cursor_coord_t height; /* Height of the cursor image in pixels */
|
||||||
FAR const uint8_t *image; /* Pointer to image data */
|
FAR const uint8_t *image; /* Pointer to bitmap image data */
|
||||||
};
|
};
|
||||||
|
|
||||||
/* The following structure defines the cursor position */
|
/* The following structure defines the cursor position */
|
||||||
|
|
@ -90,4 +90,4 @@ struct cursor_size_s
|
||||||
cursor_coord_t w; /* Width in pixels */
|
cursor_coord_t w; /* Width in pixels */
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* __INCLUDE_NUTTX_VIDIO_CURSOR_H */
|
#endif /* __INCLUDE_NUTTX_VIDEO_CURSOR_H */
|
||||||
|
|
|
||||||
|
|
@ -34,8 +34,8 @@
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifndef __INCLUDE_NUTTX_VIDIO_FB_H
|
#ifndef __INCLUDE_NUTTX_VIDEO_FB_H
|
||||||
#define __INCLUDE_NUTTX_VIDIO_FB_H
|
#define __INCLUDE_NUTTX_VIDEO_FB_H
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Included Files
|
* Included Files
|
||||||
|
|
@ -653,4 +653,4 @@ int fb_register(int display, int plane);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif /* __INCLUDE_NUTTX_VIDIO_FB_H */
|
#endif /* __INCLUDE_NUTTX_VIDEO_FB_H */
|
||||||
|
|
|
||||||
|
|
@ -51,6 +51,12 @@ CSRCS += nx_getrectangle.c nx_lower.c nx_modal.c nx_move.c nx_openwindow.c
|
||||||
CSRCS += nx_raise.c nx_redrawreq.c nx_setpixel.c nx_setposition.c
|
CSRCS += nx_raise.c nx_redrawreq.c nx_setpixel.c nx_setposition.c
|
||||||
CSRCS += nx_setsize.c
|
CSRCS += nx_setsize.c
|
||||||
|
|
||||||
|
ifeq ($(CONFIG_NX_HWCURSOR),y)
|
||||||
|
CSRCS += nx_cursor.c
|
||||||
|
else ifeq ($(CONFIG_NX_SWCURSOR),y)
|
||||||
|
CSRCS += nx_cursor.c
|
||||||
|
endif
|
||||||
|
|
||||||
# Add the nxmu/ directory to the build
|
# Add the nxmu/ directory to the build
|
||||||
|
|
||||||
DEPPATH += --dep-path nxmu
|
DEPPATH += --dep-path nxmu
|
||||||
|
|
|
||||||
215
libs/libnx/nxmu/nx_cursor.c
Normal file
215
libs/libnx/nxmu/nx_cursor.c
Normal file
|
|
@ -0,0 +1,215 @@
|
||||||
|
/****************************************************************************
|
||||||
|
* libs/libnx/nxmu/nx_cursor.c
|
||||||
|
*
|
||||||
|
* Copyright (C) 2019 Gregory Nutt. All rights reserved.
|
||||||
|
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
*
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in
|
||||||
|
* the documentation and/or other materials provided with the
|
||||||
|
* distribution.
|
||||||
|
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||||
|
* used to endorse or promote products derived from this software
|
||||||
|
* without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||||
|
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||||
|
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||||
|
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||||
|
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||||
|
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||||
|
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Included Files
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include <nuttx/config.h>
|
||||||
|
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <errno.h>
|
||||||
|
|
||||||
|
#include <nuttx/video/cursor.h>
|
||||||
|
#include <nuttx/nx/nxcursor.h>
|
||||||
|
|
||||||
|
#ifndef defined(CONFIG_NX_SWCURSOR) || defined(CONFIG_NX_HWCURSOR)
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Public Functions
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: nxcursor_enable
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Enable/disable presentation of the cursor
|
||||||
|
*
|
||||||
|
* Input Parameters:
|
||||||
|
* hnd - The server handle returned by nx_connect()
|
||||||
|
* enable - True: show the cursor, false: hide the cursor.
|
||||||
|
*
|
||||||
|
* Returned Value:
|
||||||
|
* OK on success; ERROR on failure with errno set appropriately
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
int nxcursor_enable(NXHANDLE hnd, bool enable)
|
||||||
|
{
|
||||||
|
FAR struct nxmu_conn_s *conn = (FAR struct nxmu_conn_s *)handle;
|
||||||
|
struct nxsvrmsg_curenable_s outmsg;
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
/* Send the cursor enable/disable message */
|
||||||
|
|
||||||
|
outmsg.msgid = NX_SVRMSG_CURSOR_ENABLE;
|
||||||
|
outmsg.enable = enable;
|
||||||
|
|
||||||
|
ret = nxmu_sendserver(conn, &outmsg, sizeof(struct nxsvrmsg_curenable_s));
|
||||||
|
if (ret < 0)
|
||||||
|
{
|
||||||
|
gerr("ERROR: nxmu_sendserver() returned %d\n", ret);
|
||||||
|
set_errno(-ret);
|
||||||
|
return ERROR
|
||||||
|
}
|
||||||
|
|
||||||
|
return OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: nxcursor_setimage
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Set the cursor image.
|
||||||
|
*
|
||||||
|
* NOTE: The NX logic will reference the user image buffer repeatedly.
|
||||||
|
* That image buffer must persist for as long as the NX server connection
|
||||||
|
* persists.
|
||||||
|
*
|
||||||
|
* Input Parameters:
|
||||||
|
* hnd - The server handle returned by nx_connect()
|
||||||
|
* image - Describes the cursor image in the expected format. For a
|
||||||
|
* software cursor, this is the format used with the display. The
|
||||||
|
* format may be different if a hardware cursor is used.
|
||||||
|
*
|
||||||
|
* Returned Value:
|
||||||
|
* OK on success; ERROR on failure with errno set appropriately
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#if defined(CONFIG_NX_HWCURSORIMAGE) || defined(CONFIG_NX_SWCURSOR)
|
||||||
|
int nxcursor_setimage(NXHANDLE hnd, FAR struct cursor_image_s *image)
|
||||||
|
{
|
||||||
|
FAR struct nxmu_conn_s *conn = (FAR struct nxmu_conn_s *)handle;
|
||||||
|
struct nxsvrmsg_curimage_s outmsg;
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
DEBUGASSERT(hnd != NULL && image != NULL);
|
||||||
|
|
||||||
|
/* Send the new cursor image to the server */
|
||||||
|
|
||||||
|
outmsg.msgid = NX_SVRMSG_CURSOR_IMAGE;
|
||||||
|
outmsg.image.width = image->width;
|
||||||
|
outmsg.image.height = image->height;
|
||||||
|
outmsg.image.image = image->image; /* The user pointer is sent, no data */
|
||||||
|
|
||||||
|
/* We will finish the teardown upon receipt of the DISCONNECTED message */
|
||||||
|
|
||||||
|
ret = nxmu_sendserver(conn, &outmsg, sizeof(struct nxsvrmsg_curimage_s));
|
||||||
|
if (ret < 0)
|
||||||
|
{
|
||||||
|
gerr("ERROR: nxmu_sendserver() returned %d\n", ret);
|
||||||
|
set_errno(-ret);
|
||||||
|
return ERROR
|
||||||
|
}
|
||||||
|
|
||||||
|
return OK;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: nxcursor_setposition
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Move the cursor to the specified position
|
||||||
|
*
|
||||||
|
* Input Parameters:
|
||||||
|
* hnd - The server handle returned by nx_connect()
|
||||||
|
* pos - The new cursor position
|
||||||
|
*
|
||||||
|
* Returned Value:
|
||||||
|
* OK on success; ERROR on failure with errno set appropriately
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
int nxcursor_setposition(NXHANDLE hnd, FAR const struct cursor_pos_s *pos)
|
||||||
|
{
|
||||||
|
FAR struct nxmu_conn_s *conn = (FAR struct nxmu_conn_s *)handle;
|
||||||
|
struct nxsvrmsg_curpos_s outmsg;
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
DEBUGASSERT(hnd != NULL && pos != NULL);
|
||||||
|
|
||||||
|
/* Send the new cursor position to the server */
|
||||||
|
|
||||||
|
outmsg.msgid = NX_SVRMSG_CURSOR_SETPOS;
|
||||||
|
outmsg.pos.x = pos->x;
|
||||||
|
outmsg.pos.y = pos->y;
|
||||||
|
|
||||||
|
/* We will finish the teardown upon receipt of the DISCONNECTED message */
|
||||||
|
|
||||||
|
ret = nxmu_sendserver(conn, &outmsg, sizeof(struct nxsvrmsg_curpos_s));
|
||||||
|
if (ret < 0)
|
||||||
|
{
|
||||||
|
gerr("ERROR: nxmu_sendserver() returned %d\n", ret);
|
||||||
|
set_errno(-ret);
|
||||||
|
return ERROR
|
||||||
|
}
|
||||||
|
|
||||||
|
return OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: nxcursor_get_position
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Return the current cursor position.
|
||||||
|
*
|
||||||
|
* CAUTION: The current cursor position is not updated until the display
|
||||||
|
* is actually changed. Due to asynchronies caused by queue, the new
|
||||||
|
* current cursor position may not match the cursor position set until
|
||||||
|
* the client and server are syncrhonized.
|
||||||
|
*
|
||||||
|
* Input Parameters:
|
||||||
|
* hnd - The server handle returned by nx_connect()
|
||||||
|
* pos - The location to return the cursor position
|
||||||
|
*
|
||||||
|
* Returned Value:
|
||||||
|
* OK on success; ERROR on failure with errno set appropriately
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
int nxcursor_get_position(NXHANDLE hnd, FAR struct cursor_pos_s *pos)
|
||||||
|
{
|
||||||
|
/* REVISIT: The cursor position is not accessible from here. It is in hnd,
|
||||||
|
* be we don't have the definitions exposed to get it.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#warning Missing logic
|
||||||
|
set_errno(ENOSYS);
|
||||||
|
return ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* __INCLUDE_NUTTX_NX_NXCURSOR_H */
|
||||||
|
|
@ -75,7 +75,7 @@ int nx_fill(NXWINDOW hwnd, FAR const struct nxgl_rect_s *rect,
|
||||||
struct nxsvrmsg_fill_s outmsg;
|
struct nxsvrmsg_fill_s outmsg;
|
||||||
|
|
||||||
#ifdef CONFIG_DEBUG_FEATURES
|
#ifdef CONFIG_DEBUG_FEATURES
|
||||||
if (!wnd || !rect || !color)
|
if (wnd == NULL || rect == NULL || color == NULL)
|
||||||
{
|
{
|
||||||
set_errno(EINVAL);
|
set_errno(EINVAL);
|
||||||
return ERROR;
|
return ERROR;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue