From ab7e10408563acf3d78faa13e27a13e97859f5be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BD=95=E8=A1=8D=E8=BE=89?= Date: Sun, 23 Feb 2025 15:35:16 +0800 Subject: [PATCH] =?UTF-8?q?=E5=9B=9E=E9=80=80=E6=B3=A8=E5=85=A5js=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=E7=9A=84=E5=AE=9E=E7=8E=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 何衍辉 --- .../input_event_client/src/js_register_module.cpp | 11 +---------- .../napi/input_monitor/src/js_input_monitor.cpp | 3 +-- frameworks/napi/touch_event/include/js_touch_event.h | 5 ----- frameworks/napi/touch_event/src/js_touch_event.cpp | 9 --------- .../proxy/event_handler/src/input_manager_impl.cpp | 2 +- service/window_manager/src/input_windows_manager.cpp | 12 +++++++----- 6 files changed, 10 insertions(+), 32 deletions(-) diff --git a/frameworks/napi/input_event_client/src/js_register_module.cpp b/frameworks/napi/input_event_client/src/js_register_module.cpp index bea4de94a5..079dedae2c 100644 --- a/frameworks/napi/input_event_client/src/js_register_module.cpp +++ b/frameworks/napi/input_event_client/src/js_register_module.cpp @@ -529,18 +529,9 @@ static void HandleTouchPropertyInt32(napi_env env, napi_value touchHandle, CHKPV(touchProperty); HandleTouchAttribute(env, pointerEvent, item, touchProperty, true); - bool autoToVirtualScreen = true; - int32_t fixedMode = 2; - if (GetNamedPropertyInt32(env, touchHandle, "fixedMode", fixedMode, false) == RET_OK) { - if (fixedMode != static_cast(PointerEvent::FixedMode::ONE_HAND)) { - autoToVirtualScreen = false; - } - } - pointerEvent->AddPointerItem(item); pointerEvent->SetSourceType(sourceType); pointerEvent->SetTargetDisplayId(screenId); - pointerEvent->SetAutoToVirtualScreen(autoToVirtualScreen); std::vector pointerItems; HandleTouchesProperty(env, pointerEvent, touchHandle, pointerItems); @@ -591,7 +582,7 @@ static napi_value InjectTouchEvent(napi_env env, napi_callback_info info) int32_t action = HandleTouchAction(env, touchHandle, pointerEvent, item); HandleTouchPropertyInt32(env, touchHandle, pointerEvent, item, action); - InputManager::GetInstance()->SimulateInputEvent(pointerEvent, pointerEvent->GetAutoToVirtualScreen()); + InputManager::GetInstance()->SimulateInputEvent(pointerEvent); CHKRP(napi_create_int32(env, 0, &result), CREATE_INT32); return result; } diff --git a/frameworks/napi/input_monitor/src/js_input_monitor.cpp b/frameworks/napi/input_monitor/src/js_input_monitor.cpp index 2524436b3d..d9cb1b2075 100644 --- a/frameworks/napi/input_monitor/src/js_input_monitor.cpp +++ b/frameworks/napi/input_monitor/src/js_input_monitor.cpp @@ -688,8 +688,7 @@ int32_t JsInputMonitor::TransformPointerEvent(const std::shared_ptr(pointerEvent->GetFixedMode())), - "Set fixedMode", RET_ERR); + CHKRR(SetNameProperty(jsEnv_, result, "fixedMode", pointerEvent->GetFixedModeStr()), "Set fixedMode", RET_ERR); return RET_OK; } diff --git a/frameworks/napi/touch_event/include/js_touch_event.h b/frameworks/napi/touch_event/include/js_touch_event.h index dc68470660..59f76817a9 100644 --- a/frameworks/napi/touch_event/include/js_touch_event.h +++ b/frameworks/napi/touch_event/include/js_touch_event.h @@ -50,11 +50,6 @@ public: PEN = 1, TOUCH_PAD = 2, }; - - enum class FixedMode : int32_t { - NORMAL = 1, - ONE_HAND = 2, - }; JsTouchEvent() = default; ~JsTouchEvent() = default; DISALLOW_COPY_AND_MOVE(JsTouchEvent); diff --git a/frameworks/napi/touch_event/src/js_touch_event.cpp b/frameworks/napi/touch_event/src/js_touch_event.cpp index f33a165020..9f0710d215 100644 --- a/frameworks/napi/touch_event/src/js_touch_event.cpp +++ b/frameworks/napi/touch_event/src/js_touch_event.cpp @@ -84,15 +84,6 @@ napi_value JsTouchEvent::Export(napi_env env, napi_value exports) CHKRP(napi_define_class(env, "SourceType", NAPI_AUTO_LENGTH, EnumClassConstructor, nullptr, sizeof(sourceTypeArr) / sizeof(*sourceTypeArr), sourceTypeArr, &sourceType), DEFINE_CLASS); CHKRP(napi_set_named_property(env, exports, "SourceType", sourceType), SET_NAMED_PROPERTY); - - napi_property_descriptor fixedModeArr[] = { - DECLARE_NAPI_STATIC_PROPERTY("NORMAL", GetNapiInt32(env, static_cast(FixedMode::NORMAL))), - DECLARE_NAPI_STATIC_PROPERTY("ONE_HAND", GetNapiInt32(env, static_cast(FixedMode::ONE_HAND))), - }; - napi_value fixedMode = nullptr; - CHKRP(napi_define_class(env, "FixedMode", NAPI_AUTO_LENGTH, EnumClassConstructor, nullptr, - sizeof(fixedModeArr) / sizeof(*fixedModeArr), fixedModeArr, &fixedMode), DEFINE_CLASS); - CHKRP(napi_set_named_property(env, exports, "FixedMode", fixedMode), SET_NAMED_PROPERTY); return exports; } } // namespace MMI diff --git a/frameworks/proxy/event_handler/src/input_manager_impl.cpp b/frameworks/proxy/event_handler/src/input_manager_impl.cpp index 51f41a4921..8f24ee56b9 100644 --- a/frameworks/proxy/event_handler/src/input_manager_impl.cpp +++ b/frameworks/proxy/event_handler/src/input_manager_impl.cpp @@ -817,7 +817,7 @@ void InputManagerImpl::PrintDisplayInfo() for (const auto &item : displayGroupInfo_.displaysInfo) { MMI_HILOGD("displayInfos,id:%{public}d,x:%{public}d,y:%{public}d,width:%{public}d,height:%{public}d," "dpi:%{public}d,name:%{public}s,uniq:%{public}s,direction:%{public}d,displayDirection:%{public}d," - "displayMode:%{public}d,oneHandX:%{public}d,oneHandY:%{public}d", + "displayMode:%{public}d,oneHandX:%{private}d,oneHandY:%{private}d", item.id, item.x, item.y, item.width, item.height, item.dpi, item.name.c_str(), item.uniq.c_str(), item.direction, item.displayDirection, item.displayMode, item.oneHandX, item.oneHandY); diff --git a/service/window_manager/src/input_windows_manager.cpp b/service/window_manager/src/input_windows_manager.cpp index 23130d2bad..2c43c67a01 100644 --- a/service/window_manager/src/input_windows_manager.cpp +++ b/service/window_manager/src/input_windows_manager.cpp @@ -1759,8 +1759,10 @@ void InputWindowsManager::PrintDisplayInfo() MMI_HILOGD("displayInfos,num:%{public}zu", displayGroupInfo_.displaysInfo.size()); for (const auto &item : displayGroupInfo_.displaysInfo) { - MMI_HILOGD("displayInfos,id:%{public}d,x:%d,y:%d,width:%{public}d,height:%{public}d,name:%{public}s," - "uniq:%{public}s,direction:%{public}d,displayDirection:%{public}d,oneHandX:%{public}d,oneHandY:%{public}d", + MMI_HILOGD("displayInfos,id:%{public}d,x:%d,y:%d," + "width:%{public}d,height:%{public}d,name:%{public}s," + "uniq:%{public}s,direction:%{public}d,displayDirection:%{public}d," + "oneHandX:%{private}d,oneHandY:%{private}d", item.id, item.x, item.y, item.width, item.height, item.name.c_str(), item.uniq.c_str(), item.direction, item.displayDirection, item.oneHandX, item.oneHandY); } @@ -3292,7 +3294,7 @@ void InputWindowsManager::UpdatePointerItemInOneHandMode(const DisplayInfo &disp double physicalX = pointerItem.GetDisplayXPos(); double physicalY = pointerItem.GetDisplayYPos(); if (displayInfo.height == 0 || displayInfo.height == displayInfo.oneHandY) { - MMI_HILOG_DISPATCHE("displayInfo.height=%{public}d, displayInfo.oneHandY=%{public}d is invalid", + MMI_HILOG_DISPATCHE("displayInfo.height=%{public}d, displayInfo.oneHandY=%{private}d is invalid", displayInfo.height, displayInfo.oneHandY); pointerEvent->SetFixedMode(PointerEvent::FixedMode::SCREEN_MODE_UNKNOWN); pointerItem.SetFixedDisplayX(static_cast(physicalX)); @@ -3304,7 +3306,7 @@ void InputWindowsManager::UpdatePointerItemInOneHandMode(const DisplayInfo &disp bool isOneHandMode = displayInfo.oneHandY > 0; if (isOneHandMode) { pointerEvent->SetFixedMode(PointerEvent::FixedMode::ONE_HAND); - MMI_HILOG_DISPATCHD("displayInfo.oneHandY=%{public}d, fixedMode=%{public}d, fixedModeStr=%{public}s", + MMI_HILOG_DISPATCHD("displayInfo.oneHandY=%{private}d, fixedMode=%{public}d, fixedModeStr=%{public}s", displayInfo.oneHandY, static_cast(pointerEvent->GetFixedMode()), pointerEvent->GetFixedModeStr().c_str()); double fixedDisplayX = physicalX; @@ -3325,7 +3327,7 @@ void InputWindowsManager::UpdatePointerItemInOneHandMode(const DisplayInfo &disp pointerEvent->SetFixedMode(PointerEvent::FixedMode::NORMAL); pointerItem.SetFixedDisplayX(static_cast(physicalX)); pointerItem.SetFixedDisplayY(static_cast(physicalY)); - MMI_HILOG_DISPATCHD("displayInfo.oneHandY=%{public}d, fixedMode=%{public}d, fixedModeStr=%{public}s", + MMI_HILOG_DISPATCHD("displayInfo.oneHandY=%{private}d, fixedMode=%{public}d, fixedModeStr=%{public}s", displayInfo.oneHandY, static_cast(pointerEvent->GetFixedMode()), pointerEvent->GetFixedModeStr().c_str()); } -- Gitee