| Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 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 |  | 
| Mark Salyzyn | 7823e12 | 2016-09-29 08:08:05 -0700 | [diff] [blame] | 22 | #include <log/log.h> | 
| Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 23 |  | 
|  | 24 | #include <ui/Rect.h> | 
|  | 25 | #include <ui/Region.h> | 
|  | 26 |  | 
|  | 27 | namespace android { | 
|  | 28 |  | 
|  | 29 | // --- InputWindowInfo --- | 
|  | 30 | void InputWindowInfo::addTouchableRegion(const Rect& region) { | 
|  | 31 | touchableRegion.orSelf(region); | 
|  | 32 | } | 
|  | 33 |  | 
|  | 34 | bool InputWindowInfo::touchableRegionContainsPoint(int32_t x, int32_t y) const { | 
|  | 35 | return touchableRegion.contains(x,y); | 
|  | 36 | } | 
|  | 37 |  | 
|  | 38 | bool InputWindowInfo::frameContainsPoint(int32_t x, int32_t y) const { | 
| Michael Wright | cdcd8f2 | 2016-03-22 16:52:13 -0700 | [diff] [blame] | 39 | return x >= frameLeft && x < frameRight | 
|  | 40 | && y >= frameTop && y < frameBottom; | 
| Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 41 | } | 
|  | 42 |  | 
|  | 43 | bool InputWindowInfo::isTrustedOverlay() const { | 
|  | 44 | return layoutParamsType == TYPE_INPUT_METHOD | 
|  | 45 | || layoutParamsType == TYPE_INPUT_METHOD_DIALOG | 
| Conley Owens | 51eb29f | 2014-04-23 13:50:03 -0700 | [diff] [blame] | 46 | || layoutParamsType == TYPE_MAGNIFICATION_OVERLAY | 
| Michael Wright | cdcd8f2 | 2016-03-22 16:52:13 -0700 | [diff] [blame] | 47 | || layoutParamsType == TYPE_STATUS_BAR | 
|  | 48 | || layoutParamsType == TYPE_NAVIGATION_BAR | 
| Phil Weaver | 5a07198 | 2017-06-26 16:22:26 -0700 | [diff] [blame] | 49 | || layoutParamsType == TYPE_NAVIGATION_BAR_PANEL | 
| Michael Wright | b9be0cf | 2016-05-26 13:49:53 +0100 | [diff] [blame] | 50 | || layoutParamsType == TYPE_SECURE_SYSTEM_OVERLAY | 
| Phil Weaver | 5a07198 | 2017-06-26 16:22:26 -0700 | [diff] [blame] | 51 | || layoutParamsType == TYPE_DOCK_DIVIDER | 
| Michael Wright | afe7a5c | 2017-09-19 20:19:39 +0100 | [diff] [blame] | 52 | || layoutParamsType == TYPE_ACCESSIBILITY_OVERLAY | 
|  | 53 | || layoutParamsType == TYPE_INPUT_CONSUMER; | 
| Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 54 | } | 
|  | 55 |  | 
|  | 56 | bool InputWindowInfo::supportsSplitTouch() const { | 
|  | 57 | return layoutParamsFlags & FLAG_SPLIT_TOUCH; | 
|  | 58 | } | 
|  | 59 |  | 
| Michael Wright | cdcd8f2 | 2016-03-22 16:52:13 -0700 | [diff] [blame] | 60 | bool InputWindowInfo::overlaps(const InputWindowInfo* other) const { | 
|  | 61 | return frameLeft < other->frameRight && frameRight > other->frameLeft | 
|  | 62 | && frameTop < other->frameBottom && frameBottom > other->frameTop; | 
|  | 63 | } | 
|  | 64 |  | 
| Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 65 |  | 
|  | 66 | // --- InputWindowHandle --- | 
|  | 67 |  | 
|  | 68 | InputWindowHandle::InputWindowHandle(const sp<InputApplicationHandle>& inputApplicationHandle) : | 
| Yi Kong | 9b14ac6 | 2018-07-17 13:48:38 -0700 | [diff] [blame] | 69 | inputApplicationHandle(inputApplicationHandle), mInfo(nullptr) { | 
| Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 70 | } | 
|  | 71 |  | 
|  | 72 | InputWindowHandle::~InputWindowHandle() { | 
|  | 73 | delete mInfo; | 
|  | 74 | } | 
|  | 75 |  | 
|  | 76 | void InputWindowHandle::releaseInfo() { | 
|  | 77 | if (mInfo) { | 
|  | 78 | delete mInfo; | 
| Yi Kong | 9b14ac6 | 2018-07-17 13:48:38 -0700 | [diff] [blame] | 79 | mInfo = nullptr; | 
| Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 80 | } | 
|  | 81 | } | 
|  | 82 |  | 
|  | 83 | } // namespace android |