Squashed commit of the following:

apps/graphics/twm4nx:  Fix various bugs found in bringup:  Re-order object instantiation to account for inter-object dependencies.  Correct mq_receive() buffer size.  Fix a backward comparison.

    apps/graphics/twm4nx:  Twm4Nx debug can now be separately enabled so that it does not get overwhelmed by other graphics debug output.
This commit is contained in:
Gregory Nutt 2019-05-02 09:19:45 -06:00
parent a11f55ca4c
commit 358f32bfdc
14 changed files with 235 additions and 204 deletions

View File

@ -3,7 +3,7 @@
# see the file kconfig-language.txt in the NuttX tools repository. # see the file kconfig-language.txt in the NuttX tools repository.
# #
config GRAPHICS_TWM4NX menuconfig GRAPHICS_TWM4NX
tristate "Minimal Tom's Window Manager (TWM) for NuttX (Twm4Nx)" tristate "Minimal Tom's Window Manager (TWM) for NuttX (Twm4Nx)"
default n default n
select NX_RAMBACKED select NX_RAMBACKED
@ -61,4 +61,19 @@ config TWM4NX_NETINIT
---help--- ---help---
This option enables/disables all network initialization in Twm4Nx. This option enables/disables all network initialization in Twm4Nx.
config TWM4NX_DEBUG
bool "Force debug output"
default n
depends on DEBUG_FEATURES
---help---
This option will force graphics debug output for Twm4Nx even if
graphics debug output is not enabled. This is useful for very low
level debug of the Twm4Nx logic without interfering output from
other graphics components.
NOTE: The level of this Twm4Nx debug is still controlled by the
basic debug output settings CONFIG_DEBUG_INFO, CONFIG_DEBUG_WARN,
and CONFIG_DEBUG_ERROR (but not the corresponding
CONFIG_DEBUG_GRAPHICS_* settings)
endif # GRAPHICS_TWM4NX endif # GRAPHICS_TWM4NX

View File

@ -40,8 +40,6 @@
#include <nuttx/config.h> #include <nuttx/config.h>
#include <debug.h>
#include <nuttx/nx/nxglib.h> #include <nuttx/nx/nxglib.h>
#include "graphics/nxwidgets/cscaledbitmap.hxx" #include "graphics/nxwidgets/cscaledbitmap.hxx"
@ -119,24 +117,24 @@ CBackground::~CBackground(void)
bool CBackground:: bool CBackground::
initialize(FAR const struct NXWidgets::SRlePaletteBitmap *sbitmap) initialize(FAR const struct NXWidgets::SRlePaletteBitmap *sbitmap)
{ {
ginfo("Create the backgound window\n"); twminfo("Create the backgound window\n");
// Create the background window (if we have not already done so) // Create the background window (if we have not already done so)
if (m_backWindow == (NXWidgets::CBgWindow *)0 && if (m_backWindow == (NXWidgets::CBgWindow *)0 &&
!createBackgroundWindow()) !createBackgroundWindow())
{ {
gerr("ERROR: Failed to create the background window\n"); twmerr("ERROR: Failed to create the background window\n");
return false; return false;
} }
ginfo("Create the backgound image\n"); twminfo("Create the backgound image\n");
// Create the new background image // Create the new background image
if (!createBackgroundImage(sbitmap)) if (!createBackgroundImage(sbitmap))
{ {
gerr("ERROR: Failed to create the background image\n"); twmerr("ERROR: Failed to create the background image\n");
delete m_backWindow; delete m_backWindow;
m_backWindow = (NXWidgets::CBgWindow *)0; m_backWindow = (NXWidgets::CBgWindow *)0;
return false; return false;
@ -179,7 +177,7 @@ void CBackground::getDisplaySize(FAR struct nxgl_size_s &size)
bool CBackground::event(FAR struct SEventMsg *eventmsg) bool CBackground::event(FAR struct SEventMsg *eventmsg)
{ {
ginfo("eventID: %u\n", eventmsg->eventID); twminfo("eventID: %u\n", eventmsg->eventID);
bool success = true; bool success = true;
switch (eventmsg->eventID) switch (eventmsg->eventID)
@ -225,7 +223,7 @@ bool CBackground::createBackgroundWindow(void)
m_backWindow = m_twm4nx->getBgWindow(control); m_backWindow = m_twm4nx->getBgWindow(control);
if (m_backWindow == (FAR NXWidgets::CBgWindow *)0) if (m_backWindow == (FAR NXWidgets::CBgWindow *)0)
{ {
gerr("ERROR: Failed to create BG window\n"); twmerr("ERROR: Failed to create BG window\n");
return false; return false;
} }
@ -233,7 +231,7 @@ bool CBackground::createBackgroundWindow(void)
if (!m_backWindow->open()) if (!m_backWindow->open())
{ {
gerr("ERROR: Failed to open the BG window\n"); twmerr("ERROR: Failed to open the BG window\n");
delete m_backWindow; delete m_backWindow;
m_backWindow = (FAR NXWidgets::CBgWindow *)0; m_backWindow = (FAR NXWidgets::CBgWindow *)0;
return false; return false;
@ -256,7 +254,7 @@ bool CBackground::
struct nxgl_size_s windowSize; struct nxgl_size_s windowSize;
if (!m_backWindow->getSize(&windowSize)) if (!m_backWindow->getSize(&windowSize))
{ {
gerr("ERROR: getSize failed\n"); twmerr("ERROR: getSize failed\n");
return false; return false;
} }
@ -271,7 +269,7 @@ bool CBackground::
if (cbitmap == (NXWidgets::CRlePaletteBitmap *)0) if (cbitmap == (NXWidgets::CRlePaletteBitmap *)0)
{ {
gerr("ERROR: Failed to create bitmap\n"); twmerr("ERROR: Failed to create bitmap\n");
return false; return false;
} }
@ -308,7 +306,7 @@ bool CBackground::
imageSize.w, imageSize.h, cbitmap); imageSize.w, imageSize.h, cbitmap);
if (m_backImage == (NXWidgets::CImage *)0) if (m_backImage == (NXWidgets::CImage *)0)
{ {
gerr("ERROR: Failed to create CImage\n"); twmerr("ERROR: Failed to create CImage\n");
delete cbitmap; delete cbitmap;
return false; return false;
} }
@ -335,7 +333,7 @@ bool CBackground::
bool CBackground::redrawBackgroundWindow(FAR const struct nxgl_rect_s *rect, bool CBackground::redrawBackgroundWindow(FAR const struct nxgl_rect_s *rect,
bool more) bool more)
{ {
ginfo("Redrawing..\n"); twminfo("Redrawing..\n");
// Get the widget control from the background window // Get the widget control from the background window

View File

@ -48,6 +48,7 @@
#include "nuttx/nx/nxglib.h" #include "nuttx/nx/nxglib.h"
#include "graphics/twm4nx/twm4nx_config.hxx"
#include "graphics/twm4nx/ctwm4nx.hxx" #include "graphics/twm4nx/ctwm4nx.hxx"
#include "graphics/twm4nx/cwindow.hxx" #include "graphics/twm4nx/cwindow.hxx"
#include "graphics/twm4nx/cwindowevent.hxx" #include "graphics/twm4nx/cwindowevent.hxx"
@ -352,7 +353,7 @@ void CIcon::down(FAR CWindow *cwin)
void CIcon::redrawIcons(FAR const nxgl_rect_s *nxRect, bool more) void CIcon::redrawIcons(FAR const nxgl_rect_s *nxRect, bool more)
{ {
ginfo("Redrawing...\n"); twminfo("Redrawing...\n");
// Try each region // Try each region
@ -386,7 +387,7 @@ void CIcon::redrawIcons(FAR const nxgl_rect_s *nxRect, bool more)
{ {
// Redraw the icon (or a portion of the icon) // Redraw the icon (or a portion of the icon)
ginfo("Redraw icon\n"); twminfo("Redraw icon\n");
cwin->redrawIcon(); cwin->redrawIcon();
} }
} }

View File

@ -48,7 +48,6 @@
#include <cstdio> #include <cstdio>
#include <cstring> #include <cstring>
#include <debug.h>
#include "graphics/nxwidgets/cnxwindow.hxx" #include "graphics/nxwidgets/cnxwindow.hxx"
#include "graphics/nxwidgets/cnxfont.hxx" #include "graphics/nxwidgets/cnxfont.hxx"
@ -141,8 +140,8 @@ bool CIconMgr::initialize(FAR const char *prefix)
m_eventq = mq_open(mqname, O_WRONLY | O_NONBLOCK); m_eventq = mq_open(mqname, O_WRONLY | O_NONBLOCK);
if (m_eventq == (mqd_t)-1) if (m_eventq == (mqd_t)-1)
{ {
gerr("ERROR: Failed open message queue '%s': %d\n", twmerr("ERROR: Failed open message queue '%s': %d\n",
mqname, errno); mqname, errno);
return false; return false;
} }
@ -150,7 +149,7 @@ bool CIconMgr::initialize(FAR const char *prefix)
if (!createWindow(prefix)) if (!createWindow(prefix))
{ {
gerr("ERROR: Failed to create window\n"); twmerr("ERROR: Failed to create window\n");
return false; return false;
} }
@ -158,7 +157,7 @@ bool CIconMgr::initialize(FAR const char *prefix)
if (!createButtonArray()) if (!createButtonArray())
{ {
gerr("ERROR: Failed to button array\n"); twmerr("ERROR: Failed to button array\n");
CWindowFactory *factory = m_twm4nx->getWindowFactory(); CWindowFactory *factory = m_twm4nx->getWindowFactory();
factory->destroyWindow(m_window); factory->destroyWindow(m_window);
@ -215,7 +214,7 @@ bool CIconMgr::add(FAR CWindow *cwin)
struct nxgl_size_s windowSize; struct nxgl_size_s windowSize;
if (!m_window->getWindowSize(&windowSize)) if (!m_window->getWindowSize(&windowSize))
{ {
gerr("ERROR: Failed to get window size\n"); twmerr("ERROR: Failed to get window size\n");
} }
else else
{ {
@ -280,7 +279,7 @@ void CIconMgr::pack(void)
struct nxgl_size_s windowSize; struct nxgl_size_s windowSize;
if (!m_window->getWindowSize(&windowSize)) if (!m_window->getWindowSize(&windowSize))
{ {
gerr("ERROR: Failed to get window size\n"); twmerr("ERROR: Failed to get window size\n");
return; return;
} }
@ -350,7 +349,7 @@ void CIconMgr::pack(void)
windowSize.h = getRowHeight() * m_nWindows; windowSize.h = getRowHeight() * m_nWindows;
if (!m_window->getWindowSize(&windowSize)) if (!m_window->getWindowSize(&windowSize))
{ {
gerr("ERROR: getWindowSize() failed\n"); twmerr("ERROR: getWindowSize() failed\n");
return; return;
} }
@ -371,7 +370,7 @@ void CIconMgr::pack(void)
if (!m_window->setWindowSize(&newsize)) if (!m_window->setWindowSize(&newsize))
{ {
gerr("ERROR: setWindowSize() failed\n"); twmerr("ERROR: setWindowSize() failed\n");
return; return;
} }
@ -383,7 +382,7 @@ void CIconMgr::pack(void)
if (!m_buttons->resizeArray(m_maxColumns, m_nrows, if (!m_buttons->resizeArray(m_maxColumns, m_nrows,
buttonWidth, buttonHeight)) buttonWidth, buttonHeight))
{ {
gerr("ERROR: CButtonArray::resizeArray failed\n"); twmerr("ERROR: CButtonArray::resizeArray failed\n");
return; return;
} }
@ -525,7 +524,7 @@ bool CIconMgr::createWindow(FAR const char *prefix)
if (m_window == (FAR CWindow *)0) if (m_window == (FAR CWindow *)0)
{ {
gerr("ERROR: Failed to create icon manager window"); twmerr("ERROR: Failed to create icon manager window");
success = false; success = false;
} }
@ -550,7 +549,7 @@ bool CIconMgr::createButtonArray(void)
struct nxgl_size_s windowSize; struct nxgl_size_s windowSize;
if (!m_window->getWindowSize(&windowSize)) if (!m_window->getWindowSize(&windowSize))
{ {
gerr("ERROR: Failed to get window size\n"); twmerr("ERROR: Failed to get window size\n");
return false; return false;
} }
@ -586,7 +585,7 @@ bool CIconMgr::createButtonArray(void)
buttonWidth, buttonHeight); buttonWidth, buttonHeight);
if (m_buttons == (FAR NXWidgets::CButtonArray *)0) if (m_buttons == (FAR NXWidgets::CButtonArray *)0)
{ {
gerr("ERROR: Failed to get window size\n"); twmerr("ERROR: Failed to get window size\n");
return false; return false;
} }
@ -791,14 +790,13 @@ void CIconMgr::handleActionEvent(const NXWidgets::CWidgetEventArgs &e)
sizeof(struct SEventMsg), 100); sizeof(struct SEventMsg), 100);
if (ret < 0) if (ret < 0)
{ {
gerr("ERROR: mq_send failed: %d\n", ret); twmerr("ERROR: mq_send failed: %d\n", ret);
} }
break; break;
} }
} }
gwarn("WARNING: No matching window name\n"); twmwarn("WARNING: No matching window name\n");
} }
} }

