From cd104a840ef1b9ac1f86a9b651a872e4b6041c56 Mon Sep 17 00:00:00 2001 From: zhouchengchao Date: Tue, 16 Apr 2024 22:52:07 +0800 Subject: [PATCH] window_manager keyevent interface Signed-off-by: zhouchengchao --- arkui/window_manager/BUILD.gn | 35 ++++++++ arkui/window_manager/libwm.ndk.json | 10 +++ arkui/window_manager/oh_window_comm.h | 65 +++++++++++++++ arkui/window_manager/oh_window_event_filter.h | 80 +++++++++++++++++++ 4 files changed, 190 insertions(+) create mode 100644 arkui/window_manager/BUILD.gn create mode 100644 arkui/window_manager/libwm.ndk.json create mode 100644 arkui/window_manager/oh_window_comm.h create mode 100644 arkui/window_manager/oh_window_event_filter.h diff --git a/arkui/window_manager/BUILD.gn b/arkui/window_manager/BUILD.gn new file mode 100644 index 000000000..fa532b650 --- /dev/null +++ b/arkui/window_manager/BUILD.gn @@ -0,0 +1,35 @@ +# Copyright (c) 2024 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//build/ohos.gni") +import("//build/ohos/ndk/ndk.gni") + +ohos_ndk_library("native_window_manager") { + ndk_description_file = "./libwm.ndk.json" + min_compact_version = "12" + output_name = "native_window_manager" + output_extension = "so" + system_capability = "SystemCapability.Window.SessionManager" + system_capability_headers = [ + "oh_window_comm.h", + "oh_window_event_filter.h", + ] +} + +ohos_ndk_headers("window_manager_header") { + dest_dir = "$ndk_headers_out_dir/window_manager" + sources = [ + "oh_window_comm.h", + "oh_window_event_filter.h", + ] +} diff --git a/arkui/window_manager/libwm.ndk.json b/arkui/window_manager/libwm.ndk.json new file mode 100644 index 000000000..3ed362ce4 --- /dev/null +++ b/arkui/window_manager/libwm.ndk.json @@ -0,0 +1,10 @@ +[ + { + "first_instroduced":"12", + "name":"OH_NativeWindowManager_RegisterKeyEventFilter" + }, + { + "first_instroduced":"12", + "name":"OH_NativeWindowManager_UnregisterKeyEventFilter" + } +] \ No newline at end of file diff --git a/arkui/window_manager/oh_window_comm.h b/arkui/window_manager/oh_window_comm.h new file mode 100644 index 000000000..935f13a4f --- /dev/null +++ b/arkui/window_manager/oh_window_comm.h @@ -0,0 +1,65 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +/** + * @addtogroup WindowManager_NativeModule + * @{ + * + * + * @brief Provides abilities of windowManager on the native side, such as key event + * filtration. + * + * @since 12 + */ + +/** + * @file oh_window_comm.h + * + * @brief Provides the comm type definitions of windowManager on the native side. + * + * @syscap SystemCapability.Window.SessionManager + * @library libnative_window_manager.so + * @since 12 + */ +#ifndef OH_WINDOW_COMM_H +#define OH_WINDOW_COMM_H + +#include "stdint.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Enumerates the result types of the wm interface + * + * @since 12 + */ +typedef enum { + /** succ. */ + OK = 0, + /** window id is invaild. */ + INVAILD_WINDOW_ID = 1000, + /** failed. */ + SERVICE_ERROR = 2000, +} WindowManager_ErrorCode; + +#ifdef __cplusplus +} +#endif + +#endif // OH_WINDOW_COMM_H +/** @} */ \ No newline at end of file diff --git a/arkui/window_manager/oh_window_event_filter.h b/arkui/window_manager/oh_window_event_filter.h new file mode 100644 index 000000000..3bfecbc36 --- /dev/null +++ b/arkui/window_manager/oh_window_event_filter.h @@ -0,0 +1,80 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#ifndef INCLUDE_OH_WINDOW_EVENT_FILTER_H +#define INCLUDE_OH_WINDOW_EVENT_FILTER_H + + +/** + * @addtogroup WindowManager_NativeModule + * @{ + * + * + * @brief Provides abilities of windowManager on the native side, such as key event + * filtration. + * + * @since 12 + */ + +/** + * @file oh_window_event_filter.h + * + * @brief Declares APIs for window event filter + * + * @syscap SystemCapability.Window.SessionManager + * @library libnative_window_manager.so + * @since 12 + */ +#include "stdint.h" +#include "oh_window_comm.h" +#include "multimodalinput/oh_input_manager.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief the callback funcation type when keyEvent was filter + * @param keyEvent multimodal keyEvent + * @since 12 + */ +typedef bool (*OH_NativeWindowManager_KeyEventFilter)(Input_KeyEvent* keyEvent); + +/** + * @brief Registers a filter callback for the window ,the callback is called when the + * window is dispatched to the event + * + * @param windowId windowId when window is created + * @param keyEventFilter key event callback ,called when the window is dispatched + * to the event + * @return Returns the status code of the execution. + * @since 12 + */ +WindowManager_ErrorCode OH_NativeWindowManager_RegisterKeyEventFilter(int32_t windowId, + OH_NativeWindowManager_KeyEventFilter keyEventFilter); + +/** + * @brief clear callback for the window + * + * @param windowId windowId when window is created + * @return Returns the status code of the execution. + * @since 12 + */ +WindowManager_ErrorCode OH_NativeWindowManager_UnregisterKeyEventFilter(int32_t windowId); + +#ifdef __cplusplus +} +#endif + +#endif // INCLUDE_OH_WINDOW_EVENT_FILTER_H \ No newline at end of file -- Gitee