More NxWM touchscreen fixes

git-svn-id: https://nuttx.svn.sourceforge.net/svnroot/nuttx/trunk@4719 7fd9a85b-ad96-42d3-883c-3090e2eb8679
This commit is contained in:
patacongo 2012-05-10 01:35:23 +00:00
parent 5df98379f4
commit 6e9e0c640b
5 changed files with 70 additions and 43 deletions

View File

@ -197,6 +197,35 @@ static void initMemoryUsage(void)
g_nxwmtest.mmSubStep = mmcurrent.uordblks;
}
/////////////////////////////////////////////////////////////////////////////
// Name: cleanup
/////////////////////////////////////////////////////////////////////////////
static void test_cleanup(void)
{
#ifdef CONFIG_NXWM_TOUCHSCREEN
if (g_nxwmtest.touchscreen)
{
delete g_nxwmtest.touchscreen;
}
#endif
// Delete the task bar then the start window. the order is important because
// we must bet all of the application references out of the task bar before
// deleting the start window. When the start window is deleted, it will
// also delete of of the resouces contained within the start window.
if (g_nxwmtest.taskbar)
{
delete g_nxwmtest.taskbar;
}
if (g_nxwmtest.startwindow)
{
delete g_nxwmtest.startwindow;
}
}
/////////////////////////////////////////////////////////////////////////////
// Public Functions
/////////////////////////////////////////////////////////////////////////////
@ -270,7 +299,7 @@ int MAIN_NAME(int argc, char *argv[])
if (!g_nxwmtest.taskbar->connect())
{
printf(MAIN_STRING "ERROR: Failed to connect the CTaskbar instance to the NX server\n");
delete g_nxwmtest.taskbar;
test_cleanup();
return EXIT_FAILURE;
}
showTestCaseMemory("After connecting to the server");
@ -285,7 +314,7 @@ int MAIN_NAME(int argc, char *argv[])
if (!g_nxwmtest.taskbar->initWindowManager())
{
printf(MAIN_STRING "ERROR: Failed to intialize the CTaskbar instance\n");
delete g_nxwmtest.taskbar;
test_cleanup();
return EXIT_FAILURE;
}
showTestCaseMemory("After initializing window manager");
@ -304,7 +333,7 @@ int MAIN_NAME(int argc, char *argv[])
if (!window)
{
printf(MAIN_STRING "ERROR: Failed to create CApplicationWindow for the start window\n");
delete g_nxwmtest.taskbar;
test_cleanup();
return EXIT_FAILURE;
}
showTestCaseMemory("After creating start window application window");
@ -314,7 +343,7 @@ int MAIN_NAME(int argc, char *argv[])
{
printf(MAIN_STRING "ERROR: Failed to open the CApplicationWindow \n");
delete window;
delete g_nxwmtest.taskbar;
test_cleanup();
return EXIT_FAILURE;
}
showTestCaseMemory("After initializing the start window application window");
@ -325,13 +354,26 @@ int MAIN_NAME(int argc, char *argv[])
{
printf(MAIN_STRING "ERROR: Failed to instantiate CStartWindow\n");
delete window;
delete g_nxwmtest.taskbar;
test_cleanup();
return EXIT_FAILURE;
}
showTestCaseMemory("After create the start window application");
// Perform touchscreen calibration
#if 0 // defined(CONFIG_NXWM_TOUCHSCREEN) -- Not ready for prime time
#ifdef CONFIG_NXWM_TOUCHSCREEN
// Start the window manager before adding applications
printf(MAIN_STRING "Start the window manager\n");
if (!g_nxwmtest.taskbar->startWindowManager())
{
printf(MAIN_STRING "ERROR: Failed to start the window manager\n");
test_cleanup();
return EXIT_FAILURE;
}
showTestCaseMemory("After starting the window manager");
// Perform touchscreen calibration
NxWM::CCalibration *calibration = (NxWM::CCalibration *)0; // Avoid compiler complaint
NxWM::CFullScreenWindow *fullscreen = (NxWM::CFullScreenWindow *)0; // Avoid compiler complaint
@ -340,7 +382,7 @@ int MAIN_NAME(int argc, char *argv[])
printf(MAIN_STRING "Creating CTouchscreen\n");
g_nxwmtest.touchscreen = new NxWM::CTouchscreen;
if (!touchscreen)
if (!g_nxwmtest.touchscreen)
{
printf(MAIN_STRING "ERROR: Failed to create CTouchscreen\n");
goto nocalibration;
@ -395,7 +437,7 @@ int MAIN_NAME(int argc, char *argv[])
if (!g_nxwmtest.startwindow->addApplication(calibration))
{
printf(MAIN_STRING "ERROR: Failed to add CCalibration to the start window\n");
delete fullscreen;
delete calibration;
goto nocalibration;
}
showTestCaseMemory("After adding the CCalibration application");
@ -406,11 +448,19 @@ int MAIN_NAME(int argc, char *argv[])
if (!g_nxwmtest.taskbar->startApplication(calibration, false))
{
printf(MAIN_STRING "ERROR: Failed to start the calibration application\n");
delete fullscreen;
goto nocalibration;
}
showTestCaseMemory("After starting the start window application");
// Wait for calibration data
printf(MAIN_STRING "Get calibration data\n");
struct NxWM::SCalibrationData data;
if (!calibration->waitCalibrationData(data))
{
printf(MAIN_STRING "ERROR: Failed to get calibration data\n");
}
nocalibration:
#endif
@ -432,8 +482,7 @@ nocalibration:
{
printf(MAIN_STRING "ERROR: Failed to open the CApplicationWindow \n");
delete window;
delete g_nxwmtest.taskbar;
return EXIT_FAILURE;
goto noconsole;
}
showTestCaseMemory("After initializing the NxConsole application window");
@ -476,7 +525,7 @@ noconsole:
{
printf(MAIN_STRING "ERROR: Failed to open the CApplicationWindow \n");
delete window;
delete g_nxwmtest.taskbar;
test_cleanup();
return EXIT_FAILURE;
}
showTestCaseMemory("After creating the initializing application window");
@ -509,35 +558,23 @@ nocalculator:
if (!g_nxwmtest.taskbar->startApplication(g_nxwmtest.startwindow, true))
{
printf(MAIN_STRING "ERROR: Failed to start the start window application\n");
// Delete the task bar then the start window. the order is important because
// we must bet all of the application references out of the task bar before
// deleting the start window. When the start window is deleted, it will
// also delete of of the resouces contained within the start window.
delete g_nxwmtest.taskbar;
delete g_nxwmtest.startwindow;
test_cleanup();
return EXIT_FAILURE;
}
showTestCaseMemory("After starting the start window application");
// Call CTaskBar::startWindowManager to start the display with applications in place.
#ifndef CONFIG_NXWM_TOUCHSCREEN
printf(MAIN_STRING "Start the window manager\n");
if (!g_nxwmtest.taskbar->startWindowManager())
{
printf(MAIN_STRING "ERROR: Failed to start the window manager\n");
// Delete the task bar then the start window. the order is important because
// we must bet all of the application references out of the task bar before
// deleting the start window. When the start window is deleted, it will
// also delete of of the resouces contained within the start window.
delete g_nxwmtest.taskbar;
delete g_nxwmtest.startwindow;
test_cleanup();
return EXIT_FAILURE;
}
showTestCaseMemory("After starting the window manager");
#endif
// Wait a little bit for the display to stabilize. The simulation pressing of
// the 'start window' icon in the task bar

View File

@ -89,7 +89,7 @@ namespace NxWM
* callibration data.
*/
class CCalibration : public IApplication, private NXWidgets::CWidgetEventHandler
class CCalibration : public IApplication
{
private:
/**
@ -146,14 +146,6 @@ namespace NxWM
void stateMachine(void);
/**
* Handle a mouse button click event.
*
* @param e The event data.
*/
void handleClickEvent(const NXWidgets::CWidgetEventArgs &e);
/**
* Presents the next calibration screen
*/

View File

@ -45,9 +45,6 @@
#include <semaphore.h>
#include <nuttx/input/touchscreen.h>
#include "cwidgeteventhandler.hxx"
#include "iapplication.hxx"
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
@ -63,7 +60,7 @@ namespace NxWM
* callibration data.
*/
class CTouchscreen : public IApplication, private NXWidgets::CWidgetEventHandler
class CTouchscreen
{
private:
int m_touchFd; /**< File descriptor of the opened touchscreen device */

View File

@ -156,7 +156,7 @@ bool CCalibration::run(void)
// Loop until calibration completes
while (!m_stop)
while (!m_stop && m_state != CALIB_COMPLETE)
{
// Wait for the next raw touchscreen input

View File

@ -55,6 +55,7 @@
#include <nuttx/kmalloc.h>
#include <nuttx/arch.h>
#include <nuttx/fs/fs.h>
#include <nuttx/nx/nx.h>
#include <nuttx/input/touchscreen.h>