NxWM: Correct the calculation of the physical dispaly size

git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@4726 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
patacongo 2012-05-12 16:59:57 +00:00
parent 6e07395780
commit eb31d305a1
4 changed files with 52 additions and 38 deletions

View File

@ -60,5 +60,6 @@
* NxWM::CTouchscreen: Do not read touchscreen data when there is no consumer. * NxWM::CTouchscreen: Do not read touchscreen data when there is no consumer.
* NxWM::CWindowControl: Add new class to wrap CWidgetControl and provide * NxWM::CWindowControl: Add new class to wrap CWidgetControl and provide
some special mouse and keyboard input event handling. some special mouse and keyboard input event handling.
* NxWM::CTaskbar: Correct the calculation of the physical size of the
display.

View File

@ -368,15 +368,15 @@ static bool startWindowManager(void)
#ifdef CONFIG_NXWM_TOUCHSCREEN #ifdef CONFIG_NXWM_TOUCHSCREEN
static bool createTouchScreen(void) static bool createTouchScreen(void)
{ {
// Get the physical size of the device in pixels // Get the physical size of the display in pixels
struct nxgl_size_s windowSize; struct nxgl_size_s displaySize;
(void)g_nxwmtest.taskbar->getWindowSize(&windowSize); (void)g_nxwmtest.taskbar->getDisplaySize(displaySize);
// Create the touchscreen device // Create the touchscreen device
printf(MAIN_STRING "Creating CTouchscreen\n"); printf(MAIN_STRING "Creating CTouchscreen\n");
g_nxwmtest.touchscreen = new NxWM::CTouchscreen(g_nxwmtest.taskbar, &windowSize); g_nxwmtest.touchscreen = new NxWM::CTouchscreen(g_nxwmtest.taskbar, &displaySize);
if (!g_nxwmtest.touchscreen) if (!g_nxwmtest.touchscreen)
{ {
printf(MAIN_STRING "ERROR: Failed to create CTouchscreen\n"); printf(MAIN_STRING "ERROR: Failed to create CTouchscreen\n");

View File

@ -393,10 +393,7 @@ namespace NxWM
* @return The size of the display * @return The size of the display
*/ */
inline bool getWindowSize(FAR struct nxgl_size_s *size) void getDisplaySize(FAR struct nxgl_size_s &size);
{
return m_taskbar->getSize(size);
}
/** /**
* Simulate a mouse click on the icon at index. This inline method is only * Simulate a mouse click on the icon at index. This inline method is only

View File

@ -548,6 +548,29 @@ bool CTaskbar::stopApplication(IApplication *app)
return redrawTaskbarWindow(); return redrawTaskbarWindow();
} }
/**
* Get the size of the physical display device as it is known to the task
* bar.
*
* @return The size of the display
*/
void CTaskbar::getDisplaySize(FAR struct nxgl_size_s &size)
{
// Get the widget control from the task bar window. The physical window geometry
// should be the same for all windows.
NXWidgets::CWidgetControl *control = m_taskbar->getWidgetControl();
// Get the window bounding box from the widget control
NXWidgets::CRect rect = control->getWindowBoundingBox();
// And return the size of the window
rect.getSize(size);
}
/** /**
* Create a raw window. * Create a raw window.
* *
@ -638,14 +661,10 @@ NXWidgets::CNxTkWindow *CTaskbar::openFramedWindow(void)
void CTaskbar::setApplicationGeometry(NXWidgets::INxWindow *window, bool fullscreen) void CTaskbar::setApplicationGeometry(NXWidgets::INxWindow *window, bool fullscreen)
{ {
// Get the widget control from the task bar window. The physical window geometry // Get the physical size of the display
// should be the same for all windows.
NXWidgets::CWidgetControl *control = m_taskbar->getWidgetControl(); struct nxgl_size_s displaySize;
getDisplaySize(displaySize);
// Get the size of the window from the widget control
NXWidgets::CRect rect = control->getWindowBoundingBox();
// Now position and size the application. This will depend on the position and // Now position and size the application. This will depend on the position and
// orientation of the task bar. // orientation of the task bar.
@ -660,8 +679,8 @@ void CTaskbar::setApplicationGeometry(NXWidgets::INxWindow *window, bool fullscr
pos.x = 0; pos.x = 0;
pos.y = 0; pos.y = 0;
size.w = rect.getWidth(); size.w = displaySize.w;
size.h = rect.getHeight(); size.h = displaySize.h;
} }
else else
{ {
@ -669,26 +688,26 @@ void CTaskbar::setApplicationGeometry(NXWidgets::INxWindow *window, bool fullscr
pos.x = 0; pos.x = 0;
pos.y = CONFIG_NXWM_TASKBAR_WIDTH; pos.y = CONFIG_NXWM_TASKBAR_WIDTH;
size.w = rect.getWidth(); size.w = displaySize.w;
size.h = rect.getHeight() - CONFIG_NXWM_TASKBAR_WIDTH; size.h = displaySize.h - CONFIG_NXWM_TASKBAR_WIDTH;
#elif defined(CONFIG_NXWM_TASKBAR_BOTTOM) #elif defined(CONFIG_NXWM_TASKBAR_BOTTOM)
pos.x = 0; pos.x = 0;
pos.y = 0; pos.y = 0;
size.w = rect.getWidth(); size.w = displaySize.w;
size.h = rect.getHeight() - CONFIG_NXWM_TASKBAR_WIDTH; size.h = displaySize.h - CONFIG_NXWM_TASKBAR_WIDTH;
#elif defined(CONFIG_NXWM_TASKBAR_LEFT) #elif defined(CONFIG_NXWM_TASKBAR_LEFT)
pos.x = CONFIG_NXWM_TASKBAR_WIDTH; pos.x = CONFIG_NXWM_TASKBAR_WIDTH;
pos.y = 0; pos.y = 0;
size.w = rect.getWidth() - CONFIG_NXWM_TASKBAR_WIDTH; size.w = displaySize.w - CONFIG_NXWM_TASKBAR_WIDTH;
size.h = rect.getHeight(); size.h = displaySize.h;
#else #else
pos.x = 0; pos.x = 0;
pos.y = 0; pos.y = 0;
size.w = rect.getWidth() - CONFIG_NXWM_TASKBAR_WIDTH; size.w = displaySize.w - CONFIG_NXWM_TASKBAR_WIDTH;
size.h = rect.getHeight(); size.h = displaySize.h;
#endif #endif
} }
@ -718,13 +737,10 @@ bool CTaskbar::createTaskbarWindow(void)
return false; return false;
} }
// Get the contained widget control // Get the size of the physical display
NXWidgets::CWidgetControl *control = m_taskbar->getWidgetControl(); struct nxgl_size_s displaySize;
getDisplaySize(displaySize);
// Get the size of the window from the widget control
NXWidgets::CRect rect = control->getWindowBoundingBox();
// Now position and size the task bar. This will depend on the position and // Now position and size the task bar. This will depend on the position and
// orientation of the task bar. // orientation of the task bar.
@ -736,26 +752,26 @@ bool CTaskbar::createTaskbarWindow(void)
pos.x = 0; pos.x = 0;
pos.y = 0; pos.y = 0;
size.w = rect.getWidth(); size.w = displaySize.w;
size.h = CONFIG_NXWM_TASKBAR_WIDTH; size.h = CONFIG_NXWM_TASKBAR_WIDTH;
#elif defined(CONFIG_NXWM_TASKBAR_BOTTOM) #elif defined(CONFIG_NXWM_TASKBAR_BOTTOM)
pos.x = 0; pos.x = 0;
pos.y = rect.getHeight() - CONFIG_NXWM_TASKBAR_WIDTH; pos.y = displaySize.h - CONFIG_NXWM_TASKBAR_WIDTH;
size.w = rect.getWidth(); size.w = displaySize.w;
size.h = CONFIG_NXWM_TASKBAR_WIDTH; size.h = CONFIG_NXWM_TASKBAR_WIDTH;
#elif defined(CONFIG_NXWM_TASKBAR_LEFT) #elif defined(CONFIG_NXWM_TASKBAR_LEFT)
pos.x = 0; pos.x = 0;
pos.y = 0; pos.y = 0;
size.w = CONFIG_NXWM_TASKBAR_WIDTH; size.w = CONFIG_NXWM_TASKBAR_WIDTH;
size.h = rect.getHeight(); size.h = displaySize.h;
#else #else
pos.x = rect.getWidgth() - CONFIG_NXWM_TASKBAR_WIDTH; pos.x = rect.getWidgth() - CONFIG_NXWM_TASKBAR_WIDTH;
pos.y = 0; pos.y = 0;
size.w = CONFIG_NXWM_TASKBAR_WIDTH; size.w = CONFIG_NXWM_TASKBAR_WIDTH;
size.h = rect.getHeight(); size.h = displaySize.h;
#endif #endif
/* Set the size and position the window. /* Set the size and position the window.
@ -940,7 +956,7 @@ bool CTaskbar::redrawTaskbarWindow(void)
struct nxgl_point_s iconPos; struct nxgl_point_s iconPos;
#if defined(CONFIG_NXWM_TASKBAR_TOP) || defined(CONFIG_NXWM_TASKBAR_BOTTOM) #if defined(CONFIG_NXWM_TASKBAR_TOP) || defined(CONFIG_NXWM_TASKBAR_BOTTOM)
// For horizontal task bars, the icons will be aligned at the top of // For horizontal task bars, the icons will be aligned along the top of
// the task bar // the task bar
iconPos.x = taskbarPos.x; iconPos.x = taskbarPos.x;