1 /* 2 * Copyright (c) 2022 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 #ifndef JS_POINTER_MANAGER_H 17 #define JS_POINTER_MANAGER_H 18 19 #include <memory> 20 21 #include "napi/native_api.h" 22 #include "napi/native_node_api.h" 23 #include "napi_constants.h" 24 #include "utils/log.h" 25 #include "refbase.h" 26 27 #include "stream_buffer.h" 28 #include "define_multimodal.h" 29 #include "error_multimodal.h" 30 #include "input_manager.h" 31 #include "util_napi.h" 32 #include "util_napi_error.h" 33 34 namespace OHOS { 35 namespace MMI { 36 class JsCommon { 37 public: 38 static bool TypeOf(napi_env env, napi_value value, napi_valuetype type); 39 }; 40 41 struct AsyncContext : RefBase { 42 napi_env env { nullptr }; 43 napi_async_work work { nullptr }; 44 napi_deferred deferred { nullptr }; 45 napi_ref callback { nullptr }; 46 int32_t errorCode { -1 }; 47 StreamBuffer reserve; AsyncContextAsyncContext48 AsyncContext(napi_env env) : env(env) {} 49 ~AsyncContext(); 50 }; 51 52 class JsPointerManager { 53 public: 54 JsPointerManager() = default; 55 ~JsPointerManager() = default; 56 DISALLOW_COPY_AND_MOVE(JsPointerManager); 57 58 void ResetEnv(); 59 napi_value SetPointerVisible(napi_env env, bool visible, napi_value handle = nullptr); 60 napi_value IsPointerVisible(napi_env env, napi_value handle = nullptr); 61 napi_value SetPointerSpeed(napi_env env, int32_t pointerSpeed, napi_value handle = nullptr); 62 napi_value GetPointerSpeed(napi_env env, napi_value handle = nullptr); 63 napi_value SetPointerStyle(napi_env env, int32_t windowid, int32_t pointerStyle, napi_value handle = nullptr); 64 napi_value GetPointerStyle(napi_env env, int32_t windowid, napi_value handle = nullptr); 65 }; 66 } // namespace MMI 67 } // namespace OHOS 68 69 #endif // JS_POINTER_MANAGER_H