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