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
17 #define LOG_TAG "InputWindow"
18 #define LOG_NDEBUG 0
19
20 #include "InputWindow.h"
21
22 #include <cutils/log.h>
23
24 #include <ui/Rect.h>
25 #include <ui/Region.h>
26
27 namespace android {
28
29 // --- InputWindowInfo ---
addTouchableRegion(const Rect & region)30 void InputWindowInfo::addTouchableRegion(const Rect& region) {
31 touchableRegion.orSelf(region);
32 }
33
touchableRegionContainsPoint(int32_t x,int32_t y) const34 bool InputWindowInfo::touchableRegionContainsPoint(int32_t x, int32_t y) const {
35 return touchableRegion.contains(x,y);
36 }
37
frameContainsPoint(int32_t x,int32_t y) const38 bool InputWindowInfo::frameContainsPoint(int32_t x, int32_t y) const {
39 return x >= frameLeft && x < frameRight
40 && y >= frameTop && y < frameBottom;
41 }
42
isTrustedOverlay() const43 bool InputWindowInfo::isTrustedOverlay() const {
44 return layoutParamsType == TYPE_INPUT_METHOD
45 || layoutParamsType == TYPE_INPUT_METHOD_DIALOG
46 || layoutParamsType == TYPE_MAGNIFICATION_OVERLAY
47 || layoutParamsType == TYPE_STATUS_BAR
48 || layoutParamsType == TYPE_NAVIGATION_BAR
49 || layoutParamsType == TYPE_SECURE_SYSTEM_OVERLAY;
50 }
51
supportsSplitTouch() const52 bool InputWindowInfo::supportsSplitTouch() const {
53 return layoutParamsFlags & FLAG_SPLIT_TOUCH;
54 }
55
overlaps(const InputWindowInfo * other) const56 bool InputWindowInfo::overlaps(const InputWindowInfo* other) const {
57 return frameLeft < other->frameRight && frameRight > other->frameLeft
58 && frameTop < other->frameBottom && frameBottom > other->frameTop;
59 }
60
61
62 // --- InputWindowHandle ---
63
InputWindowHandle(const sp<InputApplicationHandle> & inputApplicationHandle)64 InputWindowHandle::InputWindowHandle(const sp<InputApplicationHandle>& inputApplicationHandle) :
65 inputApplicationHandle(inputApplicationHandle), mInfo(NULL) {
66 }
67
~InputWindowHandle()68 InputWindowHandle::~InputWindowHandle() {
69 delete mInfo;
70 }
71
releaseInfo()72 void InputWindowHandle::releaseInfo() {
73 if (mInfo) {
74 delete mInfo;
75 mInfo = NULL;
76 }
77 }
78
79 } // namespace android
80