View File

@ -127,8 +127,8 @@ bool CIconWidget::initialize(FAR NXWidgets::IBitmap *ibitmap,
m_eventq = mq_open(mqname, O_WRONLY | O_NONBLOCK); m_eventq = mq_open(mqname, O_WRONLY | O_NONBLOCK);
if (m_eventq == (mqd_t)-1) if (m_eventq == (mqd_t)-1)
{ {
gerr("ERROR: Failed open message queue '%s': %d\n", twmerr("ERROR: Failed open message queue '%s': %d\n",
mqname, errno); mqname, errno);
return false; return false;
} }
@ -177,7 +177,7 @@ bool CIconWidget::initialize(FAR NXWidgets::IBitmap *ibitmap,
ibitmap, m_style); ibitmap, m_style);
if (image == (FAR NXWidgets::CImage *)0) if (image == (FAR NXWidgets::CImage *)0)
{ {
gerr("ERROR: Failed to create image\n"); twmerr("ERROR: Failed to create image\n");
return false; return false;
} }
@ -202,7 +202,7 @@ bool CIconWidget::initialize(FAR NXWidgets::IBitmap *ibitmap,
iconLabelSize.w, iconLabelSize.h, title); iconLabelSize.w, iconLabelSize.h, title);
if (label == (FAR NXWidgets::CLabel *)0) if (label == (FAR NXWidgets::CLabel *)0)
{ {
gerr("ERROR: Failed to create icon label\n"); twmerr("ERROR: Failed to create icon label\n");
delete image; delete image;
return false; return false;
} }
@ -316,7 +316,7 @@ void CIconWidget::handleUngrabEvent(const NXWidgets::CWidgetEventArgs &e)
sizeof(struct SEventMsg), 100); sizeof(struct SEventMsg), 100);
if (ret < 0) if (ret < 0)
{ {
gerr("ERROR: mq_send failed: %d\n", ret); twmerr("ERROR: mq_send failed: %d\n", ret);
} }
} }
@ -356,7 +356,7 @@ void CIconWidget::handleDragEvent(const NXWidgets::CWidgetEventArgs &e)
sizeof(struct SEventMsg), 100); sizeof(struct SEventMsg), 100);
if (ret < 0) if (ret < 0)
{ {
gerr("ERROR: mq_send failed: %d\n", ret); twmerr("ERROR: mq_send failed: %d\n", ret);
} }
} }
} }
@ -417,7 +417,7 @@ void CIconWidget::handleClickEvent(const NXWidgets::CWidgetEventArgs &e)
sizeof(struct SEventMsg), 100); sizeof(struct SEventMsg), 100);
if (ret < 0) if (ret < 0)
{ {
gerr("ERROR: mq_send failed: %d\n", ret); twmerr("ERROR: mq_send failed: %d\n", ret);
} }
} }
} }

View File

