Squashed commit of the following:

apps/graphics/NXWidgets/:  NXWidgets::CNxWidgets:  Fix some issues with returned values.  On setting the widget size or position, it was returning false if there was no change in size or position.  Many places in the code were treating the false return value as an error.

    apps/graphics/twm4nx:  Fix a couple of errors in the unused resize logic:  It was not hiding the resize menu to it appeared as a artifact in the uppler left hand corner.  Was calling setSize() on the window instead of getSize().  That was causing errors because the size being set was uninitialized.

    apps/graphics/twm4nx: Add missing event generation logic when a window is closed.
This commit is contained in:
Gregory Nutt 2019-05-12 13:46:48 -06:00
parent abd7c9a165
commit 80773daff9
4 changed files with 46 additions and 16 deletions

View File

@ -991,7 +991,7 @@ bool CNxWidget::moveTo(nxgl_coord_t x, nxgl_coord_t y)
{
// Enforce widget to stay within parent confines if necessary
if (m_parent != (CNxWidget *)NULL)
if (m_parent != (FAR CNxWidget *)NULL)
{
if (!m_parent->isPermeable())
{
@ -1052,7 +1052,7 @@ bool CNxWidget::moveTo(nxgl_coord_t x, nxgl_coord_t y)
// Perform move if necessary
if ((m_rect.getX() != x) || (m_rect.getY() != y))
if (m_rect.getX() != x || m_rect.getY() != y)
{
nxgl_coord_t oldX = m_rect.getX();
nxgl_coord_t oldY = m_rect.getY();
@ -1062,10 +1062,9 @@ bool CNxWidget::moveTo(nxgl_coord_t x, nxgl_coord_t y)
redraw();
m_widgetEventHandlers->raiseMoveEvent(x, y, x - oldX, y - oldY);
return true;
}
return false;
return true;
}
/**
@ -1130,10 +1129,9 @@ bool CNxWidget::resize(nxgl_coord_t width, nxgl_coord_t height)
m_flags.drawingEnabled = wasDrawEnabled;
redraw();
m_widgetEventHandlers->raiseResizeEvent(width, height);
return true;
}
return false;
return true;
}
/**

View File

@ -679,7 +679,7 @@ bool CMenus::setMenuWindowSize(void)
if (!m_menuWindow->resizeFrame(&frameSize, (FAR const struct nxgl_point_s *)0))
{
twmerr("ERROR: Failed to set window size\n");
twmerr("ERROR: Failed to resize menu window\n");
return false;
}

View File

@ -974,7 +974,9 @@ bool CResize::createSizeWindow(void)
// 4. Create the main window
m_sizeWindow = m_twm4nx->createFramedWindow(control, NXBE_WINDOW_RAMBACKED);
uint8_t wflags = (NXBE_WINDOW_RAMBACKED | NXBE_WINDOW_HIDDEN);
m_sizeWindow = m_twm4nx->createFramedWindow(control, wflags);
if (m_sizeWindow == (FAR NXWidgets::CNxTkWindow *)0)
{
delete control;
@ -1035,10 +1037,10 @@ bool CResize::createSizeWindow(void)
bool CResize::createSizeLabel(void)
{
// The size of the selected is selected to fill the entire size window
// The size of label is selected to fill the entire size window
struct nxgl_size_s labelSize;
if (!m_sizeWindow->setSize(&labelSize))
if (!m_sizeWindow->getSize(&labelSize))
{
twmerr("ERROR: Failed to get window size\n");
return false;
@ -1142,9 +1144,9 @@ void CResize::updateSizeLabel(FAR CWindow *cwin, FAR struct nxgl_size_s *size)
return;
}
// Bring the window to the top of the hierarchy
// Un-hide the window and bring the window to the top of the hierarchy
m_sizeWindow->raise();
m_sizeWindow->show();
// Add the string to the label widget

View File

@ -695,14 +695,38 @@ bool CWindow::event(FAR struct SEventMsg *eventmsg)
}
else
{
// Inform the application that the window is disappearing
if (m_appEvents.closeEvent != EVENT_SYSTEM_NOP)
{
twminfo("Close event...\n");
// Send the application specific [pre-]close vent
struct SEventMsg outmsg;
outmsg.eventID = m_appEvents.closeEvent;
outmsg.obj = m_appEvents.eventObj;
outmsg.pos.x = eventmsg->pos.x;
outmsg.pos.y = eventmsg->pos.y;
outmsg.context = eventmsg->context;
outmsg.handler = eventmsg->handler;
int ret = mq_send(m_eventq, (FAR const char *)&outmsg,
sizeof(struct SEventMsg), 100);
if (ret < 0)
{
twmerr("ERROR: mq_send failed: %d\n", ret);
}
}
// Close the window... but not yet. Send the blocked message.
// The actual termination will no occur until the NX server
// drains all of the message events. We will get the
// EVENT_WINDOW_DELETE event at that point
NXWidgets::CWidgetControl *control = m_nxWin->getWidgetControl();
nxtk_block(control->getWindowHandle(), (FAR void *)m_nxWin);
}
NXWidgets::CWidgetControl *control = m_nxWin->getWidgetControl();
nxtk_block(control->getWindowHandle(), (FAR void *)m_nxWin);
}
break;
@ -939,6 +963,7 @@ bool CWindow::updateToolbarLayout(void)
struct nxgl_size_s winsize;
if (!getWindowSize(&winsize))
{
twmerr("ERROR: Failed to get window size\n");
return false;
}
@ -971,7 +996,7 @@ bool CWindow::updateToolbarLayout(void)
if (!cimage->moveTo(pos.x, pos.y))
{
twmerr("ERROR: Faile to move button image\n");
twmerr("ERROR: Failed to move button image\n");
return false;
}
}
@ -989,6 +1014,11 @@ bool CWindow::updateToolbarLayout(void)
titleSize.w = m_tbRightX - m_tbLeftX - CONFIG_TWM4NX_TOOLBAR_HSPACING + 1;
bool success = m_tbTitle->resize(titleSize.w, titleSize.h);
if (!success)
{
twmerr("ERROR: Failed to resize title\n");
}
enableToolbarWidgets();
return success;
}