summaryrefslogtreecommitdiff
path: root/NxWidgets/nxwm/src
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2012-05-01 20:36:19 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2012-05-01 20:36:19 +0000
commitfd4dd86fe8de2ddda1e8723973e8b5774528ebb7 (patch)
tree076f03852cb6bcd7a34d313558f7529143337e6d /NxWidgets/nxwm/src
parent990276740afafeb69f64b01050a99f113bb89fa6 (diff)
downloadnuttx-fd4dd86fe8de2ddda1e8723973e8b5774528ebb7.tar.gz
nuttx-fd4dd86fe8de2ddda1e8723973e8b5774528ebb7.tar.bz2
nuttx-fd4dd86fe8de2ddda1e8723973e8b5774528ebb7.zip
More NxWM support
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@4682 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'NxWidgets/nxwm/src')
-rw-r--r--NxWidgets/nxwm/src/cnxconsole.cxx203
-rw-r--r--NxWidgets/nxwm/src/ctaskbar.cxx158
-rw-r--r--NxWidgets/nxwm/src/glyph_minimize.cxx2
-rw-r--r--NxWidgets/nxwm/src/glyph_nsh.cxx2
-rw-r--r--NxWidgets/nxwm/src/glyph_start.cxx2
-rw-r--r--NxWidgets/nxwm/src/glyph_stop.cxx2
6 files changed, 185 insertions, 184 deletions
diff --git a/NxWidgets/nxwm/src/cnxconsole.cxx b/NxWidgets/nxwm/src/cnxconsole.cxx
index 857b67983..5fe81d844 100644
--- a/NxWidgets/nxwm/src/cnxconsole.cxx
+++ b/NxWidgets/nxwm/src/cnxconsole.cxx
@@ -41,9 +41,9 @@
#include <cstdio>
#include <cstdlib>
+#include <cunistd>
#include <ctime>
-#include <unistd.h>
#include <fcntl.h>
#include <semaphore.h>
#include <sched.h>
@@ -53,8 +53,8 @@
#include "cwidgetcontrol.hxx"
#include "nxwmconfig.hxx"
-#include "cnxconsole.hxx"
#include "nxwmglyphs.hxx"
+#include "cnxconsole.hxx"
/********************************************************************************************
* Pre-Processor Definitions
@@ -66,119 +66,36 @@
namespace NxWM
{
- /**
- * This structure is used to pass start up parameters to nxcon_task and to assure the
- * the NxConsole is successfully started.
- */
+ /**
+ * This structure is used to pass start up parameters to the NxConsole task and to assure the
+ * the NxConsole is successfully started.
+ */
- struct nxcon_task_s
- {
- sem_t sem; // Sem that will be posted when the task is successfully initialized
- NXTKWINDOW hwnd; // Window handle
- NXCONSOLE nxcon; // NxConsole handle
- int minor; // Next device minor number
- bool result; // True if successfully initialized
- };
+ struct SNxConsole
+ {
+ sem_t sem; /**< Sem that will be posted when the task is successfully initialized */
+ NXTKWINDOW hwnd; /**< Window handle */
+ NXCONSOLE nxcon; /**< NxConsole handle */
+ int minor; /**< Next device minor number */
+ bool result; /**< True if successfully initialized */
+ };
/********************************************************************************************
* Private Data
********************************************************************************************/
/**
- * This global data structure is used to pass start parameters to nxcon_task and to
+ * This global data structure is used to pass start parameters to NxConsole task and to
* assure that the NxConsole is successfully started.
*/
- static struct nxcon_task_s g_nxconvars;
+ static struct SNxConsole g_nxconvars;
+}
/********************************************************************************************
* Private Functions
********************************************************************************************/
- /**
- * This is the NxConsole task. This function first redirects output to the console window.
- */
-
- static int nxcon_task(int argc, char *argv[])
- {
- // Configure NxConsole
-
- struct nxcon_window_s wndo; /* Describes the window */
- wndo.wcolor[0] = CONFIG_NXWM_NXCONSOLE_WCOLOR;
- wndo.fcolor[0] = CONFIG_NXWM_NXCONSOLE_FONTCOLOR;
- wndo.fontid = CONFIG_NXWM_NXCONSOLE_FONTID;
-
- // To stop compiler complaining about "jump to label crosses initialization of 'int fd'
-
- int fd = -1;
-
- // Use the window handle to create the NX console
-
- g_nxconvars.nxcon = nxtk_register(g_nxconvars.hwnd, &wndo, g_nxconvars.minor);
- if (!g_nxconvars.nxcon)
- {
- goto errout;
- }
-
- // Construct the driver name using this minor number
-
- char devname[32];
- snprintf(devname, 32, "/dev/nxcon%d", g_nxconvars.minor);
-
- // Increment the minor number while it is protect by the semaphore
-
- g_nxconvars.minor++;
-
- // Open the NxConsole driver
-
- fd = open(devname, O_WRONLY);
- if (fd < 0)
- {
- goto errout_with_nxcon;
- }
-
- // Now re-direct stdout and stderr so that they use the NX console driver.
- // Note that stdin is retained (file descriptor 0, probably the the serial console).
-
- (void)fflush(stdout);
- (void)fflush(stderr);
-
- (void)fclose(stdout);
- (void)fclose(stderr);
-
- (void)dup2(fd, 1);
- (void)dup2(fd, 2);
-
- // And we can close our original driver file descriptor
-
- close(fd);
-
- // Inform the parent thread that we successfully initialize
-
- g_nxconvars.result = true;
- sem_post(&g_nxconvars.sem);
-
- // Run the NSH console
-
-#ifdef CONFIG_NSH_CONSOLE
- (void)nsh_consolemain(argc, argv);
-#endif
-
- // We get here if console exits
-#warning "Missing logic"
- return EXIT_SUCCESS;
-
- errout_with_nxcon:
- nxcon_unregister(g_nxconvars.nxcon);
-
- errout:
- g_nxconvars.nxcon = 0;
- g_nxconvars.result = false;
- sem_post(&g_nxconvars.sem);
- return EXIT_FAILURE;
- }
-}
-
/********************************************************************************************
* CNxConsole Method Implementations
********************************************************************************************/
@@ -328,7 +245,7 @@ bool CNxConsole::run(void)
sched_lock();
m_pid = TASK_CREATE("NxConsole", CONFIG_NXWM_NXCONSOLE_PRIO,
- CONFIG_NXWM_NXCONSOLE_STACKSIZE, nxcon_task,
+ CONFIG_NXWM_NXCONSOLE_STACKSIZE, nxconsole,
(FAR const char **)0);
// Did we successfully start the NxConsole task?
@@ -424,6 +341,90 @@ void CNxConsole::redraw(void)
}
/**
+ * This is the NxConsole task. This function first redirects output to the
+ * console window.
+ */
+
+int CNxConsole::nxconsole(int argc, char *argv[])
+{
+ // Configure NxConsole
+
+ struct nxcon_window_s wndo; /* Describes the window */
+ wndo.wcolor[0] = CONFIG_NXWM_NXCONSOLE_WCOLOR;
+ wndo.fcolor[0] = CONFIG_NXWM_NXCONSOLE_FONTCOLOR;
+ wndo.fontid = CONFIG_NXWM_NXCONSOLE_FONTID;
+
+ // To stop compiler complaining about "jump to label crosses initialization of 'int fd'
+
+ int fd = -1;
+
+ // Use the window handle to create the NX console
+
+ g_nxconvars.nxcon = nxtk_register(g_nxconvars.hwnd, &wndo, g_nxconvars.minor);
+ if (!g_nxconvars.nxcon)
+ {
+ goto errout;
+ }
+
+ // Construct the driver name using this minor number
+
+ char devname[32];
+ snprintf(devname, 32, "/dev/nxcon%d", g_nxconvars.minor);
+
+ // Increment the minor number while it is protect by the semaphore
+
+ g_nxconvars.minor++;
+
+ // Open the NxConsole driver
+
+ fd = open(devname, O_WRONLY);
+ if (fd < 0)
+ {
+ goto errout_with_nxcon;
+ }
+
+ // Now re-direct stdout and stderr so that they use the NX console driver.
+ // Note that stdin is retained (file descriptor 0, probably the the serial console).
+
+ (void)std::fflush(stdout);
+ (void)std::fflush(stderr);
+
+ (void)std::fclose(stdout);
+ (void)std::fclose(stderr);
+
+ (void)std::dup2(fd, 1);
+ (void)std::dup2(fd, 2);
+
+ // And we can close our original driver file descriptor
+
+ std::close(fd);
+
+ // Inform the parent thread that we successfully initialize
+
+ g_nxconvars.result = true;
+ sem_post(&g_nxconvars.sem);
+
+ // Run the NSH console
+
+#ifdef CONFIG_NSH_CONSOLE
+ (void)nsh_consolemain(argc, argv);
+#endif
+
+ // We get here if console exits
+#warning "Missing logic"
+ return EXIT_SUCCESS;
+
+errout_with_nxcon:
+ nxcon_unregister(g_nxconvars.nxcon);
+
+errout:
+ g_nxconvars.nxcon = 0;
+ g_nxconvars.result = false;
+ sem_post(&g_nxconvars.sem);
+ return EXIT_FAILURE;
+}
+
+/**
* Called when the window minimize button is pressed.
*/
diff --git a/NxWidgets/nxwm/src/ctaskbar.cxx b/NxWidgets/nxwm/src/ctaskbar.cxx
index 8d2907266..faac2fa76 100644
--- a/NxWidgets/nxwm/src/ctaskbar.cxx
+++ b/NxWidgets/nxwm/src/ctaskbar.cxx
@@ -83,6 +83,84 @@ CTaskbar::~CTaskbar(void)
}
/**
+ * Connect to the server
+ */
+
+bool CTaskbar::connect(void)
+{
+ // Connect to the server
+
+ bool nxConnected = CNxServer::connect();
+ if (nxConnected)
+ {
+ // Set the background color
+
+ if (!setBackgroundColor(CONFIG_NXWM_DEFAULT_BACKGROUNDCOLOR))
+ {
+ // Failed
+ }
+ }
+
+ return nxConnected;
+}
+
+/**
+ * Disconnect from the server
+ */
+
+void CTaskbar::disconnect(void)
+{
+ // Stop all applications and remove them from the task bar. Clearly, there
+ // are some ordering issues here... On an orderly system shutdown, disconnection
+ // should really occur priority to deleting instances
+
+ while (!m_slots.empty())
+ {
+ IApplication *app = m_slots.at(0).app;
+ stopApplication(app);
+ }
+
+ // Close the windows
+
+ NXWidgets::CWidgetControl *control;
+ if (m_taskbar)
+ {
+ // Delete the contained widget control. We are responsible for it
+ // because we created it
+
+ control = m_taskbar->getWidgetControl();
+ if (control)
+ {
+ delete control;
+ }
+
+ // Then delete the task bar window
+
+ delete m_taskbar;
+ }
+
+ if (m_background)
+ {
+ // Delete the contained widget control. We are responsible for it
+ // because we created it
+
+ control = m_background->getWidgetControl();
+ if (control)
+ {
+ delete control;
+ }
+
+ // Then delete the background
+
+ delete m_background;
+ }
+
+ // And disconnect from the server
+
+ CNxServer::disconnect();
+}
+
+/**
* Initialize task bar. Task bar initialization is separate from
* object instantiation so that failures can be reported. The window
* manager start-up sequence is:
@@ -427,84 +505,6 @@ bool CTaskbar::stopApplication(IApplication *app)
}
/**
- * Connect to the server
- */
-
-bool CTaskbar::connect(void)
-{
- // Connect to the server
-
- bool nxConnected = CNxServer::connect();
- if (nxConnected)
- {
- // Set the background color
-
- if (!setBackgroundColor(CONFIG_NXWM_DEFAULT_BACKGROUNDCOLOR))
- {
- // Failed
- }
- }
-
- return nxConnected;
-}
-
-/**
- * Disconnect from the server
- */
-
-void CTaskbar::disconnect(void)
-{
- // Stop all applications and remove them from the task bar. Clearly, there
- // are some ordering issues here... On an orderly system shutdown, disconnection
- // should really occur priority to deleting instances
-
- while (!m_slots.empty())
- {
- IApplication *app = m_slots.at(0).app;
- stopApplication(app);
- }
-
- // Close the windows
-
- NXWidgets::CWidgetControl *control;
- if (m_taskbar)
- {
- // Delete the contained widget control. We are responsible for it
- // because we created it
-
- control = m_taskbar->getWidgetControl();
- if (control)
- {
- delete control;
- }
-
- // Then delete the task bar window
-
- delete m_taskbar;
- }
-
- if (m_background)
- {
- // Delete the contained widget control. We are responsible for it
- // because we created it
-
- control = m_background->getWidgetControl();
- if (control)
- {
- delete control;
- }
-
- // Then delete the background
-
- delete m_background;
- }
-
- // And disconnect from the server
-
- CNxServer::disconnect();
-}
-
-/**
* Create a raw window.
*
* 1) Create a dumb CWigetControl instance
@@ -893,7 +893,7 @@ bool CTaskbar::redrawTaskbarWindow(void)
// For vertical task bars, the icons will be centered horizontally
iconPos.x = (windowSize.w - rect.getWidth()) >> 1;
- iconPos.y = taskbarPos.y
+ iconPos.y = taskbarPos.y;
#endif
// Set the position of the icon bitmap
diff --git a/NxWidgets/nxwm/src/glyph_minimize.cxx b/NxWidgets/nxwm/src/glyph_minimize.cxx
index 8c4228279..f86015367 100644
--- a/NxWidgets/nxwm/src/glyph_minimize.cxx
+++ b/NxWidgets/nxwm/src/glyph_minimize.cxx
@@ -170,7 +170,7 @@ static const struct NXWidgets::SRlePaletteBitmapEntry g_minimizeRleEntries[] =
* Public Bitmap Structure Defintions
********************************************************************************************/
-const struct NXWidgets::SRlePaletteBitmap g_minimizeBitmap =
+const struct NXWidgets::SRlePaletteBitmap NxWM::g_minimizeBitmap =
{
CONFIG_NXWIDGETS_BPP, // bpp - Bits per pixel
CONFIG_NXWIDGETS_FMT, // fmt - Color format
diff --git a/NxWidgets/nxwm/src/glyph_nsh.cxx b/NxWidgets/nxwm/src/glyph_nsh.cxx
index 8e9b0746d..5ddeb9008 100644
--- a/NxWidgets/nxwm/src/glyph_nsh.cxx
+++ b/NxWidgets/nxwm/src/glyph_nsh.cxx
@@ -196,7 +196,7 @@ static const struct NXWidgets::SRlePaletteBitmapEntry g_nshRleEntries[] =
* Public Bitmap Structure Defintions
********************************************************************************************/
-const struct NXWidgets::SRlePaletteBitmap g_nshBitmap =
+const struct NXWidgets::SRlePaletteBitmap NxWM::g_nshBitmap =
{
CONFIG_NXWIDGETS_BPP, // bpp - Bits per pixel
CONFIG_NXWIDGETS_FMT, // fmt - Color format
diff --git a/NxWidgets/nxwm/src/glyph_start.cxx b/NxWidgets/nxwm/src/glyph_start.cxx
index a81d6b19f..85457799d 100644
--- a/NxWidgets/nxwm/src/glyph_start.cxx
+++ b/NxWidgets/nxwm/src/glyph_start.cxx
@@ -197,7 +197,7 @@ static const struct NXWidgets::SRlePaletteBitmapEntry g_startRleEntries[] =
* Public Bitmap Structure Defintions
********************************************************************************************/
-const struct NXWidgets::SRlePaletteBitmap g_startBitmap =
+const struct NXWidgets::SRlePaletteBitmap NxWM::g_startBitmap =
{
CONFIG_NXWIDGETS_BPP, // bpp - Bits per pixel
CONFIG_NXWIDGETS_FMT, // fmt - Color format
diff --git a/NxWidgets/nxwm/src/glyph_stop.cxx b/NxWidgets/nxwm/src/glyph_stop.cxx
index 5c4c5477e..fdb08fa51 100644
--- a/NxWidgets/nxwm/src/glyph_stop.cxx
+++ b/NxWidgets/nxwm/src/glyph_stop.cxx
@@ -209,7 +209,7 @@ static const struct NXWidgets::SRlePaletteBitmapEntry g_stopRleEntries[] =
* Public Bitmap Structure Defintions
********************************************************************************************/
-const struct NXWidgets::SRlePaletteBitmap g_stopBitmap =
+const struct NXWidgets::SRlePaletteBitmap NxWM::g_stopBitmap =
{
CONFIG_NXWIDGETS_BPP, // bpp - Bits per pixel
CONFIG_NXWIDGETS_FMT, // fmt - Color format