• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2024 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 /**
17  * @addtogroup WindowManager
18  * @{
19  *
20  * @brief Provides abilities of window on the native side.
21  * @since 15
22  */
23 
24 /**
25  * @file oh_window.h
26  *
27  * @brief Declares APIs for window
28  *
29  * @library libnative_window_manager.so
30  * @kit ArkUI
31  * @syscap SystemCapability.Window.SessionManager
32  * @since 15
33  */
34 #ifndef OH_WINDOW_H
35 #define OH_WINDOW_H
36 
37 #include "stdbool.h"
38 #include "stdint.h"
39 
40 #include "oh_window_comm.h"
41 #include "multimodalinput/oh_input_manager.h"
42 
43 #ifdef __cplusplus
44 extern "C" {
45 #endif
46 
47 /**
48  * @brief Set whether to show status bar.
49  *
50  * @param windowId WindowId when window is created.
51  * @param enabled If true, the status bar is displayed. If false, the status bar is hidden.
52  * @param enableAnimation If true, the status bar is displayed and hidden with animation.
53  *                        If false, the status bar is displayed and hidden with no animation.
54  * @return Returns the result code.
55  *         {@link OK} the function call is successful.
56  *         {@link WINDOW_MANAGER_ERRORCODE_INVALID_PARAM} parameter error.
57  *         {@link WINDOW_MANAGER_ERRORCODE_DEVICE_NOT_SUPPORTED} capability not supported.
58  *         {@link WINDOW_MANAGER_ERRORCODE_STATE_ABNORMAL} this window state is abnormal.
59  *         {@link WINDOW_MANAGER_ERRORCODE_SYSTEM_ABNORMAL} the window manager service works abnormally.
60  * @since 15
61  */
62 int32_t OH_WindowManager_SetWindowStatusBarEnabled(int32_t windowId, bool enabled, bool enableAnimation);
63 
64 /**
65  * @brief Set status bar content color.
66  *
67  * @param windowId WindowId when window is created.
68  * @param color The color value to set, the format is ARGB.
69  * @return Returns the result code.
70  *         {@link OK} the function call is successful.
71  *         {@link WINDOW_MANAGER_ERRORCODE_INVALID_PARAM} parameter error.
72  *         {@link WINDOW_MANAGER_ERRORCODE_DEVICE_NOT_SUPPORTED} capability not supported.
73  *         {@link WINDOW_MANAGER_ERRORCODE_STATE_ABNORMAL} this window state is abnormal.
74  *         {@link WINDOW_MANAGER_ERRORCODE_SYSTEM_ABNORMAL} the window manager service works abnormally.
75  * @since 15
76  */
77 int32_t OH_WindowManager_SetWindowStatusBarColor(int32_t windowId, int32_t color);
78 
79 /**
80  * @brief Set whether to show navigation bar.
81  *
82  * @param windowId WindowId when window is created.
83  * @param enabled If true, the navigation bar is displayed. If false, the navigation bar is hidden.
84  * @param enableAnimation If true, the navigation bar is displayed and hidden with animation.
85  *                        If false, the navigation bar is displayed and hidden with no animation.
86  * @return Returns the result code.
87  *         {@link OK} the function call is successful.
88  *         {@link WINDOW_MANAGER_ERRORCODE_INVALID_PARAM} parameter error.
89  *         {@link WINDOW_MANAGER_ERRORCODE_DEVICE_NOT_SUPPORTED} capability not supported.
90  *         {@link WINDOW_MANAGER_ERRORCODE_STATE_ABNORMAL} this window state is abnormal.
91  *         {@link WINDOW_MANAGER_ERRORCODE_SYSTEM_ABNORMAL} the window manager service works abnormally.
92  * @since 15
93  */
94 int32_t OH_WindowManager_SetWindowNavigationBarEnabled(int32_t windowId, bool enabled, bool enableAnimation);
95 
96 /**
97  * @brief Get the avoid area
98  *
99  * @param windowId WindowId when window is created.
100  * @param type Type of the avoid area.
101  * @param avoidArea Indicates the pointer to a WindowManager_AvoidArea object.
102  * @return Returns the result code.
103  *         {@link OK} the function call is successful, return avoid area ptr in avoidArea.
104  *         {@link WINDOW_MANAGER_ERRORCODE_INVALID_PARAM} parameter error.
105  *         {@link WINDOW_MANAGER_ERRORCODE_STATE_ABNORMAL} this window state is abnormal.
106  *         {@link WINDOW_MANAGER_ERRORCODE_SYSTEM_ABNORMAL} the window manager service works abnormally.
107  * @since 15
108  */
109 int32_t OH_WindowManager_GetWindowAvoidArea(
110     int32_t windowId, WindowManager_AvoidAreaType type, WindowManager_AvoidArea* avoidArea);
111 
112 /**
113  * @brief Checks whether the window is displayed.
114  *
115  * @param windowId WindowId when window is created.
116  * @param isShow Whether the window is displayed. The value true means that the window is displayed, and false means the opposite.
117  * @return Returns the result code.
118  *         {@link OK} the function call is successful.
119  *         {@link WINDOW_MANAGER_ERRORCODE_INVALID_PARAM} parameter error.
120  *         {@link WINDOW_MANAGER_ERRORCODE_STATE_ABNORMAL} this window state is abnormal.
121  * @since 15
122  */
123 int32_t OH_WindowManager_IsWindowShown(int32_t windowId, bool* isShow);
124 
125 /**
126  * @brief Show window.
127  *
128  * @param windowId WindowId when window is created.
129  * @return Returns the result code.
130  *         {@link OK} the function call is successful.
131  *         {@link WINDOW_MANAGER_ERRORCODE_INVALID_PARAM} parameter error.
132  *         {@link WINDOW_MANAGER_ERRORCODE_STATE_ABNORMAL} this window state is abnormal.
133  *         {@link WINDOW_MANAGER_ERRORCODE_SYSTEM_ABNORMAL} the window manager service works abnormally.
134  * @since 15
135  */
136 int32_t OH_WindowManager_ShowWindow(int32_t windowId);
137 
138 /**
139  * @brief Set window touchable
140  *
141  * @param windowId WindowId when window is created.
142  * @param isTouchable Indicates whether the specified window can be touched.
143  * @return Returns the result code.
144  *         {@link OK} the function call is successful.
145  *         {@link WINDOW_MANAGER_ERRORCODE_INVALID_PARAM} parameter error.
146  *         {@link WINDOW_MANAGER_ERRORCODE_STATE_ABNORMAL} this window state is abnormal.
147  *         {@link WINDOW_MANAGER_ERRORCODE_SYSTEM_ABNORMAL} the window manager service works abnormally.
148  * @since 15
149  */
150 int32_t OH_WindowManager_SetWindowTouchable(int32_t windowId, bool isTouchable);
151 
152 /**
153  * @brief Set focusable property of window.
154  *
155  * @param windowId WindowId when window is created.
156  * @param isFocusable Window can be focused or not.
157  * @return Returns the result code.
158  *         {@link OK} the function call is successful.
159  *         {@link WINDOW_MANAGER_ERRORCODE_INVALID_PARAM} parameter error.
160  *         {@link WINDOW_MANAGER_ERRORCODE_STATE_ABNORMAL} this window state is abnormal.
161  *         {@link WINDOW_MANAGER_ERRORCODE_SYSTEM_ABNORMAL} the window manager service works abnormally.
162  * @since 15
163  */
164 int32_t OH_WindowManager_SetWindowFocusable(int32_t windowId, bool isFocusable);
165 
166 /**
167  * @brief Sets the background color of window.
168  *
169  * @param windowId WindowId when window is created.
170  * @param color the specified color.
171  * @return Returns the result code.
172  *         {@link OK} the function call is successful.
173  *         {@link WINDOW_MANAGER_ERRORCODE_INVALID_PARAM} parameter error.
174  *         {@link WINDOW_MANAGER_ERRORCODE_STATE_ABNORMAL} this window state is abnormal.
175  * @since 15
176  */
177 int32_t OH_WindowManager_SetWindowBackgroundColor(int32_t windowId, const char* color);
178 
179 /**
180  * @brief Sets the brightness of window.
181  *
182  * @param windowId WindowId when window is created.
183  * @param brightness the specified brightness value.
184  * @return Returns the result code.
185  *         {@link OK} the function call is successful.
186  *         {@link WINDOW_MANAGER_ERRORCODE_INVALID_PARAM} parameter error.
187  *         {@link WINDOW_MANAGER_ERRORCODE_STATE_ABNORMAL} this window state is abnormal.
188  *         {@link WINDOW_MANAGER_ERRORCODE_SYSTEM_ABNORMAL} the window manager service works abnormally.
189  * @since 15
190  */
191 int32_t OH_WindowManager_SetWindowBrightness(int32_t windowId, float brightness);
192 
193 /**
194  * @brief Sets whether keep screen on or not.
195  *
196  * @param windowId WindowId when window is created.
197  * @param isKeepScreenOn keep screen on if true, or not if false.
198  * @return Returns the result code.
199  *         {@link OK} the function call is successful.
200  *         {@link WINDOW_MANAGER_ERRORCODE_INVALID_PARAM} parameter error.
201  *         {@link WINDOW_MANAGER_ERRORCODE_STATE_ABNORMAL} this window state is abnormal.
202  *         {@link WINDOW_MANAGER_ERRORCODE_SYSTEM_ABNORMAL} the window manager service works abnormally.
203  * @since 15
204  */
205 int32_t OH_WindowManager_SetWindowKeepScreenOn(int32_t windowId, bool isKeepScreenOn);
206 
207 /**
208  * @brief Sets whether is private mode or not.
209  *
210  * @permission {@code ohos.permission.PRIVACY_WINDOW}
211  * @param windowId WindowId when window is created.
212  * @param isPrivacy In private mode if true, or not if false.
213  * @return Returns the result code.
214  *         {@link OK} the function call is successful.
215  *         {@link WINDOW_MANAGER_ERRORCODE_INVALID_PARAM} parameter error.
216  *         {@link WINDOW_MANAGER_ERRORCODE_STATE_ABNORMAL} this window state is abnormal.
217  *         {@link WINDOW_MANAGER_ERRORCODE_SYSTEM_ABNORMAL} the window manager service works abnormally.
218  *         {@link WINDOW_MANAGER_ERRORCODE_NO_PERMISSION} permission verification failed.
219  * @since 15
220  */
221 int32_t OH_WindowManager_SetWindowPrivacyMode(int32_t windowId, bool isPrivacy);
222 
223 /**
224  * @brief Get the properties of current window.
225  *
226  * @param windowId WindowId when window is created.
227  * @param windowProperties Properties of current window.
228  * @return Returns the result code.
229  *         {@link OK} the function call is successful, return window properties ptr in windowProperties.
230  *         {@link WINDOW_MANAGER_ERRORCODE_INVALID_PARAM} parameter error.
231  *         {@link WINDOW_MANAGER_ERRORCODE_STATE_ABNORMAL} this window state is abnormal.
232  * @since 15
233  */
234 int32_t OH_WindowManager_GetWindowProperties(
235     int32_t windowId, WindowManager_WindowProperties* windowProperties);
236 
237 /**
238  * @brief Obtains snapshot of window.
239  *
240  * @param windowId windowId when window is created.
241  * @param pixelMap snapshot of window.
242  * @return Returns the result code.
243  *         {@link OK} the function call is successful, return pixel map ptr in pixelMap.
244  *         {@link WINDOW_MANAGER_ERRORCODE_INVALID_PARAM} parameter error.
245  *         {@link WINDOW_MANAGER_ERRORCODE_STATE_ABNORMAL} this window state is abnormal.
246  *         {@link WINDOW_MANAGER_ERRORCODE_SYSTEM_ABNORMAL} the window manager service works abnormally.
247  * @since 15
248  */
249 int32_t OH_WindowManager_Snapshot(int32_t windowId, OH_PixelmapNative* pixelMap);
250 
251 /**
252  * @brief Get layout info of all windows on the selected display.
253  *
254  * @param displayId Indicate the id of display.
255  * @param windowLayoutInfoList Pointer to the layout information of the visible windows on the specified screen.
256  * @param windowLayoutInfoSize Pointer to the size of the array of layout information of the visible windows on the
257  * specified screen.
258  * @return Returns the result code.
259  *         {@link OK} the function call is successful, return Window layout info list.
260  *         {@link WINDOW_MANAGER_ERRORCODE_INVALID_PARAM} parameter error.
261  *         {@link WINDOW_MANAGER_ERRORCODE_DEVICE_NOT_SUPPORTED} capability not supported.
262  *         {@link WINDOW_MANAGER_ERRORCODE_SYSTEM_ABNORMAL} the window manager service works abnormally.
263  * @since 17
264  */
265 int32_t OH_WindowManager_GetAllWindowLayoutInfoList(int64_t displayId,
266     WindowManager_Rect** windowLayoutInfoList, size_t* windowLayoutInfoSize);
267 
268 /**
269  * @brief Release the memory of window layout info list.
270  *
271  * @param windowLayoutInfoList Pointer to the layout information of the visible windows on the specified screen.
272  * @since 17
273  */
274 void OH_WindowManager_ReleaseAllWindowLayoutInfoList(WindowManager_Rect* windowLayoutInfoList);
275 
276 /**
277  * @brief app can inject a touchEvent to target window without Focus and zOrder changed, just send to ArkUI.
278  *
279  * @param windowId windowId when window is created.
280  * @param touchEvent multimodal touchEvent.
281  * @param windowX The position of the event relative to the abscissa of the window.
282  * @param windowY The position of the event relative to the ordinate of the window.
283  * @return Returns the result code.
284  *         {@link OK} the function call is successful.
285  *         {@link WINDOW_MANAGER_ERRORCODE_STATE_ABNORMAL} this window state is abnormal.
286  *         {@link WINDOW_MANAGER_ERRORCODE_SYSTEM_ABNORMAL} the window manager service works abnormally.
287  * @since 20
288  */
289 int32_t OH_WindowManager_InjectTouchEvent(
290     int32_t windowId, Input_TouchEvent* touchEvent, int32_t windowX, int32_t windowY);
291 
292 #ifdef __cplusplus
293 }
294 #endif
295 
296 #endif // OH_WINDOW_H
297 /** @} */