Wed, 31 Dec 2014 07:22:50 +0100
Correct previous dual key logic pending first delivery installment.
michael@0 | 1 | /* |
michael@0 | 2 | * Copyright (C) 2011 The Android Open Source Project |
michael@0 | 3 | * |
michael@0 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
michael@0 | 5 | * you may not use this file except in compliance with the License. |
michael@0 | 6 | * You may obtain a copy of the License at |
michael@0 | 7 | * |
michael@0 | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
michael@0 | 9 | * |
michael@0 | 10 | * Unless required by applicable law or agreed to in writing, software |
michael@0 | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
michael@0 | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
michael@0 | 13 | * See the License for the specific language governing permissions and |
michael@0 | 14 | * limitations under the License. |
michael@0 | 15 | */ |
michael@0 | 16 | |
michael@0 | 17 | #ifndef _UI_INPUT_WINDOW_H |
michael@0 | 18 | #define _UI_INPUT_WINDOW_H |
michael@0 | 19 | |
michael@0 | 20 | #include "Input.h" |
michael@0 | 21 | #include "InputTransport.h" |
michael@0 | 22 | #include <utils/RefBase.h> |
michael@0 | 23 | #include <utils/Timers.h> |
michael@0 | 24 | #include <utils/String8.h> |
michael@0 | 25 | |
michael@0 | 26 | #include <SkRegion.h> |
michael@0 | 27 | |
michael@0 | 28 | #include "InputApplication.h" |
michael@0 | 29 | |
michael@0 | 30 | namespace android { |
michael@0 | 31 | |
michael@0 | 32 | /* |
michael@0 | 33 | * Describes the properties of a window that can receive input. |
michael@0 | 34 | */ |
michael@0 | 35 | struct InputWindowInfo { |
michael@0 | 36 | // Window flags from WindowManager.LayoutParams |
michael@0 | 37 | enum { |
michael@0 | 38 | FLAG_ALLOW_LOCK_WHILE_SCREEN_ON = 0x00000001, |
michael@0 | 39 | FLAG_DIM_BEHIND = 0x00000002, |
michael@0 | 40 | FLAG_BLUR_BEHIND = 0x00000004, |
michael@0 | 41 | FLAG_NOT_FOCUSABLE = 0x00000008, |
michael@0 | 42 | FLAG_NOT_TOUCHABLE = 0x00000010, |
michael@0 | 43 | FLAG_NOT_TOUCH_MODAL = 0x00000020, |
michael@0 | 44 | FLAG_TOUCHABLE_WHEN_WAKING = 0x00000040, |
michael@0 | 45 | FLAG_KEEP_SCREEN_ON = 0x00000080, |
michael@0 | 46 | FLAG_LAYOUT_IN_SCREEN = 0x00000100, |
michael@0 | 47 | FLAG_LAYOUT_NO_LIMITS = 0x00000200, |
michael@0 | 48 | FLAG_FULLSCREEN = 0x00000400, |
michael@0 | 49 | FLAG_FORCE_NOT_FULLSCREEN = 0x00000800, |
michael@0 | 50 | FLAG_DITHER = 0x00001000, |
michael@0 | 51 | FLAG_SECURE = 0x00002000, |
michael@0 | 52 | FLAG_SCALED = 0x00004000, |
michael@0 | 53 | FLAG_IGNORE_CHEEK_PRESSES = 0x00008000, |
michael@0 | 54 | FLAG_LAYOUT_INSET_DECOR = 0x00010000, |
michael@0 | 55 | FLAG_ALT_FOCUSABLE_IM = 0x00020000, |
michael@0 | 56 | FLAG_WATCH_OUTSIDE_TOUCH = 0x00040000, |
michael@0 | 57 | FLAG_SHOW_WHEN_LOCKED = 0x00080000, |
michael@0 | 58 | FLAG_SHOW_WALLPAPER = 0x00100000, |
michael@0 | 59 | FLAG_TURN_SCREEN_ON = 0x00200000, |
michael@0 | 60 | FLAG_DISMISS_KEYGUARD = 0x00400000, |
michael@0 | 61 | FLAG_SPLIT_TOUCH = 0x00800000, |
michael@0 | 62 | FLAG_HARDWARE_ACCELERATED = 0x01000000, |
michael@0 | 63 | FLAG_HARDWARE_ACCELERATED_SYSTEM = 0x02000000, |
michael@0 | 64 | FLAG_SLIPPERY = 0x04000000, |
michael@0 | 65 | FLAG_NEEDS_MENU_KEY = 0x08000000, |
michael@0 | 66 | FLAG_KEEP_SURFACE_WHILE_ANIMATING = 0x10000000, |
michael@0 | 67 | FLAG_COMPATIBLE_WINDOW = 0x20000000, |
michael@0 | 68 | FLAG_SYSTEM_ERROR = 0x40000000, |
michael@0 | 69 | }; |
michael@0 | 70 | |
michael@0 | 71 | // Window types from WindowManager.LayoutParams |
michael@0 | 72 | enum { |
michael@0 | 73 | FIRST_APPLICATION_WINDOW = 1, |
michael@0 | 74 | TYPE_BASE_APPLICATION = 1, |
michael@0 | 75 | TYPE_APPLICATION = 2, |
michael@0 | 76 | TYPE_APPLICATION_STARTING = 3, |
michael@0 | 77 | LAST_APPLICATION_WINDOW = 99, |
michael@0 | 78 | FIRST_SUB_WINDOW = 1000, |
michael@0 | 79 | TYPE_APPLICATION_PANEL = FIRST_SUB_WINDOW, |
michael@0 | 80 | TYPE_APPLICATION_MEDIA = FIRST_SUB_WINDOW+1, |
michael@0 | 81 | TYPE_APPLICATION_SUB_PANEL = FIRST_SUB_WINDOW+2, |
michael@0 | 82 | TYPE_APPLICATION_ATTACHED_DIALOG = FIRST_SUB_WINDOW+3, |
michael@0 | 83 | TYPE_APPLICATION_MEDIA_OVERLAY = FIRST_SUB_WINDOW+4, |
michael@0 | 84 | LAST_SUB_WINDOW = 1999, |
michael@0 | 85 | FIRST_SYSTEM_WINDOW = 2000, |
michael@0 | 86 | TYPE_STATUS_BAR = FIRST_SYSTEM_WINDOW, |
michael@0 | 87 | TYPE_SEARCH_BAR = FIRST_SYSTEM_WINDOW+1, |
michael@0 | 88 | TYPE_PHONE = FIRST_SYSTEM_WINDOW+2, |
michael@0 | 89 | TYPE_SYSTEM_ALERT = FIRST_SYSTEM_WINDOW+3, |
michael@0 | 90 | TYPE_KEYGUARD = FIRST_SYSTEM_WINDOW+4, |
michael@0 | 91 | TYPE_TOAST = FIRST_SYSTEM_WINDOW+5, |
michael@0 | 92 | TYPE_SYSTEM_OVERLAY = FIRST_SYSTEM_WINDOW+6, |
michael@0 | 93 | TYPE_PRIORITY_PHONE = FIRST_SYSTEM_WINDOW+7, |
michael@0 | 94 | TYPE_SYSTEM_DIALOG = FIRST_SYSTEM_WINDOW+8, |
michael@0 | 95 | TYPE_KEYGUARD_DIALOG = FIRST_SYSTEM_WINDOW+9, |
michael@0 | 96 | TYPE_SYSTEM_ERROR = FIRST_SYSTEM_WINDOW+10, |
michael@0 | 97 | TYPE_INPUT_METHOD = FIRST_SYSTEM_WINDOW+11, |
michael@0 | 98 | TYPE_INPUT_METHOD_DIALOG= FIRST_SYSTEM_WINDOW+12, |
michael@0 | 99 | TYPE_WALLPAPER = FIRST_SYSTEM_WINDOW+13, |
michael@0 | 100 | TYPE_STATUS_BAR_PANEL = FIRST_SYSTEM_WINDOW+14, |
michael@0 | 101 | TYPE_SECURE_SYSTEM_OVERLAY = FIRST_SYSTEM_WINDOW+15, |
michael@0 | 102 | TYPE_DRAG = FIRST_SYSTEM_WINDOW+16, |
michael@0 | 103 | TYPE_STATUS_BAR_SUB_PANEL = FIRST_SYSTEM_WINDOW+17, |
michael@0 | 104 | TYPE_POINTER = FIRST_SYSTEM_WINDOW+18, |
michael@0 | 105 | TYPE_NAVIGATION_BAR = FIRST_SYSTEM_WINDOW+19, |
michael@0 | 106 | TYPE_VOLUME_OVERLAY = FIRST_SYSTEM_WINDOW+20, |
michael@0 | 107 | TYPE_BOOT_PROGRESS = FIRST_SYSTEM_WINDOW+21, |
michael@0 | 108 | LAST_SYSTEM_WINDOW = 2999, |
michael@0 | 109 | }; |
michael@0 | 110 | |
michael@0 | 111 | enum { |
michael@0 | 112 | INPUT_FEATURE_DISABLE_TOUCH_PAD_GESTURES = 0x00000001, |
michael@0 | 113 | INPUT_FEATURE_NO_INPUT_CHANNEL = 0x00000002, |
michael@0 | 114 | INPUT_FEATURE_DISABLE_USER_ACTIVITY = 0x00000004, |
michael@0 | 115 | }; |
michael@0 | 116 | |
michael@0 | 117 | sp<InputChannel> inputChannel; |
michael@0 | 118 | String8 name; |
michael@0 | 119 | int32_t layoutParamsFlags; |
michael@0 | 120 | int32_t layoutParamsType; |
michael@0 | 121 | nsecs_t dispatchingTimeout; |
michael@0 | 122 | int32_t frameLeft; |
michael@0 | 123 | int32_t frameTop; |
michael@0 | 124 | int32_t frameRight; |
michael@0 | 125 | int32_t frameBottom; |
michael@0 | 126 | float scaleFactor; |
michael@0 | 127 | SkRegion touchableRegion; |
michael@0 | 128 | bool visible; |
michael@0 | 129 | bool canReceiveKeys; |
michael@0 | 130 | bool hasFocus; |
michael@0 | 131 | bool hasWallpaper; |
michael@0 | 132 | bool paused; |
michael@0 | 133 | int32_t layer; |
michael@0 | 134 | int32_t ownerPid; |
michael@0 | 135 | int32_t ownerUid; |
michael@0 | 136 | int32_t inputFeatures; |
michael@0 | 137 | int32_t displayId; |
michael@0 | 138 | |
michael@0 | 139 | bool touchableRegionContainsPoint(int32_t x, int32_t y) const; |
michael@0 | 140 | bool frameContainsPoint(int32_t x, int32_t y) const; |
michael@0 | 141 | |
michael@0 | 142 | /* Returns true if the window is of a trusted type that is allowed to silently |
michael@0 | 143 | * overlay other windows for the purpose of implementing the secure views feature. |
michael@0 | 144 | * Trusted overlays, such as IME windows, can partly obscure other windows without causing |
michael@0 | 145 | * motion events to be delivered to them with AMOTION_EVENT_FLAG_WINDOW_IS_OBSCURED. |
michael@0 | 146 | */ |
michael@0 | 147 | bool isTrustedOverlay() const; |
michael@0 | 148 | |
michael@0 | 149 | bool supportsSplitTouch() const; |
michael@0 | 150 | }; |
michael@0 | 151 | |
michael@0 | 152 | |
michael@0 | 153 | /* |
michael@0 | 154 | * Handle for a window that can receive input. |
michael@0 | 155 | * |
michael@0 | 156 | * Used by the native input dispatcher to indirectly refer to the window manager objects |
michael@0 | 157 | * that describe a window. |
michael@0 | 158 | */ |
michael@0 | 159 | class InputWindowHandle : public RefBase { |
michael@0 | 160 | public: |
michael@0 | 161 | const sp<InputApplicationHandle> inputApplicationHandle; |
michael@0 | 162 | |
michael@0 | 163 | inline const InputWindowInfo* getInfo() const { |
michael@0 | 164 | return mInfo; |
michael@0 | 165 | } |
michael@0 | 166 | |
michael@0 | 167 | inline sp<InputChannel> getInputChannel() const { |
michael@0 | 168 | return mInfo ? mInfo->inputChannel : NULL; |
michael@0 | 169 | } |
michael@0 | 170 | |
michael@0 | 171 | inline String8 getName() const { |
michael@0 | 172 | return mInfo ? mInfo->name : String8("<invalid>"); |
michael@0 | 173 | } |
michael@0 | 174 | |
michael@0 | 175 | inline nsecs_t getDispatchingTimeout(nsecs_t defaultValue) const { |
michael@0 | 176 | return mInfo ? mInfo->dispatchingTimeout : defaultValue; |
michael@0 | 177 | } |
michael@0 | 178 | |
michael@0 | 179 | /** |
michael@0 | 180 | * Requests that the state of this object be updated to reflect |
michael@0 | 181 | * the most current available information about the application. |
michael@0 | 182 | * |
michael@0 | 183 | * This method should only be called from within the input dispatcher's |
michael@0 | 184 | * critical section. |
michael@0 | 185 | * |
michael@0 | 186 | * Returns true on success, or false if the handle is no longer valid. |
michael@0 | 187 | */ |
michael@0 | 188 | virtual bool updateInfo() = 0; |
michael@0 | 189 | |
michael@0 | 190 | /** |
michael@0 | 191 | * Releases the storage used by the associated information when it is |
michael@0 | 192 | * no longer needed. |
michael@0 | 193 | */ |
michael@0 | 194 | void releaseInfo(); |
michael@0 | 195 | |
michael@0 | 196 | protected: |
michael@0 | 197 | InputWindowHandle(const sp<InputApplicationHandle>& inputApplicationHandle); |
michael@0 | 198 | virtual ~InputWindowHandle(); |
michael@0 | 199 | |
michael@0 | 200 | InputWindowInfo* mInfo; |
michael@0 | 201 | }; |
michael@0 | 202 | |
michael@0 | 203 | } // namespace android |
michael@0 | 204 | |
michael@0 | 205 | #endif // _UI_INPUT_WINDOW_H |