@ -47,7 +47,6 @@
#include <poll.h> #include <poll.h>
#include <pthread.h> #include <pthread.h>
#include <assert.h> #include <assert.h>
#include <debug.h>
#include <nuttx/nx/nxglib.h> #include <nuttx/nx/nxglib.h>
@ -118,7 +117,7 @@ bool CInput::start(void)
{ {
pthread_attr_t attr; pthread_attr_t attr;
ginfo("Starting listener\n"); twminfo("Starting listener\n");
// Start a separate thread to listen for keyboard events // Start a separate thread to listen for keyboard events
@ -135,7 +134,7 @@ bool CInput::start(void)
int ret = pthread_create(&m_thread, &attr, listener, (FAR void *)this); int ret = pthread_create(&m_thread, &attr, listener, (FAR void *)this);
if (ret != 0) if (ret != 0)
{ {
gerr("ERROR: CInput::start: pthread_create failed: %d\n", ret); twmerr("ERROR: CInput::start: pthread_create failed: %d\n", ret);
return false; return false;
} }
@ -157,7 +156,7 @@ bool CInput::start(void)
// Then return true only if the listener thread reported successful // Then return true only if the listener thread reported successful
// initialization. // initialization.
ginfo("Listener m_state=%d\n", (int)m_state); twminfo("Listener m_state=%d\n", (int)m_state);
return m_state == LISTENER_RUNNING; return m_state == LISTENER_RUNNING;
} }
@ -211,7 +210,7 @@ int CInput::keyboardOpen(void)
// Sleep a bit and try again // Sleep a bit and try again
ginfo("WAITING for a USB keyboard\n"); twminfo("WAITING for a USB keyboard\n");
std::sleep(2); std::sleep(2);
} }
@ -223,8 +222,8 @@ int CInput::keyboardOpen(void)
// Let the top-level logic decide what it wants to do // Let the top-level logic decide what it wants to do
// about all really bad things // about all really bad things
gerr("ERROR: Failed to open %s for reading: %d\n", twmerr("ERROR: Failed to open %s for reading: %d\n",
CONFIG_TWM4NX_KEYBOARD_DEVPATH, errcode); CONFIG_TWM4NX_KEYBOARD_DEVPATH, errcode);
return -errcode; return -errcode;
} }
} }
@ -285,7 +284,7 @@ inline int CInput::mouseOpen(void)
// Sleep a bit and try again // Sleep a bit and try again
ginfo("WAITING for a USB mouse\n"); twminfo("WAITING for a USB mouse\n");
std::sleep(2); std::sleep(2);
} }
@ -297,8 +296,8 @@ inline int CInput::mouseOpen(void)
// Let the top-level logic decide what it wants to do // Let the top-level logic decide what it wants to do
// about all really bad things // about all really bad things
gerr("ERROR: Failed to open %s for reading: %d\n", twmerr("ERROR: Failed to open %s for reading: %d\n",
CONFIG_TWM4NX_MOUSE_DEVPATH, errcode); CONFIG_TWM4NX_MOUSE_DEVPATH, errcode);
return -errcode; return -errcode;
} }
} }
@ -321,7 +320,7 @@ int CInput::keyboardInput(void)
{ {
// Read one keyboard sample // Read one keyboard sample
ginfo("Reading keyboard input\n"); twminfo("Reading keyboard input\n");
uint8_t rxbuffer[CONFIG_TWM4NX_KEYBOARD_BUFSIZE]; uint8_t rxbuffer[CONFIG_TWM4NX_KEYBOARD_BUFSIZE];
ssize_t nbytes = read(m_kbdFd, rxbuffer, ssize_t nbytes = read(m_kbdFd, rxbuffer,
@ -343,8 +342,8 @@ int CInput::keyboardInput(void)
// Let the top-level listener logic decide what to do about // Let the top-level listener logic decide what to do about
// the read failure. // the read failure.
gerr("ERROR: read %s failed: %d\n", twmerr("ERROR: read %s failed: %d\n",
CONFIG_TWM4NX_KEYBOARD_DEVPATH, errcode); CONFIG_TWM4NX_KEYBOARD_DEVPATH, errcode);
return -errcode; return -errcode;
} }
@ -364,7 +363,7 @@ int CInput::keyboardInput(void)
int ret = nx_kbdin(m_twm4nx, (uint8_t)nbytes, rxbuffer); int ret = nx_kbdin(m_twm4nx, (uint8_t)nbytes, rxbuffer);
if (ret < 0) if (ret < 0)
{ {
gerr("ERROR: nx_kbdin failed: %d\n", ret); twmerr("ERROR: nx_kbdin failed: %d\n", ret);
// Ignore the error // Ignore the error
} }
@ -385,7 +384,7 @@ int CInput::mouseInput(void)
{ {
// Read one mouse sample // Read one mouse sample
ginfo("Reading mouse input\n"); twminfo("Reading mouse input\n");
uint8_t rxbuffer[CONFIG_TWM4NX_MOUSE_BUFSIZE]; uint8_t rxbuffer[CONFIG_TWM4NX_MOUSE_BUFSIZE];
ssize_t nbytes = read(m_mouseFd, rxbuffer, ssize_t nbytes = read(m_mouseFd, rxbuffer,
@ -407,8 +406,8 @@ int CInput::mouseInput(void)
// Let the top-level listener logic decide what to do about // Let the top-level listener logic decide what to do about
// the read failure. // the read failure.
gerr("ERROR: read %s failed: %d\n", twmerr("ERROR: read %s failed: %d\n",
CONFIG_TWM4NX_KEYBOARD_DEVPATH, errcode); CONFIG_TWM4NX_KEYBOARD_DEVPATH, errcode);
return -errcode; return -errcode;
} }
@ -422,8 +421,8 @@ int CInput::mouseInput(void)
else if (nbytes < (ssize_t)sizeof(struct mouse_report_s)) else if (nbytes < (ssize_t)sizeof(struct mouse_report_s))
{ {
gerr("ERROR Unexpected read size=%d, expected=%d\n", twmerr("ERROR Unexpected read size=%d, expected=%d\n",
nbytes, sizeof(struct mouse_report_s)); nbytes, sizeof(struct mouse_report_s));
return -EIO; return -EIO;
} }
else else
@ -446,7 +445,7 @@ int CInput::mouseInput(void)
int ret = nxcursor_setposition(m_twm4nx, &pos); int ret = nxcursor_setposition(m_twm4nx, &pos);
if (ret < 0) if (ret < 0)
{ {
gerr("ERROR: nxcursor_setposition failed: %d\n", ret); twmerr("ERROR: nxcursor_setposition failed: %d\n", ret);
// Ignore the error // Ignore the error
} }
@ -456,7 +455,7 @@ int CInput::mouseInput(void)
ret = nx_mousein(m_twm4nx, rpt->x, rpt->y, rpt->buttons); ret = nx_mousein(m_twm4nx, rpt->x, rpt->y, rpt->buttons);
if (ret < 0) if (ret < 0)
{ {
gerr("ERROR: nx_mousein failed: %d\n", ret); twmerr("ERROR: nx_mousein failed: %d\n", ret);
// Ignore the error // Ignore the error
} }
@ -480,7 +479,7 @@ int CInput::mouseInput(void)
int CInput::session(void) int CInput::session(void)
{ {
ginfo("Session started\n"); twminfo("Session started\n");
// Center the cursor // Center the cursor
@ -535,7 +534,7 @@ int CInput::session(void)
} }
else else
{ {
gerr("ERROR: poll() failed"); twmerr("ERROR: poll() failed");
break; break;
} }
} }
@ -544,8 +543,8 @@ int CInput::session(void)
if ((pfd[0].revents & (POLLERR | POLLHUP)) != 0) if ((pfd[0].revents & (POLLERR | POLLHUP)) != 0)
{ {
gerr("ERROR: keyboard poll() failed. revents=%04x\n", twmerr("ERROR: keyboard poll() failed. revents=%04x\n",
pfd[0].revents); pfd[0].revents);
ret = -EIO; ret = -EIO;
break; break;
} }
@ -555,7 +554,7 @@ int CInput::session(void)
ret = keyboardInput(); ret = keyboardInput();
if (ret < 0) if (ret < 0)
{ {
gerr("ERROR: keyboardInput() failed: %d\n", ret); twmerr("ERROR: keyboardInput() failed: %d\n", ret);
break; break;
} }
} }
@ -564,8 +563,8 @@ int CInput::session(void)
if ((pfd[1].revents & (POLLERR | POLLHUP)) != 0) if ((pfd[1].revents & (POLLERR | POLLHUP)) != 0)
{ {
gerr("ERROR: Mouse poll() failed. revents=%04x\n", twmerr("ERROR: Mouse poll() failed. revents=%04x\n",
pfd[1].revents); pfd[1].revents);
ret = -EIO; ret = -EIO;
break; break;
} }
@ -575,7 +574,7 @@ int CInput::session(void)
ret = mouseInput(); ret = mouseInput();
if (ret < 0) if (ret < 0)
{ {
gerr("ERROR: mouseInput() failed: %d\n", ret); twmerr("ERROR: mouseInput() failed: %d\n", ret);
break; break;
} }
} }
@ -607,7 +606,7 @@ FAR void *CInput::listener(FAR void *arg)
{ {
CInput *This = (CInput *)arg; CInput *This = (CInput *)arg;
ginfo("Listener started\n"); twminfo("Listener started\n");
#if defined(CONFIG_TWM4NX_KEYBOARD_USBHOST) || defined(CONFIG_TWM4NX_MOUSE_USBHOST) #if defined(CONFIG_TWM4NX_KEYBOARD_USBHOST) || defined(CONFIG_TWM4NX_MOUSE_USBHOST)
// Indicate that we have successfully started. We might be stuck waiting // Indicate that we have successfully started. We might be stuck waiting
@ -626,7 +625,7 @@ FAR void *CInput::listener(FAR void *arg)
This->m_kbdFd = This->keyboardOpen(); This->m_kbdFd = This->keyboardOpen();
if (This->m_kbdFd < 0) if (This->m_kbdFd < 0)
{ {
gerr("ERROR: open failed: %d\n", This->m_kbdFd); twmerr("ERROR: open failed: %d\n", This->m_kbdFd);
This->m_state = LISTENER_FAILED; This->m_state = LISTENER_FAILED;
sem_post(&This->m_waitSem); sem_post(&This->m_waitSem);
return (FAR void *)0; return (FAR void *)0;
@ -637,7 +636,7 @@ FAR void *CInput::listener(FAR void *arg)
This->m_mouseFd = This->mouseOpen(); This->m_mouseFd = This->mouseOpen();
if (This->m_mouseFd < 0) if (This->m_mouseFd < 0)
{ {
gerr("ERROR: open failed: %d\n", This->m_mouseFd); twmerr("ERROR: open failed: %d\n", This->m_mouseFd);
This->m_state = LISTENER_FAILED; This->m_state = LISTENER_FAILED;
sem_post(&This->m_waitSem); sem_post(&This->m_waitSem);
return (FAR void *)0; return (FAR void *)0;
@ -686,7 +685,7 @@ FAR void *CInput::listener(FAR void *arg)
// m_state = LISTENER_STOPREQUESTED (or perhaps if some irrecoverable // m_state = LISTENER_STOPREQUESTED (or perhaps if some irrecoverable
// error has occurred). // error has occurred).
ginfo("Listener exiting\n"); twminfo("Listener exiting\n");
This->m_state = LISTENER_TERMINATED; This->m_state = LISTENER_TERMINATED;
return (FAR void *)0; return (FAR void *)0;
} }

View File

@ -52,7 +52,6 @@
#include <cassert> #include <cassert>
#include <cerrno> #include <cerrno>
#include <fcntl.h> #include <fcntl.h>
#include <debug.h>
#include <nuttx/version.h> #include <nuttx/version.h>
@ -60,6 +59,7 @@
#include "graphics/nxwidgets/clistbox.hxx" #include "graphics/nxwidgets/clistbox.hxx"
#include "graphics/nxwidgets/cwidgeteventargs.hxx" #include "graphics/nxwidgets/cwidgeteventargs.hxx"
#include "graphics/twm4nx/twm4nx_config.hxx"
#include "graphics/twm4nx/ctwm4nx.hxx" #include "graphics/twm4nx/ctwm4nx.hxx"
#include "graphics/twm4nx/cmenus.hxx" #include "graphics/twm4nx/cmenus.hxx"
#include "graphics/twm4nx/cresize.hxx" #include "graphics/twm4nx/cresize.hxx"
@ -132,8 +132,8 @@ bool CMenus::initialize(FAR const char *name)
m_eventq = mq_open(mqname, O_WRONLY | O_NONBLOCK); m_eventq = mq_open(mqname, O_WRONLY | O_NONBLOCK);
if (m_eventq == (mqd_t)-1) if (m_eventq == (mqd_t)-1)
{ {
gerr("ERROR: Failed open message queue '%s': %d\n", twmerr("ERROR: Failed open message queue '%s': %d\n",
mqname, errno); mqname, errno);
return false; return false;
} }
@ -149,7 +149,7 @@ bool CMenus::initialize(FAR const char *name)
if (!createMenuWindow()) if (!createMenuWindow())
{ {
gerr("ERROR: Failed to create menu window\n"); twmerr("ERROR: Failed to create menu window\n");
cleanup(); cleanup();
return false; return false;
} }
@ -158,7 +158,7 @@ bool CMenus::initialize(FAR const char *name)
if (!createMenuListBox()) if (!createMenuListBox())
{ {
gerr("ERROR: Failed to create menu list box\n"); twmerr("ERROR: Failed to create menu list box\n");
cleanup(); cleanup();
return false; return false;
} }
@ -179,8 +179,8 @@ bool CMenus::initialize(FAR const char *name)
bool CMenus::addMenuItem(FAR const char *text, FAR CMenus *subMenu, bool CMenus::addMenuItem(FAR const char *text, FAR CMenus *subMenu,
FAR CTwm4NxEvent *handler, uint16_t event) FAR CTwm4NxEvent *handler, uint16_t event)
{ {
ginfo("Adding menu text=\"%s\", subMenu=%p, event=%04x\n", twminfo("Adding menu text=\"%s\", subMenu=%p, event=%04x\n",
text, subMenu, event); text, subMenu, event);
// Allocate a new menu item entry // Allocate a new menu item entry
@ -188,7 +188,7 @@ bool CMenus::addMenuItem(FAR const char *text, FAR CMenus *subMenu,
if (item == (FAR struct SMenuItem *)0) if (item == (FAR struct SMenuItem *)0)
{ {
gerr("ERROR: Failed to allocate menu item\n"); twmerr("ERROR: Failed to allocate menu item\n");
return false; return false;
} }
@ -197,7 +197,7 @@ bool CMenus::addMenuItem(FAR const char *text, FAR CMenus *subMenu,
item->text = std::strdup(text); item->text = std::strdup(text);
if (item->text == (FAR char *)0) if (item->text == (FAR char *)0)
{ {
gerr("ERROR: strdup of item text failed\n"); twmerr("ERROR: strdup of item text failed\n");
std::free(item); std::free(item);
return false; return false;
} }
@ -339,7 +339,7 @@ bool CMenus::event(FAR struct SEventMsg *eventmsg)
sizeof(struct SEventMsg), 100); sizeof(struct SEventMsg), 100);
if (ret < 0) if (ret < 0)
{ {
gerr("ERROR: mq_send failed: %d\n", ret); twmerr("ERROR: mq_send failed: %d\n", ret);
success = false; success = false;
} }
} }
@ -598,7 +598,7 @@ bool CMenus::setMenuWindowSize(void)
if (!m_menuWindow->setSize(&menuSize)) if (!m_menuWindow->setSize(&menuSize))
{ {
gerr("ERROR: Failed to set window size\n"); twmerr("ERROR: Failed to set window size\n");
return false; return false;
} }
@ -653,7 +653,7 @@ bool CMenus::createMenuListBox(void)
size.w, size.h); size.w, size.h);
if (m_menuListBox == (FAR NXWidgets::CListBox *)0) if (m_menuListBox == (FAR NXWidgets::CListBox *)0)
{ {
gerr("ERROR: Failed to instantiate list box\n"); twmerr("ERROR: Failed to instantiate list box\n");
return false; return false;
} }
@ -698,13 +698,13 @@ bool CMenus::popUpMenu(FAR struct nxgl_point_s *pos)
m_popUpMenu = new CMenus(m_twm4nx); m_popUpMenu = new CMenus(m_twm4nx);
if (m_popUpMenu == (FAR CMenus *)0) if (m_popUpMenu == (FAR CMenus *)0)
{ {
gerr("ERROR: Failed to create popup menu.\n"); twmerr("ERROR: Failed to create popup menu.\n");
return false; return false;
} }
if (!m_popUpMenu->initialize(m_activeItem->text)) if (!m_popUpMenu->initialize(m_activeItem->text))
{ {
gerr("ERROR: Failed to intialize popup menu.\n"); twmerr("ERROR: Failed to intialize popup menu.\n");
delete m_popUpMenu; delete m_popUpMenu;
m_popUpMenu = (FAR CMenus *)0; m_popUpMenu = (FAR CMenus *)0;
return false; return false;
@ -730,7 +730,7 @@ bool CMenus::popUpMenu(FAR struct nxgl_point_s *pos)
if (windowNames == (FAR CWindow **)0) if (windowNames == (FAR CWindow **)0)
{ {
gerr("ERROR: Failed to allocat window name\n"); twmerr("ERROR: Failed to allocat window name\n");
return false; return false;
} }
@ -879,14 +879,14 @@ void CMenus::handleValueChangeEvent(const NXWidgets::CWidgetEventArgs &e)
sizeof(struct SEventMsg), 100); sizeof(struct SEventMsg), 100);
if (ret < 0) if (ret < 0)
{ {
gerr("ERROR: mq_send failed: %d\n", ret); twmerr("ERROR: mq_send failed: %d\n", ret);
} }
break; break;
} }
} }
gwarn("WARNING: No matching menu item\n"); twmwarn("WARNING: No matching menu item\n");
} }
} }

