summaryrefslogtreecommitdiffstats
path: root/NxWidgets
diff options
context:
space:
mode:
authorpatacongo <patacongo@7fd9a85b-ad96-42d3-883c-3090e2eb8679>2012-05-18 23:08:34 +0000
committerpatacongo <patacongo@7fd9a85b-ad96-42d3-883c-3090e2eb8679>2012-05-18 23:08:34 +0000
commit3f31a6667c712f2bde22eb0ca6e05c7b96964124 (patch)
tree8c305f903a5334c3b7b2a48830c6f63199dedfda /NxWidgets
parent1f8818931f451fa064aeb3a3b530aa3ea830a610 (diff)
Final refactoring and implementation of delayed window deletion logic. Works worse now, but the changes are important and need to be checked in now
git-svn-id: https://nuttx.svn.sourceforge.net/svnroot/nuttx/trunk@4747 7fd9a85b-ad96-42d3-883c-3090e2eb8679
Diffstat (limited to 'NxWidgets')
-rw-r--r--NxWidgets/UnitTests/nxwm/main.cxx52
-rw-r--r--NxWidgets/libnxwidgets/include/ibitmap.hxx9
-rw-r--r--NxWidgets/libnxwidgets/include/ilistbox.hxx8
-rw-r--r--NxWidgets/libnxwidgets/include/ilistdataeventhandler.hxx9
-rw-r--r--NxWidgets/libnxwidgets/include/inxwindow.hxx8
-rw-r--r--NxWidgets/libnxwidgets/include/iscrollable.hxx9
-rw-r--r--NxWidgets/libnxwidgets/include/islider.hxx8
-rw-r--r--NxWidgets/libnxwidgets/include/itextbox.hxx8
-rw-r--r--NxWidgets/libnxwidgets/src/ccallback.cxx2
-rw-r--r--NxWidgets/libnxwidgets/src/cnxwindow.cxx2
-rw-r--r--NxWidgets/nxwm/Makefile12
-rw-r--r--NxWidgets/nxwm/doc/NxWM-ThreadingModel.pptbin92672 -> 126464 bytes
-rw-r--r--NxWidgets/nxwm/include/capplicationwindow.hxx30
-rw-r--r--NxWidgets/nxwm/include/ccalibration.hxx13
-rw-r--r--NxWidgets/nxwm/include/cfullscreenwindow.hxx30
-rw-r--r--NxWidgets/nxwm/include/cnxconsole.hxx21
-rw-r--r--NxWidgets/nxwm/include/cstartwindow.hxx56
-rw-r--r--NxWidgets/nxwm/include/ctaskbar.hxx37
-rw-r--r--NxWidgets/nxwm/include/cwindowmessenger.hxx (renamed from NxWidgets/nxwm/include/cwindowcontrol.hxx)27
-rw-r--r--NxWidgets/nxwm/include/iapplication.hxx29
-rw-r--r--NxWidgets/nxwm/include/iapplicationwindow.hxx41
-rw-r--r--NxWidgets/nxwm/include/nxwmconfig.hxx2
-rw-r--r--NxWidgets/nxwm/src/capplicationwindow.cxx73
-rw-r--r--NxWidgets/nxwm/src/ccalibration.cxx30
-rw-r--r--NxWidgets/nxwm/src/cfullscreenwindow.cxx40
-rw-r--r--NxWidgets/nxwm/src/cnxconsole.cxx37
-rw-r--r--NxWidgets/nxwm/src/cstartwindow.cxx90
-rw-r--r--NxWidgets/nxwm/src/ctaskbar.cxx100
-rw-r--r--NxWidgets/nxwm/src/cwindowmessenger.cxx (renamed from NxWidgets/nxwm/src/cwindowcontrol.cxx)43
29 files changed, 602 insertions, 224 deletions
diff --git a/NxWidgets/UnitTests/nxwm/main.cxx b/NxWidgets/UnitTests/nxwm/main.cxx
index 6a2e952d85..86ea324d5d 100644
--- a/NxWidgets/UnitTests/nxwm/main.cxx
+++ b/NxWidgets/UnitTests/nxwm/main.cxx
@@ -46,10 +46,13 @@
#include "ctaskbar.hxx"
#include "cstartwindow.hxx"
-#include "ctouchscreen.hxx"
-#include "ccalibration.hxx"
#include "cnxconsole.hxx"
+#ifdef CONFIG_NXWM_TOUCHSCREEN
+# include "ctouchscreen.hxx"
+# include "ccalibration.hxx"
+#endif
+
/////////////////////////////////////////////////////////////////////////////
// Pre-processor Definitions
/////////////////////////////////////////////////////////////////////////////
@@ -67,10 +70,19 @@
#ifdef CONFIG_HAVE_FILENAME
# define showTestStepMemory(msg) \
_showTestStepMemory((FAR const char*)__FILE__, (int)__LINE__, msg)
-# define showTestCaseMemory(msg) \
- _showTestCaseMemory((FAR const char*)__FILE__, (int)__LINE__, msg)
-# define showTestMemory(msg) \
- _showTestMemory((FAR const char*)__FILE__, (int)__LINE__, msg)
+#endif
+
+#ifdef CONFIG_NXWIDGET_MEMMONITOR
+# ifdef CONFIG_HAVE_FILENAME
+# define showTestCaseMemory(msg) \
+ _showTestCaseMemory((FAR const char*)__FILE__, (int)__LINE__, msg)
+# define showTestMemory(msg) \
+ _showTestMemory((FAR const char*)__FILE__, (int)__LINE__, msg)
+# endif
+#else
+# define initMemoryUsage()
+# define showTestCaseMemory(msg)
+# define showTestMemory(msg)
#endif
/////////////////////////////////////////////////////////////////////////////
@@ -85,9 +97,11 @@ struct SNxWmTest
NxWM::CTouchscreen *touchscreen; // The touchscreen
struct NxWM::SCalibrationData calibData; // Calibration data
#endif
+#ifdef CONFIG_NXWIDGET_MEMMONITOR
unsigned int mmInitial; // Initial memory usage
unsigned int mmStep; // Memory Usage at beginning of test step
unsigned int mmSubStep; // Memory Usage at beginning of test sub-step
+#endif
};
/////////////////////////////////////////////////////////////////////////////
@@ -112,6 +126,7 @@ extern "C" int MAIN_NAME(int argc, char *argv[]);
// Name: updateMemoryUsage
/////////////////////////////////////////////////////////////////////////////
+#ifdef CONFIG_NXWIDGET_MEMMONITOR
#ifdef CONFIG_HAVE_FILENAME
static void updateMemoryUsage(unsigned int *previous,
FAR const char *file, int line,
@@ -145,11 +160,13 @@ static void updateMemoryUsage(unsigned int *previous,
*previous = mmcurrent.uordblks;
}
+#endif
/////////////////////////////////////////////////////////////////////////////
// Name: showTestCaseMemory
/////////////////////////////////////////////////////////////////////////////
+#ifdef CONFIG_NXWIDGET_MEMMONITOR
#ifdef CONFIG_HAVE_FILENAME
static void _showTestCaseMemory(FAR const char *file, int line, FAR const char *msg)
{
@@ -163,11 +180,13 @@ static void showTestCaseMemory(FAR const char *msg)
g_nxwmtest.mmSubStep = g_nxwmtest.mmInitial;
}
#endif
+#endif
/////////////////////////////////////////////////////////////////////////////
// Name: showTestMemory
/////////////////////////////////////////////////////////////////////////////
+#ifdef CONFIG_NXWIDGET_MEMMONITOR
#ifdef CONFIG_HAVE_FILENAME
static void _showTestMemory(FAR const char *file, int line, FAR const char *msg)
{
@@ -179,11 +198,13 @@ static void showTestMemory(FAR const char *msg)
updateMemoryUsage(&g_nxwmtest.mmInitial, msg);
}
#endif
+#endif
/////////////////////////////////////////////////////////////////////////////
// Name: initMemoryUsage
/////////////////////////////////////////////////////////////////////////////
+#ifdef CONFIG_NXWIDGET_MEMMONITOR
static void initMemoryUsage(void)
{
struct mallinfo mmcurrent;
@@ -198,6 +219,7 @@ static void initMemoryUsage(void)
g_nxwmtest.mmStep = mmcurrent.uordblks;
g_nxwmtest.mmSubStep = mmcurrent.uordblks;
}
+#endif
/////////////////////////////////////////////////////////////////////////////
// Name: cleanup
@@ -361,7 +383,7 @@ static bool startWindowManager(void)
return false;
}
- showTestCaseMemory("AstartWindowManager: fter starting the window manager");
+ showTestCaseMemory("startWindowManager: After starting the window manager");
return true;
}
@@ -497,12 +519,16 @@ static bool createNxConsole(void)
#ifdef CONFIG_HAVE_FILENAME
void _showTestStepMemory(FAR const char *file, int line, FAR const char *msg)
{
+#ifdef CONFIG_NXWIDGET_MEMMONITOR
updateMemoryUsage(&g_nxwmtest.mmSubStep, file, line, msg);
+#endif
}
#else
void showTestStepMemory(FAR const char *msg)
{
+#ifdef CONFIG_NXWIDGET_MEMMONITOR
updateMemoryUsage(&g_nxwmtest.mmSubStep, msg);
+#endif
}
#endif
@@ -608,19 +634,23 @@ int MAIN_NAME(int argc, char *argv[])
}
#endif
- // Wait a little bit for the display to stabilize. The simulation pressing of
+ // Wait a little bit for the display to stabilize. Then simulate pressing of
// the 'start window' icon in the task bar
#ifndef CONFIG_NXWM_TOUCHSCREEN
sleep(2);
- g_nxwmtest.taskbar->clickIcon(0);
+ g_nxwmtest.taskbar->clickIcon(0, true);
+ usleep(500*1000);
+ g_nxwmtest.taskbar->clickIcon(0, false);
showTestCaseMemory(MAIN_STRING "After clicking the start window icon");
- // Wait bit to see the result of the button press. The press the first icon
+ // Wait bit to see the result of the button press. Then press the first icon
// in the start menu. That should be the NxConsole icon.
sleep(2);
- g_nxwmtest.startwindow->clickIcon(0);
+ g_nxwmtest.startwindow->clickIcon(0, true);
+ usleep(500*1000);
+ g_nxwmtest.startwindow->clickIcon(0, false);
showTestCaseMemory(MAIN_STRING "After clicking the NxConsole icon");
#endif
diff --git a/NxWidgets/libnxwidgets/include/ibitmap.hxx b/NxWidgets/libnxwidgets/include/ibitmap.hxx
index 5eaa5b3c95..923df407a8 100644
--- a/NxWidgets/libnxwidgets/include/ibitmap.hxx
+++ b/NxWidgets/libnxwidgets/include/ibitmap.hxx
@@ -103,6 +103,15 @@ namespace NXWidgets
{
public:
/**
+ * A virtual destructor is required in order to override the IBitmap
+ * destructor. We do this because if we delete IBitmap, we want the
+ * destructor of the class that inherits from IBitmap to run, not this
+ * one.
+ */
+
+ virtual ~IBitmap(void) { }
+
+ /**
* Get the bitmap's color format.
*
* @return The bitmap's width.
diff --git a/NxWidgets/libnxwidgets/include/ilistbox.hxx b/NxWidgets/libnxwidgets/include/ilistbox.hxx
index 9184f23c81..0eb33bc3b4 100644
--- a/NxWidgets/libnxwidgets/include/ilistbox.hxx
+++ b/NxWidgets/libnxwidgets/include/ilistbox.hxx
@@ -102,6 +102,14 @@ namespace NXWidgets
class IListBox
{
public:
+ /**
+ * A virtual destructor is required in order to override the IListBox
+ * destructor. We do this because if we delete IListBox, we want the
+ * destructor of the class that inherits from IListBox to run, not this
+ * one.
+ */
+
+ virtual ~IListBox(void) { }
/**
* Add a new option to the widget using default colors.
diff --git a/NxWidgets/libnxwidgets/include/ilistdataeventhandler.hxx b/NxWidgets/libnxwidgets/include/ilistdataeventhandler.hxx
index b6119a2ae2..26bf1411b0 100644
--- a/NxWidgets/libnxwidgets/include/ilistdataeventhandler.hxx
+++ b/NxWidgets/libnxwidgets/include/ilistdataeventhandler.hxx
@@ -104,6 +104,15 @@ namespace NXWidgets
{
public:
/**
+ * A virtual destructor is required in order to override the IListDataEventHandler
+ * destructor. We do this because if we delete IListDataEventHandler, we want the
+ * destructor of the class that inherits from IListDataEventHandler to run, not this
+ * one.
+ */
+
+ virtual ~IListDataEventHandler(void) { }
+
+ /**
* Handle data changes.
*
* @param e Event arguments.
diff --git a/NxWidgets/libnxwidgets/include/inxwindow.hxx b/NxWidgets/libnxwidgets/include/inxwindow.hxx
index c38052de02..750994a71b 100644
--- a/NxWidgets/libnxwidgets/include/inxwindow.hxx
+++ b/NxWidgets/libnxwidgets/include/inxwindow.hxx
@@ -79,6 +79,14 @@ namespace NXWidgets
class INxWindow
{
public:
+ /**
+ * A virtual destructor is required in order to override the INxWindow
+ * destructor. We do this because if we delete INxWindow, we want the
+ * destructor of the class that inherits from INxWindow to run, not this
+ * one.
+ */
+
+ virtual ~INxWindow(void) { }
/**
* Creates a new window. Window creation is separate from
diff --git a/NxWidgets/libnxwidgets/include/iscrollable.hxx b/NxWidgets/libnxwidgets/include/iscrollable.hxx
index 21a69e487e..b0e65a9dbc 100644
--- a/NxWidgets/libnxwidgets/include/iscrollable.hxx
+++ b/NxWidgets/libnxwidgets/include/iscrollable.hxx
@@ -103,6 +103,15 @@ namespace NXWidgets
{
public:
/**
+ * A virtual destructor is required in order to override the IScrollable
+ * destructor. We do this because if we delete IScrollable, we want the
+ * destructor of the class that inherits from IScrollable to run, not this
+ * one.
+ */
+
+ virtual ~IScrollable(void) { }
+
+ /**
* Gets the x coordinate of the virtual canvas.
*
* @return The x coordinate of the virtual canvas.
diff --git a/NxWidgets/libnxwidgets/include/islider.hxx b/NxWidgets/libnxwidgets/include/islider.hxx
index 5ea821e427..5a93409230 100644
--- a/NxWidgets/libnxwidgets/include/islider.hxx
+++ b/NxWidgets/libnxwidgets/include/islider.hxx
@@ -99,6 +99,14 @@ namespace NXWidgets
class ISlider
{
public:
+ /**
+ * A virtual destructor is required in order to override the ISlider
+ * destructor. We do this because if we delete ISlider, we want the
+ * destructor of the class that inherits from ISlider to run, not this
+ * one.
+ */
+
+ virtual ~ISlider(void) { }
/**
* Get the smallest value that the slider can represent.
diff --git a/NxWidgets/libnxwidgets/include/itextbox.hxx b/NxWidgets/libnxwidgets/include/itextbox.hxx
index 78de7e5029..0e2e7b824e 100644
--- a/NxWidgets/libnxwidgets/include/itextbox.hxx
+++ b/NxWidgets/libnxwidgets/include/itextbox.hxx
@@ -115,6 +115,14 @@ namespace NXWidgets
class ITextBox
{
public:
+ /**
+ * A virtual destructor is required in order to override the ITextBox
+ * destructor. We do this because if we delete ITextBox, we want the
+ * destructor of the class that inherits from ITextBox to run, not this
+ * one.
+ */
+
+ virtual ~ITextBox(void) { }
/**
* Sets the cursor display mode.
diff --git a/NxWidgets/libnxwidgets/src/ccallback.cxx b/NxWidgets/libnxwidgets/src/ccallback.cxx
index 09dc53a5aa..32c5b7d642 100644
--- a/NxWidgets/libnxwidgets/src/ccallback.cxx
+++ b/NxWidgets/libnxwidgets/src/ccallback.cxx
@@ -36,7 +36,7 @@
/****************************************************************************
* Included Files
****************************************************************************/
-
+
#include <nuttx/config.h>
#include <sys/types.h>
diff --git a/NxWidgets/libnxwidgets/src/cnxwindow.cxx b/NxWidgets/libnxwidgets/src/cnxwindow.cxx
index 5993359721..5ba4d734c4 100644
--- a/NxWidgets/libnxwidgets/src/cnxwindow.cxx
+++ b/NxWidgets/libnxwidgets/src/cnxwindow.cxx
@@ -36,7 +36,7 @@
/****************************************************************************
* Included Files
****************************************************************************/
-
+
#include <nuttx/config.h>
#include <stdint.h>
diff --git a/NxWidgets/nxwm/Makefile b/NxWidgets/nxwm/Makefile
index d951d11b26..b0b33c73d5 100644
--- a/NxWidgets/nxwm/Makefile
+++ b/NxWidgets/nxwm/Makefile
@@ -41,10 +41,16 @@ NXWIDGETDIR := $(NXWMDIR)/../libnxwidgets
ASRCS =
CSRCS =
+
+
# Window Manager
-CXXSRCS = capplicationwindow.cxx ccalibration.cxx cfullscreenwindow.cxx
-CXXSRCS += cnxconsole.cxx cstartwindow.cxx ctaskbar.cxx ctouchscreen.cxx
-CXXSRCS += cwindowcontrol.cxx
+CXXSRCS = capplicationwindow.cxx cfullscreenwindow.cxx cnxconsole.cxx
+CXXSRCS += cstartwindow.cxx ctaskbar.cxx cwindowmessenger.cxx
+
+ifeq ($(CONFIG_NXWM_TOUCHSCREEN),y)
+CXXSRCS += ccalibration.cxx ctouchscreen.cxx
+endif
+
# Images
CXXSRCS += glyph_calibration.cxx glyph_cmd.cxx glyph_minimize.cxx glyph_nsh.cxx
CXXSRCS += glyph_play.cxx glyph_start.cxx glyph_stop.cxx
diff --git a/NxWidgets/nxwm/doc/NxWM-ThreadingModel.ppt b/NxWidgets/nxwm/doc/NxWM-ThreadingModel.ppt
index 382f69dd84..b532eaa659 100644
--- a/NxWidgets/nxwm/doc/NxWM-ThreadingModel.ppt
+++ b/NxWidgets/nxwm/doc/NxWM-ThreadingModel.ppt
Binary files differ
diff --git a/NxWidgets/nxwm/include/capplicationwindow.hxx b/NxWidgets/nxwm/include/capplicationwindow.hxx
index f923f28b48..686150d144 100644
--- a/NxWidgets/nxwm/include/capplicationwindow.hxx
+++ b/NxWidgets/nxwm/include/capplicationwindow.hxx
@@ -44,6 +44,7 @@
#include "cnxtkwindow.hxx"
#include "cnxtoolbar.hxx"
+#include "cwidgetcontrol.hxx"
#include "cwidgeteventargs.hxx"
#include "cwidgeteventhandler.hxx"
#include "cimage.hxx"
@@ -151,12 +152,19 @@ namespace NxWM
NXWidgets::INxWindow *getWindow(void) const;
/**
- * Recover the contained window control
+ * Recover the contained widget control
*
- * @return. The window control used by this application
+ * @return. The widget control used by this application
*/
- CWindowControl *getWindowControl(void) const ;
+ NXWidgets::CWidgetControl *getWidgetControl(void) const;
+
+ /**
+ * Block further activity on this window in preparation for window
+ * shutdown.
+ */
+
+ void block(void);
/**
* Set the window label
@@ -195,21 +203,25 @@ namespace NxWM
}
/**
- * Simulate a mouse click on the minimize icon. This inline method is only
- * used during automated testing of NxWM.
+ * Simulate a mouse click or release on the minimize icon. This method
+ * is only available for automated testing of NxWM.
+ *
+ * @param click. True to click; false to release;
*/
#if defined(CONFIG_NXWM_UNITTEST) && !defined(CONFIG_NXWM_TOUCHSCREEN)
- void clickMinimizeIcon(int index);
+ void clickMinimizePosition(bool click);
#endif
/**
- * Simulate a mouse click on the stop applicaiton icon. This inline method is only
- * used during automated testing of NxWM.
+ * Simulate a mouse click or release on the stop icon. This method
+ * is only available for automated testing of NxWM.
+ *
+ * @param click. True to click; false to release;
*/
#if defined(CONFIG_NXWM_UNITTEST) && !defined(CONFIG_NXWM_TOUCHSCREEN)
- void clickStopIcon(int index);
+ void clickStopIcon(bool click);
#endif
};
}
diff --git a/NxWidgets/nxwm/include/ccalibration.hxx b/NxWidgets/nxwm/include/ccalibration.hxx
index 55cef6d848..e9b5d400f3 100644
--- a/NxWidgets/nxwm/include/ccalibration.hxx
+++ b/NxWidgets/nxwm/include/ccalibration.hxx
@@ -52,6 +52,7 @@
#include "ctaskbar.hxx"
#include "iapplication.hxx"
#include "cfullscreenwindow.hxx"
+#include "cwindowmessenger.hxx"
/****************************************************************************
* Pre-processor Definitions
@@ -143,6 +144,7 @@ namespace NxWM
* CCalibration state data
*/
+ CWindowMessenger m_messenger; /**< Window event handler/messenger */
CTaskbar *m_taskbar; /**< The taskbar (used to terminate calibration) */
CFullScreenWindow *m_window; /**< The window for the calibration display */
CTouchscreen *m_touchscreen; /**< The touchscreen device */
@@ -290,6 +292,17 @@ namespace NxWM
void stop(void);
/**
+ * Destroy the application and free all of its resources. This method
+ * will initiate blocking of messages from the NX server. The server
+ * will flush the window message queue and reply with the blocked
+ * message. When the block message is received by CWindowMessenger,
+ * it will send the destroy message to the start window task which
+ * will, finally, safely delete the application.
+ */
+
+ void destroy(void);
+
+ /**
* The application window is hidden (either it is minimized or it is
* maximized, but not at the top of the hierarchy
*/
diff --git a/NxWidgets/nxwm/include/cfullscreenwindow.hxx b/NxWidgets/nxwm/include/cfullscreenwindow.hxx
index 2e3fbd45d5..1bab37543f 100644
--- a/NxWidgets/nxwm/include/cfullscreenwindow.hxx
+++ b/NxWidgets/nxwm/include/cfullscreenwindow.hxx
@@ -43,6 +43,7 @@
#include <nuttx/config.h>
#include "cnxwindow.hxx"
+#include "cwidgetcontrol.hxx"
#include "iapplicationwindow.hxx"
@@ -115,12 +116,19 @@ namespace NxWM
NXWidgets::INxWindow *getWindow(void) const;
/**
- * Recover the contained window control
+ * Recover the contained widget control
*
- * @return. The window control used by this application
+ * @return. The widget control used by this application
*/
- CWindowControl *getWindowControl(void) const;
+ NXWidgets::CWidgetControl *getWidgetControl(void) const;
+
+ /**
+ * Block further activity on this window in preparation for window
+ * shutdown.
+ */
+
+ void block(void);
/**
* Set the window label
@@ -147,21 +155,25 @@ namespace NxWM
void registerCallbacks(IApplicationCallback *callback);
/**
- * Simulate a mouse click on the minimize icon. This inline method is only
- * used during automated testing of NxWM.
+ * Simulate a mouse click or release on the minimize icon. This method
+ * is only available for automated testing of NxWM.
+ *
+ * @param click. True to click; false to release;
*/
#if defined(CONFIG_NXWM_UNITTEST) && !defined(CONFIG_NXWM_TOUCHSCREEN)
- void clickMinimizeIcon(int index);
+ void clickMinimizePosition(bool click);
#endif
/**
- * Simulate a mouse click on the stop applicaiton icon. This inline method is only
- * used during automated testing of NxWM.
+ * Simulate a mouse click or release on the stop icon. This method
+ * is only available for automated testing of NxWM.
+ *
+ * @param click. True to click; false to release;
*/
#if defined(CONFIG_NXWM_UNITTEST) && !defined(CONFIG_NXWM_TOUCHSCREEN)
- void clickStopIcon(int index);
+ void clickStopIcon(bool click);
#endif
};
}
diff --git a/NxWidgets/nxwm/include/cnxconsole.hxx b/NxWidgets/nxwm/include/cnxconsole.hxx
index b95c86406c..bf3606f053 100644
--- a/NxWidgets/nxwm/include/cnxconsole.hxx
+++ b/NxWidgets/nxwm/include/cnxconsole.hxx
@@ -49,6 +49,7 @@
#include "iapplication.hxx"
#include "capplicationwindow.hxx"
#include "ctaskbar.hxx"
+#include "cwindowmessenger.hxx"
/****************************************************************************
* Pre-Processor Definitions
@@ -78,10 +79,11 @@ namespace NxWM
class CNxConsole : public IApplication, private IApplicationCallback
{
private:
- CTaskbar *m_taskbar; /**< Reference to the "parent" taskbar */
- CApplicationWindow *m_window; /**< Reference to the application window */
- NXCONSOLE m_nxcon; /**< NxConsole handle */
- pid_t m_pid; /**< Task ID of the NxConsole thread */
+ CWindowMessenger m_messenger; /**< Window event handler/messenger */
+ CTaskbar *m_taskbar; /**< Reference to the "parent" taskbar */
+ CApplicationWindow *m_window; /**< Reference to the application window */
+ NXCONSOLE m_nxcon; /**< NxConsole handle */
+ pid_t m_pid; /**< Task ID of the NxConsole thread */
/**
* This is the NxConsole task. This function first redirects output to the
@@ -167,6 +169,17 @@ namespace NxWM
void stop(void);
/**
+ * Destroy the application and free all of its resources. This method
+ * will initiate blocking of messages from the NX server. The server
+ * will flush the window message queue and reply with the blocked
+ * message. When the block message is received by CWindowMessenger,
+ * it will send the destroy message to the start window task which
+ * will, finally, safely delete the application.
+ */
+
+ void destroy(void);
+
+ /**
* The application window is hidden (either it is minimized or it is
* maximized, but not at the top of the hierarchy
*/
diff --git a/NxWidgets/nxwm/include/cstartwindow.hxx b/NxWidgets/nxwm/include/cstartwindow.hxx
index 8b5fd92d36..3a5325cb75 100644
--- a/NxWidgets/nxwm/include/cstartwindow.hxx
+++ b/NxWidgets/nxwm/include/cstartwindow.hxx
@@ -48,6 +48,7 @@
#include "iapplication.hxx"
#include "capplicationwindow.hxx"
+#include "cwindowmessenger.hxx"
/****************************************************************************
* Pre-Processor Definitions
@@ -115,11 +116,12 @@ namespace NxWM
* CStartWindow state data
*/
- CTaskbar *m_taskbar; /**< Reference to the "parent" taskbar */
- CApplicationWindow *m_window; /**< Reference to the application window */
- TNxArray<struct SStartWindowSlot> m_slots; /**< List of apps in the start window */
- struct nxgl_size_s m_iconSize; /**< A box big enough to hold the largest icon */
- pid_t m_taskId; /**< ID of the start window task */
+ CWindowMessenger m_messenger; /**< Window event handler/messenger */
+ CTaskbar *m_taskbar; /**< Reference to the "parent" taskbar */
+ CApplicationWindow *m_window; /**< Reference to the application window */
+ TNxArray<struct SStartWindowSlot> m_slots; /**< List of apps in the start window */
+ struct nxgl_size_s m_iconSize; /**< A box big enough to hold the largest icon */
+ pid_t m_taskId; /**< ID of the start window task */
/**
* This is the start window task. This function receives window events from
@@ -138,8 +140,8 @@ namespace NxWM
* 4. NXWidgets::CWidgetControl records the new state data and raises a
* window event.
* 5. NXWidgets::CWindowEventHandlerList will give the event to
- * NxWM::CWindowControl.
- * 6. NxWM::CWindowControl will send the a message on a well-known message
+ * NxWM::CWindowMessenger.
+ * 6. NxWM::CWindowMessenger will send the a message on a well-known message
* queue.
* 7. This CStartWindow::startWindow task will receive and process that
* message.
@@ -236,6 +238,17 @@ namespace NxWM
void stop(void);
/**
+ * Destroy the application and free all of its resources. This method
+ * will initiate blocking of messages from the NX server. The server
+ * will flush the window message queue and reply with the blocked
+ * message. When the block message is received by CWindowMessenger,
+ * it will send the destroy message to the start window task which
+ * will, finally, safely delete the application.
+ */
+
+ void destroy(void);
+
+ /**
* The application window is hidden (either it is minimized or it is
* maximized, but not at the top of the hierarchy)
*/
@@ -275,32 +288,15 @@ namespace NxWM
bool addApplication(IApplicationFactory *app);
/**
- * Simulate a mouse click on the icon at index. This inline method is only
- * used during automated testing of NxWM.
+ * Simulate a mouse click or release on the icon at index. This method
+ * is only available during automated testing of NxWM.
+ *
+ * @param index. Selects the icon in the start window
+ * @param click. True to click and false to release
*/
#if defined(CONFIG_NXWM_UNITTEST) && !defined(CONFIG_NXWM_TOUCHSCREEN)
- inline void clickIcon(int index)
- {
- if (index < m_slots.size())
- {
- // Get the image widget at this index
-
- NXWidgets::CImage *image = m_slots.at(index).image;
-
- // Get the size and position of the widget
-
- struct nxgl_size_s imageSize;
- image->getSize(imageSize);
-
- struct nxgl_point_s imagePos;
- image->getPos(imagePos);
-
- // And click the image at its center
-
- image->click(imagePos.x + (imageSize.w >> 1), imagePos.y + (imageSize.h >> 1));
- }
- }
+ void clickIcon(int index, bool click);
#endif
};
}
diff --git a/NxWidgets/nxwm/include/ctaskbar.hxx b/NxWidgets/nxwm/include/ctaskbar.hxx
index cf98d10d9f..a78fb17394 100644
--- a/NxWidgets/nxwm/include/ctaskbar.hxx
+++ b/NxWidgets/nxwm/include/ctaskbar.hxx
@@ -110,12 +110,12 @@ namespace NxWM
/**
* Create a raw window.
*
- * 1) Create a dumb CWindowControl instance
- * 2) Pass the dumb CWindowControl instance to the window constructor
- * that inherits from INxWindow. This will "smarten" the CWindowControl
+ * 1) Create a dumb NXWidgets::CWidgetControl instance
+ * 2) Pass the dumb NXWidgets::CWidgetControl instance to the window constructor
+ * that inherits from INxWindow. This will "smarten" the NXWidgets::CWidgetControl
* instance with some window knowlede
* 3) Call the open() method on the window to display the window.
- * 4) After that, the fully smartened CWindowControl instance can
+ * 4) After that, the fully smartened NXWidgets::CWidgetControl instance can
* be used to generate additional widgets by passing it to the
* widget constructor
*/
@@ -398,32 +398,15 @@ namespace NxWM
void getDisplaySize(FAR struct nxgl_size_s &size);
/**
- * Simulate a mouse click on the icon at index. This inline method is only
- * used during automated testing of NxWM.
+ * Simulate a mouse click or release on the icon at index. This method
+ * is only available during automated testing of NxWM.
+ *
+ * @param index. Selects the icon in the start window
+ * @param click. True to click and false to release
*/
#if defined(CONFIG_NXWM_UNITTEST) && !defined(CONFIG_NXWM_TOUCHSCREEN)
- inline void clickIcon(int index)
- {
- if (index < m_slots.size())
- {
- // Get the image widget at this index
-
- NXWidgets::CImage *image = m_slots.at(index).image;
-
- // Get the size and position of the widget
-
- struct nxgl_size_s imageSize;
- image->getSize(imageSize);
-
- struct nxgl_point_s imagePos;
- image->getPos(imagePos);
-
- // And click the image at its center
-
- image->click(imagePos.x + (imageSize.w >> 1), imagePos.y + (imageSize.h >> 1));
- }
- }
+ void clickIcon(int index, bool click);
#endif
};
}
diff --git a/NxWidgets/nxwm/include/cwindowcontrol.hxx b/NxWidgets/nxwm/include/cwindowmessenger.hxx
index 91e430c5c0..645e750cb1 100644
--- a/NxWidgets/nxwm/include/cwindowcontrol.hxx
+++ b/NxWidgets/nxwm/include/cwindowmessenger.hxx
@@ -1,5 +1,5 @@
/****************************************************************************
- * NxWidgets/nxwm/include/cwindowcontrol.hxx
+ * NxWidgets/nxwm/include/cwindowmessenger.hxx
*
* Copyright (C) 2012 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
@@ -33,8 +33,8 @@
*
****************************************************************************/
-#ifndef __INCLUDE_CWINDOWCONTROL_HXX
-#define __INCLUDE_CWINDOWCONTROL_HXX
+#ifndef __INCLUDE_CWINDOWMESSENGER_HXX
+#define __INCLUDE_CWINDOWMESSENGER_HXX
/****************************************************************************
* Included Files
@@ -70,12 +70,11 @@ namespace NxWM
class IApplication;
/**
- * The class CWindowControl integrates the widget control with some special
+ * The class CWindowMessenger integrates the widget control with some special
* handling of mouse and keyboard inputs neesed by NxWM
*/
- class CWindowControl : public NXWidgets::CWidgetControl,
- private NXWidgets::CWindowEventHandler
+ class CWindowMessenger : public NXWidgets::CWindowEventHandler
{
private:
mqd_t m_mqd; /**< Message queue descriptor used to commincate with the
@@ -102,24 +101,20 @@ namespace NxWM
public:
/**
- * Constructor
- *
- * @param style The default style that all widgets on this display
- * should use. If this is not specified, the widget will use the
- * values stored in the defaultCWidgetStyle object.
+ * CWindowMessenger Constructor
*/
- CWindowControl(FAR const NXWidgets::CWidgetStyle *style = (const NXWidgets::CWidgetStyle *)NULL);
+ CWindowMessenger(void);
/**
- * Destructor.
+ * CWindowMessenger Destructor.
*/
- ~CWindowControl(void);
+ ~CWindowMessenger(void);
/**
* Destroy the application window and everything in it. This is
- * handled by CWindowControl (vs just calling the destructors) because
+ * handled by CWindowMessenger (vs just calling the destructors) because
* in the case where an application destroys itself (because of pressing
* the stop button), then we need to unwind and get out of the application
* logic before destroying all of its objects.
@@ -130,4 +125,4 @@ namespace NxWM
}
#endif // __cplusplus
-#endif // __INCLUDE_CWINDOWCONTROL_HXX
+#endif // __INCLUDE_CWINDOWMESSENGER_HXX
diff --git a/NxWidgets/nxwm/include/iapplication.hxx b/NxWidgets/nxwm/include/iapplication.hxx
index 45067d900a..28e50e0136 100644
--- a/NxWidgets/nxwm/include/iapplication.hxx
+++ b/NxWidgets/nxwm/include/iapplication.hxx
@@ -45,8 +45,7 @@
#include "cnxstring.hxx"
#include "ibitmap.hxx"
-#include "cwindowcontrol.hxx"
-#include "capplicationwindow.hxx"
+#include "iapplicationwindow.hxx"
/****************************************************************************
* Pre-Processor Definitions
@@ -94,18 +93,6 @@ namespace NxWM
virtual IApplicationWindow *getWindow(void) const = 0;
/**
- * Get the window widget control.
- *
- * @return The widget control of the underlying window instance.
- */
-
- virtual inline CWindowControl *getWindowControl(void) const
- {
- IApplicationWindow *window = getWindow();
- return window->getWindowControl();
- }
-
- /**
* Get the icon associated with the application
*
* @return An instance if IBitmap that may be used to rend the
@@ -132,12 +119,24 @@ namespace NxWM
virtual bool run(void) = 0;
/**
- * Stop the application.
+ * Stop the application, put all widgets in a deactivated/disabled state
+ * and wait to see what happens next.
*/
virtual void stop(void) = 0;
/**
+ * Destroy the application and free all of its resources. This method
+ * will initiate blocking of messages from the NX server. The server
+ * will flush the window message queue and reply with the blocked
+ * message. When the block message is received by CWindowMessenger,
+ * it will send the destroy message to the start window task which
+ * will, finally, safely delete the application.
+ */
+
+ virtual void destroy(void) = 0;
+
+ /**
* The application window is hidden (either it is minimized or it is
* maximized, but not at the top of the hierarchy
*/
diff --git a/NxWidgets/nxwm/include/iapplicationwindow.hxx b/NxWidgets/nxwm/include/iapplicationwindow.hxx
index fe8830c2fa..ed221797d4 100644
--- a/NxWidgets/nxwm/include/iapplicationwindow.hxx
+++ b/NxWidgets/nxwm/include/iapplicationwindow.hxx
@@ -44,8 +44,7 @@
#include "inxwindow.hxx"
#include "cnxstring.hxx"
-
-#include "cwindowcontrol.hxx"
+#include "cwidgetcontrol.hxx"
/****************************************************************************
* Pre-Processor Definitions
@@ -89,6 +88,15 @@ namespace NxWM
{
public:
/**
+ * A virtual destructor is required in order to override the IApplicationWindow
+ * destructor. We do this because if we delete IApplicationWindow, we want the
+ * destructor of the class that inherits from IApplicationWindow to run, not this
+ * one.
+ */
+
+ virtual ~IApplicationWindow(void) { }
+
+ /**
* Initialize window. Window initialization is separate from
* object instantiation so that failures can be reported.
*
@@ -119,12 +127,19 @@ namespace NxWM
virtual NXWidgets::INxWindow *getWindow(void) const = 0;
/**
- * Recover the contained window control
+ * Recover the contained widget control
*
- * @return. The window control used by this application
+ * @return. The widget control used by this application
*/
- virtual CWindowControl *getWindowControl(void) const = 0;
+ virtual NXWidgets::CWidgetControl *getWidgetControl(void) const = 0;
+
+ /**
+ * Block further activity on this window in preparation for window
+ * shutdown.
+ */
+
+ virtual void block(void) = 0;
/**
* Set the window label
@@ -151,21 +166,25 @@ namespace NxWM
virtual void registerCallbacks(IApplicationCallback *callback) = 0;
/**
- * Simulate a mouse click on the minimize icon. This inline method is only
- * used during automated testing of NxWM.
+ * Simulate a mouse click or release on the minimize icon. This method
+ * is only available for automated testing of NxWM.
+ *
+ * @param click. True to click; false to release;
*/
#if defined(CONFIG_NXWM_UNITTEST) && !defined(CONFIG_NXWM_TOUCHSCREEN)
- virtual void clickMinimizeIcon(int index) = 0;
+ virtual void clickMinimizePosition(bool click) = 0;
#endif
/**
- * Simulate a mouse click on the stop applicaiton icon. This inline method is only
- * used during automated testing of NxWM.
+ * Simulate a mouse click or release on the stop icon. This method
+ * is only available for automated testing of NxWM.
+ *
+ * @param click. True to click; false to release;
*/
#if defined(CONFIG_NXWM_UNITTEST) && !defined(CONFIG_NXWM_TOUCHSCREEN)
- virtual void clickStopIcon(int index) = 0;
+ virtual void clickStopIcon(bool click) = 0;
#endif
};
}
diff --git a/NxWidgets/nxwm/include/nxwmconfig.hxx b/NxWidgets/nxwm/include/nxwmconfig.hxx
index 3605f8c4fc..25a8beb662 100644
--- a/NxWidgets/nxwm/include/nxwmconfig.hxx
+++ b/NxWidgets/nxwm/include/nxwmconfig.hxx
@@ -264,7 +264,7 @@
* CONFIG_NXWM_STARTWINDOW_HSPACING - Horizontal spacing. Default: 2 rows
* CONFIG_NXWM_STARTWINDOW_ICON - The glyph to use as the start window icon
* CONFIG_NXWM_STARTWINDOW_MQNAME - The well known name of the message queue
- * Used to communicated from CWindowControl tothe start window thread.
+ * Used to communicated from CWindowMessenger to the start window thread.
* Default: "/dev/nxwm"
* CONFIG_NXWM_STARTWINDOW_MXMSGS - The maximum number of messages to queue
* before blocking. Defualt 32
diff --git a/NxWidgets/nxwm/src/capplicationwindow.cxx b/NxWidgets/nxwm/src/capplicationwindow.cxx
index 15d4a4a9d0..c0bc9ed62c 100644
--- a/NxWidgets/nxwm/src/capplicationwindow.cxx
+++ b/NxWidgets/nxwm/src/capplicationwindow.cxx
@@ -47,7 +47,6 @@
#include "nxwmconfig.hxx"
#include "nxwmglyphs.hxx"
-#include "cwindowcontrol.hxx"
#include "capplicationwindow.hxx"
/********************************************************************************************
@@ -153,9 +152,9 @@ CApplicationWindow::~CApplicationWindow(void)
bool CApplicationWindow::open(void)
{
- // Create one of our special window controls for the tool bar
+ // Create a widget control for the tool bar
- CWindowControl *control = new CWindowControl();
+ NXWidgets::CWidgetControl *control = new NXWidgets::CWidgetControl();
if (!control)
{
return false;
@@ -414,15 +413,31 @@ NXWidgets::INxWindow *CApplicationWindow::getWindow(void) const
}
/**
- * Recover the contained window control
+ * Recover the contained widget control
*
- * @return. The window control used by this application
+ * @return. The widget control used by this application
*/
-CWindowControl *CApplicationWindow::getWindowControl(void) const
+NXWidgets::CWidgetControl *CApplicationWindow::getWidgetControl(void) const
{
+ return m_window->getWidgetControl();
+}
+
+/**
+ * Block further activity on this window in preparation for window
+ * shutdown.
+ */
+
+void CApplicationWindow::block(void)
+{
+ // Get the widget control from the NXWidgets::CNxWindow instance
+
NXWidgets::CWidgetControl *control = m_window->getWidgetControl();
- return static_cast<CWindowControl*>(control);
+
+ // And then block further reporting activity on the underlying
+ // NX framed window
+
+ nxtk_block(control->getWindowHandle());
}
/**
@@ -459,12 +474,14 @@ void CApplicationWindow::registerCallbacks(IApplicationCallback *callback)
}
/**
- * Simulate a mouse click on the minimize icon. This method is only
- * used during automated testing of NxWM.
+ * Simulate a mouse click or release on the minimize icon. This method
+ * is only available for automated testing of NxWM.
+ *
+ * @param click. True to click; false to release;
*/
#if defined(CONFIG_NXWM_UNITTEST) && !defined(CONFIG_NXWM_TOUCHSCREEN)
-void CApplicationWindow::clickMinimizeIcon(int index)
+void CApplicationWindow::clickMinimizePosition(bool click)
{
// Get the size and position of the widget
@@ -474,20 +491,30 @@ void CApplicationWindow::clickMinimizeIcon(int index)
struct nxgl_point_s imagePos;
m_minimizeImage->getPos(imagePos);
- // And click the image at its center
+ // And click or release the image at its center
- m_minimizeImage->click(imagePos.x + (imageSize.w >> 1),
- imagePos.y + (imageSize.h >> 1));
+ if (click)
+ {
+ m_minimizeImage->click(imagePos.x + (imageSize.w >> 1),
+ imagePos.y + (imageSize.h >> 1));
+ }
+ else
+ {
+ m_minimizeImage->release(imagePos.x + (imageSize.w >> 1),
+ imagePos.y + (imageSize.h >> 1));
+ }
}
#endif
/**
- * Simulate a mouse click on the stop applicaiton icon. This method is only
- * used during automated testing of NxWM.
+ * Simulate a mouse click or release on the stop icon. This method
+ * is only available for automated testing of NxWM.
+ *
+ * @param click. True to click; false to release;
*/
#if defined(CONFIG_NXWM_UNITTEST) && !defined(CONFIG_NXWM_TOUCHSCREEN)
-void CApplicationWindow::clickStopIcon(int index)
+void CApplicationWindow::clickStopIcon(bool click)
{
// The stop icon will not be available for "persistent" applications
@@ -501,10 +528,18 @@ void CApplicationWindow::clickStopIcon(int index)
struct nxgl_point_s imagePos;
m_stopImage->getPos(imagePos);
- // And click the image at its center
+ // And click or release the image at its center
- m_stopImage->click(imagePos.x + (imageSize.w >> 1),
- imagePos.y + (imageSize.h >> 1));
+ if (click)
+ {
+ m_stopImage->click(imagePos.x + (imageSize.w >> 1),
+ imagePos.y + (imageSize.h >> 1));
+ }
+ else
+ {
+ m_stopImage->release(imagePos.x + (imageSize.w >> 1),
+ imagePos.y + (imageSize.h >> 1));
+ }
}
}
#endif
diff --git a/NxWidgets/nxwm/src/ccalibration.cxx b/NxWidgets/nxwm/src/ccalibration.cxx
index 248aca8389..d93f56a47a 100644
--- a/NxWidgets/nxwm/src/ccalibration.cxx
+++ b/NxWidgets/nxwm/src/ccalibration.cxx
@@ -99,6 +99,11 @@ CCalibration::CCalibration(CTaskbar *taskbar, CFullScreenWindow *window,
m_calthread = CALTHREAD_NOTRUNNING;
m_calphase = CALPHASE_NOT_STARTED;
m_touched = false;
+
+ // Add our messenger as the window callback
+
+ NXWidgets::CWidgetControl *control = window->getWidgetControl();
+ control->addWindowEventHandler(&m_messenger);
}
/**
@@ -112,6 +117,11 @@ CCalibration::~CCalibration(void)
stop();
+ // Remove ourself from the window callback
+
+ NXWidgets::CWidgetControl *control = m_window->getWidgetControl();
+ control->removeWindowEventHandler(&m_messenger);
+
// Although we did not create the window, the rule is that I have to dispose
// of it
@@ -200,6 +210,26 @@ void CCalibration::stop(void)
}
/**
+ * Destroy the application and free all of its resources. This method
+ * will initiate blocking of messages from the NX server. The server
+ * will flush the window message queue and reply with the blocked
+ * message. When the block message is received by CWindowMessenger,
+ * it will send the destroy message to the start window task which
+ * will, finally, safely delete the application.
+ */
+
+void CCalibration::destroy(void)
+{
+ // Block any further window messages
+
+ m_window->block();
+
+ // Make sure that the application is stopped
+
+ stop();
+}
+
+/**
* The application window is hidden (either it is minimized or it is
* maximized, but it is not at the top of the hierarchy)
*/
diff --git a/NxWidgets/nxwm/src/cfullscreenwindow.cxx b/NxWidgets/nxwm/src/cfullscreenwindow.cxx
index 40647d8e90..0c34166c06 100644
--- a/NxWidgets/nxwm/src/cfullscreenwindow.cxx
+++ b/NxWidgets/nxwm/src/cfullscreenwindow.cxx
@@ -128,15 +128,31 @@ NXWidgets::INxWindow *CFullScreenWindow::getWindow(void) const
}
/**
- * Recover the contained window control
+ * Recover the contained widget control
*
- * @return. The window control used by this application
+ * @return. The widget control used by this application
*/
-CWindowControl *CFullScreenWindow::getWindowControl(void) const
+NXWidgets::CWidgetControl *CFullScreenWindow::getWidgetControl(void) const
{
+ return m_window->getWidgetControl();
+}
+
+/**
+ * Block further activity on this window in preparation for window
+ * shutdown.
+ */
+
+void CFullScreenWindow::block(void)
+{
+ // Get the widget control from the NXWidgets::CNxWindow instance
+
NXWidgets::CWidgetControl *control = m_window->getWidgetControl();
- return static_cast<CWindowControl*>(control);
+
+ // And then block further reporting activity on the underlying
+ // NX raw window
+
+ nx_block(control->getWindowHandle());
}
/**
@@ -171,23 +187,27 @@ void CFullScreenWindow::registerCallbacks(IApplicationCallback *callback)
}
/**
- * Simulate a mouse click on the minimize icon. This method is only
- * used during automated testing of NxWM.
+ * Simulate a mouse click or release on the minimize icon. This method
+ * is only available for automated testing of NxWM.
+ *
+ * @param click. True to click; false to release;
*/
#if defined(CONFIG_NXWM_UNITTEST) && !defined(CONFIG_NXWM_TOUCHSCREEN)
-void CFullScreenWindow::clickMinimizeIcon(int index)
+void CFullScreenWindow::clickMinimizePosition(bool click)
{
}
#endif
/**
- * Simulate a mouse click on the stop applicaiton icon. This method is only
- * used during automated testing of NxWM.
+ * Simulate a mouse click or release on the stop icon. This method
+ * is only available for automated testing of NxWM.
+ *
+ * @param click. True to click; false to release;
*/
#if defined(CONFIG_NXWM_UNITTEST) && !defined(CONFIG_NXWM_TOUCHSCREEN)
-void CFullScreenWindow::clickStopIcon(int index)
+void CFullScreenWindow::clickStopIcon(bool click)
{
}
#endif
diff --git a/NxWidgets/nxwm/src/cnxconsole.cxx b/NxWidgets/nxwm/src/cnxconsole.cxx
index 577bf661e0..64321ddfbf 100644
--- a/NxWidgets/nxwm/src/cnxconsole.cxx
+++ b/NxWidgets/nxwm/src/cnxconsole.cxx
@@ -129,9 +129,14 @@ CNxConsole::CNxConsole(CTaskbar *taskbar, CApplicationWindow *window)
NXWidgets::CNxString myName = getName();
window->setWindowLabel(myName);
- // Add our callbacks to the application window
+ // Add our callbacks with the application window
window->registerCallbacks(static_cast<IApplicationCallback *>(this));
+
+ // Add our messenger as the window callback
+
+ NXWidgets::CWidgetControl *control = window->getWidgetControl();
+ control->addWindowEventHandler(&m_messenger);
}
/**
@@ -147,13 +152,15 @@ CNxConsole::~CNxConsole(void)
stop();
+ // Remove ourself from the window callback
+
+ NXWidgets::CWidgetControl *control = m_window->getWidgetControl();
+ control->removeWindowEventHandler(&m_messenger);
+
// Although we didn't create it, we are responsible for deleting the
// application window
- if (m_window)
- {
- delete m_window;
- }
+ delete m_window;
}
/**
@@ -322,6 +329,26 @@ void CNxConsole::stop(void)
}
/**
+ * Destroy the application and free all of its resources. This method
+ * will initiate blocking of messages from the NX server. The server
+ * will flush the window message queue and reply with the blocked
+ * message. When the block message is received by CWindowMessenger,
+ * it will send the destroy message to the start window task which
+ * will, finally, safely delete the application.
+ */
+
+void CNxConsole::destroy(void)
+{
+ // Block any further window messages
+
+ m_window->block();
+
+ // Make sure that the application is stopped
+
+ stop();
+}
+
+/**
* The application window is hidden (either it is minimized or it is
* maximized, but not at the top of the hierarchy
*/
diff --git a/NxWidgets/nxwm/src/cstartwindow.cxx b/NxWidgets/nxwm/src/cstartwindow.cxx
index 2b7ecbe66d..3dfab50975 100644
--- a/NxWidgets/nxwm/src/cstartwindow.cxx
+++ b/NxWidgets/nxwm/src/cstartwindow.cxx
@@ -99,6 +99,11 @@ CStartWindow::CStartWindow(CTaskbar *taskbar, CApplicationWindow *window)
// Add our callbacks to the application window
window->registerCallbacks(static_cast<IApplicationCallback *>(this));
+
+ // Add our messenger as the window callback
+
+ NXWidgets::CWidgetControl *control = window->getWidgetControl();
+ control->addWindowEventHandler(&m_messenger);
}
/**
@@ -112,13 +117,15 @@ CStartWindow::~CStartWindow(void)
stop();
+ // Remove ourself from the window callback
+
+ NXWidgets::CWidgetControl *control = m_window->getWidgetControl();
+ control->removeWindowEventHandler(&m_messenger);
+
// Although we didn't create it, we are responsible for deleting the
// application window
- if (m_window)
- {
- delete m_window;
- }
+ delete m_window;
// Then stop and delete all applications
@@ -211,6 +218,28 @@ void CStartWindow::stop(void)
task_delete(pid);
}
}
+/**
+ * Destroy the application and free all of its resources. This method
+ * will initiate blocking of messages from the NX server. The server
+ * will flush the window message queue and reply with the blocked
+ * message. When the block message is received by CWindowMessenger,
+ * it will send the destroy message to the start window task which
+ * will, finally, safely delete the application.
+ */
+
+void CStartWindow::destroy(void)
+{
+ // What are we doing? This should never happen because the start
+ // window task is persistent!
+
+ // Block any further window messages
+
+ m_window->block();
+
+ // Make sure that the application is stopped
+
+ stop();
+}
/**
* The application window is hidden (either it is minimized or it is
@@ -405,6 +434,47 @@ bool CStartWindow::addApplication(IApplicationFactory *app)
}
/**
+ * Simulate a mouse click or release on the icon at index. This method
+ * is only available during automated testing of NxWM.
+ *
+ * @param index. Selects the icon in the start window
+ * @param click. True to click and false to release
+ */
+
+#if defined(CONFIG_NXWM_UNITTEST) && !defined(CONFIG_NXWM_TOUCHSCREEN)
+void CStartWindow::clickIcon(int index, bool click)
+{
+ if (index < m_slots.size())
+ {
+ // Get the image widget at this index
+
+ NXWidgets::CImage *image = m_slots.at(index).image;
+
+ // Get the size and position of the widget
+
+ struct nxgl_size_s imageSize;
+ image->getSize(imageSize);
+
+ struct nxgl_point_s imagePos;
+ image->getPos(imagePos);
+
+ // And click or release the image at its center
+
+ if (click)
+ {
+ image->click(imagePos.x + (imageSize.w >> 1),
+ imagePos.y + (imageSize.h >> 1));
+ }
+ else
+ {
+ image->release(imagePos.x + (imageSize.w >> 1),
+ imagePos.y + (imageSize.h >> 1));
+ }
+ }
+}
+#endif
+
+/**
* Called when the window minimize button is pressed.
*/
@@ -523,11 +593,11 @@ void CStartWindow::handleActionEvent(const NXWidgets::CWidgetEventArgs &e)
}
else
{
- // If we cannot start the app. Destroy the
- // instance we created and see what happens next.
+ // If we cannot start the app. Destroy the instance we
+ // created and see what happens next. Could be interesting.
- CWindowControl *control = app->getWindowControl();
- control->destroy(app);
+ app->stop();
+ app->destroy();
}
}
}
@@ -548,8 +618,8 @@ void CStartWindow::handleActionEvent(const NXWidgets::CWidgetEventArgs &e)
* 4. NXWidgets::CWidgetControl records the new state data and raises a
* window event.
* 5. NXWidgets::CWindowEventHandlerList will give the event to
- * NxWM::CWindowControl.
- * 6. NxWM::CWindowControl will send the a message on a well-known message
+ * NxWM::CWindowMessenger.
+ * 6. NxWM::CWindowMessenger will send the a message on a well-known message
* queue.
* 7. This CStartWindow::startWindow task will receive and process that
* message.
diff --git a/NxWidgets/nxwm/src/ctaskbar.cxx b/NxWidgets/nxwm/src/ctaskbar.cxx
index ab686f81cc..b4df0bb862 100644
--- a/NxWidgets/nxwm/src/ctaskbar.cxx
+++ b/NxWidgets/nxwm/src/ctaskbar.cxx
@@ -47,7 +47,6 @@
#include "cwidgetcontrol.hxx"
#include "cnxtkwindow.hxx"
-#include "cwindowcontrol.hxx"
#include "ctaskbar.hxx"
/********************************************************************************************
@@ -68,11 +67,11 @@ using namespace NxWM;
CTaskbar::CTaskbar(void)
{
- m_taskbar = (NXWidgets::CNxWindow *)0;
- m_background = (NXWidgets::CNxWindow *)0;
- m_backImage = (NXWidgets::CImage *)0;
- m_topApp = (IApplication *)0;
- m_started = false;
+ m_taskbar = (NXWidgets::CNxWindow *)0;
+ m_background = (NXWidgets::CNxWindow *)0;
+ m_backImage = (NXWidgets::CImage *)0;
+ m_topApp = (IApplication *)0;
+ m_started = false;
}
/**
@@ -81,6 +80,9 @@ CTaskbar::CTaskbar(void)
CTaskbar::~CTaskbar(void)
{
+ // The disconnect,putting the instance back in the state that it
+ // was before it was constructed.
+
disconnect();
}
@@ -107,7 +109,8 @@ bool CTaskbar::connect(void)
}
/**
- * Disconnect from the server
+ * Disconnect from the server. This method restores the taskbar to the
+ * same state that it was in when it was constructed.
*/
void CTaskbar::disconnect(void)
@@ -141,6 +144,7 @@ void CTaskbar::disconnect(void)
// Then delete the task bar window
delete m_taskbar;
+ m_taskbar = (NXWidgets::CNxWindow *)0;
}
if (m_background)
@@ -157,8 +161,22 @@ void CTaskbar::disconnect(void)
// Then delete the background
delete m_background;
+ m_background = (NXWidgets::CNxWindow *)0;
+ }
+
+ // Delete the background image
+
+ if (m_backImage)
+ {
+ delete m_backImage;
+ m_backImage = (NXWidgets::CImage *)0;
}
+ // Reset other variables
+
+ m_topApp = (IApplication *)0;
+ m_started = false;
+
// And disconnect from the server
CNxServer::disconnect();
@@ -279,7 +297,9 @@ bool CTaskbar::startWindowManager(void)
continue;
}
- // Hide all appliations except for the top application
+ // Hide all applications except for the top application. NOTE:
+ // topIndex may still be -1, meaning that there is no application
+ // and that all applications should be hidden.
if (i != topIndex)
{
@@ -303,6 +323,17 @@ bool CTaskbar::startWindowManager(void)
i++;
}
+ // If there is no top appliation (i.e., no applications or all applications
+ // are minimized), then draw the background image
+
+ if (!m_topApp)
+ {
+ if (!redrawBackgroundWindow())
+ {
+ return false;
+ }
+ }
+
// Draw the taskbar. It will be draw at a higher level than the application.
return redrawTaskbarWindow();
@@ -418,7 +449,7 @@ bool CTaskbar::startApplication(IApplication *app, bool minimized)
{
// Get the widget control associated with the task bar window
- NXWidgets::CWidgetControl *control = m_taskbar->getWidgetControl();
+ NXWidgets::CWidgetControl *control = m_taskbar->getWidgetControl();
// Get the bitmap icon that goes with this application
@@ -633,10 +664,10 @@ bool CTaskbar::stopApplication(IApplication *app)
}
}
- // destroy the application
+ // Destroy the application (actually, this just sets up the application for
+ // later destruction.
- CWindowControl *control = app->getWindowControl();
- control->destroy(app);
+ app->destroy();
// Re-draw the new top, non-minimized application
@@ -674,6 +705,47 @@ void CTaskbar::getDisplaySize(FAR struct nxgl_size_s &size)
}
/**
+ * Simulate a mouse click or release on the icon at index. This method
+ * is only available during automated testing of NxWM.
+ *
+ * @param index. Selects the icon in the start window
+ * @param click. True to click and false to release
+ */
+
+#if defined(CONFIG_NXWM_UNITTEST) && !defined(CONFIG_NXWM_TOUCHSCREEN)
+void CTaskbar::clickIcon(int index, bool click)
+{
+ if (index < m_slots.size())
+ {
+ // Get the image widget at this index
+
+ NXWidgets::CImage *image = m_slots.at(index).image;
+
+ // Get the size and position of the widget
+
+ struct nxgl_size_s imageSize;
+ image->getSize(imageSize);
+
+ struct nxgl_point_s imagePos;
+ image->getPos(imagePos);
+
+ // And click or release the image at its center
+
+ if (click)
+ {
+ image->click(imagePos.x + (imageSize.w >> 1),
+ imagePos.y + (imageSize.h >> 1));
+ }
+ else
+ {
+ image->release(imagePos.x + (imageSize.w >> 1),
+ imagePos.y + (imageSize.h >> 1));
+ }
+ }
+}
+#endif
+
+/**
* Create a raw window.
*
* 1) Create a dumb CWigetControl instance
@@ -690,7 +762,7 @@ NXWidgets::CNxWindow *CTaskbar::openRawWindow(void)
{
// Initialize the widget control using the default style
- CWindowControl *control = new CWindowControl((NXWidgets::CWidgetStyle *)NULL);
+ NXWidgets::CWidgetControl *control = new NXWidgets::CWidgetControl((NXWidgets::CWidgetStyle *)NULL);
// Get an (uninitialized) instance of the background window as a class
// that derives from INxWindow.
@@ -727,7 +799,7 @@ NXWidgets::CNxTkWindow *CTaskbar::openFramedWindow(void)
{
// Initialize the widget control using the default style
- CWindowControl *control = new CWindowControl((NXWidgets::CWidgetStyle *)NULL);
+ NXWidgets::CWidgetControl *control = new NXWidgets::CWidgetControl((NXWidgets::CWidgetStyle *)NULL);
// Get an (uninitialized) instance of the framed window as a class
// that derives from INxWindow.
diff --git a/NxWidgets/nxwm/src/cwindowcontrol.cxx b/NxWidgets/nxwm/src/cwindowmessenger.cxx
index 6c2144bad7..4e458566d3 100644
--- a/NxWidgets/nxwm/src/cwindowcontrol.cxx
+++ b/NxWidgets/nxwm/src/cwindowmessenger.cxx
@@ -1,5 +1,5 @@
/********************************************************************************************
- * NxWidgets/nxwm/src/cwindowcontrol.cxx
+ * NxWidgets/nxwm/src/cwindowmessenger.cxx
*
* Copyright (C) 2012 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
@@ -46,28 +46,23 @@
#include "nxwmconfig.hxx"
#include "cstartwindow.hxx"
-#include "cwindowcontrol.hxx"
+#include "cwindowmessenger.hxx"
/********************************************************************************************
* Pre-Processor Definitions
********************************************************************************************/
/********************************************************************************************
- * CWindowControl Method Implementations
+ * CWindowMessenger Method Implementations
********************************************************************************************/
using namespace NxWM;
/**
- * Constructor
- *
- * @param style The default style that all widgets on this display
- * should use. If this is not specified, the widget will use the
- * values stored in the defaultCWidgetStyle object.
+ * CWindowMessenger Constructor
*/
-CWindowControl::CWindowControl(FAR const NXWidgets::CWidgetStyle *style)
-: NXWidgets::CWidgetControl(style)
+CWindowMessenger::CWindowMessenger(void)
{
// Open a message queue to communicate with the start window task. We need to create
// the message queue if it does not exist.
@@ -82,36 +77,28 @@ CWindowControl::CWindowControl(FAR const NXWidgets::CWidgetStyle *style)
{
gdbg("ERROR: mq_open(%s) failed: %d\n", g_startWindowMqName, errno);
}
-
- // Add ourself as the window callback
-
- addWindowEventHandler(this);
}
/**
- * Destructor.
+ * CWindowMessenger Destructor.
*/
-CWindowControl::~CWindowControl(void)
+CWindowMessenger::~CWindowMessenger(void)
{
// Close the message queue
(void)mq_close(m_mqd);
-
- // Remove ourself from the window callback
-
- removeWindowEventHandler(this);
}
/**
* Destroy the application window and everything in it. This is
- * handled by CWindowControl (vs just calling the destructors) because
+ * handled by CWindowMessenger (vs just calling the destructors) because
* in the case where an application destroys itself (because of pressing
* the stop button), then we need to unwind and get out of the application
* logic before destroying all of its objects.
*/
-void CWindowControl::destroy(IApplication *app)
+void CWindowMessenger::destroy(IApplication *app)
{
// Send a message to destroy the window isntance at a later time
@@ -135,7 +122,7 @@ void CWindowControl::destroy(IApplication *app)
*/
#ifdef CONFIG_NX_MOUSE
-void CWindowControl::handleMouseEvent(void)
+void CWindowMessenger::handleMouseEvent(void)
{
// The logic path here is tortuous but flexible:
//
@@ -157,8 +144,8 @@ void CWindowControl::handleMouseEvent(void)
// 7. NXWidgets::CWidgetControl records the new state data and raises a
// window event.
// 8. NXWidgets::CWindowEventHandlerList will give the event to this method
- // NxWM::CWindowControl.
- // 9. This NxWM::CWindowControl method will send the a message on a well-
+ // NxWM::CWindowMessenger.
+ // 9. This NxWM::CWindowMessenger method will send the a message on a well-
// known message queue.
// 10. This CStartWindow::startWindow task will receive and process that
// message by calling CWidgetControl::pollEvents()
@@ -181,7 +168,7 @@ void CWindowControl::handleMouseEvent(void)
*/
#ifdef CONFIG_NX_KBD
-void CWindowControl::handleKeyboardEvent(void)
+void CWindowMessenger::handleKeyboardEvent(void)
{
// The logic path here is tortuous but flexible:
//
@@ -203,8 +190,8 @@ void CWindowControl::handleKeyboardEvent(void)
// 7. NXWidgets::CWidgetControl records the new state data and raises a
// window event.
// 8. NXWidgets::CWindowEventHandlerList will give the event to this method
- // NxWM::CWindowControl.
- // 9. This NxWM::CWindowControl method will send the a message on a well-
+ // NxWM::CWindowMessenger.
+ // 9. This NxWM::CWindowMessenger method will send the a message on a well-
// known message queue.
// 10. This CStartWindow::startWindow task will receive and process that
// message by calling CWidgetControl::pollEvents()