Jeff Brown | 928e054 | 2011-01-10 11:17:36 -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" |
Michael Wright | a407d6a | 2014-02-05 18:02:40 -0800 | [diff] [blame^] | 18 | #define LOG_NDEBUG 0 |
Jeff Brown | 928e054 | 2011-01-10 11:17:36 -0800 | [diff] [blame] | 19 | |
| 20 | #include "InputWindow.h" |
| 21 | |
| 22 | #include <cutils/log.h> |
| 23 | |
Michael Wright | a407d6a | 2014-02-05 18:02:40 -0800 | [diff] [blame^] | 24 | #include <ui/Rect.h> |
| 25 | #include <ui/Region.h> |
| 26 | |
Jeff Brown | 928e054 | 2011-01-10 11:17:36 -0800 | [diff] [blame] | 27 | namespace android { |
| 28 | |
Jeff Brown | cc4f7db | 2011-08-30 20:34:48 -0700 | [diff] [blame] | 29 | // --- InputWindowInfo --- |
Michael Wright | a407d6a | 2014-02-05 18:02:40 -0800 | [diff] [blame^] | 30 | void InputWindowInfo::addTouchableRegion(const Rect& region) { |
| 31 | touchableRegion.orSelf(region); |
| 32 | } |
Jeff Brown | 928e054 | 2011-01-10 11:17:36 -0800 | [diff] [blame] | 33 | |
Jeff Brown | cc4f7db | 2011-08-30 20:34:48 -0700 | [diff] [blame] | 34 | bool InputWindowInfo::touchableRegionContainsPoint(int32_t x, int32_t y) const { |
Michael Wright | a407d6a | 2014-02-05 18:02:40 -0800 | [diff] [blame^] | 35 | return touchableRegion.contains(x,y); |
Jeff Brown | 928e054 | 2011-01-10 11:17:36 -0800 | [diff] [blame] | 36 | } |
| 37 | |
Jeff Brown | cc4f7db | 2011-08-30 20:34:48 -0700 | [diff] [blame] | 38 | bool InputWindowInfo::frameContainsPoint(int32_t x, int32_t y) const { |
Jeff Brown | 4fb7625 | 2011-05-13 12:51:12 -0700 | [diff] [blame] | 39 | return x >= frameLeft && x <= frameRight |
| 40 | && y >= frameTop && y <= frameBottom; |
Jeff Brown | 928e054 | 2011-01-10 11:17:36 -0800 | [diff] [blame] | 41 | } |
| 42 | |
Jeff Brown | cc4f7db | 2011-08-30 20:34:48 -0700 | [diff] [blame] | 43 | bool InputWindowInfo::isTrustedOverlay() const { |
Jeff Brown | 928e054 | 2011-01-10 11:17:36 -0800 | [diff] [blame] | 44 | return layoutParamsType == TYPE_INPUT_METHOD |
| 45 | || layoutParamsType == TYPE_INPUT_METHOD_DIALOG |
| 46 | || layoutParamsType == TYPE_SECURE_SYSTEM_OVERLAY; |
| 47 | } |
| 48 | |
Jeff Brown | cc4f7db | 2011-08-30 20:34:48 -0700 | [diff] [blame] | 49 | bool InputWindowInfo::supportsSplitTouch() const { |
Jeff Brown | 9302c87 | 2011-07-13 22:51:29 -0700 | [diff] [blame] | 50 | return layoutParamsFlags & FLAG_SPLIT_TOUCH; |
Jeff Brown | 928e054 | 2011-01-10 11:17:36 -0800 | [diff] [blame] | 51 | } |
| 52 | |
Jeff Brown | cc4f7db | 2011-08-30 20:34:48 -0700 | [diff] [blame] | 53 | |
| 54 | // --- InputWindowHandle --- |
| 55 | |
| 56 | InputWindowHandle::InputWindowHandle(const sp<InputApplicationHandle>& inputApplicationHandle) : |
| 57 | inputApplicationHandle(inputApplicationHandle), mInfo(NULL) { |
| 58 | } |
| 59 | |
| 60 | InputWindowHandle::~InputWindowHandle() { |
| 61 | delete mInfo; |
| 62 | } |
| 63 | |
| 64 | void InputWindowHandle::releaseInfo() { |
| 65 | if (mInfo) { |
| 66 | delete mInfo; |
| 67 | mInfo = NULL; |
| 68 | } |
| 69 | } |
| 70 | |
Jeff Brown | 928e054 | 2011-01-10 11:17:36 -0800 | [diff] [blame] | 71 | } // namespace android |