• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-2023 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 
26 inline constexpr int32_t DEFAULT_DISPLAY_ID = -1;
27 
28 /**
29  * @brief Enumerates the fold display mode.
30  */
31 enum class DisplayMode: uint32_t {
32     /**
33      * The default display mode
34      *
35      * @since 9
36      */
37     UNKNOWN = 0,
38 
39     /**
40      * The full display mode
41      *
42      * @since 9
43      */
44     FULL = 1,
45 
46     /**
47      * The main display mode
48      *
49      * @since 9
50      */
51     MAIN = 2,
52 
53     /**
54      * The sub display mode
55      *
56      * @since 9
57      */
58     SUB = 3,
59 
60     /**
61      * The coordination display mode
62      *
63      * @since 9
64      */
65     COORDINATION = 4,
66 };
67 
68 enum class WINDOW_UPDATE_ACTION: uint32_t {
69     /**
70      * The default window update action
71      *
72      * @since 9
73      */
74     UNKNOWN = 0,
75 
76     /**
77      * Add the window action
78      *
79      * @since 9
80      */
81     ADD = 1,
82 
83     /**
84      * Delete the window action
85      *
86      * @since 9
87      */
88     DEL = 2,
89 
90      /**
91      * Change the window action
92      *
93      * @since 9
94      */
95     CHANGE = 3,
96 
97     /**
98      * Add the window action end
99      *
100      * @since 9
101      */
102     ADD_END = 4,
103 };
104 
105 enum Direction {
106     /**
107      * Rotating the display clockwise by 0 degree
108      *
109      * @since 9
110      */
111     DIRECTION0,
112 
113     /**
114      * Rotating the display clockwise by 90 degrees
115      *
116      * @since 9
117      */
118     DIRECTION90,
119 
120     /**
121      * Rotating the display clockwise by 180 degrees
122      *
123      * @since 9
124      */
125     DIRECTION180,
126 
127     /**
128      * Rotating the display clockwise by 270 degrees
129      *
130      * @since 9
131      */
132     DIRECTION270
133 };
134 
135 struct Rect {
136     /**
137      * X coordinate of the upper left corner
138      *
139      * @since 9
140      */
141     int32_t x;
142 
143     /**
144      * Y coordinate of the upper left corner
145      *
146      * @since 9
147      */
148     int32_t y;
149 
150     /**
151      * Width
152      *
153      * @since 9
154      */
155     int32_t width;
156 
157     /**
158      * Height
159      *
160      * @since 9
161      */
162     int32_t height;
163 };
164 
165 
166 struct WindowInfo {
167     /**
168      * Maximum number of hot areas
169      *
170      * @since 9
171      */
172     static constexpr int32_t MAX_HOTAREA_COUNT = 10;
173 
174     /**
175      * The number of pointer change areas
176      *
177      * @since 9
178      */
179     static constexpr int32_t POINTER_CHANGEAREA_COUNT = 8;
180 
181     /**
182      * The size of window transform, which create a 3*3 matrix
183      *
184      * @since 9
185      */
186     static constexpr int32_t WINDOW_TRANSFORM_SIZE = 9;
187 
188     /**
189      * Untouchable window
190      *
191      * @since 9
192      */
193     static constexpr uint32_t FLAG_BIT_UNTOUCHABLE = 1;
194 
195     /**
196      * Globally unique identifier of the window
197      *
198      * @since 9
199      */
200     int32_t id;
201 
202     /**
203      * ID of the process where the window is located
204      *
205      * @since 9
206      */
207     int32_t pid;
208 
209     /**
210      * UID of the process where the window is located
211      *
212      * @since 9
213      */
214     int32_t uid;
215 
216     /**
217      * Window display area
218      *
219      * @since 9
220      */
221     Rect area;
222 
223     /**
224      * Number of touch response areas (excluding the mouse response areas) in the window.
225      * The value cannot exceed the value of MAX_HOTAREA_COUNT.
226      *
227      * @since 9
228      */
229     std::vector<Rect> defaultHotAreas;
230 
231     /**
232      * Number of mouse response areas in the window. The value cannot exceed the value of MAX_HOTAREA_COUNT.
233      *
234      * @since 9
235      */
236     std::vector<Rect> pointerHotAreas;
237 
238     /**
239      * Agent window ID
240      *
241      * @since 9
242      */
243     int32_t agentWindowId;
244 
245     /**
246      * A 32-bit flag that represents the window status. If the 0th bit is 1,
247      * the window is untouchable; if the 0th bit is 0, the window is touchable.
248      *
249      * @since 9
250      */
251     uint32_t flags;
252 
253     /**
254      * Agent window ID
255      *
256      * @since 9
257      */
258     WINDOW_UPDATE_ACTION action { WINDOW_UPDATE_ACTION::UNKNOWN };
259 
260     /**
261      * Window display ID
262      *
263      * @since 9
264      */
265     int32_t displayId { DEFAULT_DISPLAY_ID };
266 
267     /**
268      * Window order in Z-index
269      *
270      * @since 9
271      */
272     float zOrder { 0.0f };
273 
274     /**
275      * Number of mouse style change areas in the window. The value must be POINTER_CHANGEAREA_COUNT.
276      *
277      * @since 9
278      */
279     std::vector<int32_t> pointerChangeAreas;
280 
281     /**
282      * Number of transform in the window which is used to calculate the window x and window y by logic x and window y.
283      * The value must be POINTER_CHANGEAREA_COUNT.
284      *
285      * @since 9
286      */
287     std::vector<float> transform;
288 };
289 
290 /**
291  * Physical screen information
292  *
293  * @since 9
294  */
295 struct DisplayInfo {
296     /**
297      * Unique ID of the physical display
298      *
299      * @since 9
300      */
301     int32_t id;
302 
303     /**
304      * X coordinate of the upper left corner on the logical screen
305      *
306      * @since 9
307      */
308     int32_t x;
309 
310     /**
311      * Y coordinate of the upper left corner on the logical screen
312      *
313      * @since 9
314      */
315     int32_t y;
316 
317     /**
318      * Display width, which is the logical width of the original screen when the rotation angle is 0.
319      * The value remains unchanged even if the display screen is rotated.
320      *
321      * @since 9
322      */
323     int32_t width;
324 
325     /**
326      * Display height, which is the logical height of the original screen when the rotation angle is 0.
327      * The value remains unchanged even if the display screen is rotated.
328      *
329      * @since 9
330      */
331     int32_t height;
332 
333     /**
334      * Pixel density, which indicates the number of pixels in an inch
335      *
336      * @since 10
337      */
338     int32_t dpi;
339 
340     /**
341      * Name of the physical display, which is used for debugging
342      *
343      * @since 9
344      */
345     std::string name;
346 
347     /**
348      * Unique screen ID, which is used to associate the corresponding touchscreen. The default value is default0.
349      *
350      * @since 9
351      */
352     std::string uniq;
353 
354     /**
355      * Orientation of the physical display
356      *
357      * @since 9
358      */
359     Direction direction;
360 
361     Direction displayDirection;
362 
363     /**
364      * DisplayMode of the display
365      *
366      * @since 9
367      */
368     DisplayMode displayMode { DisplayMode::UNKNOWN };
369 };
370 
371 /**
372  * Logical screen information
373  *
374  * @since 9
375  */
376 struct DisplayGroupInfo {
377     /**
378      * Width of the logical display
379      *
380      * @since 9
381      */
382     int32_t width;
383 
384     /**
385      * Height of the logical display
386      *
387      * @since 9
388      */
389     int32_t height;
390 
391     /**
392      * ID of the focus window
393      *
394      * @since 9
395      */
396     int32_t focusWindowId;
397 
398     /**
399      * List of window information of the logical display arranged in Z order, with the top window at the top
400      *
401      * @since 9
402      */
403     std::vector<WindowInfo> windowsInfo;
404 
405     /**
406      * Physical screen information list
407      *
408      * @since 9
409      */
410     std::vector<DisplayInfo> displaysInfo;
411 };
412 
413 struct WindowGroupInfo {
414     /**
415      * ID of the focus window
416      *
417      * @since 9
418      */
419     int32_t focusWindowId { GLOBAL_WINDOW_ID };
420 
421     /**
422      * Window display ID
423      *
424      * @since 9
425      */
426     int32_t displayId { DEFAULT_DISPLAY_ID };
427 
428     /**
429      * List of window information of the logical display arranged in Z order, with the top window at the top
430      *
431      * @since 9
432      */
433     std::vector<WindowInfo> windowsInfo;
434 };
435 
436 struct DisplayBindInfo {
437     int32_t inputDeviceId = -1;
438     std::string inputDeviceName;
439     int32_t displayId = -1;
440     std::string displayName;
441 };
442 enum class WindowArea: int32_t {
443     ENTER = 0,
444     EXIT,
445     FOCUS_ON_INNER,
446     FOCUS_ON_TOP,
447     FOCUS_ON_BOTTOM,
448     FOCUS_ON_LEFT,
449     FOCUS_ON_RIGHT,
450     FOCUS_ON_TOP_LEFT,
451     FOCUS_ON_TOP_RIGHT,
452     FOCUS_ON_BOTTOM_LEFT,
453     FOCUS_ON_BOTTOM_RIGHT,
454     TOP_LEFT_LIMIT,
455     TOP_RIGHT_LIMIT,
456     TOP_LIMIT,
457     LEFT_LIMIT,
458     RIGHT_LIMIT,
459     BOTTOM_LEFT_LIMIT,
460     BOTTOM_LIMIT,
461     BOTTOM_RIGHT_LIMIT
462 };
463 
464 using DisplayBindInfos = std::vector<DisplayBindInfo>;
465 } // namespace MMI
466 } // namespace OHOS
467 #endif // DISPLAY_INFO_H
468