!12263 添加SetTouchable 接口

Merge pull request !12263 from 红书包指挥官/master
This commit is contained in:
openharmony_ci 2025-01-21 10:05:13 +00:00 committed by Gitee
commit d02c279f1c
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
3 changed files with 38 additions and 0 deletions

View File

@ -71,6 +71,10 @@
"first_instroduced":"16",
"name":"OH_WindowManager_Snapshot"
},
{
"first_instroduced":"16",
"name":"OH_WindowManager_SetWindowTouchable"
},
{
"first_instroduced":"16",
"name":"OH_WindowManager_SetWindowFocusable"

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);
/**
* @brief Set focusable property of window.
*

View File

@ -439,6 +439,26 @@ int32_t OH_WindowManager_GetWindowProperties(
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;
}
int32_t OH_WindowManager_SetWindowFocusable(int32_t windowId, bool isFocusable)
{
auto eventHandler = GetMainEventHandler();