From a9990e4f81cbd4e9201e60e9123b3caeb5ecb35b Mon Sep 17 00:00:00 2001 From: patacongo Date: Sat, 12 May 2012 16:59:57 +0000 Subject: 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 --- NxWidgets/ChangeLog.txt | 3 +- NxWidgets/UnitTests/nxwm/main.cxx | 8 ++-- NxWidgets/nxwm/include/ctaskbar.hxx | 5 +-- NxWidgets/nxwm/src/ctaskbar.cxx | 74 ++++++++++++++++++++++--------------- nuttx/graphics/nxmu/nxmu_mouse.c | 6 +-- nuttx/graphics/nxsu/nx_mousein.c | 4 +- 6 files changed, 57 insertions(+), 43 deletions(-) diff --git a/NxWidgets/ChangeLog.txt b/NxWidgets/ChangeLog.txt index 5d316d081..da14da62b 100755 --- a/NxWidgets/ChangeLog.txt +++ b/NxWidgets/ChangeLog.txt @@ -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. diff --git a/NxWidgets/UnitTests/nxwm/main.cxx b/NxWidgets/UnitTests/nxwm/main.cxx index c230b9f87..271fd22c2 100644 --- a/NxWidgets/UnitTests/nxwm/main.cxx +++ b/NxWidgets/UnitTests/nxwm/main.cxx @@ -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"); diff --git a/NxWidgets/nxwm/include/ctaskbar.hxx b/NxWidgets/nxwm/include/ctaskbar.hxx index 1f2f69580..431c2be48 100644 --- a/NxWidgets/nxwm/include/ctaskbar.hxx +++ b/NxWidgets/nxwm/include/ctaskbar.hxx @@ -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 diff --git a/NxWidgets/nxwm/src/ctaskbar.cxx b/NxWidgets/nxwm/src/ctaskbar.cxx index a840fdcb2..87fa34c3d 100644 --- a/NxWidgets/nxwm/src/ctaskbar.cxx +++ b/NxWidgets/nxwm/src/ctaskbar.cxx @@ -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. - - NXWidgets::CWidgetControl *control = m_taskbar->getWidgetControl(); + // Get the physical size of the display - // 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 - - NXWidgets::CWidgetControl *control = m_taskbar->getWidgetControl(); - - // Get the size of the window from the widget control + // Get the size of the physical display - 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; diff --git a/nuttx/graphics/nxmu/nxmu_mouse.c b/nuttx/graphics/nxmu/nxmu_mouse.c index 44ec9918a..1ae31bec2 100644 --- a/nuttx/graphics/nxmu/nxmu_mouse.c +++ b/nuttx/graphics/nxmu/nxmu_mouse.c @@ -1,8 +1,8 @@ /**************************************************************************** * graphics/nxmu/nxmu__mouse.c * - * Copyright (C) 2008-2009, 2011 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt + * Copyright (C) 2008-2009, 2011-2012 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt * * 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 */ diff --git a/nuttx/graphics/nxsu/nx_mousein.c b/nuttx/graphics/nxsu/nx_mousein.c index 01505ee8b..bee4a2265 100644 --- a/nuttx/graphics/nxsu/nx_mousein.c +++ b/nuttx/graphics/nxsu/nx_mousein.c @@ -1,8 +1,8 @@ /**************************************************************************** * graphics/nxsu/nx_mousein.c * - * Copyright (C) 2008-2009, 2011 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt + * Copyright (C) 2008-2009, 2011-2012 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions -- cgit v1.2.3