InputWindow.cpp 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. /*
  2. * Copyright (C) 2011 The Android Open Source Project
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. #define LOG_TAG "InputWindow"
  17. #define LOG_NDEBUG 0
  18. #include "InputWindow.h"
  19. #include <cutils/log.h>
  20. #include <ui/Rect.h>
  21. #include <ui/Region.h>
  22. namespace android {
  23. // --- InputWindowInfo ---
  24. void InputWindowInfo::addTouchableRegion(const Rect& region) {
  25. touchableRegion.orSelf(region);
  26. }
  27. bool InputWindowInfo::touchableRegionContainsPoint(int32_t x, int32_t y) const {
  28. return touchableRegion.contains(x,y);
  29. }
  30. bool InputWindowInfo::frameContainsPoint(int32_t x, int32_t y) const {
  31. return x >= frameLeft && x < frameRight
  32. && y >= frameTop && y < frameBottom;
  33. }
  34. bool InputWindowInfo::isTrustedOverlay() const {
  35. return layoutParamsType == TYPE_INPUT_METHOD
  36. || layoutParamsType == TYPE_INPUT_METHOD_DIALOG
  37. || layoutParamsType == TYPE_MAGNIFICATION_OVERLAY
  38. || layoutParamsType == TYPE_STATUS_BAR
  39. || layoutParamsType == TYPE_NAVIGATION_BAR
  40. || layoutParamsType == TYPE_SECURE_SYSTEM_OVERLAY;
  41. }
  42. bool InputWindowInfo::supportsSplitTouch() const {
  43. return layoutParamsFlags & FLAG_SPLIT_TOUCH;
  44. }
  45. bool InputWindowInfo::overlaps(const InputWindowInfo* other) const {
  46. return frameLeft < other->frameRight && frameRight > other->frameLeft
  47. && frameTop < other->frameBottom && frameBottom > other->frameTop;
  48. }
  49. // --- InputWindowHandle ---
  50. InputWindowHandle::InputWindowHandle(const sp<InputApplicationHandle>& inputApplicationHandle) :
  51. inputApplicationHandle(inputApplicationHandle), mInfo(NULL) {
  52. }
  53. InputWindowHandle::~InputWindowHandle() {
  54. delete mInfo;
  55. }
  56. void InputWindowHandle::releaseInfo() {
  57. if (mInfo) {
  58. delete mInfo;
  59. mInfo = NULL;
  60. }
  61. }
  62. } // namespace android