mirror of
https://gitee.com/openharmony/window_window_manager
synced 2025-05-13 06:41:12 +00:00
!12268 焦点接口SetFocusable新增ndk接口
Merge pull request !12268 from 胡晗/SetFocusable_ndk
This commit is contained in:
commit
765b28642f
@ -70,5 +70,9 @@
|
||||
{
|
||||
"first_instroduced":"16",
|
||||
"name":"OH_WindowManager_Snapshot"
|
||||
},
|
||||
{
|
||||
"first_instroduced":"16",
|
||||
"name":"OH_WindowManager_SetWindowFocusable"
|
||||
}
|
||||
]
|
@ -203,6 +203,20 @@ int32_t OH_WindowManager_GetWindowProperties(
|
||||
*/
|
||||
int32_t OH_WindowManager_Snapshot(int32_t windowId, OH_PixelmapNative* pixelMap);
|
||||
|
||||
/**
|
||||
* @brief Set focusable property of window.
|
||||
*
|
||||
* @param windowId WindowId when window is created.
|
||||
* @param isFocusable Window can be focused or not.
|
||||
* @return Returns 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 abnormally.
|
||||
* @since 16
|
||||
*/
|
||||
int32_t OH_WindowManager_SetWindowFocusable(int32_t windowId, bool isFocusable);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -438,3 +438,23 @@ int32_t OH_WindowManager_GetWindowProperties(
|
||||
}, __func__);
|
||||
return errCode;
|
||||
}
|
||||
|
||||
int32_t OH_WindowManager_SetWindowFocusable(int32_t windowId, bool isFocusable)
|
||||
{
|
||||
auto eventHandler = GetMainEventHandler();
|
||||
if (eventHandler == nullptr) {
|
||||
TLOGE(WmsLogTag::WMS_FOCUS, "eventHandler is null, windowId:%{public}d", windowId);
|
||||
return WindowManager_ErrorCode::WINDOW_MANAGER_ERRORCODE_SYSTEM_ABNORMALLY;
|
||||
}
|
||||
WindowManager_ErrorCode errCode = WindowManager_ErrorCode::WINDOW_MANAGER_ERRORCODE_SYSTEM_ABNORMALLY;
|
||||
eventHandler->PostSyncTask([windowId, isFocusable, &errCode, where = __func__] {
|
||||
auto window = Window::GetWindowWithId(windowId);
|
||||
if (window == nullptr) {
|
||||
TLOGNE(WmsLogTag::WMS_FOCUS, "%{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->SetFocusable(isFocusable));
|
||||
}, __func__);
|
||||
return errCode;
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user