Squashed commit of the following:

graphics/nxterm:  Needs to clear display initially.  Otherwise, garbage from previous display may still be present from preceding NxWM window.

    graphics/nxterm:  Back out most of the preceding NxTerm changes related to window size.  apps/examples/nxterm passed the complete NxTK window size.  Those changes were needed to make aps/examples/nxterm work.  But NxWM passes the the size of the NxTK main sub-window.  So I needed to back out the changes and then change the applications so that they passed the same value (the size of the NxTK sub-window).
This commit is contained in:
Gregory Nutt 2019-03-09 13:13:05 -06:00
parent 9f4ac58054
commit ffca6badfc
10 changed files with 101 additions and 66 deletions

View File

@ -37,7 +37,7 @@ ifeq ($(CONFIG_NXTERM),y)
CSRCS += nx_register.c nxterm_driver.c nxterm_font.c nxterm_putc.c
CSRCS += nxterm_redraw.c nxterm_register.c nxterm_scroll.c
CSRCS += nxterm_vt100.c nxtk_register.c nxtool_register.c
CSRCS += nxterm_vt100.c nxtk_register.c nxtool_register.c nxterm_clear.c
ifneq ($(CONFIG_DISABLE_PSEUDOFS_OPERATIONS),y)
CSRCS += nxterm_unregister.c

View File

@ -184,5 +184,6 @@ static int nxterm_bitmap(FAR struct nxterm_state_s *priv,
NXTERM nx_register(NXWINDOW hwnd, FAR struct nxterm_window_s *wndo, int minor)
{
return nxterm_register((NXTERM)hwnd, wndo, &wndo->wsize, &g_nxops, minor);
return nxterm_register((NXTERM)hwnd, wndo, &g_nxops, minor);
}

View File

@ -124,7 +124,6 @@ struct nxterm_state_s
FAR const struct nxterm_operations_s *ops; /* Window operations */
FAR void *handle; /* The window handle */
FAR struct nxterm_window_s wndo; /* Describes the window and font */
struct nxgl_size_s wsize; /* NXTK main window size */
sem_t exclsem; /* Forces mutually exclusive access */
#ifdef CONFIG_DEBUG_FEATURES
pid_t holder; /* Deadlock avoidance */
@ -203,8 +202,8 @@ int nxterm_sempost(FAR struct nxterm_state_s *priv);
/* Common device registration/un-registration */
FAR struct nxterm_state_s *nxterm_register(NXTERM handle,
FAR struct nxterm_window_s *wndo, FAR struct nxgl_size_s *wsize,
FAR const struct nxterm_operations_s *ops, int minor);
FAR struct nxterm_window_s *wndo, FAR const struct nxterm_operations_s *ops,
int minor);
#ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS
void nxterm_unregister(FAR struct nxterm_state_s *priv);
#endif
@ -223,6 +222,7 @@ enum nxterm_vt100state_e nxterm_vt100(FAR struct nxterm_state_s *priv, char ch);
/* Generic text display helpers */
void nxterm_home(FAR struct nxterm_state_s *priv);
void nxterm_clear(FAR struct nxterm_state_s *priv);
void nxterm_newline(FAR struct nxterm_state_s *priv);
FAR const struct nxterm_bitmap_s *nxterm_addchar(FAR struct nxterm_state_s *priv,
uint8_t ch);

View File

@ -0,0 +1,75 @@
/****************************************************************************
* nuttx/graphics/nxterm/nxterm_clear.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 <debug.h>
#include <nuttx/nx/nxglib.h>
#include "nxterm.h"
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: nxterm_clear
*
* Description:
* Clear the display.
*
****************************************************************************/
void nxterm_clear(FAR struct nxterm_state_s *priv)
{
struct nxgl_rect_s rect;
int ret;
rect.pt1.x = 0;
rect.pt1.y = 0;
rect.pt2.x = priv->wndo.wsize.w - 1;
rect.pt2.y = priv->wndo.wsize.h - 1;
ret = priv->ops->fill(priv, &rect, priv->wndo.wcolor);
if (ret < 0)
{
gerr("ERROR: Fill failed: %d\n", errno);
}
}

