blob: 272081c4a04c6ae6f4c841d51fe957b8826e711e [file] [log] [blame]
Jeff Brown928e0542011-01-10 11:17:36 -08001/*
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 Brownfbf09772011-01-16 14:06:57 -080026#include <SkRegion.h>
27
Jeff Brown928e0542011-01-10 11:17:36 -080028#include "InputApplication.h"
29
30namespace android {
31
32/*
33 * A handle to a window that can receive input.
Jeff Brown9302c872011-07-13 22:51:29 -070034 *
Jeff Brown928e0542011-01-10 11:17:36 -080035 * Used by the native input dispatcher to indirectly refer to the window manager objects
36 * that describe a window.
37 */
38class InputWindowHandle : public RefBase {
Jeff Brown928e0542011-01-10 11:17:36 -080039public:
Jeff Brown9302c872011-07-13 22:51:29 -070040 const sp<InputApplicationHandle> inputApplicationHandle;
Jeff Brown928e0542011-01-10 11:17:36 -080041
Jeff Brown928e0542011-01-10 11:17:36 -080042 // Window flags from WindowManager.LayoutParams
43 enum {
44 FLAG_ALLOW_LOCK_WHILE_SCREEN_ON = 0x00000001,
45 FLAG_DIM_BEHIND = 0x00000002,
46 FLAG_BLUR_BEHIND = 0x00000004,
47 FLAG_NOT_FOCUSABLE = 0x00000008,
48 FLAG_NOT_TOUCHABLE = 0x00000010,
49 FLAG_NOT_TOUCH_MODAL = 0x00000020,
50 FLAG_TOUCHABLE_WHEN_WAKING = 0x00000040,
51 FLAG_KEEP_SCREEN_ON = 0x00000080,
52 FLAG_LAYOUT_IN_SCREEN = 0x00000100,
53 FLAG_LAYOUT_NO_LIMITS = 0x00000200,
54 FLAG_FULLSCREEN = 0x00000400,
55 FLAG_FORCE_NOT_FULLSCREEN = 0x00000800,
56 FLAG_DITHER = 0x00001000,
57 FLAG_SECURE = 0x00002000,
58 FLAG_SCALED = 0x00004000,
59 FLAG_IGNORE_CHEEK_PRESSES = 0x00008000,
60 FLAG_LAYOUT_INSET_DECOR = 0x00010000,
61 FLAG_ALT_FOCUSABLE_IM = 0x00020000,
62 FLAG_WATCH_OUTSIDE_TOUCH = 0x00040000,
63 FLAG_SHOW_WHEN_LOCKED = 0x00080000,
64 FLAG_SHOW_WALLPAPER = 0x00100000,
65 FLAG_TURN_SCREEN_ON = 0x00200000,
66 FLAG_DISMISS_KEYGUARD = 0x00400000,
67 FLAG_SPLIT_TOUCH = 0x00800000,
Jeff Brown98db5fa2011-06-08 15:37:10 -070068 FLAG_HARDWARE_ACCELERATED = 0x01000000,
69 FLAG_HARDWARE_ACCELERATED_SYSTEM = 0x02000000,
70 FLAG_SLIPPERY = 0x04000000,
71 FLAG_NEEDS_MENU_KEY = 0x08000000,
Jeff Brown928e0542011-01-10 11:17:36 -080072 FLAG_KEEP_SURFACE_WHILE_ANIMATING = 0x10000000,
73 FLAG_COMPATIBLE_WINDOW = 0x20000000,
74 FLAG_SYSTEM_ERROR = 0x40000000,
75 };
76
77 // Window types from WindowManager.LayoutParams
78 enum {
79 FIRST_APPLICATION_WINDOW = 1,
80 TYPE_BASE_APPLICATION = 1,
81 TYPE_APPLICATION = 2,
82 TYPE_APPLICATION_STARTING = 3,
83 LAST_APPLICATION_WINDOW = 99,
84 FIRST_SUB_WINDOW = 1000,
85 TYPE_APPLICATION_PANEL = FIRST_SUB_WINDOW,
86 TYPE_APPLICATION_MEDIA = FIRST_SUB_WINDOW+1,
87 TYPE_APPLICATION_SUB_PANEL = FIRST_SUB_WINDOW+2,
88 TYPE_APPLICATION_ATTACHED_DIALOG = FIRST_SUB_WINDOW+3,
89 TYPE_APPLICATION_MEDIA_OVERLAY = FIRST_SUB_WINDOW+4,
90 LAST_SUB_WINDOW = 1999,
91 FIRST_SYSTEM_WINDOW = 2000,
92 TYPE_STATUS_BAR = FIRST_SYSTEM_WINDOW,
93 TYPE_SEARCH_BAR = FIRST_SYSTEM_WINDOW+1,
94 TYPE_PHONE = FIRST_SYSTEM_WINDOW+2,
95 TYPE_SYSTEM_ALERT = FIRST_SYSTEM_WINDOW+3,
96 TYPE_KEYGUARD = FIRST_SYSTEM_WINDOW+4,
97 TYPE_TOAST = FIRST_SYSTEM_WINDOW+5,
98 TYPE_SYSTEM_OVERLAY = FIRST_SYSTEM_WINDOW+6,
99 TYPE_PRIORITY_PHONE = FIRST_SYSTEM_WINDOW+7,
100 TYPE_SYSTEM_DIALOG = FIRST_SYSTEM_WINDOW+8,
101 TYPE_KEYGUARD_DIALOG = FIRST_SYSTEM_WINDOW+9,
102 TYPE_SYSTEM_ERROR = FIRST_SYSTEM_WINDOW+10,
103 TYPE_INPUT_METHOD = FIRST_SYSTEM_WINDOW+11,
104 TYPE_INPUT_METHOD_DIALOG= FIRST_SYSTEM_WINDOW+12,
105 TYPE_WALLPAPER = FIRST_SYSTEM_WINDOW+13,
Daniel Sandler6d8a98a2011-04-27 14:07:12 -0400106 TYPE_STATUS_BAR_PANEL = FIRST_SYSTEM_WINDOW+14,
Jeff Brown928e0542011-01-10 11:17:36 -0800107 TYPE_SECURE_SYSTEM_OVERLAY = FIRST_SYSTEM_WINDOW+15,
108 TYPE_DRAG = FIRST_SYSTEM_WINDOW+16,
Daniel Sandler6d8a98a2011-04-27 14:07:12 -0400109 TYPE_STATUS_BAR_SUB_PANEL = FIRST_SYSTEM_WINDOW+17,
110 TYPE_POINTER = FIRST_SYSTEM_WINDOW+18,
Daniel Sandler8956dbb2011-04-22 07:55:02 -0400111 TYPE_NAVIGATION_BAR = FIRST_SYSTEM_WINDOW+19,
Jeff Brown928e0542011-01-10 11:17:36 -0800112 LAST_SYSTEM_WINDOW = 2999,
113 };
114
Jeff Brown474dcb52011-06-14 20:22:50 -0700115 enum {
116 INPUT_FEATURE_DISABLE_TOUCH_PAD_GESTURES = 0x00000001,
117 };
118
Jeff Brown928e0542011-01-10 11:17:36 -0800119 sp<InputWindowHandle> inputWindowHandle;
120 sp<InputChannel> inputChannel;
121 String8 name;
122 int32_t layoutParamsFlags;
123 int32_t layoutParamsType;
124 nsecs_t dispatchingTimeout;
125 int32_t frameLeft;
126 int32_t frameTop;
127 int32_t frameRight;
128 int32_t frameBottom;
Dianne Hackborne2515ee2011-04-27 18:52:56 -0400129 float scaleFactor;
Jeff Brownfbf09772011-01-16 14:06:57 -0800130 SkRegion touchableRegion;
Jeff Brown928e0542011-01-10 11:17:36 -0800131 bool visible;
132 bool canReceiveKeys;
133 bool hasFocus;
134 bool hasWallpaper;
135 bool paused;
136 int32_t layer;
137 int32_t ownerPid;
138 int32_t ownerUid;
Jeff Brown474dcb52011-06-14 20:22:50 -0700139 int32_t inputFeatures;
Jeff Brown928e0542011-01-10 11:17:36 -0800140
Jeff Brownfbf09772011-01-16 14:06:57 -0800141 bool touchableRegionContainsPoint(int32_t x, int32_t y) const;
Jeff Brown928e0542011-01-10 11:17:36 -0800142 bool frameContainsPoint(int32_t x, int32_t y) const;
143
Jeff Brown928e0542011-01-10 11:17:36 -0800144 /* Returns true if the window is of a trusted type that is allowed to silently
145 * overlay other windows for the purpose of implementing the secure views feature.
146 * Trusted overlays, such as IME windows, can partly obscure other windows without causing
147 * motion events to be delivered to them with AMOTION_EVENT_FLAG_WINDOW_IS_OBSCURED.
148 */
149 bool isTrustedOverlay() const;
150
151 bool supportsSplitTouch() const;
Jeff Brown9302c872011-07-13 22:51:29 -0700152
153 /**
154 * Requests that the state of this object be updated to reflect
155 * the most current available information about the application.
156 *
157 * This method should only be called from within the input dispatcher's
158 * critical section.
159 *
160 * Returns true on success, or false if the handle is no longer valid.
161 */
162 virtual bool update() = 0;
163
164protected:
165 InputWindowHandle(const sp<InputApplicationHandle>& inputApplicationHandle) :
166 inputApplicationHandle(inputApplicationHandle) { }
167 virtual ~InputWindowHandle() { }
Jeff Brown928e0542011-01-10 11:17:36 -0800168};
169
170} // namespace android
171
172#endif // _UI_INPUT_WINDOW_H