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 | #ifndef _UI_INPUT_WINDOW_H |
| 18 | #define _UI_INPUT_WINDOW_H |
| 19 | |
| 20 | #include <ui/Input.h> |
| 21 | #include <ui/InputTransport.h> |
| 22 | #include <utils/RefBase.h> |
| 23 | #include <utils/Timers.h> |
| 24 | #include <utils/String8.h> |
| 25 | |
| 26 | #include "InputApplication.h" |
| 27 | |
| 28 | namespace android { |
| 29 | |
| 30 | /* |
| 31 | * A handle to a window that can receive input. |
| 32 | * Used by the native input dispatcher to indirectly refer to the window manager objects |
| 33 | * that describe a window. |
| 34 | */ |
| 35 | class InputWindowHandle : public RefBase { |
| 36 | protected: |
| 37 | InputWindowHandle(const sp<InputApplicationHandle>& inputApplicationHandle) : |
| 38 | mInputApplicationHandle(inputApplicationHandle) { } |
| 39 | virtual ~InputWindowHandle() { } |
| 40 | |
| 41 | public: |
| 42 | inline sp<InputApplicationHandle> getInputApplicationHandle() { |
| 43 | return mInputApplicationHandle; |
| 44 | } |
| 45 | |
| 46 | private: |
| 47 | sp<InputApplicationHandle> mInputApplicationHandle; |
| 48 | }; |
| 49 | |
| 50 | |
| 51 | /* |
| 52 | * An input window describes the bounds of a window that can receive input. |
| 53 | */ |
| 54 | struct InputWindow { |
| 55 | // Window flags from WindowManager.LayoutParams |
| 56 | enum { |
| 57 | FLAG_ALLOW_LOCK_WHILE_SCREEN_ON = 0x00000001, |
| 58 | FLAG_DIM_BEHIND = 0x00000002, |
| 59 | FLAG_BLUR_BEHIND = 0x00000004, |
| 60 | FLAG_NOT_FOCUSABLE = 0x00000008, |
| 61 | FLAG_NOT_TOUCHABLE = 0x00000010, |
| 62 | FLAG_NOT_TOUCH_MODAL = 0x00000020, |
| 63 | FLAG_TOUCHABLE_WHEN_WAKING = 0x00000040, |
| 64 | FLAG_KEEP_SCREEN_ON = 0x00000080, |
| 65 | FLAG_LAYOUT_IN_SCREEN = 0x00000100, |
| 66 | FLAG_LAYOUT_NO_LIMITS = 0x00000200, |
| 67 | FLAG_FULLSCREEN = 0x00000400, |
| 68 | FLAG_FORCE_NOT_FULLSCREEN = 0x00000800, |
| 69 | FLAG_DITHER = 0x00001000, |
| 70 | FLAG_SECURE = 0x00002000, |
| 71 | FLAG_SCALED = 0x00004000, |
| 72 | FLAG_IGNORE_CHEEK_PRESSES = 0x00008000, |
| 73 | FLAG_LAYOUT_INSET_DECOR = 0x00010000, |
| 74 | FLAG_ALT_FOCUSABLE_IM = 0x00020000, |
| 75 | FLAG_WATCH_OUTSIDE_TOUCH = 0x00040000, |
| 76 | FLAG_SHOW_WHEN_LOCKED = 0x00080000, |
| 77 | FLAG_SHOW_WALLPAPER = 0x00100000, |
| 78 | FLAG_TURN_SCREEN_ON = 0x00200000, |
| 79 | FLAG_DISMISS_KEYGUARD = 0x00400000, |
| 80 | FLAG_SPLIT_TOUCH = 0x00800000, |
| 81 | FLAG_KEEP_SURFACE_WHILE_ANIMATING = 0x10000000, |
| 82 | FLAG_COMPATIBLE_WINDOW = 0x20000000, |
| 83 | FLAG_SYSTEM_ERROR = 0x40000000, |
| 84 | }; |
| 85 | |
| 86 | // Window types from WindowManager.LayoutParams |
| 87 | enum { |
| 88 | FIRST_APPLICATION_WINDOW = 1, |
| 89 | TYPE_BASE_APPLICATION = 1, |
| 90 | TYPE_APPLICATION = 2, |
| 91 | TYPE_APPLICATION_STARTING = 3, |
| 92 | LAST_APPLICATION_WINDOW = 99, |
| 93 | FIRST_SUB_WINDOW = 1000, |
| 94 | TYPE_APPLICATION_PANEL = FIRST_SUB_WINDOW, |
| 95 | TYPE_APPLICATION_MEDIA = FIRST_SUB_WINDOW+1, |
| 96 | TYPE_APPLICATION_SUB_PANEL = FIRST_SUB_WINDOW+2, |
| 97 | TYPE_APPLICATION_ATTACHED_DIALOG = FIRST_SUB_WINDOW+3, |
| 98 | TYPE_APPLICATION_MEDIA_OVERLAY = FIRST_SUB_WINDOW+4, |
| 99 | LAST_SUB_WINDOW = 1999, |
| 100 | FIRST_SYSTEM_WINDOW = 2000, |
| 101 | TYPE_STATUS_BAR = FIRST_SYSTEM_WINDOW, |
| 102 | TYPE_SEARCH_BAR = FIRST_SYSTEM_WINDOW+1, |
| 103 | TYPE_PHONE = FIRST_SYSTEM_WINDOW+2, |
| 104 | TYPE_SYSTEM_ALERT = FIRST_SYSTEM_WINDOW+3, |
| 105 | TYPE_KEYGUARD = FIRST_SYSTEM_WINDOW+4, |
| 106 | TYPE_TOAST = FIRST_SYSTEM_WINDOW+5, |
| 107 | TYPE_SYSTEM_OVERLAY = FIRST_SYSTEM_WINDOW+6, |
| 108 | TYPE_PRIORITY_PHONE = FIRST_SYSTEM_WINDOW+7, |
| 109 | TYPE_SYSTEM_DIALOG = FIRST_SYSTEM_WINDOW+8, |
| 110 | TYPE_KEYGUARD_DIALOG = FIRST_SYSTEM_WINDOW+9, |
| 111 | TYPE_SYSTEM_ERROR = FIRST_SYSTEM_WINDOW+10, |
| 112 | TYPE_INPUT_METHOD = FIRST_SYSTEM_WINDOW+11, |
| 113 | TYPE_INPUT_METHOD_DIALOG= FIRST_SYSTEM_WINDOW+12, |
| 114 | TYPE_WALLPAPER = FIRST_SYSTEM_WINDOW+13, |
| 115 | TYPE_STATUS_BAR_SUB_PANEL = FIRST_SYSTEM_WINDOW+14, |
| 116 | TYPE_SECURE_SYSTEM_OVERLAY = FIRST_SYSTEM_WINDOW+15, |
| 117 | TYPE_DRAG = FIRST_SYSTEM_WINDOW+16, |
| 118 | TYPE_STATUS_BAR_PANEL = FIRST_SYSTEM_WINDOW+17, |
| 119 | LAST_SYSTEM_WINDOW = 2999, |
| 120 | }; |
| 121 | |
| 122 | sp<InputWindowHandle> inputWindowHandle; |
| 123 | sp<InputChannel> inputChannel; |
| 124 | String8 name; |
| 125 | int32_t layoutParamsFlags; |
| 126 | int32_t layoutParamsType; |
| 127 | nsecs_t dispatchingTimeout; |
| 128 | int32_t frameLeft; |
| 129 | int32_t frameTop; |
| 130 | int32_t frameRight; |
| 131 | int32_t frameBottom; |
| 132 | int32_t visibleFrameLeft; |
| 133 | int32_t visibleFrameTop; |
| 134 | int32_t visibleFrameRight; |
| 135 | int32_t visibleFrameBottom; |
| 136 | int32_t touchableAreaLeft; |
| 137 | int32_t touchableAreaTop; |
| 138 | int32_t touchableAreaRight; |
| 139 | int32_t touchableAreaBottom; |
| 140 | bool visible; |
| 141 | bool canReceiveKeys; |
| 142 | bool hasFocus; |
| 143 | bool hasWallpaper; |
| 144 | bool paused; |
| 145 | int32_t layer; |
| 146 | int32_t ownerPid; |
| 147 | int32_t ownerUid; |
| 148 | |
| 149 | bool touchableAreaContainsPoint(int32_t x, int32_t y) const; |
| 150 | bool frameContainsPoint(int32_t x, int32_t y) const; |
| 151 | |
| 152 | /* Returns true if the window is of a trusted type that is allowed to silently |
| 153 | * overlay other windows for the purpose of implementing the secure views feature. |
| 154 | * Trusted overlays, such as IME windows, can partly obscure other windows without causing |
| 155 | * motion events to be delivered to them with AMOTION_EVENT_FLAG_WINDOW_IS_OBSCURED. |
| 156 | */ |
| 157 | bool isTrustedOverlay() const; |
| 158 | |
| 159 | bool supportsSplitTouch() const; |
| 160 | }; |
| 161 | |
| 162 | } // namespace android |
| 163 | |
| 164 | #endif // _UI_INPUT_WINDOW_H |