View File

@ -138,8 +138,8 @@ bool CResize::initialize(void)
m_eventq = mq_open(mqname, O_WRONLY | O_NONBLOCK); m_eventq = mq_open(mqname, O_WRONLY | O_NONBLOCK);
if (m_eventq == (mqd_t)-1) if (m_eventq == (mqd_t)-1)
{ {
gerr("ERROR: Failed open message queue '%s': %d\n", twmerr("ERROR: Failed open message queue '%s': %d\n",
mqname, errno); mqname, errno);
return false; return false;
} }
@ -147,7 +147,7 @@ bool CResize::initialize(void)
if (!createSizeWindow()) if (!createSizeWindow())
{ {
gerr("ERROR: Failed to create menu window\n"); twmerr("ERROR: Failed to create menu window\n");
return false; return false;
} }
@ -155,7 +155,7 @@ bool CResize::initialize(void)
if (!createSizeLabel()) if (!createSizeLabel())
{ {
gerr("ERROR: Failed to recreate size label\n"); twmerr("ERROR: Failed to recreate size label\n");
delete m_sizeWindow; delete m_sizeWindow;
m_sizeWindow = (FAR NXWidgets::CNxTkWindow *)0; m_sizeWindow = (FAR NXWidgets::CNxTkWindow *)0;
@ -234,7 +234,7 @@ void CResize::startResize(FAR struct SEventMsg *eventmsg, FAR CWindow *cwin)
if (!setWindowSize(&size)) if (!setWindowSize(&size))
{ {
gerr("ERROR: setWindowSize() failed\n"); twmerr("ERROR: setWindowSize() failed\n");
return; return;
} }
@ -251,7 +251,7 @@ void CResize::startResize(FAR struct SEventMsg *eventmsg, FAR CWindow *cwin)
if (!cwin->resizeFrame(&m_dragsize, &m_dragpos)) if (!cwin->resizeFrame(&m_dragsize, &m_dragpos))
{ {
gerr("ERROR: Failed to resize frame\n"); twmerr("ERROR: Failed to resize frame\n");
} }
} }
@ -287,7 +287,7 @@ void CResize::menuStartResize(FAR CWindow *cwin,
if (!setWindowSize(&winsize)) if (!setWindowSize(&winsize))
{ {
gerr("ERROR: setWindowSize() failed\n"); twmerr("ERROR: setWindowSize() failed\n");
return; return;
} }
@ -300,7 +300,7 @@ void CResize::menuStartResize(FAR CWindow *cwin,
if (!cwin->resizeFrame(&m_dragsize, &m_dragpos)) if (!cwin->resizeFrame(&m_dragsize, &m_dragpos))
{ {
gerr("ERROR: Failed to resize frame\n"); twmerr("ERROR: Failed to resize frame\n");
} }
} }
@ -459,7 +459,7 @@ void CResize::menuDoResize(FAR CWindow *cwin,
if (!cwin->resizeFrame(&m_dragsize, &m_dragpos)) if (!cwin->resizeFrame(&m_dragsize, &m_dragpos))
{ {
gerr("ERROR: Failed to resize frame\n"); twmerr("ERROR: Failed to resize frame\n");
} }
} }
@ -591,7 +591,7 @@ void CResize::doResize(FAR CWindow *cwin,
if (!cwin->resizeFrame(&m_dragsize, &m_dragpos)) if (!cwin->resizeFrame(&m_dragsize, &m_dragpos))
{ {
gerr("ERROR: Failed to resize frame\n"); twmerr("ERROR: Failed to resize frame\n");
} }
} }
@ -618,7 +618,7 @@ void CResize::endResize(FAR CWindow *cwin)
if (!cwin->resizeFrame(&size, &pos)) if (!cwin->resizeFrame(&size, &pos))
{ {
gerr("ERROR: Failed to resize frame\n"); twmerr("ERROR: Failed to resize frame\n");
} }
constrainSize(cwin, &m_dragsize); constrainSize(cwin, &m_dragsize);
@ -676,7 +676,7 @@ void CResize::menuEndResize(FAR CWindow *cwin)
if (!cwin->resizeFrame(&size, &pos)) if (!cwin->resizeFrame(&size, &pos))
{ {
gerr("ERROR: CWindow::resizeFrame() failed\n"); twmerr("ERROR: CWindow::resizeFrame() failed\n");
} }
constrainSize(cwin, &m_dragsize); constrainSize(cwin, &m_dragsize);
@ -748,8 +748,8 @@ void CResize::constrainSize(FAR CWindow *cwin, FAR nxgl_size_s *size)
void CResize::setupWindow(FAR CWindow *cwin, FAR nxgl_point_s *pos, void CResize::setupWindow(FAR CWindow *cwin, FAR nxgl_point_s *pos,
FAR nxgl_size_s *size) FAR nxgl_size_s *size)
{ {
ginfo("pos={%d, %d} size={%d, %d}\n", twminfo("pos={%d, %d} size={%d, %d}\n",
pos->x, pos->y, size->w, size->h); pos->x, pos->y, size->w, size->h);
// Clip the position the so that it is within the display (with a little // Clip the position the so that it is within the display (with a little
// extra space for the cursor) // extra space for the cursor)
@ -778,7 +778,7 @@ void CResize::setupWindow(FAR CWindow *cwin, FAR nxgl_point_s *pos,
if (!cwin->resizeFrame(size, pos)) if (!cwin->resizeFrame(size, pos))
{ {
gerr("ERROR: CWindow::resizeFrame() failed\n"); twmerr("ERROR: CWindow::resizeFrame() failed\n");
} }
} }
@ -1025,7 +1025,7 @@ bool CResize::createSizeLabel(void)
struct nxgl_size_s labelSize; struct nxgl_size_s labelSize;
if (!m_sizeWindow->setSize(&labelSize)) if (!m_sizeWindow->setSize(&labelSize))
{ {
gerr("ERROR: Failed to get window size\n"); twmerr("ERROR: Failed to get window size\n");
return false; return false;
} }
@ -1055,7 +1055,7 @@ bool CResize::createSizeLabel(void)
" 8888 x 8888 "); " 8888 x 8888 ");
if (m_sizeLabel == (FAR NXWidgets::CLabel *)0) if (m_sizeLabel == (FAR NXWidgets::CLabel *)0)
{ {
gerr("ERROR: Failed to construct size label widget\n"); twmerr("ERROR: Failed to construct size label widget\n");
return false; return false;
} }
@ -1123,7 +1123,7 @@ void CResize::updateSizeLabel(FAR CWindow *cwin, FAR struct nxgl_size_s *size)
(void)asprintf(&str, " %4d x %-4d ", size->w, size->h); (void)asprintf(&str, " %4d x %-4d ", size->w, size->h);
if (str == (FAR char *)0) if (str == (FAR char *)0)
{ {
gerr("ERROR: Failed to get size string\n"); twmerr("ERROR: Failed to get size string\n");
return; return;
} }

