1 /* 2 * Copyright (c) 2021-2022 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef DISPLAY_INFO_H 17 #define DISPLAY_INFO_H 18 19 #include <string> 20 #include <vector> 21 22 namespace OHOS { 23 namespace MMI { 24 inline constexpr int32_t GLOBAL_WINDOW_ID = -1; 25 enum Direction { 26 /** 27 * Rotating the display clockwise by 0 degree 28 * 29 * @since 9 30 */ 31 DIRECTION0, 32 33 /** 34 * Rotating the display clockwise by 90 degrees 35 * 36 * @since 9 37 */ 38 DIRECTION90, 39 40 /** 41 * Rotating the display clockwise by 180 degrees 42 * 43 * @since 9 44 */ 45 DIRECTION180, 46 47 /** 48 * Rotating the display clockwise by 270 degrees 49 * 50 * @since 9 51 */ 52 DIRECTION270 53 }; 54 55 struct Rect { 56 /** 57 * X coordinate of the upper left corner 58 * 59 * @since 9 60 */ 61 int32_t x; 62 63 /** 64 * Y coordinate of the upper left corner 65 * 66 * @since 9 67 */ 68 int32_t y; 69 70 /** 71 * Width 72 * 73 * @since 9 74 */ 75 int32_t width; 76 77 /** 78 * Height 79 * 80 * @since 9 81 */ 82 int32_t height; 83 }; 84 85 86 struct WindowInfo { 87 /** 88 * Maximum number of hot areas 89 * 90 * @since 9 91 */ 92 static constexpr int32_t MAX_HOTAREA_COUNT = 10; 93 94 /** 95 * Untouchable window 96 * 97 * @since 9 98 */ 99 static constexpr uint32_t FLAG_BIT_UNTOUCHABLE = 1; 100 101 /** 102 * Globally unique identifier of the window 103 * 104 * @since 9 105 */ 106 int32_t id; 107 108 /** 109 * ID of the process where the window is located 110 * 111 * @since 9 112 */ 113 int32_t pid; 114 115 /** 116 * UID of the process where the window is located 117 * 118 * @since 9 119 */ 120 int32_t uid; 121 122 /** 123 * Window display area 124 * 125 * @since 9 126 */ 127 Rect area; 128 129 /** 130 * Number of touch response areas (excluding the mouse response areas) in the window. 131 * The value cannot exceed the value of MAX_HOTAREA_COUNT. 132 * 133 * @since 9 134 */ 135 std::vector<Rect> defaultHotAreas; 136 137 /** 138 * Number of mouse response areas in the window. The value cannot exceed the value of MAX_HOTAREA_COUNT. 139 * 140 * @since 9 141 */ 142 std::vector<Rect> pointerHotAreas; 143 144 /** 145 * Agent window ID 146 * 147 * @since 9 148 */ 149 int32_t agentWindowId; 150 151 /** 152 * A 32-bit flag that represents the window status. If the 0th bit is 1, 153 * the window is untouchable; if the 0th bit is 0, the window is touchable. 154 * 155 * @since 9 156 */ 157 uint32_t flags; 158 }; 159 160 /** 161 * Physical screen information 162 * 163 * @since 9 164 */ 165 struct DisplayInfo { 166 /** 167 * Unique ID of the physical display 168 * 169 * @since 9 170 */ 171 int32_t id; 172 173 /** 174 * X coordinate of the upper left corner on the logical screen 175 * 176 * @since 9 177 */ 178 int32_t x; 179 180 /** 181 * Y coordinate of the upper left corner on the logical screen 182 * 183 * @since 9 184 */ 185 int32_t y; 186 187 /** 188 * Display width, which is the logical width of the original screen when the rotation angle is 0. 189 * The value remains unchanged even if the display screen is rotated. 190 * 191 * @since 9 192 */ 193 int32_t width; 194 195 /** 196 * Display height, which is the logical height of the original screen when the rotation angle is 0. 197 * The value remains unchanged even if the display screen is rotated. 198 * 199 * @since 9 200 */ 201 int32_t height; 202 203 /** 204 * Pixel density, which indicates the number of pixels in an inch 205 * 206 * @since 10 207 */ 208 int32_t dpi; 209 210 /** 211 * Name of the physical display, which is used for debugging 212 * 213 * @since 9 214 */ 215 std::string name; 216 217 /** 218 * Unique screen ID, which is used to associate the corresponding touchscreen. The default value is default0. 219 * 220 * @since 9 221 */ 222 std::string uniq; 223 224 /** 225 * Orientation of the physical display 226 * 227 * @since 9 228 */ 229 Direction direction; 230 }; 231 232 /** 233 * Logical screen information 234 * 235 * @since 9 236 */ 237 struct DisplayGroupInfo { 238 /** 239 * Width of the logical display 240 * 241 * @since 9 242 */ 243 int32_t width; 244 245 /** 246 * Height of the logical display 247 * 248 * @since 9 249 */ 250 int32_t height; 251 252 /** 253 * ID of the focus window 254 * 255 * @since 9 256 */ 257 int32_t focusWindowId; 258 259 /** 260 * List of window information of the logical display arranged in Z order, with the top window at the top 261 * 262 * @since 9 263 */ 264 std::vector<WindowInfo> windowsInfo; 265 266 /** 267 * Physical screen information list 268 * 269 * @since 9 270 */ 271 std::vector<DisplayInfo> displaysInfo; 272 }; 273 274 struct DisplayBindInfo { 275 int32_t inputDeviceId = -1; 276 std::string inputDeviceName; 277 int32_t displayId = -1; 278 std::string displayName; 279 }; 280 using DisplayBindInfos = std::vector<DisplayBindInfo>; 281 } // namespace MMI 282 } // namespace OHOS 283 #endif // DISPLAY_INFO_H