Signed-off-by: 红书包指挥官 <gongjingbo2@huawei.com>
This commit is contained in:
红书包指挥官 2025-01-20 15:41:44 +08:00
parent 9e2aedff61
commit e8053d050d
3 changed files with 38 additions and 0 deletions

View File

@ -70,5 +70,9 @@
{
"first_instroduced":"16",
"name":"OH_WindowManager_Snapshot"
},
{
"first_instroduced":"16",
"name":"OH_WindowManager_SetWindowTouchable"
}
]

View File

@ -203,6 +203,20 @@ int32_t OH_WindowManager_GetWindowProperties(
*/
int32_t OH_WindowManager_Snapshot(int32_t windowId, OH_PixelmapNative* pixelMap);
/**
* @brief set window touchable status.
*
* @param windowId windowId when window is created.
* @param touchable window touchable status.
* @return Return the result code.
* {@link OK} the function call is successful.
* {@link WINDOW_MANAGER_ERRORCODE_INVALID_PARAM} parameter error.
* {@link WINDOW_MANAGER_ERRORCODE_STATE_ABNORMALLY} this window state is abnormal.
* {@link WINDOW_MANAGER_ERRORCODE_SYSTEM_ABNORMALLY} the window manager service works abnormal.
* @since 16
*/
int32_t OH_WindowManager_SetWindowTouchable(int32_t windowId, bool touchable);
#ifdef __cplusplus
}
#endif

View File

@ -437,4 +437,24 @@ int32_t OH_WindowManager_GetWindowProperties(
TransformedToWindowManagerRect(drawableRect, windowProperties->drawableRect);
}, __func__);
return errCode;
}
int32_t OH_WindowManager_SetWindowTouchable(int32_t windowId, bool touchable)
{
auto eventHandler = GetMainEventHandler();
if (eventHandler == nullptr) {
TLOGE(WmsLogTag::WMS_EVENT, "eventHandler null, windowId:%{public}d", windowId);
return WindowManager_ErrorCode::SERVICE_ERROR;
}
WindowManager_ErrorCode errCode = WindowManager_ErrorCode::SERVICE_ERROR;
eventHandler->PostSyncTask([windowId, touchable, &errCode, where = __func__] {
auto window = Window::GetWindowWithId(windowId);
if (window == nullptr) {
TLOGNE(WmsLogTag::WMS_EVENT, "%{public}s window is null, windowId:%{public}d", where, windowId);
errCode = WindowManager_ErrorCode::INVAILD_WINDOW_ID;
return;
}
errCode = OH_WINDOW_TO_ERROR_CODE_MAP.at(window->SetTouchable(touchable));
}, __func__);
return errCode;
}