Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 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 | |
chaviw | 3277faf | 2021-05-19 16:45:23 -0500 | [diff] [blame] | 17 | #pragma once |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 18 | |
chaviw | 3277faf | 2021-05-19 16:45:23 -0500 | [diff] [blame] | 19 | #include <android/gui/TouchOcclusionMode.h> |
Prabir Pradhan | 51e7db0 | 2022-02-07 06:02:57 -0800 | [diff] [blame] | 20 | #include <android/os/InputConfig.h> |
Chris Ye | 0783e99 | 2020-06-02 21:34:49 -0700 | [diff] [blame] | 21 | #include <binder/Parcel.h> |
| 22 | #include <binder/Parcelable.h> |
Dominik Laskowski | 2f01d77 | 2022-03-23 16:01:29 -0700 | [diff] [blame] | 23 | #include <ftl/flags.h> |
Prabir Pradhan | 8a5c41d | 2023-06-08 19:13:46 +0000 | [diff] [blame] | 24 | #include <ftl/mixins.h> |
Prabir Pradhan | aeebeb4 | 2023-06-13 19:53:03 +0000 | [diff] [blame] | 25 | #include <gui/PidUid.h> |
Linnan Li | 13bf76a | 2024-05-05 19:18:02 +0800 | [diff] [blame] | 26 | #include <ui/LogicalDisplayId.h> |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 27 | #include <ui/Rect.h> |
| 28 | #include <ui/Region.h> |
Vishnu Nair | 494a2e4 | 2023-11-10 17:21:19 -0800 | [diff] [blame] | 29 | #include <ui/Size.h> |
chaviw | fd9c1ed | 2020-07-01 10:57:59 -0700 | [diff] [blame] | 30 | #include <ui/Transform.h> |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 31 | #include <utils/RefBase.h> |
| 32 | #include <utils/Timers.h> |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 33 | |
| 34 | #include "InputApplication.h" |
| 35 | |
chaviw | 3277faf | 2021-05-19 16:45:23 -0500 | [diff] [blame] | 36 | namespace android::gui { |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 37 | |
| 38 | /* |
| 39 | * Describes the properties of a window that can receive input. |
| 40 | */ |
chaviw | 3277faf | 2021-05-19 16:45:23 -0500 | [diff] [blame] | 41 | struct WindowInfo : public Parcelable { |
| 42 | WindowInfo() = default; |
Robert Carr | 1cc7867 | 2018-07-31 14:25:57 -0700 | [diff] [blame] | 43 | |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 44 | // Window flags from WindowManager.LayoutParams |
Michael Wright | 44753b1 | 2020-07-08 13:48:11 +0100 | [diff] [blame] | 45 | enum class Flag : uint32_t { |
| 46 | ALLOW_LOCK_WHILE_SCREEN_ON = 0x00000001, |
| 47 | DIM_BEHIND = 0x00000002, |
| 48 | BLUR_BEHIND = 0x00000004, |
| 49 | NOT_FOCUSABLE = 0x00000008, |
| 50 | NOT_TOUCHABLE = 0x00000010, |
| 51 | NOT_TOUCH_MODAL = 0x00000020, |
| 52 | TOUCHABLE_WHEN_WAKING = 0x00000040, |
| 53 | KEEP_SCREEN_ON = 0x00000080, |
| 54 | LAYOUT_IN_SCREEN = 0x00000100, |
| 55 | LAYOUT_NO_LIMITS = 0x00000200, |
| 56 | FULLSCREEN = 0x00000400, |
| 57 | FORCE_NOT_FULLSCREEN = 0x00000800, |
| 58 | DITHER = 0x00001000, |
| 59 | SECURE = 0x00002000, |
| 60 | SCALED = 0x00004000, |
| 61 | IGNORE_CHEEK_PRESSES = 0x00008000, |
| 62 | LAYOUT_INSET_DECOR = 0x00010000, |
| 63 | ALT_FOCUSABLE_IM = 0x00020000, |
| 64 | WATCH_OUTSIDE_TOUCH = 0x00040000, |
| 65 | SHOW_WHEN_LOCKED = 0x00080000, |
| 66 | SHOW_WALLPAPER = 0x00100000, |
| 67 | TURN_SCREEN_ON = 0x00200000, |
| 68 | DISMISS_KEYGUARD = 0x00400000, |
| 69 | SPLIT_TOUCH = 0x00800000, |
| 70 | HARDWARE_ACCELERATED = 0x01000000, |
| 71 | LAYOUT_IN_OVERSCAN = 0x02000000, |
| 72 | TRANSLUCENT_STATUS = 0x04000000, |
| 73 | TRANSLUCENT_NAVIGATION = 0x08000000, |
| 74 | LOCAL_FOCUS_MODE = 0x10000000, |
| 75 | SLIPPERY = 0x20000000, |
| 76 | LAYOUT_ATTACHED_IN_DECOR = 0x40000000, |
| 77 | DRAWS_SYSTEM_BAR_BACKGROUNDS = 0x80000000, |
Dominik Laskowski | 7578845 | 2021-02-09 18:51:25 -0800 | [diff] [blame] | 78 | }; |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 79 | |
Dominik Laskowski | 7578845 | 2021-02-09 18:51:25 -0800 | [diff] [blame] | 80 | // Window types from WindowManager.LayoutParams |
Michael Wright | 44753b1 | 2020-07-08 13:48:11 +0100 | [diff] [blame] | 81 | enum class Type : int32_t { |
| 82 | UNKNOWN = 0, |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 83 | FIRST_APPLICATION_WINDOW = 1, |
Michael Wright | 44753b1 | 2020-07-08 13:48:11 +0100 | [diff] [blame] | 84 | BASE_APPLICATION = 1, |
| 85 | APPLICATION = 2, |
| 86 | APPLICATION_STARTING = 3, |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 87 | LAST_APPLICATION_WINDOW = 99, |
wilsonshih | 599042f | 2020-05-04 16:24:58 +0800 | [diff] [blame] | 88 | FIRST_SUB_WINDOW = 1000, |
Michael Wright | 44753b1 | 2020-07-08 13:48:11 +0100 | [diff] [blame] | 89 | APPLICATION_PANEL = FIRST_SUB_WINDOW, |
| 90 | APPLICATION_MEDIA = FIRST_SUB_WINDOW + 1, |
| 91 | APPLICATION_SUB_PANEL = FIRST_SUB_WINDOW + 2, |
| 92 | APPLICATION_ATTACHED_DIALOG = FIRST_SUB_WINDOW + 3, |
| 93 | APPLICATION_MEDIA_OVERLAY = FIRST_SUB_WINDOW + 4, |
wilsonshih | 599042f | 2020-05-04 16:24:58 +0800 | [diff] [blame] | 94 | LAST_SUB_WINDOW = 1999, |
Dominik Laskowski | 7578845 | 2021-02-09 18:51:25 -0800 | [diff] [blame] | 95 | |
| 96 | #define FIRST_SYSTEM_WINDOW_ 2000 |
| 97 | |
| 98 | STATUS_BAR = FIRST_SYSTEM_WINDOW_, |
| 99 | SEARCH_BAR = FIRST_SYSTEM_WINDOW_ + 1, |
| 100 | PHONE = FIRST_SYSTEM_WINDOW_ + 2, |
| 101 | SYSTEM_ALERT = FIRST_SYSTEM_WINDOW_ + 3, |
| 102 | KEYGUARD = FIRST_SYSTEM_WINDOW_ + 4, |
| 103 | TOAST = FIRST_SYSTEM_WINDOW_ + 5, |
| 104 | SYSTEM_OVERLAY = FIRST_SYSTEM_WINDOW_ + 6, |
| 105 | PRIORITY_PHONE = FIRST_SYSTEM_WINDOW_ + 7, |
| 106 | SYSTEM_DIALOG = FIRST_SYSTEM_WINDOW_ + 8, |
| 107 | KEYGUARD_DIALOG = FIRST_SYSTEM_WINDOW_ + 9, |
| 108 | SYSTEM_ERROR = FIRST_SYSTEM_WINDOW_ + 10, |
| 109 | INPUT_METHOD = FIRST_SYSTEM_WINDOW_ + 11, |
| 110 | INPUT_METHOD_DIALOG = FIRST_SYSTEM_WINDOW_ + 12, |
| 111 | WALLPAPER = FIRST_SYSTEM_WINDOW_ + 13, |
| 112 | STATUS_BAR_PANEL = FIRST_SYSTEM_WINDOW_ + 14, |
| 113 | SECURE_SYSTEM_OVERLAY = FIRST_SYSTEM_WINDOW_ + 15, |
| 114 | DRAG = FIRST_SYSTEM_WINDOW_ + 16, |
| 115 | STATUS_BAR_SUB_PANEL = FIRST_SYSTEM_WINDOW_ + 17, |
| 116 | POINTER = FIRST_SYSTEM_WINDOW_ + 18, |
| 117 | NAVIGATION_BAR = FIRST_SYSTEM_WINDOW_ + 19, |
| 118 | VOLUME_OVERLAY = FIRST_SYSTEM_WINDOW_ + 20, |
| 119 | BOOT_PROGRESS = FIRST_SYSTEM_WINDOW_ + 21, |
| 120 | INPUT_CONSUMER = FIRST_SYSTEM_WINDOW_ + 22, |
| 121 | NAVIGATION_BAR_PANEL = FIRST_SYSTEM_WINDOW_ + 24, |
| 122 | MAGNIFICATION_OVERLAY = FIRST_SYSTEM_WINDOW_ + 27, |
| 123 | ACCESSIBILITY_OVERLAY = FIRST_SYSTEM_WINDOW_ + 32, |
| 124 | DOCK_DIVIDER = FIRST_SYSTEM_WINDOW_ + 34, |
| 125 | ACCESSIBILITY_MAGNIFICATION_OVERLAY = FIRST_SYSTEM_WINDOW_ + 39, |
| 126 | NOTIFICATION_SHADE = FIRST_SYSTEM_WINDOW_ + 40, |
| 127 | |
| 128 | FIRST_SYSTEM_WINDOW = FIRST_SYSTEM_WINDOW_, |
wilsonshih | 599042f | 2020-05-04 16:24:58 +0800 | [diff] [blame] | 129 | LAST_SYSTEM_WINDOW = 2999, |
Dominik Laskowski | 7578845 | 2021-02-09 18:51:25 -0800 | [diff] [blame] | 130 | |
| 131 | #undef FIRST_SYSTEM_WINDOW_ |
| 132 | |
| 133 | // Small range to limit LUT size. |
| 134 | ftl_first = FIRST_SYSTEM_WINDOW, |
| 135 | ftl_last = FIRST_SYSTEM_WINDOW + 15 |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 136 | }; |
| 137 | |
Prabir Pradhan | 4d5c52f | 2022-01-31 08:52:10 -0800 | [diff] [blame] | 138 | // Flags used to determine configuration of this input window. |
Prabir Pradhan | 51e7db0 | 2022-02-07 06:02:57 -0800 | [diff] [blame] | 139 | // This is a conversion of os::InputConfig to an enum backed by an unsigned |
| 140 | // type. This indicates that they are flags, so it can be used with ftl/enum.h. |
Prabir Pradhan | 4d5c52f | 2022-01-31 08:52:10 -0800 | [diff] [blame] | 141 | enum class InputConfig : uint32_t { |
| 142 | // clang-format off |
Prabir Pradhan | 51e7db0 | 2022-02-07 06:02:57 -0800 | [diff] [blame] | 143 | DEFAULT = |
| 144 | static_cast<uint32_t>(os::InputConfig::DEFAULT), |
| 145 | NO_INPUT_CHANNEL = |
| 146 | static_cast<uint32_t>(os::InputConfig::NO_INPUT_CHANNEL), |
| 147 | NOT_VISIBLE = |
| 148 | static_cast<uint32_t>(os::InputConfig::NOT_VISIBLE), |
| 149 | NOT_FOCUSABLE = |
| 150 | static_cast<uint32_t>(os::InputConfig::NOT_FOCUSABLE), |
| 151 | NOT_TOUCHABLE = |
| 152 | static_cast<uint32_t>(os::InputConfig::NOT_TOUCHABLE), |
| 153 | PREVENT_SPLITTING = |
| 154 | static_cast<uint32_t>(os::InputConfig::PREVENT_SPLITTING), |
| 155 | DUPLICATE_TOUCH_TO_WALLPAPER = |
| 156 | static_cast<uint32_t>(os::InputConfig::DUPLICATE_TOUCH_TO_WALLPAPER), |
| 157 | IS_WALLPAPER = |
| 158 | static_cast<uint32_t>(os::InputConfig::IS_WALLPAPER), |
| 159 | PAUSE_DISPATCHING = |
| 160 | static_cast<uint32_t>(os::InputConfig::PAUSE_DISPATCHING), |
| 161 | TRUSTED_OVERLAY = |
| 162 | static_cast<uint32_t>(os::InputConfig::TRUSTED_OVERLAY), |
| 163 | WATCH_OUTSIDE_TOUCH = |
| 164 | static_cast<uint32_t>(os::InputConfig::WATCH_OUTSIDE_TOUCH), |
| 165 | SLIPPERY = |
| 166 | static_cast<uint32_t>(os::InputConfig::SLIPPERY), |
| 167 | DISABLE_USER_ACTIVITY = |
| 168 | static_cast<uint32_t>(os::InputConfig::DISABLE_USER_ACTIVITY), |
| 169 | DROP_INPUT = |
| 170 | static_cast<uint32_t>(os::InputConfig::DROP_INPUT), |
| 171 | DROP_INPUT_IF_OBSCURED = |
| 172 | static_cast<uint32_t>(os::InputConfig::DROP_INPUT_IF_OBSCURED), |
| 173 | SPY = |
| 174 | static_cast<uint32_t>(os::InputConfig::SPY), |
| 175 | INTERCEPTS_STYLUS = |
| 176 | static_cast<uint32_t>(os::InputConfig::INTERCEPTS_STYLUS), |
chaviw | 8577ea8 | 2022-06-01 16:32:26 -0500 | [diff] [blame] | 177 | CLONE = |
| 178 | static_cast<uint32_t>(os::InputConfig::CLONE), |
Siarhei Vishniakou | f77f60a | 2023-10-23 17:26:05 -0700 | [diff] [blame] | 179 | GLOBAL_STYLUS_BLOCKS_TOUCH = |
| 180 | static_cast<uint32_t>(os::InputConfig::GLOBAL_STYLUS_BLOCKS_TOUCH), |
Arpit Singh | 490ccc9 | 2024-04-30 14:26:21 +0000 | [diff] [blame] | 181 | SENSITIVE_FOR_PRIVACY = |
| 182 | static_cast<uint32_t>(os::InputConfig::SENSITIVE_FOR_PRIVACY), |
Prabir Pradhan | 4d5c52f | 2022-01-31 08:52:10 -0800 | [diff] [blame] | 183 | // clang-format on |
| 184 | }; |
| 185 | |
Robert Carr | 5cb2578 | 2018-11-14 14:01:42 -0800 | [diff] [blame] | 186 | /* These values are filled in by the WM and passed through SurfaceFlinger |
| 187 | * unless specified otherwise. |
| 188 | */ |
chaviw | af87b3e | 2019-10-01 16:59:28 -0700 | [diff] [blame] | 189 | // This value should NOT be used to uniquely identify the window. There may be different |
| 190 | // input windows that have the same token. |
Robert Carr | 5c8a026 | 2018-10-03 16:30:44 -0700 | [diff] [blame] | 191 | sp<IBinder> token; |
chaviw | e0ba4e9 | 2021-08-11 11:38:41 -0500 | [diff] [blame] | 192 | |
| 193 | // The token that identifies which client window this WindowInfo was created for. |
| 194 | sp<IBinder> windowToken; |
| 195 | |
chaviw | af87b3e | 2019-10-01 16:59:28 -0700 | [diff] [blame] | 196 | // This uniquely identifies the input window. |
Robert Carr | 7174efe | 2020-04-13 16:55:27 -0700 | [diff] [blame] | 197 | int32_t id = -1; |
Siarhei Vishniakou | f93fcf4 | 2017-11-22 16:00:14 -0800 | [diff] [blame] | 198 | std::string name; |
Siarhei Vishniakou | c1ae556 | 2020-06-30 14:22:57 -0500 | [diff] [blame] | 199 | std::chrono::nanoseconds dispatchingTimeout = std::chrono::seconds(5); |
Robert Carr | 5cb2578 | 2018-11-14 14:01:42 -0800 | [diff] [blame] | 200 | |
| 201 | /* These values are filled in by SurfaceFlinger. */ |
Chavi Weingarten | 7f01919 | 2023-08-08 20:39:01 +0000 | [diff] [blame] | 202 | Rect frame = Rect::INVALID_RECT; |
Robert Carr | 5cb2578 | 2018-11-14 14:01:42 -0800 | [diff] [blame] | 203 | |
Vishnu Nair | 494a2e4 | 2023-11-10 17:21:19 -0800 | [diff] [blame] | 204 | // The real size of the content, excluding any crop. If no buffer is rendered, this is 0,0 |
| 205 | ui::Size contentSize = ui::Size(0, 0); |
| 206 | |
Robert Carr | 5cb2578 | 2018-11-14 14:01:42 -0800 | [diff] [blame] | 207 | /* |
| 208 | * SurfaceFlinger consumes this value to shrink the computed frame. This is |
| 209 | * different from shrinking the touchable region in that it DOES shift the coordinate |
| 210 | * space where-as the touchable region does not and is more like "cropping". This |
| 211 | * is used for window shadows. |
| 212 | */ |
| 213 | int32_t surfaceInset = 0; |
| 214 | |
Robert Carr | e07e103 | 2018-11-26 12:55:53 -0800 | [diff] [blame] | 215 | // A global scaling factor for all windows. Unlike windowScaleX/Y this results |
| 216 | // in scaling of the TOUCH_MAJOR/TOUCH_MINOR axis. |
Robert Carr | 7174efe | 2020-04-13 16:55:27 -0700 | [diff] [blame] | 217 | float globalScaleFactor = 1.0f; |
Robert Carr | e07e103 | 2018-11-26 12:55:53 -0800 | [diff] [blame] | 218 | |
Bernardo Rufino | ea97d18 | 2020-08-19 14:43:14 +0100 | [diff] [blame] | 219 | // The opacity of this window, from 0.0 to 1.0 (inclusive). |
| 220 | // An alpha of 1.0 means fully opaque and 0.0 means fully transparent. |
| 221 | float alpha; |
| 222 | |
chaviw | fd9c1ed | 2020-07-01 10:57:59 -0700 | [diff] [blame] | 223 | // Transform applied to individual windows. |
| 224 | ui::Transform transform; |
| 225 | |
Robert Carr | 5cb2578 | 2018-11-14 14:01:42 -0800 | [diff] [blame] | 226 | /* |
| 227 | * This is filled in by the WM relative to the frame and then translated |
| 228 | * to absolute coordinates by SurfaceFlinger once the frame is computed. |
| 229 | */ |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 230 | Region touchableRegion; |
Prabir Pradhan | 4d5c52f | 2022-01-31 08:52:10 -0800 | [diff] [blame] | 231 | |
Bernardo Rufino | ea97d18 | 2020-08-19 14:43:14 +0100 | [diff] [blame] | 232 | TouchOcclusionMode touchOcclusionMode = TouchOcclusionMode::BLOCK_UNTRUSTED; |
Prabir Pradhan | aeebeb4 | 2023-06-13 19:53:03 +0000 | [diff] [blame] | 233 | Pid ownerPid = Pid::INVALID; |
Prabir Pradhan | 8a5c41d | 2023-06-08 19:13:46 +0000 | [diff] [blame] | 234 | Uid ownerUid = Uid::INVALID; |
Bernardo Rufino | ea97d18 | 2020-08-19 14:43:14 +0100 | [diff] [blame] | 235 | std::string packageName; |
Dominik Laskowski | 2f01d77 | 2022-03-23 16:01:29 -0700 | [diff] [blame] | 236 | ftl::Flags<InputConfig> inputConfig; |
Linnan Li | 13bf76a | 2024-05-05 19:18:02 +0800 | [diff] [blame] | 237 | ui::LogicalDisplayId displayId = ui::ADISPLAY_ID_NONE; |
Robert Carr | 740167f | 2018-10-11 19:03:41 -0700 | [diff] [blame] | 238 | InputApplicationInfo applicationInfo; |
Robert Carr | 7174efe | 2020-04-13 16:55:27 -0700 | [diff] [blame] | 239 | bool replaceTouchableRegionWithCrop = false; |
Vishnu Nair | 6fabeec | 2019-03-12 13:42:49 -0700 | [diff] [blame] | 240 | wp<IBinder> touchableRegionCropHandle; |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 241 | |
Prabir Pradhan | 4d5c52f | 2022-01-31 08:52:10 -0800 | [diff] [blame] | 242 | // The window's layout params flags and type set by WM. |
| 243 | Type layoutParamsType = Type::UNKNOWN; |
Dominik Laskowski | 2f01d77 | 2022-03-23 16:01:29 -0700 | [diff] [blame] | 244 | ftl::Flags<Flag> layoutParamsFlags; |
Prabir Pradhan | 4d5c52f | 2022-01-31 08:52:10 -0800 | [diff] [blame] | 245 | |
Chavi Weingarten | 847e851 | 2023-03-29 00:26:09 +0000 | [diff] [blame] | 246 | // The input token for the window to which focus should be transferred when this input window |
| 247 | // can be successfully focused. If null, this input window will not transfer its focus to |
| 248 | // any other window. |
| 249 | sp<IBinder> focusTransferTarget; |
| 250 | |
Vishnu Nair | 59a6be3 | 2024-01-29 10:26:21 -0800 | [diff] [blame] | 251 | // Sets a property on this window indicating that its visible region should be considered when |
| 252 | // computing TrustedPresentation Thresholds. |
| 253 | bool canOccludePresentation = false; |
| 254 | |
Dominik Laskowski | 2f01d77 | 2022-03-23 16:01:29 -0700 | [diff] [blame] | 255 | void setInputConfig(ftl::Flags<InputConfig> config, bool value); |
Prabir Pradhan | 4d5c52f | 2022-01-31 08:52:10 -0800 | [diff] [blame] | 256 | |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 257 | void addTouchableRegion(const Rect& region); |
| 258 | |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 259 | bool supportsSplitTouch() const; |
Michael Wright | cdcd8f2 | 2016-03-22 16:52:13 -0700 | [diff] [blame] | 260 | |
Prabir Pradhan | 07e05b6 | 2021-11-19 03:57:24 -0800 | [diff] [blame] | 261 | bool isSpy() const; |
| 262 | |
Prabir Pradhan | d65552b | 2021-10-07 11:23:50 -0700 | [diff] [blame] | 263 | bool interceptsStylus() const; |
| 264 | |
chaviw | 3277faf | 2021-05-19 16:45:23 -0500 | [diff] [blame] | 265 | bool overlaps(const WindowInfo* other) const; |
Robert Carr | 3720ed0 | 2018-08-08 16:08:27 -0700 | [diff] [blame] | 266 | |
chaviw | 3277faf | 2021-05-19 16:45:23 -0500 | [diff] [blame] | 267 | bool operator==(const WindowInfo& inputChannel) const; |
Chris Ye | fcdff3e | 2020-05-10 15:16:04 -0700 | [diff] [blame] | 268 | |
Chris Ye | 0783e99 | 2020-06-02 21:34:49 -0700 | [diff] [blame] | 269 | status_t writeToParcel(android::Parcel* parcel) const override; |
| 270 | |
| 271 | status_t readFromParcel(const android::Parcel* parcel) override; |
Michael Wright | 44753b1 | 2020-07-08 13:48:11 +0100 | [diff] [blame] | 272 | }; |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 273 | |
Siarhei Vishniakou | aeed0da | 2024-01-09 08:57:13 -0800 | [diff] [blame] | 274 | std::ostream& operator<<(std::ostream& out, const WindowInfo& window); |
| 275 | |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 276 | /* |
| 277 | * Handle for a window that can receive input. |
| 278 | * |
| 279 | * Used by the native input dispatcher to indirectly refer to the window manager objects |
| 280 | * that describe a window. |
| 281 | */ |
chaviw | 3277faf | 2021-05-19 16:45:23 -0500 | [diff] [blame] | 282 | class WindowInfoHandle : public RefBase { |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 283 | public: |
chaviw | 3277faf | 2021-05-19 16:45:23 -0500 | [diff] [blame] | 284 | explicit WindowInfoHandle(); |
| 285 | WindowInfoHandle(const WindowInfoHandle& other); |
| 286 | WindowInfoHandle(const WindowInfo& other); |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 287 | |
chaviw | 3277faf | 2021-05-19 16:45:23 -0500 | [diff] [blame] | 288 | inline const WindowInfo* getInfo() const { return &mInfo; } |
Vishnu Nair | dc4d31b | 2022-11-17 03:20:58 +0000 | [diff] [blame] | 289 | inline WindowInfo* editInfo() { return &mInfo; } |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 290 | |
Robert Carr | 5c8a026 | 2018-10-03 16:30:44 -0700 | [diff] [blame] | 291 | sp<IBinder> getToken() const; |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 292 | |
chaviw | af87b3e | 2019-10-01 16:59:28 -0700 | [diff] [blame] | 293 | int32_t getId() const { return mInfo.id; } |
| 294 | |
Chris Ye | 0783e99 | 2020-06-02 21:34:49 -0700 | [diff] [blame] | 295 | sp<IBinder> getApplicationToken() { return mInfo.applicationInfo.token; } |
Robert Carr | 740167f | 2018-10-11 19:03:41 -0700 | [diff] [blame] | 296 | |
Chris Ye | 0783e99 | 2020-06-02 21:34:49 -0700 | [diff] [blame] | 297 | inline std::string getName() const { return !mInfo.name.empty() ? mInfo.name : "<invalid>"; } |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 298 | |
Siarhei Vishniakou | 4cb50ca | 2020-05-26 21:43:02 -0700 | [diff] [blame] | 299 | inline std::chrono::nanoseconds getDispatchingTimeout( |
| 300 | std::chrono::nanoseconds defaultValue) const { |
| 301 | return mInfo.token ? std::chrono::nanoseconds(mInfo.dispatchingTimeout) : defaultValue; |
| 302 | } |
| 303 | |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 304 | /** |
Garfield Tan | bd0fbcd | 2018-11-30 12:45:03 -0800 | [diff] [blame] | 305 | * Updates from another input window handle. |
| 306 | */ |
chaviw | 3277faf | 2021-05-19 16:45:23 -0500 | [diff] [blame] | 307 | void updateFrom(const sp<WindowInfoHandle> handle); |
Garfield Tan | bd0fbcd | 2018-11-30 12:45:03 -0800 | [diff] [blame] | 308 | |
| 309 | /** |
Arthur Hung | 3b413f2 | 2018-10-26 18:05:34 +0800 | [diff] [blame] | 310 | * Releases the channel used by the associated information when it is |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 311 | * no longer needed. |
| 312 | */ |
Arthur Hung | 3b413f2 | 2018-10-26 18:05:34 +0800 | [diff] [blame] | 313 | void releaseChannel(); |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 314 | |
Chris Ye | 0783e99 | 2020-06-02 21:34:49 -0700 | [diff] [blame] | 315 | // Not override since this class is not derrived from Parcelable. |
| 316 | status_t readFromParcel(const android::Parcel* parcel); |
| 317 | status_t writeToParcel(android::Parcel* parcel) const; |
| 318 | |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 319 | protected: |
chaviw | 3277faf | 2021-05-19 16:45:23 -0500 | [diff] [blame] | 320 | virtual ~WindowInfoHandle(); |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 321 | |
chaviw | 3277faf | 2021-05-19 16:45:23 -0500 | [diff] [blame] | 322 | WindowInfo mInfo; |
Michael Wright | d02c5b6 | 2014-02-10 15:10:22 -0800 | [diff] [blame] | 323 | }; |
Siarhei Vishniakou | 366fb5b | 2023-12-06 11:23:41 -0800 | [diff] [blame] | 324 | |
| 325 | std::ostream& operator<<(std::ostream& out, const WindowInfoHandle& window); |
| 326 | |
Dominik Laskowski | 7578845 | 2021-02-09 18:51:25 -0800 | [diff] [blame] | 327 | } // namespace android::gui |