diff --git a/graphics/nxwidgets/src/cnxwidget.cxx b/graphics/nxwidgets/src/cnxwidget.cxx index 6005623fe..63abd4d77 100644 --- a/graphics/nxwidgets/src/cnxwidget.cxx +++ b/graphics/nxwidgets/src/cnxwidget.cxx @@ -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; } /** diff --git a/graphics/twm4nx/src/cmenus.cxx b/graphics/twm4nx/src/cmenus.cxx index 817d00504..4d4262565 100644 --- a/graphics/twm4nx/src/cmenus.cxx +++ b/graphics/twm4nx/src/cmenus.cxx @@ -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; } diff --git a/graphics/twm4nx/src/cresize.cxx b/graphics/twm4nx/src/cresize.cxx index 29176eb8e..55db98a1d 100644 --- a/graphics/twm4nx/src/cresize.cxx +++ b/graphics/twm4nx/src/cresize.cxx @@ -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 diff --git a/graphics/twm4nx/src/cwindow.cxx b/graphics/twm4nx/src/cwindow.cxx index 309ff27ba..ccdc7f6b0 100644 --- a/graphics/twm4nx/src/cwindow.cxx +++ b/graphics/twm4nx/src/cwindow.cxx @@ -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; }