blob: cde7294ee00e153affd908f7d66ef1691ca5d88b [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,
Daniel Sandler6d8a98a2011-04-27 14:07:12 -0400117 TYPE_STATUS_BAR_PANEL = FIRST_SYSTEM_WINDOW+14,
Jeff Brown928e0542011-01-10 11:17:36 -0800118 TYPE_SECURE_SYSTEM_OVERLAY = FIRST_SYSTEM_WINDOW+15,
119 TYPE_DRAG = FIRST_SYSTEM_WINDOW+16,
Daniel Sandler6d8a98a2011-04-27 14:07:12 -0400120 TYPE_STATUS_BAR_SUB_PANEL = FIRST_SYSTEM_WINDOW+17,
121 TYPE_POINTER = FIRST_SYSTEM_WINDOW+18,
Daniel Sandler8956dbb2011-04-22 07:55:02 -0400122 TYPE_NAVIGATION_BAR = FIRST_SYSTEM_WINDOW+19,
Jeff Brown928e0542011-01-10 11:17:36 -0800123 LAST_SYSTEM_WINDOW = 2999,
124 };
125
126 sp<InputWindowHandle> inputWindowHandle;
127 sp<InputChannel> inputChannel;
128 String8 name;
129 int32_t layoutParamsFlags;
130 int32_t layoutParamsType;
131 nsecs_t dispatchingTimeout;
132 int32_t frameLeft;
133 int32_t frameTop;
134 int32_t frameRight;
135 int32_t frameBottom;
Dianne Hackborne2515ee2011-04-27 18:52:56 -0400136 float scaleFactor;
Jeff Brownfbf09772011-01-16 14:06:57 -0800137 SkRegion touchableRegion;
Jeff Brown928e0542011-01-10 11:17:36 -0800138 bool visible;
139 bool canReceiveKeys;
140 bool hasFocus;
141 bool hasWallpaper;
142 bool paused;
143 int32_t layer;
144 int32_t ownerPid;
145 int32_t ownerUid;
146
Jeff Brownfbf09772011-01-16 14:06:57 -0800147 bool touchableRegionContainsPoint(int32_t x, int32_t y) const;
Jeff Brown928e0542011-01-10 11:17:36 -0800148 bool frameContainsPoint(int32_t x, int32_t y) const;
149
Dianne Hackborne2515ee2011-04-27 18:52:56 -0400150 /* These use the globalScale to convert a given screen offset to the
151 * corresponding location within the window.
152 */
153 int32_t displayToWindowX(int32_t x) const;
154
Jeff Brown928e0542011-01-10 11:17:36 -0800155 /* Returns true if the window is of a trusted type that is allowed to silently
156 * overlay other windows for the purpose of implementing the secure views feature.
157 * Trusted overlays, such as IME windows, can partly obscure other windows without causing
158 * motion events to be delivered to them with AMOTION_EVENT_FLAG_WINDOW_IS_OBSCURED.
159 */
160 bool isTrustedOverlay() const;
161
162 bool supportsSplitTouch() const;
163};
164
165} // namespace android
166
167#endif // _UI_INPUT_WINDOW_H