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 | |
Jeff Brown | fbf0977 | 2011-01-16 14:06:57 -0800 | [diff] [blame] | 26 | #include <SkRegion.h> |
| 27 | |
Jeff Brown | 928e054 | 2011-01-10 11:17:36 -0800 | [diff] [blame] | 28 | #include "InputApplication.h" |
| 29 | |
| 30 | namespace android { |
| 31 | |
| 32 | /* |
Jeff Brown | cc4f7db | 2011-08-30 20:34:48 -0700 | [diff] [blame] | 33 | * Describes the properties of a window that can receive input. |
Jeff Brown | 928e054 | 2011-01-10 11:17:36 -0800 | [diff] [blame] | 34 | */ |
Jeff Brown | cc4f7db | 2011-08-30 20:34:48 -0700 | [diff] [blame] | 35 | struct InputWindowInfo { |
Jeff Brown | 928e054 | 2011-01-10 11:17:36 -0800 | [diff] [blame] | 36 | // Window flags from WindowManager.LayoutParams |
| 37 | enum { |
| 38 | FLAG_ALLOW_LOCK_WHILE_SCREEN_ON = 0x00000001, |
| 39 | FLAG_DIM_BEHIND = 0x00000002, |
| 40 | FLAG_BLUR_BEHIND = 0x00000004, |
| 41 | FLAG_NOT_FOCUSABLE = 0x00000008, |
| 42 | FLAG_NOT_TOUCHABLE = 0x00000010, |
| 43 | FLAG_NOT_TOUCH_MODAL = 0x00000020, |
| 44 | FLAG_TOUCHABLE_WHEN_WAKING = 0x00000040, |
| 45 | FLAG_KEEP_SCREEN_ON = 0x00000080, |
| 46 | FLAG_LAYOUT_IN_SCREEN = 0x00000100, |
| 47 | FLAG_LAYOUT_NO_LIMITS = 0x00000200, |
| 48 | FLAG_FULLSCREEN = 0x00000400, |
| 49 | FLAG_FORCE_NOT_FULLSCREEN = 0x00000800, |
| 50 | FLAG_DITHER = 0x00001000, |
| 51 | FLAG_SECURE = 0x00002000, |
| 52 | FLAG_SCALED = 0x00004000, |
| 53 | FLAG_IGNORE_CHEEK_PRESSES = 0x00008000, |
| 54 | FLAG_LAYOUT_INSET_DECOR = 0x00010000, |
| 55 | FLAG_ALT_FOCUSABLE_IM = 0x00020000, |
| 56 | FLAG_WATCH_OUTSIDE_TOUCH = 0x00040000, |
| 57 | FLAG_SHOW_WHEN_LOCKED = 0x00080000, |
| 58 | FLAG_SHOW_WALLPAPER = 0x00100000, |
| 59 | FLAG_TURN_SCREEN_ON = 0x00200000, |
| 60 | FLAG_DISMISS_KEYGUARD = 0x00400000, |
| 61 | FLAG_SPLIT_TOUCH = 0x00800000, |
Jeff Brown | 98db5fa | 2011-06-08 15:37:10 -0700 | [diff] [blame] | 62 | FLAG_HARDWARE_ACCELERATED = 0x01000000, |
| 63 | FLAG_HARDWARE_ACCELERATED_SYSTEM = 0x02000000, |
| 64 | FLAG_SLIPPERY = 0x04000000, |
| 65 | FLAG_NEEDS_MENU_KEY = 0x08000000, |
Jeff Brown | 928e054 | 2011-01-10 11:17:36 -0800 | [diff] [blame] | 66 | FLAG_KEEP_SURFACE_WHILE_ANIMATING = 0x10000000, |
| 67 | FLAG_COMPATIBLE_WINDOW = 0x20000000, |
| 68 | FLAG_SYSTEM_ERROR = 0x40000000, |
| 69 | }; |
| 70 | |
| 71 | // Window types from WindowManager.LayoutParams |
| 72 | enum { |
| 73 | FIRST_APPLICATION_WINDOW = 1, |
| 74 | TYPE_BASE_APPLICATION = 1, |
| 75 | TYPE_APPLICATION = 2, |
| 76 | TYPE_APPLICATION_STARTING = 3, |
| 77 | LAST_APPLICATION_WINDOW = 99, |
| 78 | FIRST_SUB_WINDOW = 1000, |
| 79 | TYPE_APPLICATION_PANEL = FIRST_SUB_WINDOW, |
| 80 | TYPE_APPLICATION_MEDIA = FIRST_SUB_WINDOW+1, |
| 81 | TYPE_APPLICATION_SUB_PANEL = FIRST_SUB_WINDOW+2, |
| 82 | TYPE_APPLICATION_ATTACHED_DIALOG = FIRST_SUB_WINDOW+3, |
| 83 | TYPE_APPLICATION_MEDIA_OVERLAY = FIRST_SUB_WINDOW+4, |
| 84 | LAST_SUB_WINDOW = 1999, |
| 85 | FIRST_SYSTEM_WINDOW = 2000, |
| 86 | TYPE_STATUS_BAR = FIRST_SYSTEM_WINDOW, |
| 87 | TYPE_SEARCH_BAR = FIRST_SYSTEM_WINDOW+1, |
| 88 | TYPE_PHONE = FIRST_SYSTEM_WINDOW+2, |
| 89 | TYPE_SYSTEM_ALERT = FIRST_SYSTEM_WINDOW+3, |
| 90 | TYPE_KEYGUARD = FIRST_SYSTEM_WINDOW+4, |
| 91 | TYPE_TOAST = FIRST_SYSTEM_WINDOW+5, |
| 92 | TYPE_SYSTEM_OVERLAY = FIRST_SYSTEM_WINDOW+6, |
| 93 | TYPE_PRIORITY_PHONE = FIRST_SYSTEM_WINDOW+7, |
| 94 | TYPE_SYSTEM_DIALOG = FIRST_SYSTEM_WINDOW+8, |
| 95 | TYPE_KEYGUARD_DIALOG = FIRST_SYSTEM_WINDOW+9, |
| 96 | TYPE_SYSTEM_ERROR = FIRST_SYSTEM_WINDOW+10, |
| 97 | TYPE_INPUT_METHOD = FIRST_SYSTEM_WINDOW+11, |
| 98 | TYPE_INPUT_METHOD_DIALOG= FIRST_SYSTEM_WINDOW+12, |
| 99 | TYPE_WALLPAPER = FIRST_SYSTEM_WINDOW+13, |
Daniel Sandler | 6d8a98a | 2011-04-27 14:07:12 -0400 | [diff] [blame] | 100 | TYPE_STATUS_BAR_PANEL = FIRST_SYSTEM_WINDOW+14, |
Jeff Brown | 928e054 | 2011-01-10 11:17:36 -0800 | [diff] [blame] | 101 | TYPE_SECURE_SYSTEM_OVERLAY = FIRST_SYSTEM_WINDOW+15, |
| 102 | TYPE_DRAG = FIRST_SYSTEM_WINDOW+16, |
Daniel Sandler | 6d8a98a | 2011-04-27 14:07:12 -0400 | [diff] [blame] | 103 | TYPE_STATUS_BAR_SUB_PANEL = FIRST_SYSTEM_WINDOW+17, |
| 104 | TYPE_POINTER = FIRST_SYSTEM_WINDOW+18, |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 105 | TYPE_NAVIGATION_BAR = FIRST_SYSTEM_WINDOW+19, |
Jeff Brown | bfcb60a | 2011-09-08 18:51:14 -0700 | [diff] [blame] | 106 | TYPE_VOLUME_OVERLAY = FIRST_SYSTEM_WINDOW+20, |
| 107 | TYPE_BOOT_PROGRESS = FIRST_SYSTEM_WINDOW+21, |
Jeff Brown | 928e054 | 2011-01-10 11:17:36 -0800 | [diff] [blame] | 108 | LAST_SYSTEM_WINDOW = 2999, |
| 109 | }; |
| 110 | |
Jeff Brown | 474dcb5 | 2011-06-14 20:22:50 -0700 | [diff] [blame] | 111 | enum { |
| 112 | INPUT_FEATURE_DISABLE_TOUCH_PAD_GESTURES = 0x00000001, |
| 113 | }; |
| 114 | |
Jeff Brown | 928e054 | 2011-01-10 11:17:36 -0800 | [diff] [blame] | 115 | sp<InputChannel> inputChannel; |
| 116 | String8 name; |
| 117 | int32_t layoutParamsFlags; |
| 118 | int32_t layoutParamsType; |
| 119 | nsecs_t dispatchingTimeout; |
| 120 | int32_t frameLeft; |
| 121 | int32_t frameTop; |
| 122 | int32_t frameRight; |
| 123 | int32_t frameBottom; |
Dianne Hackborn | e2515ee | 2011-04-27 18:52:56 -0400 | [diff] [blame] | 124 | float scaleFactor; |
Jeff Brown | fbf0977 | 2011-01-16 14:06:57 -0800 | [diff] [blame] | 125 | SkRegion touchableRegion; |
Jeff Brown | 928e054 | 2011-01-10 11:17:36 -0800 | [diff] [blame] | 126 | bool visible; |
| 127 | bool canReceiveKeys; |
| 128 | bool hasFocus; |
| 129 | bool hasWallpaper; |
| 130 | bool paused; |
| 131 | int32_t layer; |
| 132 | int32_t ownerPid; |
| 133 | int32_t ownerUid; |
Jeff Brown | 474dcb5 | 2011-06-14 20:22:50 -0700 | [diff] [blame] | 134 | int32_t inputFeatures; |
Jeff Brown | 928e054 | 2011-01-10 11:17:36 -0800 | [diff] [blame] | 135 | |
Jeff Brown | fbf0977 | 2011-01-16 14:06:57 -0800 | [diff] [blame] | 136 | bool touchableRegionContainsPoint(int32_t x, int32_t y) const; |
Jeff Brown | 928e054 | 2011-01-10 11:17:36 -0800 | [diff] [blame] | 137 | bool frameContainsPoint(int32_t x, int32_t y) const; |
| 138 | |
Jeff Brown | 928e054 | 2011-01-10 11:17:36 -0800 | [diff] [blame] | 139 | /* Returns true if the window is of a trusted type that is allowed to silently |
| 140 | * overlay other windows for the purpose of implementing the secure views feature. |
| 141 | * Trusted overlays, such as IME windows, can partly obscure other windows without causing |
| 142 | * motion events to be delivered to them with AMOTION_EVENT_FLAG_WINDOW_IS_OBSCURED. |
| 143 | */ |
| 144 | bool isTrustedOverlay() const; |
| 145 | |
| 146 | bool supportsSplitTouch() const; |
Jeff Brown | cc4f7db | 2011-08-30 20:34:48 -0700 | [diff] [blame] | 147 | }; |
| 148 | |
| 149 | |
| 150 | /* |
| 151 | * Handle for a window that can receive input. |
| 152 | * |
| 153 | * Used by the native input dispatcher to indirectly refer to the window manager objects |
| 154 | * that describe a window. |
| 155 | */ |
| 156 | class InputWindowHandle : public RefBase { |
| 157 | public: |
| 158 | const sp<InputApplicationHandle> inputApplicationHandle; |
| 159 | |
| 160 | inline const InputWindowInfo* getInfo() const { |
| 161 | return mInfo; |
| 162 | } |
| 163 | |
| 164 | inline sp<InputChannel> getInputChannel() const { |
| 165 | return mInfo ? mInfo->inputChannel : NULL; |
| 166 | } |
| 167 | |
| 168 | inline String8 getName() const { |
| 169 | return mInfo ? mInfo->name : String8("<invalid>"); |
| 170 | } |
| 171 | |
| 172 | inline nsecs_t getDispatchingTimeout(nsecs_t defaultValue) const { |
| 173 | return mInfo ? mInfo->dispatchingTimeout : defaultValue; |
| 174 | } |
Jeff Brown | 9302c87 | 2011-07-13 22:51:29 -0700 | [diff] [blame] | 175 | |
| 176 | /** |
| 177 | * Requests that the state of this object be updated to reflect |
| 178 | * the most current available information about the application. |
| 179 | * |
| 180 | * This method should only be called from within the input dispatcher's |
| 181 | * critical section. |
| 182 | * |
| 183 | * Returns true on success, or false if the handle is no longer valid. |
| 184 | */ |
Jeff Brown | cc4f7db | 2011-08-30 20:34:48 -0700 | [diff] [blame] | 185 | virtual bool updateInfo() = 0; |
| 186 | |
| 187 | /** |
| 188 | * Releases the storage used by the associated information when it is |
| 189 | * no longer needed. |
| 190 | */ |
| 191 | void releaseInfo(); |
Jeff Brown | 9302c87 | 2011-07-13 22:51:29 -0700 | [diff] [blame] | 192 | |
| 193 | protected: |
Jeff Brown | cc4f7db | 2011-08-30 20:34:48 -0700 | [diff] [blame] | 194 | InputWindowHandle(const sp<InputApplicationHandle>& inputApplicationHandle); |
| 195 | virtual ~InputWindowHandle(); |
| 196 | |
| 197 | InputWindowInfo* mInfo; |
Jeff Brown | 928e054 | 2011-01-10 11:17:36 -0800 | [diff] [blame] | 198 | }; |
| 199 | |
| 200 | } // namespace android |
| 201 | |
| 202 | #endif // _UI_INPUT_WINDOW_H |