blob: 72f1773ec52926c3e5a2b1189e9eda347b41fbd8 [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.
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_KEEP_SURFACE_WHILE_ANIMATING = 0x10000000,
84 FLAG_COMPATIBLE_WINDOW = 0x20000000,
85 FLAG_SYSTEM_ERROR = 0x40000000,
86 };
87
88 // Window types from WindowManager.LayoutParams
89 enum {
90 FIRST_APPLICATION_WINDOW = 1,
91 TYPE_BASE_APPLICATION = 1,
92 TYPE_APPLICATION = 2,
93 TYPE_APPLICATION_STARTING = 3,
94 LAST_APPLICATION_WINDOW = 99,
95 FIRST_SUB_WINDOW = 1000,
96 TYPE_APPLICATION_PANEL = FIRST_SUB_WINDOW,
97 TYPE_APPLICATION_MEDIA = FIRST_SUB_WINDOW+1,
98 TYPE_APPLICATION_SUB_PANEL = FIRST_SUB_WINDOW+2,
99 TYPE_APPLICATION_ATTACHED_DIALOG = FIRST_SUB_WINDOW+3,
100 TYPE_APPLICATION_MEDIA_OVERLAY = FIRST_SUB_WINDOW+4,
101 LAST_SUB_WINDOW = 1999,
102 FIRST_SYSTEM_WINDOW = 2000,
103 TYPE_STATUS_BAR = FIRST_SYSTEM_WINDOW,
104 TYPE_SEARCH_BAR = FIRST_SYSTEM_WINDOW+1,
105 TYPE_PHONE = FIRST_SYSTEM_WINDOW+2,
106 TYPE_SYSTEM_ALERT = FIRST_SYSTEM_WINDOW+3,
107 TYPE_KEYGUARD = FIRST_SYSTEM_WINDOW+4,
108 TYPE_TOAST = FIRST_SYSTEM_WINDOW+5,
109 TYPE_SYSTEM_OVERLAY = FIRST_SYSTEM_WINDOW+6,
110 TYPE_PRIORITY_PHONE = FIRST_SYSTEM_WINDOW+7,
111 TYPE_SYSTEM_DIALOG = FIRST_SYSTEM_WINDOW+8,
112 TYPE_KEYGUARD_DIALOG = FIRST_SYSTEM_WINDOW+9,
113 TYPE_SYSTEM_ERROR = FIRST_SYSTEM_WINDOW+10,
114 TYPE_INPUT_METHOD = FIRST_SYSTEM_WINDOW+11,
115 TYPE_INPUT_METHOD_DIALOG= FIRST_SYSTEM_WINDOW+12,
116 TYPE_WALLPAPER = FIRST_SYSTEM_WINDOW+13,
117 TYPE_STATUS_BAR_SUB_PANEL = FIRST_SYSTEM_WINDOW+14,
118 TYPE_SECURE_SYSTEM_OVERLAY = FIRST_SYSTEM_WINDOW+15,
119 TYPE_DRAG = FIRST_SYSTEM_WINDOW+16,
120 TYPE_STATUS_BAR_PANEL = FIRST_SYSTEM_WINDOW+17,
121 LAST_SYSTEM_WINDOW = 2999,
122 };
123
124 sp<InputWindowHandle> inputWindowHandle;
125 sp<InputChannel> inputChannel;
126 String8 name;
127 int32_t layoutParamsFlags;
128 int32_t layoutParamsType;
129 nsecs_t dispatchingTimeout;
130 int32_t frameLeft;
131 int32_t frameTop;
132 int32_t frameRight;
133 int32_t frameBottom;
Dianne Hackborne2515ee2011-04-27 18:52:56 -0400134 float scaleFactor;
Jeff Brownfbf09772011-01-16 14:06:57 -0800135 SkRegion touchableRegion;
Jeff Brown928e0542011-01-10 11:17:36 -0800136 bool visible;
137 bool canReceiveKeys;
138 bool hasFocus;
139 bool hasWallpaper;
140 bool paused;
141 int32_t layer;
142 int32_t ownerPid;
143 int32_t ownerUid;
144
Jeff Brownfbf09772011-01-16 14:06:57 -0800145 bool touchableRegionContainsPoint(int32_t x, int32_t y) const;
Jeff Brown928e0542011-01-10 11:17:36 -0800146 bool frameContainsPoint(int32_t x, int32_t y) const;
147
Dianne Hackborne2515ee2011-04-27 18:52:56 -0400148 /* These use the globalScale to convert a given screen offset to the
149 * corresponding location within the window.
150 */
151 int32_t displayToWindowX(int32_t x) const;
152
Jeff Brown928e0542011-01-10 11:17:36 -0800153 /* Returns true if the window is of a trusted type that is allowed to silently
154 * overlay other windows for the purpose of implementing the secure views feature.
155 * Trusted overlays, such as IME windows, can partly obscure other windows without causing
156 * motion events to be delivered to them with AMOTION_EVENT_FLAG_WINDOW_IS_OBSCURED.
157 */
158 bool isTrustedOverlay() const;
159
160 bool supportsSplitTouch() const;
161};
162
163} // namespace android
164
165#endif // _UI_INPUT_WINDOW_H