NxWM: Correct the calculation of the physical dispaly size

git-svn-id: https://nuttx.svn.sourceforge.net/svnroot/nuttx/trunk@4726 7fd9a85b-ad96-42d3-883c-3090e2eb8679
This commit is contained in:
patacongo 2012-05-12 16:59:57 +00:00
parent 48e8fe2304
commit d4c261ea71
6 changed files with 57 additions and 43 deletions

View File

@ -60,5 +60,6 @@
* NxWM::CTouchscreen: Do not read touchscreen data when there is no consumer.
* NxWM::CWindowControl: Add new class to wrap CWidgetControl and provide
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
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;
(void)g_nxwmtest.taskbar->getWindowSize(&windowSize);
struct nxgl_size_s displaySize;
(void)g_nxwmtest.taskbar->getDisplaySize(displaySize);
// Create the touchscreen device
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)
{
printf(MAIN_STRING "ERROR: Failed to create CTouchscreen\n");

View File

@ -393,10 +393,7 @@ namespace NxWM
* @return The size of the display
*/
inline bool getWindowSize(FAR struct nxgl_size_s *size)
{
return m_taskbar->getSize(size);
}
void getDisplaySize(FAR struct nxgl_size_s &size);
/**
* 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();
}
/**
* 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.
*
@ -638,14 +661,10 @@ NXWidgets::CNxTkWindow *CTaskbar::openFramedWindow(void)
void CTaskbar::setApplicationGeometry(NXWidgets::INxWindow *window, bool fullscreen)
{
// Get the widget control from the task bar window. The physical window geometry
// should be the same for all windows.
// Get the physical size of the display
NXWidgets::CWidgetControl *control = m_taskbar->getWidgetControl();
// Get the size of the window from the widget control
NXWidgets::CRect rect = control->getWindowBoundingBox();
struct nxgl_size_s displaySize;
getDisplaySize(displaySize);
// Now position and size the application. This will depend on the position and
// orientation of the task bar.
@ -660,8 +679,8 @@ void CTaskbar::setApplicationGeometry(NXWidgets::INxWindow *window, bool fullscr
pos.x = 0;
pos.y = 0;
size.w = rect.getWidth();
size.h = rect.getHeight();
size.w = displaySize.w;
size.h = displaySize.h;
}
else
{
@ -669,26 +688,26 @@ void CTaskbar::setApplicationGeometry(NXWidgets::INxWindow *window, bool fullscr
pos.x = 0;
pos.y = CONFIG_NXWM_TASKBAR_WIDTH;
size.w = rect.getWidth();
size.h = rect.getHeight() - CONFIG_NXWM_TASKBAR_WIDTH;
size.w = displaySize.w;
size.h = displaySize.h - CONFIG_NXWM_TASKBAR_WIDTH;
#elif defined(CONFIG_NXWM_TASKBAR_BOTTOM)
pos.x = 0;
pos.y = 0;
size.w = rect.getWidth();
size.h = rect.getHeight() - CONFIG_NXWM_TASKBAR_WIDTH;
size.w = displaySize.w;
size.h = displaySize.h - CONFIG_NXWM_TASKBAR_WIDTH;
#elif defined(CONFIG_NXWM_TASKBAR_LEFT)
pos.x = CONFIG_NXWM_TASKBAR_WIDTH;
pos.y = 0;
size.w = rect.getWidth() - CONFIG_NXWM_TASKBAR_WIDTH;
size.h = rect.getHeight();
size.w = displaySize.w - CONFIG_NXWM_TASKBAR_WIDTH;
size.h = displaySize.h;
#else
pos.x = 0;
pos.y = 0;
size.w = rect.getWidth() - CONFIG_NXWM_TASKBAR_WIDTH;
size.h = rect.getHeight();
size.w = displaySize.w - CONFIG_NXWM_TASKBAR_WIDTH;
size.h = displaySize.h;
#endif
}
@ -718,13 +737,10 @@ bool CTaskbar::createTaskbarWindow(void)
return false;
}
// Get the contained widget control
// Get the size of the physical display
NXWidgets::CWidgetControl *control = m_taskbar->getWidgetControl();
// Get the size of the window from the widget control
NXWidgets::CRect rect = control->getWindowBoundingBox();
struct nxgl_size_s displaySize;
getDisplaySize(displaySize);
// Now position and size the task bar. This will depend on the position and
// orientation of the task bar.
@ -736,26 +752,26 @@ bool CTaskbar::createTaskbarWindow(void)
pos.x = 0;
pos.y = 0;
size.w = rect.getWidth();
size.w = displaySize.w;
size.h = CONFIG_NXWM_TASKBAR_WIDTH;
#elif defined(CONFIG_NXWM_TASKBAR_BOTTOM)
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;
#elif defined(CONFIG_NXWM_TASKBAR_LEFT)
pos.x = 0;
pos.y = 0;
size.w = CONFIG_NXWM_TASKBAR_WIDTH;
size.h = rect.getHeight();
size.h = displaySize.h;
#else
pos.x = rect.getWidgth() - CONFIG_NXWM_TASKBAR_WIDTH;
pos.y = 0;
size.w = CONFIG_NXWM_TASKBAR_WIDTH;
size.h = rect.getHeight();
size.h = displaySize.h;
#endif
/* Set the size and position the window.
@ -940,7 +956,7 @@ bool CTaskbar::redrawTaskbarWindow(void)
struct nxgl_point_s iconPos;
#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
iconPos.x = taskbarPos.x;

View File

@ -1,8 +1,8 @@
/****************************************************************************
* graphics/nxmu/nxmu__mouse.c
*
* Copyright (C) 2008-2009, 2011 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
* Copyright (C) 2008-2009, 2011-2012 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@ -194,7 +194,7 @@ int nxmu_mousein(FAR struct nxfe_state_s *fe,
g_mbutton = buttons;
/* Pick the window to receive the mouse event. Start with
* the top window and go down. Step with the first window
* the top window and go down. Stop with the first window
* that gets the mouse report
*/

View File

@ -1,8 +1,8 @@
/****************************************************************************
* graphics/nxsu/nx_mousein.c
*
* Copyright (C) 2008-2009, 2011 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
* Copyright (C) 2008-2009, 2011-2012 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions