summaryrefslogtreecommitdiff
path: root/NxWidgets/libnxwidgets
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2012-05-01 22:31:26 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2012-05-01 22:31:26 +0000
commitfe90fbdbd18eed8712bbc30909efb1b7870f859f (patch)
treeeee1c00f81d018b0b2ec87c6a61d59947ad75606 /NxWidgets/libnxwidgets
parentfd4dd86fe8de2ddda1e8723973e8b5774528ebb7 (diff)
downloadpx4-nuttx-fe90fbdbd18eed8712bbc30909efb1b7870f859f.tar.gz
px4-nuttx-fe90fbdbd18eed8712bbc30909efb1b7870f859f.tar.bz2
px4-nuttx-fe90fbdbd18eed8712bbc30909efb1b7870f859f.zip
NxWM update
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@4683 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'NxWidgets/libnxwidgets')
-rw-r--r--NxWidgets/libnxwidgets/include/cwidgetcontrol.hxx33
-rw-r--r--NxWidgets/libnxwidgets/src/cimage.cxx2
-rw-r--r--NxWidgets/libnxwidgets/src/cwidgetcontrol.cxx27
3 files changed, 60 insertions, 2 deletions
diff --git a/NxWidgets/libnxwidgets/include/cwidgetcontrol.hxx b/NxWidgets/libnxwidgets/include/cwidgetcontrol.hxx
index 9fedd4618..0a894eae8 100644
--- a/NxWidgets/libnxwidgets/include/cwidgetcontrol.hxx
+++ b/NxWidgets/libnxwidgets/include/cwidgetcontrol.hxx
@@ -193,6 +193,9 @@ namespace NXWidgets
struct nxgl_size_s m_size; /**< Size of the window */
struct nxgl_point_s m_pos; /**< Position in display space */
struct nxgl_rect_s m_bounds; /**< Size of the display */
+#ifdef CONFIG_NX_MULTIUSER
+ sem_t m_geosem; /**< Posted when geometry is valid */
+#endif
/**
* Style
@@ -280,6 +283,27 @@ namespace NXWidgets
void wakeupModalLoop(void);
/**
+ * Take the geometry semaphore (handling signal interruptions)
+ */
+
+#ifdef CONFIG_NX_MULTIUSER
+ void takeGeoSem(void);
+#else
+ inline void takeGeoSem(void) {}
+#endif
+
+ /**
+ * Give the geometry semaphore
+ */
+
+ inline void giveGeoSem(void)
+ {
+#ifdef CONFIG_NX_MULTIUSER
+ sem_post(&m_geosem);
+#endif
+ }
+
+ /**
* Clear all mouse events
*/
@@ -553,7 +577,10 @@ namespace NXWidgets
inline CRect getWindowBoundingBox(void)
{
- return CRect(&m_bounds);
+ takeGeoSem();
+ CRect rect(&m_bounds);
+ giveGeoSem();
+ return rect;
}
/**
@@ -564,8 +591,10 @@ namespace NXWidgets
inline bool getWindowPosition(FAR struct nxgl_point_s *pPos)
{
+ takeGeoSem();
pPos->x = m_pos.x;
pPos->x = m_pos.y;
+ giveGeoSem();
return true;
}
@@ -577,8 +606,10 @@ namespace NXWidgets
inline bool getWindowSize(FAR struct nxgl_size_s *pSize)
{
+ takeGeoSem();
pSize->h = m_size.h;
pSize->w = m_size.w;
+ giveGeoSem();
return true;
}
diff --git a/NxWidgets/libnxwidgets/src/cimage.cxx b/NxWidgets/libnxwidgets/src/cimage.cxx
index c905737fd..0ca6f571e 100644
--- a/NxWidgets/libnxwidgets/src/cimage.cxx
+++ b/NxWidgets/libnxwidgets/src/cimage.cxx
@@ -272,7 +272,7 @@ void CImage::drawContents(CGraphicsPort *port)
}
else
{
- port->drawBitmapGreyScale(rect.getX(),displayRow,
+ port->drawBitmapGreyScale(rect.getX(), displayRow,
rect.getWidth(), 1,
&bitmap, 0, 0);
}
diff --git a/NxWidgets/libnxwidgets/src/cwidgetcontrol.cxx b/NxWidgets/libnxwidgets/src/cwidgetcontrol.cxx
index 5ea672a2f..a6807dad5 100644
--- a/NxWidgets/libnxwidgets/src/cwidgetcontrol.cxx
+++ b/NxWidgets/libnxwidgets/src/cwidgetcontrol.cxx
@@ -42,6 +42,7 @@
#include <stdint.h>
#include <stdbool.h>
#include <cstring>
+#include <cerrno>
#include "nxconfig.hxx"
#include "cnxserver.hxx"
@@ -427,6 +428,13 @@ void CWidgetControl::geometryEvent(NXHANDLE hWindow,
m_hWindow = hWindow;
nxgl_rectcopy(&m_bounds, bounds);
+
+ // Wake up any threads waiting for initial position information.
+ // REVISIT: If the window is moved or repositioned, then the
+ // position and size data will be incorrect for a period of time.
+ // That case should be handled here as well.
+
+ giveGeoSem();
}
}
@@ -865,6 +873,25 @@ bool CWidgetControl::pollCursorControlEvents(void)
}
/**
+ * Take the geometry semaphore (handling signal interruptions)
+ */
+
+#ifdef CONFIG_NX_MULTIUSER
+void CWidgetControl::takeGeoSem(void)
+{
+ // Take the geometry semaphore. Retry is an error occurs (only if
+ // the error is due to a signal interruption).
+
+ int ret;
+ do
+ {
+ ret = sem_wait(&m_geosem);
+ }
+ while (ret < 0 && errno == EINTR);
+}
+#endif
+
+/**
* Clear all mouse events
*/