View File

@ -57,7 +57,6 @@
#include <sys/boardctl.h> #include <sys/boardctl.h>
#include <semaphore.h> #include <semaphore.h>
#include <debug.h>
#include <nuttx/semaphore.h> #include <nuttx/semaphore.h>
#include <nuttx/nx/nx.h> #include <nuttx/nx/nx.h>
@ -163,7 +162,7 @@ bool CTwm4Nx::run(void)
struct mq_attr attr; struct mq_attr attr;
attr.mq_maxmsg = 32; // REVISIT: Should be configurable attr.mq_maxmsg = 32; // REVISIT: Should be configurable
attr.mq_msgsize = CONFIG_MQ_MAXMSGSIZE; attr.mq_msgsize = MAX_EVENT_MSGSIZE;
attr.mq_flags = 0; attr.mq_flags = 0;
attr.mq_curmsgs = 0; attr.mq_curmsgs = 0;
@ -171,8 +170,8 @@ bool CTwm4Nx::run(void)
m_eventq = mq_open(m_queueName, O_RDONLY | O_CREAT, 0666, &attr); m_eventq = mq_open(m_queueName, O_RDONLY | O_CREAT, 0666, &attr);
if (m_eventq == (mqd_t)-1) if (m_eventq == (mqd_t)-1)
{ {
gerr("ERROR: Failed open message queue '%s': %d\n", twmerr("ERROR: Failed open message queue '%s': %d\n",
m_queueName, errno); m_queueName, errno);
cleanup(); cleanup();
return false; return false;
} }
@ -187,7 +186,7 @@ bool CTwm4Nx::run(void)
if (!connect()) if (!connect())
{ {
gerr("ERROR: Failed to connect to the NX server\n"); twmerr("ERROR: Failed to connect to the NX server\n");
cleanup(); cleanup();
return false; return false;
} }
@ -197,7 +196,7 @@ bool CTwm4Nx::run(void)
m_background = new CBackground(this); m_background = new CBackground(this);
if (m_background == (FAR CBackground *)0) if (m_background == (FAR CBackground *)0)
{ {
gerr("ERROR: Failed to create CBackground\n"); twmerr("ERROR: Failed to create CBackground\n");
cleanup(); cleanup();
return false; return false;
} }
@ -206,7 +205,7 @@ bool CTwm4Nx::run(void)
if (!m_background->initialize(&CONFIG_TWM4NX_BACKGROUND_IMAGE)) if (!m_background->initialize(&CONFIG_TWM4NX_BACKGROUND_IMAGE))
{ {
gerr("ERROR: Failed to set backgournd image\n"); twmerr("ERROR: Failed to set backgournd image\n");
cleanup(); cleanup();
return false; return false;
} }
@ -228,19 +227,47 @@ bool CTwm4Nx::run(void)
m_input = new CInput(this); m_input = new CInput(this);
if (m_input == (CInput *)0) if (m_input == (CInput *)0)
{ {
gerr("ERROR: Failed to create CInput\n"); twmerr("ERROR: Failed to create CInput\n");
cleanup(); cleanup();
return false; return false;
} }
if (!m_input->start()) if (!m_input->start())
{ {
gerr("ERROR: Failed start the keyboard/mouse listener\n"); twmerr("ERROR: Failed start the keyboard/mouse listener\n");
cleanup(); cleanup();
return false; return false;
} }
#endif #endif
// Cache a CWindowFactory instance for use across the session. The window
// factory is needed by the Icon Manager which is instantiated below.
m_factory = new CWindowFactory(this);
if (m_factory == (CWindowFactory *)0)
{
cleanup();
return false;
}
// Cache a CFonts instance for use across the session. Font support is
// need by the Icon Manager which is instantiated next.
m_fonts = new CFonts(this);
if (m_fonts == (CFonts *)0)
{
cleanup();
return false;
}
// Create all fonts
if (!m_fonts->initialize())
{
cleanup();
return false;
}
// Create the Icon Manager // Create the Icon Manager
m_iconmgr = new CIconMgr(this, 4); m_iconmgr = new CIconMgr(this, 4);
@ -259,33 +286,7 @@ bool CTwm4Nx::run(void)
// Cache a CIcon instance for use across the session // Cache a CIcon instance for use across the session
m_icon = new CIcon(this); m_icon = new CIcon(this);
if (m_iconmgr == (CIconMgr *)0) if (m_icon == (CIcon *)0)
{
cleanup();
return false;
}
// Cache a CFonts instance for use across the session
m_fonts = new CFonts(this);
if (m_fonts == (CFonts *)0)
{
cleanup();
return false;
}
// Create all fonts
if (!m_fonts->initialize())
{
cleanup();
return false;
}
// Cache a CWindowFactory instance for use across the session
m_factory = new CWindowFactory(this);
if (m_factory == (CWindowFactory *)0)
{ {
cleanup(); cleanup();
return false; return false;
@ -308,25 +309,31 @@ bool CTwm4Nx::run(void)
// Enter the event loop // Enter the event loop
twminfo("Entering event loop\n");
for (; ; ) for (; ; )
{ {
// Wait for the next NxWidget event // Wait for the next NxWidget event
struct SEventMsg eventmsg; union
int ret = mq_receive(m_eventq, (FAR char *)&eventmsg, {
sizeof(struct SEventMsg), (FAR unsigned int *)0); struct SEventMsg eventmsg;
char buffer[MAX_EVENT_MSGSIZE];
} u;
int ret = mq_receive(m_eventq, u.buffer, MAX_EVENT_MSGSIZE,
(FAR unsigned int *)0);
if (ret < 0) if (ret < 0)
{ {
gerr("ERROR: mq_receive failed: %d\n", errno); twmerr("ERROR: mq_receive failed: %d\n", errno);
cleanup(); cleanup();
return false; return false;
} }
// Dispatch the new event // Dispatch the new event
if (!dispatchEvent(&eventmsg)) if (!dispatchEvent(&u.eventmsg))
{ {
gerr("ERROR: dispatchEvent failed\n"); twmerr("ERROR: dispatchEvent failed\n");
cleanup(); cleanup();
return false; return false;
} }
@ -383,7 +390,7 @@ void CTwm4Nx::genMqName(void)
bool CTwm4Nx::systemEvent(FAR struct SEventMsg *eventmsg) bool CTwm4Nx::systemEvent(FAR struct SEventMsg *eventmsg)
{ {
ginfo("eventID: %u\n", eventmsg->eventID); twminfo("eventID: %u\n", eventmsg->eventID);
switch (eventmsg->eventID) switch (eventmsg->eventID)
{ {
@ -415,7 +422,7 @@ bool CTwm4Nx::systemEvent(FAR struct SEventMsg *eventmsg)
bool CTwm4Nx::dispatchEvent(FAR struct SEventMsg *eventmsg) bool CTwm4Nx::dispatchEvent(FAR struct SEventMsg *eventmsg)
{ {
ginfo("eventID: %u\n", eventmsg->eventID); twminfo("eventID: %u\n", eventmsg->eventID);
enum EEventRecipient recipient = enum EEventRecipient recipient =
(enum EEventRecipient)(eventmsg->eventID & EVENT_RECIPIENT_MASK); (enum EEventRecipient)(eventmsg->eventID & EVENT_RECIPIENT_MASK);
@ -428,11 +435,11 @@ bool CTwm4Nx::dispatchEvent(FAR struct SEventMsg *eventmsg)
break; break;
case EVENT_RECIPIENT_SYSTEM: // Twm4Nx system event case EVENT_RECIPIENT_SYSTEM: // Twm4Nx system event
ret = m_background->event(eventmsg); ret = systemEvent(eventmsg);
break; break;
case EVENT_RECIPIENT_BACKGROUND: // Background window event case EVENT_RECIPIENT_BACKGROUND: // Background window event
ret = systemEvent(eventmsg); ret = m_background->event(eventmsg);
break; break;
case EVENT_RECIPIENT_ICONWIDGET: // Icon widget event case EVENT_RECIPIENT_ICONWIDGET: // Icon widget event
@ -596,7 +603,7 @@ int twm4nx_main(int argc, char *argv[])
} }
usage: usage:
gerr("Usage: %s [-display <number>]\n", argv[0]); twmerr("Usage: %s [-display <number>]\n", argv[0]);
return EXIT_FAILURE; return EXIT_FAILURE;
} }
@ -614,7 +621,7 @@ int twm4nx_main(int argc, char *argv[])
ret = boardctl(BOARDIOC_INIT, 0); ret = boardctl(BOARDIOC_INIT, 0);
if (ret < 0) if (ret < 0)
{ {
gerr("ERROR: boardctl(BOARDIOC_INIT) failed: %d\n", errno); twmerr("ERROR: boardctl(BOARDIOC_INIT) failed: %d\n", errno);
return EXIT_FAILURE; return EXIT_FAILURE;
} }
#endif #endif
@ -625,7 +632,7 @@ int twm4nx_main(int argc, char *argv[])
ret = netinit_bringup(); ret = netinit_bringup();
if (ret < 0) if (ret < 0)
{ {
gerr("ERROR: netinit_bringup() failed: %d\n", ret); twmerr("ERROR: netinit_bringup() failed: %d\n", ret);
return EXIT_FAILURE; return EXIT_FAILURE;
} }
#endif #endif
@ -637,7 +644,7 @@ int twm4nx_main(int argc, char *argv[])
FAR CTwm4Nx *twm4nx = new CTwm4Nx(display); FAR CTwm4Nx *twm4nx = new CTwm4Nx(display);
if (twm4nx == (FAR CTwm4Nx *)0) if (twm4nx == (FAR CTwm4Nx *)0)
{ {
gerr("ERROR: Failed to instantiate CTwm4Nx\n"); twmerr("ERROR: Failed to instantiate CTwm4Nx\n");
return EXIT_FAILURE; return EXIT_FAILURE;
} }
@ -646,7 +653,7 @@ int twm4nx_main(int argc, char *argv[])
bool success = twm4nx->run(); bool success = twm4nx->run();
if (!success) if (!success)
{ {
gerr(" ERROR: Terminating due to failure\n"); twmerr(" ERROR: Terminating due to failure\n");
return EXIT_FAILURE; return EXIT_FAILURE;
} }

View File

@ -53,7 +53,6 @@
#include <cerrno> #include <cerrno>
#include <mqueue.h> #include <mqueue.h>
#include <debug.h>
#include <nuttx/nx/nxglib.h> #include <nuttx/nx/nxglib.h>
@ -208,8 +207,8 @@ bool CWindow::initialize(FAR const char *name,
m_eventq = mq_open(mqname, O_WRONLY | O_NONBLOCK); m_eventq = mq_open(mqname, O_WRONLY | O_NONBLOCK);
if (m_eventq == (mqd_t)-1) if (m_eventq == (mqd_t)-1)
{ {
gerr("ERROR: Failed open message queue '%s': %d\n", twmerr("ERROR: Failed open message queue '%s': %d\n",
mqname, errno); mqname, errno);
return false; return false;
} }
@ -254,7 +253,7 @@ bool CWindow::initialize(FAR const char *name,
if (!createMainWindow(&winsize, pos)) if (!createMainWindow(&winsize, pos))
{ {
gerr("ERROR: createMainWindow() failed\n"); twmerr("ERROR: createMainWindow() failed\n");
cleanup(); cleanup();
return false; return false;
} }
@ -268,7 +267,7 @@ bool CWindow::initialize(FAR const char *name,
if (!getToolbarHeight(name)) if (!getToolbarHeight(name))
{ {
gerr("ERROR: getToolbarHeight() failed\n"); twmerr("ERROR: getToolbarHeight() failed\n");
cleanup(); cleanup();
return false; return false;
} }
@ -277,7 +276,7 @@ bool CWindow::initialize(FAR const char *name,
if (!createToolbar()) if (!createToolbar())
{ {
gerr("ERROR: createToolbar() failed\n"); twmerr("ERROR: createToolbar() failed\n");
cleanup(); cleanup();
return false; return false;
} }
@ -286,7 +285,7 @@ bool CWindow::initialize(FAR const char *name,
if (!createToolbarButtons()) if (!createToolbarButtons())
{ {
gerr("ERROR: createToolbarButtons() failed\n"); twmerr("ERROR: createToolbarButtons() failed\n");
cleanup(); cleanup();
return false; return false;
} }
@ -295,7 +294,7 @@ bool CWindow::initialize(FAR const char *name,
if (!createToolbarTitle(name)) if (!createToolbarTitle(name))
{ {
gerr("ERROR: createToolbarTitle() failed\n"); twmerr("ERROR: createToolbarTitle() failed\n");
cleanup(); cleanup();
return false; return false;
} }
@ -306,7 +305,7 @@ bool CWindow::initialize(FAR const char *name,
m_iconBitMap = new NXWidgets::CRlePaletteBitmap(sbitmap); m_iconBitMap = new NXWidgets::CRlePaletteBitmap(sbitmap);
if (m_iconBitMap == (NXWidgets::CRlePaletteBitmap *)0) if (m_iconBitMap == (NXWidgets::CRlePaletteBitmap *)0)
{ {
gerr("ERROR: Failed to create icon image\n"); twmerr("ERROR: Failed to create icon image\n");
cleanup(); cleanup();
return false; return false;
} }
@ -322,14 +321,14 @@ bool CWindow::initialize(FAR const char *name,
m_iconWidget = new CIconWidget(m_twm4nx, control, pos->x, pos->y); m_iconWidget = new CIconWidget(m_twm4nx, control, pos->x, pos->y);
if (m_iconWidget == (FAR CIconWidget *)0) if (m_iconWidget == (FAR CIconWidget *)0)
{ {
gerr("ERROR: Failed to create the icon widget\n"); twmerr("ERROR: Failed to create the icon widget\n");
cleanup(); cleanup();
return false; return false;
} }
if (!m_iconWidget->initialize(m_iconBitMap, m_name)) if (!m_iconWidget->initialize(m_iconBitMap, m_name))
{ {
gerr("ERROR: Failed to initialize the icon widget\n"); twmerr("ERROR: Failed to initialize the icon widget\n");
cleanup(); cleanup();
return false; return false;
} }
@ -403,7 +402,7 @@ bool CWindow::resizeFrame(FAR const struct nxgl_size_s *size,
bool success = m_nxWin->setSize(&winsize); bool success = m_nxWin->setSize(&winsize);
if (!success) if (!success)
{ {
gerr("ERROR: Failed to setSize()\n"); twmerr("ERROR: Failed to setSize()\n");
return false; return false;
} }
@ -412,7 +411,7 @@ bool CWindow::resizeFrame(FAR const struct nxgl_size_s *size,
success = setFramePosition(pos); success = setFramePosition(pos);
if (!success) if (!success)
{ {
gerr("ERROR: Failed to setSize()\n"); twmerr("ERROR: Failed to setSize()\n");
return false; return false;
} }
@ -753,7 +752,7 @@ bool CWindow::updateToolbarLayout(void)
if (!cimage->moveTo(pos.x, pos.y)) if (!cimage->moveTo(pos.x, pos.y))
{ {
gerr("ERROR: Faile to move button image\n"); twmerr("ERROR: Faile to move button image\n");
return false; return false;
} }
} }
@ -848,7 +847,7 @@ bool CWindow::createToolbarButtons(void)
if (scaler == (FAR NXWidgets::CScaledBitmap *)0) if (scaler == (FAR NXWidgets::CScaledBitmap *)0)
{ {
gerr("ERROR: Failed to created scaled bitmap\n"); twmerr("ERROR: Failed to created scaled bitmap\n");
return false; return false;
} }
#endif #endif
@ -873,7 +872,7 @@ bool CWindow::createToolbarButtons(void)
new NXWidgets::CImage(control, 0, 0, w, h, scaler, 0); new NXWidgets::CImage(control, 0, 0, w, h, scaler, 0);
if (m_tbButtons[btindex] == (FAR NXWidgets::CImage *)0) if (m_tbButtons[btindex] == (FAR NXWidgets::CImage *)0)
{ {
gerr("ERROR: Failed to create image\n"); twmerr("ERROR: Failed to create image\n");
delete scalar; delete scalar;
return false; return false;
} }
@ -882,7 +881,7 @@ bool CWindow::createToolbarButtons(void)
new NXWidgets::CRlePaletteBitmap(sbitmap); new NXWidgets::CRlePaletteBitmap(sbitmap);
if (cbitmap == (FAR NXWidgets::CRlePaletteBitmap *)0) if (cbitmap == (FAR NXWidgets::CRlePaletteBitmap *)0)
{ {
gerr("ERROR: Failed to create CrlPaletteBitmap\n"); twmerr("ERROR: Failed to create CrlPaletteBitmap\n");
return false; return false;
} }
@ -893,7 +892,7 @@ bool CWindow::createToolbarButtons(void)
new NXWidgets::CImage(control, 0, 0, w, h, cbitmap, 0); new NXWidgets::CImage(control, 0, 0, w, h, cbitmap, 0);
if (m_tbButtons[btindex] == (FAR NXWidgets::CImage *)0) if (m_tbButtons[btindex] == (FAR NXWidgets::CImage *)0)
{ {
gerr("ERROR: Failed to create image\n"); twmerr("ERROR: Failed to create image\n");
delete cbitmap; delete cbitmap;
return false; return false;
} }
@ -955,7 +954,7 @@ bool CWindow::createToolbarTitle(FAR const char *name)
{ {
// Is there a title? // Is there a title?
if (name != (FAR const char *)0) if (name == (FAR const char *)0)
{ {
// No.. then there is nothing to be done here // No.. then there is nothing to be done here
@ -997,7 +996,7 @@ bool CWindow::createToolbarTitle(FAR const char *name)
titleSize.w, titleSize.h, name); titleSize.w, titleSize.h, name);
if (m_tbTitle == (FAR NXWidgets::CLabel *)0) if (m_tbTitle == (FAR NXWidgets::CLabel *)0)
{ {
gerr("ERROR: Failed to construct tool bar title widget\n"); twmerr("ERROR: Failed to construct tool bar title widget\n");
return false; return false;
} }
@ -1059,7 +1058,7 @@ void CWindow::handleUngrabEvent(const NXWidgets::CWidgetEventArgs &e)
sizeof(struct SEventMsg), 100); sizeof(struct SEventMsg), 100);
if (ret < 0) if (ret < 0)
{ {
gerr("ERROR: mq_send failed: %d\n", ret); twmerr("ERROR: mq_send failed: %d\n", ret);
} }
} }
@ -1099,7 +1098,7 @@ void CWindow::handleDragEvent(const NXWidgets::CWidgetEventArgs &e)
sizeof(struct SEventMsg), 100); sizeof(struct SEventMsg), 100);
if (ret < 0) if (ret < 0)
{ {
gerr("ERROR: mq_send failed: %d\n", ret); twmerr("ERROR: mq_send failed: %d\n", ret);
} }
} }
} }
@ -1163,7 +1162,7 @@ void CWindow::handleClickEvent(const NXWidgets::CWidgetEventArgs &e)
sizeof(struct SEventMsg), 100); sizeof(struct SEventMsg), 100);
if (ret < 0) if (ret < 0)
{ {
gerr("ERROR: mq_send failed: %d\n", ret); twmerr("ERROR: mq_send failed: %d\n", ret);
} }
} }
} }
@ -1236,7 +1235,7 @@ void CWindow::handleActionEvent(const NXWidgets::CWidgetEventArgs &e)
sizeof(struct SEventMsg), 100); sizeof(struct SEventMsg), 100);
if (ret < 0) if (ret < 0)
{ {
gerr("ERROR: mq_send failed: %d\n", ret); twmerr("ERROR: mq_send failed: %d\n", ret);
} }
} }
} }

