From 9302c8796fc4dcda08d4bd1e11733848fd4fafaf Mon Sep 17 00:00:00 2001 From: Jeff Brown Date: Wed, 13 Jul 2011 22:51:29 -0700 Subject: Refactor input dispatcher use of window/app handles. This change moves the cached window and application input state into the handle objects themselves. It simplifies the dispatcher somewhat because it no longer needs to fix up references to transient InputWindow objects each time the window list is updated. This change will also make it easier to optimize setInputWindows to avoid doing a lot of redundant data copying. In principle, only the modified fields need to be updated. However, for now we continue to update all fields in unison as before. It turns out that the input dispatcher was inappropriately retaining pointers to InputWindow objects within the mWindows InputWindow vector. This vector is copy-on-write so it is possible and the item pointers to change if an editing operation is performed on the vector when it does not exclusively own the underlying SharedBuffer. This bug was uncovered by a previous change that replaced calls to clear() and appendVector() with a simple use of operator= which caused the buffer to be shared. Consequently after editItemAt was called (which it shouldn't have, actually) the buffer was copied and the cached InputWindow pointers became invalid. Oops. This change fixes the problem. Change-Id: I0a259339a6015fcf9113dc4081a6875e047fd425 --- services/input/InputWindow.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'services/input/InputWindow.cpp') diff --git a/services/input/InputWindow.cpp b/services/input/InputWindow.cpp index b552f6d5b43d..0ce886738108 100644 --- a/services/input/InputWindow.cpp +++ b/services/input/InputWindow.cpp @@ -22,25 +22,25 @@ namespace android { -// --- InputWindow --- +// --- InputWindowHandle --- -bool InputWindow::touchableRegionContainsPoint(int32_t x, int32_t y) const { +bool InputWindowHandle::touchableRegionContainsPoint(int32_t x, int32_t y) const { return touchableRegion.contains(x, y); } -bool InputWindow::frameContainsPoint(int32_t x, int32_t y) const { +bool InputWindowHandle::frameContainsPoint(int32_t x, int32_t y) const { return x >= frameLeft && x <= frameRight && y >= frameTop && y <= frameBottom; } -bool InputWindow::isTrustedOverlay() const { +bool InputWindowHandle::isTrustedOverlay() const { return layoutParamsType == TYPE_INPUT_METHOD || layoutParamsType == TYPE_INPUT_METHOD_DIALOG || layoutParamsType == TYPE_SECURE_SYSTEM_OVERLAY; } -bool InputWindow::supportsSplitTouch() const { - return layoutParamsFlags & InputWindow::FLAG_SPLIT_TOUCH; +bool InputWindowHandle::supportsSplitTouch() const { + return layoutParamsFlags & FLAG_SPLIT_TOUCH; } } // namespace android -- cgit v1.2.3-59-g8ed1b