View File

@ -81,7 +81,7 @@ void nxterm_putc(FAR struct nxterm_state_s *priv, uint8_t ch)
/* Will another character fit on this line? */
if (priv->fpos.x + priv->fwidth > priv->wsize.w)
if (priv->fpos.x + priv->fwidth > priv->wndo.wsize.w)
{
#ifndef CONFIG_NXTERM_NOWRAP
/* No.. move to the next line */
@ -117,7 +117,7 @@ void nxterm_putc(FAR struct nxterm_state_s *priv, uint8_t ch)
/* Check if we need to scroll up */
lineheight = (priv->fheight + CONFIG_NXTERM_LINESEPARATION);
while (priv->fpos.y >= priv->wsize.h - lineheight)
while (priv->fpos.y >= priv->wndo.wsize.h - lineheight)
{
nxterm_scroll(priv, lineheight);
}
@ -147,7 +147,7 @@ void nxterm_showcursor(FAR struct nxterm_state_s *priv)
/* Will another character fit on this line? */
if (priv->fpos.x + priv->fwidth > priv->wsize.w)
if (priv->fpos.x + priv->fwidth > priv->wndo.wsize.w)
{
#ifndef CONFIG_NXTERM_NOWRAP
/* No.. move to the next line */
@ -161,7 +161,7 @@ void nxterm_showcursor(FAR struct nxterm_state_s *priv)
/* Check if we need to scroll up */
lineheight = (priv->fheight + CONFIG_NXTERM_LINESEPARATION);
while (priv->fpos.y >= priv->wsize.h - lineheight)
while (priv->fpos.y >= priv->wndo.wsize.h - lineheight)
{
nxterm_scroll(priv, lineheight);
}

View File

@ -63,7 +63,6 @@
FAR struct nxterm_state_s *
nxterm_register(NXTERM handle, FAR struct nxterm_window_s *wndo,
FAR struct nxgl_size_s *wsize,
FAR const struct nxterm_operations_s *ops, int minor)
{
FAR struct nxterm_state_s *priv;
@ -88,9 +87,7 @@ FAR struct nxterm_state_s *
priv->ops = ops;
priv->handle = handle;
priv->minor = minor;
memcpy(&priv->wndo, wndo, sizeof(struct nxterm_window_s));
memcpy(&priv->wsize, wsize, sizeof(struct nxgl_size_s));
nxsem_init(&priv->exclsem, 0, 1);
#ifdef CONFIG_DEBUG_FEATURES
@ -141,6 +138,10 @@ FAR struct nxterm_state_s *
priv->maxchars = CONFIG_NXTERM_MXCHARS;
/* Clear the display */
nxterm_clear(priv);
/* Set the initial display position */
nxterm_home(priv);

View File

@ -85,7 +85,7 @@ static inline void nxterm_movedisplay(FAR struct nxterm_state_s *priv,
*/
rect.pt1.x = 0;
rect.pt2.x = priv->wsize.w - 1;
rect.pt2.x = priv->wndo.wsize.w - 1;
for (row = CONFIG_NXTERM_LINESEPARATION; row < bottom; row += scrollheight)
{
@ -118,7 +118,7 @@ static inline void nxterm_movedisplay(FAR struct nxterm_state_s *priv,
/* Finally, clear the vacated part of the display */
rect.pt1.y = bottom;
rect.pt2.y = priv->wsize.h - 1;
rect.pt2.y = priv->wndo.wsize.h - 1;
ret = priv->ops->fill(priv, &rect, priv->wndo.wcolor);
if (ret < 0)
@ -146,8 +146,8 @@ static inline void nxterm_movedisplay(FAR struct nxterm_state_s *priv,
rect.pt1.x = 0;
rect.pt1.y = scrollheight;
rect.pt2.x = priv->wsize.w - 1;
rect.pt2.y = priv->wsize.h - 1;
rect.pt2.x = priv->wndo.wsize.w - 1;
rect.pt2.y = priv->wndo.wsize.h - 1;
/* The offset that determines how far to move the source rectangle */
@ -164,7 +164,7 @@ static inline void nxterm_movedisplay(FAR struct nxterm_state_s *priv,
/* Finally, clear the vacated bottom part of the display */
rect.pt1.y = priv->wsize.h - scrollheight;
rect.pt1.y = priv->wndo.wsize.h - scrollheight;
ret = priv->ops->fill(priv, &rect, priv->wndo.wcolor);
if (ret < 0)

View File

@ -160,22 +160,6 @@ static int nxtkcon_bitmap(FAR struct nxterm_state_s *priv,
return nxtk_bitmapwindow((NXTKWINDOW)priv->handle, dest, src, origin, stride);
}
/****************************************************************************
* Name: nxterm_tbheight
*
* Description:
* Get the current height of the toolbar.
*
****************************************************************************/
static nxgl_coord_t nxterm_tbheight(NXTKWINDOW hfwnd)
{
FAR struct nxgl_rect_s bounds;
(void)nxtk_toolbarbounds(hfwnd, &bounds);
return bounds.pt2.y - bounds.pt1.y + 1;
}
/****************************************************************************
* Public Functions
****************************************************************************/
@ -201,13 +185,5 @@ static nxgl_coord_t nxterm_tbheight(NXTKWINDOW hfwnd)
NXTERM nxtk_register(NXTKWINDOW hfwnd, FAR struct nxterm_window_s *wndo,
int minor)
{
struct nxgl_size_s wsize;
/* REVISIT: What if the window or toolbar size changes? */
wsize.w = wndo->wsize.w - 2 * CONFIG_NXTK_BORDERWIDTH;
wsize.h = wndo->wsize.h - nxterm_tbheight(hfwnd) -
2 * CONFIG_NXTK_BORDERWIDTH;
return nxterm_register((NXTERM)hfwnd, wndo, &wsize, &g_nxtkops, minor);
return nxterm_register((NXTERM)hfwnd, wndo, &g_nxtkops, minor);
}

View File

@ -160,24 +160,6 @@ static int nxtool_bitmap(FAR struct nxterm_state_s *priv,
return nxtk_bitmaptoolbar((NXTKWINDOW)priv->handle, dest, src, origin, stride);
}
/****************************************************************************
* Name: nxterm_toolbar_size
*
* Description:
* Get the current size of the toolbar.
*
****************************************************************************/
static void nxterm_toolbar_size(NXTKWINDOW hfwnd,
FAR struct nxgl_size_s *size)
{
FAR struct nxgl_rect_s bounds;
(void)nxtk_toolbarbounds(hfwnd, &bounds);
size->w = bounds.pt2.x - bounds.pt1.x + 1;
size->h = bounds.pt2.y - bounds.pt1.y + 1;
}
/****************************************************************************
* Public Functions
****************************************************************************/
@ -204,9 +186,6 @@ static void nxterm_toolbar_size(NXTKWINDOW hfwnd,
NXTERM nxtool_register(NXTKWINDOW hfwnd, FAR struct nxterm_window_s *wndo, int minor)
{
FAR struct nxgl_size_s tbsize;
nxterm_toolbar_size(hfwnd, &tbsize);
return nxterm_register((NXTERM)hfwnd, wndo, &tbsize, &g_nxtoolops, minor);
return nxterm_register((NXTERM)hfwnd, wndo, &g_nxtoolops, minor);
}

View File

@ -200,13 +200,16 @@
typedef FAR void *NXTERM;
/* This structure describes the window and font characteristics */
/* This structure describes the window and font characteristics.
* For raw windows, wsize if the full size of the window. For
* NxTK windows, wsize is the size of the sub-window.
*/
struct nxterm_window_s
{
nxgl_mxpixel_t wcolor[CONFIG_NX_NPLANES]; /* Window background color */
nxgl_mxpixel_t fcolor[CONFIG_NX_NPLANES]; /* Font color */
struct nxgl_size_s wsize; /* Window size */
struct nxgl_size_s wsize; /* Window/Sub-window size */
int fontid; /* The ID of the font to use */
};