View File

@ -43,10 +43,10 @@
#include <cerrno> #include <cerrno>
#include <mqueue.h> #include <mqueue.h>
#include <debug.h>
#include "graphics/nxwidgets/cwidgetcontrol.hxx" #include "graphics/nxwidgets/cwidgetcontrol.hxx"
#include "graphics/twm4nx/twm4nx_config.hxx"
#include "graphics/twm4nx/cwindow.hxx" #include "graphics/twm4nx/cwindow.hxx"
#include "graphics/twm4nx/cwindowevent.hxx" #include "graphics/twm4nx/cwindowevent.hxx"
@ -79,8 +79,8 @@ CWindowEvent::CWindowEvent(FAR CTwm4Nx *twm4nx, bool isBackground,
m_eventq = mq_open(mqname, O_WRONLY); m_eventq = mq_open(mqname, O_WRONLY);
if (m_eventq == (mqd_t)-1) if (m_eventq == (mqd_t)-1)
{ {
gerr("ERROR: Failed open message queue '%s': %d\n", twmerr("ERROR: Failed open message queue '%s': %d\n",
mqname, errno); mqname, errno);
} }
// Add ourself to the list of window event handlers // Add ourself to the list of window event handlers
@ -117,7 +117,7 @@ CWindowEvent::~CWindowEvent(void)
bool CWindowEvent::event(FAR struct SEventMsg *eventmsg) bool CWindowEvent::event(FAR struct SEventMsg *eventmsg)
{ {
ginfo("eventID: %u\n", eventmsg->eventID); twminfo("eventID: %u\n", eventmsg->eventID);
// Handle the event // Handle the event
@ -147,7 +147,7 @@ bool CWindowEvent::event(FAR struct SEventMsg *eventmsg)
void CWindowEvent::sendInputEvent(void) void CWindowEvent::sendInputEvent(void)
{ {
ginfo("Input...\n"); twminfo("Input...\n");
// The logic path here is tortuous but flexible: // The logic path here is tortuous but flexible:
// //
@ -192,7 +192,7 @@ void CWindowEvent::sendInputEvent(void)
sizeof(struct SNxEventMsg), 100); sizeof(struct SNxEventMsg), 100);
if (ret < 0) if (ret < 0)
{ {
gerr("ERROR: mq_send failed: %d\n", ret); twmerr("ERROR: mq_send failed: %d\n", ret);
} }
} }
@ -206,7 +206,7 @@ void CWindowEvent::sendInputEvent(void)
void CWindowEvent::handleRedrawEvent(FAR const nxgl_rect_s *nxRect, void CWindowEvent::handleRedrawEvent(FAR const nxgl_rect_s *nxRect,
bool more) bool more)
{ {
ginfo("backgound=%s\n", m_isBackground ? "YES" : "NO"); twminfo("backgound=%s\n", m_isBackground ? "YES" : "NO");
// At present, only the background window will get redraw events // At present, only the background window will get redraw events
@ -231,7 +231,7 @@ void CWindowEvent::handleRedrawEvent(FAR const nxgl_rect_s *nxRect,
sizeof(struct SRedrawEventMsg), 100); sizeof(struct SRedrawEventMsg), 100);
if (ret < 0) if (ret < 0)
{ {
gerr("ERROR: mq_send failed: %d\n", ret); twmerr("ERROR: mq_send failed: %d\n", ret);
} }
} }
} }
@ -243,7 +243,7 @@ void CWindowEvent::handleRedrawEvent(FAR const nxgl_rect_s *nxRect,
#ifdef CONFIG_NX_XYINPUT #ifdef CONFIG_NX_XYINPUT
void CWindowEvent::handleMouseEvent(void) void CWindowEvent::handleMouseEvent(void)
{ {
ginfo("Mouse input...\n"); twminfo("Mouse input...\n");
// Stimulate an input poll // Stimulate an input poll
@ -258,7 +258,7 @@ void CWindowEvent::handleMouseEvent(void)
void CWindowEvent::handleKeyboardEvent(void) void CWindowEvent::handleKeyboardEvent(void)
{ {
ginfo("Keyboard input...\n"); twminfo("Keyboard input...\n");
// Stimulate an input poll // Stimulate an input poll
@ -282,7 +282,7 @@ void CWindowEvent::handleKeyboardEvent(void)
void CWindowEvent::handleBlockedEvent(FAR void *arg) void CWindowEvent::handleBlockedEvent(FAR void *arg)
{ {
ginfo("Blocked...\n"); twminfo("Blocked...\n");
struct SNxEventMsg msg = struct SNxEventMsg msg =
{ {
@ -295,6 +295,6 @@ void CWindowEvent::handleBlockedEvent(FAR void *arg)
sizeof(struct SNxEventMsg), 100); sizeof(struct SNxEventMsg), 100);
if (ret < 0) if (ret < 0)
{ {
gerr("ERROR: mq_send failed: %d\n", ret); twmerr("ERROR: mq_send failed: %d\n", ret);
} }
} }

View File

@ -51,13 +51,13 @@
#include <cstdbool> #include <cstdbool>
#include <cassert> #include <cassert>
#include <mqueue.h> #include <mqueue.h>
#include <debug.h>
#include "graphics/nxwidgets/cwidgetcontrol.hxx" #include "graphics/nxwidgets/cwidgetcontrol.hxx"
#include "graphics/nxwidgets/cnxwindow.hxx" #include "graphics/nxwidgets/cnxwindow.hxx"
#include "graphics/nxwidgets/cnxtkwindow.hxx" #include "graphics/nxwidgets/cnxtkwindow.hxx"
#include "graphics/nxwidgets/cnxtoolbar.hxx" #include "graphics/nxwidgets/cnxtoolbar.hxx"
#include "graphics/twm4nx/twm4nx_config.hxx"
#include "graphics/twm4nx/ctwm4nx.hxx" #include "graphics/twm4nx/ctwm4nx.hxx"
#include "graphics/twm4nx/cwindow.hxx" #include "graphics/twm4nx/cwindow.hxx"
#include "graphics/twm4nx/cwindowfactory.hxx" #include "graphics/twm4nx/cwindowfactory.hxx"
@ -112,7 +112,7 @@ FAR CWindow *
bool isIconMgr, FAR CIconMgr *iconMgr, bool isIconMgr, FAR CIconMgr *iconMgr,
bool noToolbar) bool noToolbar)
{ {
ginfo("name=%p\n", name); twminfo("name=%p\n", name);
// Allocate a container for the Twm4NX window // Allocate a container for the Twm4NX window
@ -120,8 +120,8 @@ FAR CWindow *
(FAR struct SWindow *)std::zalloc(sizeof(struct SWindow)); (FAR struct SWindow *)std::zalloc(sizeof(struct SWindow));
if (win == (FAR struct SWindow *)0) if (win == (FAR struct SWindow *)0)
{ {
gerr("ERROR: Unable to allocate memory to manage window %s\n", twmerr("ERROR: Unable to allocate memory to manage window %s\n",
name); name);
return (FAR CWindow *)0; return (FAR CWindow *)0;
} }
@ -130,7 +130,7 @@ FAR CWindow *
win->cwin = new CWindow(m_twm4nx); win->cwin = new CWindow(m_twm4nx);
if (win->cwin == (FAR CWindow *)0) if (win->cwin == (FAR CWindow *)0)
{ {
gerr("ERROR: Failed to create CWindow\n"); twmerr("ERROR: Failed to create CWindow\n");
std::free(win); std::free(win);
return (FAR CWindow *)0; return (FAR CWindow *)0;
} }
@ -165,13 +165,13 @@ FAR CWindow *
winsize.h = displaySize.h - m_winpos.y - 16; winsize.h = displaySize.h - m_winpos.y - 16;
} }
ginfo("Position window at (%d,%d), size (%d,%d)\n", twminfo("Position window at (%d,%d), size (%d,%d)\n",
m_winpos.x, m_winpos.y, winsize.w, winsize.h); m_winpos.x, m_winpos.y, winsize.w, winsize.h);
if (!win->cwin->initialize(name, &m_winpos, &winsize, sbitmap, if (!win->cwin->initialize(name, &m_winpos, &winsize, sbitmap,
isIconMgr, iconMgr, noToolbar)) isIconMgr, iconMgr, noToolbar))
{ {
gerr("ERROR: Failed to initialize CWindow\n"); twmerr("ERROR: Failed to initialize CWindow\n");
delete win->cwin; delete win->cwin;
std::free(win); std::free(win);
return (FAR CWindow *)0; return (FAR CWindow *)0;
@ -222,7 +222,7 @@ void CWindowFactory::destroyWindow(FAR CWindow *cwin)
{ {
// This should not happen.. worthy of an assertion // This should not happen.. worthy of an assertion
gerr("ERROR: Failed to find CWindow container\n"); twmerr("ERROR: Failed to find CWindow container\n");
} }
else else
{ {

View File

@ -42,6 +42,7 @@
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
#include <nuttx/config.h> #include <nuttx/config.h>
#include <debug.h>
#include "graphics/nxglyphs.hxx" #include "graphics/nxglyphs.hxx"
#include "graphics/nxwidgets/nxconfig.hxx" #include "graphics/nxwidgets/nxconfig.hxx"
@ -51,6 +52,18 @@
// Pre-Processor Definitions // Pre-Processor Definitions
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// Debug ////////////////////////////////////////////////////////////////////
#ifdef CONFIG_TWM4NX_DEBUG
# define twminfo(format, ...) _info(format, ##__VA_ARGS__)
# define twmwarn(format, ...) _warn(format, ##__VA_ARGS__)
# define twmerr(format, ...) _err(format, ##__VA_ARGS__)
#else
# define twminfo(format, ...) ginfo(format, ##__VA_ARGS__)
# define twmwarn(format, ...) gwarn(format, ##__VA_ARGS__)
# define twmerr(format, ...) gerr(format, ##__VA_ARGS__)
#endif
// General Configuration //////////////////////////////////////////////////// // General Configuration ////////////////////////////////////////////////////
/** /**

View File

@ -53,7 +53,8 @@
// Preprocessor Definitions // Preprocessor Definitions
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
#define MAX_EVENT_PAYLOAD (64 - sizeof(uint16_t)) #define MAX_EVENT_MSGSIZE sizeof(struct SEventMsg)
#define MAX_EVENT_PAYLOAD (MAX_EVENT_MSGSIZE - sizeof(uint16_t))
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// WidgetEvent // WidgetEvent