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 0434d0341537499f7f0b04d0790520003973ebc1..eec405bc9823b7d4122dd4c60091677538fdd6e5 100644 --- a/frameworks/napi/input_event_client/src/js_register_module.cpp +++ b/frameworks/napi/input_event_client/src/js_register_module.cpp @@ -371,12 +371,22 @@ static void HandleMousePropertyInt32(napi_env env, napi_value mouseHandle, MMI_HILOGE("toolType:%{public}d is less 0, can not process", toolType); THROWERR_CUSTOM(env, COMMON_PARAMETER_ERROR, "toolType must be greater than or equal to 0"); } + int32_t globalX = INT_MAX; + if (GetNamedPropertyInt32(env, mouseHandle, "globalX", globalX) != RET_OK) { + MMI_HILOGI("No globaX"); + } + int32_t globalY = INT_MAX; + if (GetNamedPropertyInt32(env, mouseHandle, "globalY", globalY) != RET_OK) { + MMI_HILOGI("No globaY"); + } pointerEvent->SetSourceType(toolType); item.SetPointerId(0); item.SetDisplayX(screenX); item.SetDisplayY(screenY); - item.SetDisplayXPos(screenX); - item.SetDisplayYPos(screenY); + if (globalX != INT_MAX && globalY != INT_MAX) { + item.SetGlobalX(globalX); + item.SetGlobalY(globalY); + } pointerEvent->SetPointerId(0); pointerEvent->AddPointerItem(item); } @@ -504,6 +514,15 @@ static void HandleTouchAttribute(napi_env env, std::shared_ptr poi if (GetNamedPropertyDouble(env, touchObject, "pressure", pressure) != RET_OK) { MMI_HILOGE("Get pressure failed"); } + int32_t globalX = INT_MAX; + if (GetNamedPropertyInt32(env, touchObject, "globalX", globalX) != RET_OK) { + MMI_HILOGI("No globaX"); + } + int32_t globalY = INT_MAX; + if (GetNamedPropertyInt32(env, touchObject, "globalY", globalY) != RET_OK) { + MMI_HILOGI("No globaY"); + } + pointerItem.SetDisplayX(screenX); pointerItem.SetDisplayY(screenY); pointerItem.SetDisplayXPos(screenX); @@ -511,6 +530,10 @@ static void HandleTouchAttribute(napi_env env, std::shared_ptr poi pointerItem.SetPointerId(pointerId); pointerItem.SetToolType(toolType); pointerItem.SetPressure(pressure); + if (globalX != INT_MAX && globalY != INT_MAX) { + pointerItem.SetGlobalX(globalX); + pointerItem.SetGlobalY(globalY); + } if (isTouch) { pointerEvent->SetPointerId(pointerId); pointerEvent->SetActionTime(pressedTime); diff --git a/frameworks/native/input/oh_input_manager.cpp b/frameworks/native/input/oh_input_manager.cpp index d25dba17a7c3de638410cff802ae129d9802d659..9ba3eed602ab2d83d8eee72198dfd278d3bd9fff 100644 --- a/frameworks/native/input/oh_input_manager.cpp +++ b/frameworks/native/input/oh_input_manager.cpp @@ -49,8 +49,8 @@ struct Input_MouseEvent { int32_t action; int32_t displayX; int32_t displayY; - int32_t globalX; - int32_t globalY; + int32_t globalX { INT_MAX }; + int32_t globalY { INT_MAX }; int32_t button { -1 }; int32_t axisType { -1 }; float axisValue { 0.0f }; @@ -64,8 +64,8 @@ struct Input_TouchEvent { int32_t id; int32_t displayX; int32_t displayY; - int32_t globalX; - int32_t globalY; + int32_t globalX { INT_MAX }; + int32_t globalY { INT_MAX };; int64_t actionTime { -1 }; int32_t windowId { -1 }; int32_t displayId { -1 }; @@ -506,8 +506,12 @@ static int32_t HandleMouseProperty(const struct Input_MouseEvent* mouseEvent, item.SetPointerId(0); item.SetDisplayX(screenX); item.SetDisplayY(screenY); - item.SetDisplayXPos(screenX); - item.SetDisplayYPos(screenY); + int32_t globalX = mouseEvent->globalX; + int32_t globalY = mouseEvent->globalY; + if (globalX != INT_MAX && globalY != INT_MAX) { + item.SetGlobalX(globalX); + item.SetGlobalX(globalY); + } g_mouseEvent->SetPointerId(0); g_mouseEvent->UpdatePointerItem(g_mouseEvent->GetPointerId(), item); return INPUT_SUCCESS; @@ -793,8 +797,12 @@ static int32_t HandleTouchProperty(const struct Input_TouchEvent* touchEvent, } item.SetDisplayX(screenX); item.SetDisplayY(screenY); - item.SetDisplayXPos(screenX); - item.SetDisplayYPos(screenY); + int32_t globalX = touchEvent->globalX; + int32_t globalY = touchEvent->globalY; + if (globalX != INT_MAX && globalY != INT_MAX) { + item.SetGlobalX(globalX); + item.SetGlobalX(globalY); + } item.SetPointerId(id); g_touchEvent->SetPointerId(id); g_touchEvent->SetSourceType(OHOS::MMI::PointerEvent::SOURCE_TYPE_TOUCHSCREEN); diff --git a/frameworks/proxy/event_handler/include/input_manager_impl.h b/frameworks/proxy/event_handler/include/input_manager_impl.h index 042cd74a66b9399bbd776bbb1853b110fdda94ec..620f078a49c5102b1610b9aeee0194dadd851ba7 100644 --- a/frameworks/proxy/event_handler/include/input_manager_impl.h +++ b/frameworks/proxy/event_handler/include/input_manager_impl.h @@ -52,8 +52,7 @@ public: int32_t GetAllMmiSubscribedEvents(std::map, int32_t> &datas); int32_t SetDisplayBind(int32_t deviceId, int32_t displayId, std::string &msg); int32_t GetWindowPid(int32_t windowId); - int32_t UpdateDisplayInfo(const DisplayGroupInfo &displayGroupInfo); - int32_t UpdateDisplayInfo(const std::vector &displayGroupInfo); + int32_t UpdateDisplayInfo(const UserScreenInfo &userScreenInfo); int32_t UpdateWindowInfo(const WindowGroupInfo &windowGroupInfo); #ifdef OHOS_BUILD_ENABLE_SECURITY_COMPONENT void SetEnhanceConfig(uint8_t *cfg, uint32_t cfgLen); @@ -102,7 +101,7 @@ public: #if defined(OHOS_BUILD_ENABLE_POINTER) || defined(OHOS_BUILD_ENABLE_TOUCH) void OnPointerEvent(std::shared_ptr pointerEvent); #endif // OHOS_BUILD_ENABLE_POINTER || OHOS_BUILD_ENABLE_TOUCH - int32_t PackDisplayData(NetPacket &pkt, const DisplayGroupInfo &displayGroupInfo); + int32_t PackDisplayData(NetPacket &pkt, const UserScreenInfo &userScreenInfo); int32_t AddMonitor(std::function)> monitor); int32_t AddMonitor(std::function)> monitor); @@ -258,15 +257,21 @@ public: int32_t QueryPointerRecord(int32_t count, std::vector> &pointerList); private: - int32_t PackWindowInfo(NetPacket &pkt, const DisplayGroupInfo &displayGroupInfo); + int32_t PackScreensInfo(NetPacket &pkt, const std::vector& screens); + int32_t PackDisplayGroupsInfo(NetPacket &pkt, const std::vector& displayGroups); + int32_t PackDisplaysInfo(NetPacket &pkt, const std::vector& displaysInfo); + int32_t PackWindowInfo(NetPacket &pkt, const std::vector &windowsInfo); int32_t PackWindowGroupInfo(NetPacket &pkt); - int32_t PackDisplayInfo(NetPacket &pkt, DisplayGroupInfo &displayGroupInfo); + int32_t PackUiExtentionWindowInfo(const std::vector& windowsInfo, NetPacket &pkt); void PrintWindowInfo(const std::vector &windowsInfo); void PrintForemostThreeWindowInfo(const std::vector &windowsInfo); - void PrintDisplayInfo(const DisplayGroupInfo &displayGroupInfo); void PrintWindowGroupInfo(); - int32_t SendDisplayInfo(const DisplayGroupInfo &displayGroupInfo); + void PrintDisplayInfo(const UserScreenInfo &userScreenInfo); + void PrintScreens(const std::vector& screens); + void PrintDisplayGroups(const std::vector& displayGroups); + void PrintDisplaysInfo(const std::vector& displaysInfo); + int32_t SendDisplayInfo(const UserScreenInfo &userScreenInfo); int32_t SendWindowInfo(); void SendWindowAreaInfo(WindowArea area, int32_t pid, int32_t windowId); bool IsValiadWindowAreas(const std::vector &windows); @@ -311,7 +316,7 @@ private: std::shared_ptr lastPointerEvent_ { nullptr }; std::function windowStatecallback_; bool knuckleSwitch_ { true }; - std::vector displayGroupInfoArray_; + UserScreenInfo userScreenInfo_; #ifdef OHOS_BUILD_ENABLE_SECURITY_COMPONENT uint8_t* enhanceCfg_ = nullptr; uint32_t enhanceCfgLen_ = 0; diff --git a/frameworks/proxy/event_handler/src/input_manager_impl.cpp b/frameworks/proxy/event_handler/src/input_manager_impl.cpp index 5b29521b4df2fa8ead3d45fa30506fbdacee2240..67d29f94f4aa48da7c8861966fce173f32f2c01d 100644 --- a/frameworks/proxy/event_handler/src/input_manager_impl.cpp +++ b/frameworks/proxy/event_handler/src/input_manager_impl.cpp @@ -134,7 +134,7 @@ int32_t InputManagerImpl::GetWindowPid(int32_t windowId) return MULTIMODAL_INPUT_CONNECT_MGR->GetWindowPid(windowId); } -int32_t InputManagerImpl::UpdateDisplayInfo(const DisplayGroupInfo &displayGroupInfo) +int32_t InputManagerImpl::UpdateDisplayInfo(const UserScreenInfo &userScreenInfo) { CALL_DEBUG_ENTER; if (!MMIEventHdl.InitClient()) { @@ -143,48 +143,21 @@ int32_t InputManagerImpl::UpdateDisplayInfo(const DisplayGroupInfo &displayGroup } { std::lock_guard guard(mtx_); - if (displayGroupInfo.windowsInfo.size() < MAX_WINDOW_SIZE) { - windowGroupInfo_.windowsInfo.clear(); - } - displayGroupInfoArray_.clear(); - displayGroupInfoArray_.emplace_back(displayGroupInfo); - } - int32_t ret = SendDisplayInfo(displayGroupInfo); - if (ret != RET_OK) { - MMI_HILOGE("Failed to send display information to service"); - return ret; - } - PrintDisplayInfo(displayGroupInfo); - return RET_OK; -} - -int32_t InputManagerImpl::UpdateDisplayInfo(const std::vector &displayGroupInfos) -{ - CALL_DEBUG_ENTER; - if (!MMIEventHdl.InitClient()) { - MMI_HILOGE("Failed to initialize MMI client"); - return RET_ERR; - } - { - std::lock_guard guard(mtx_); - displayGroupInfoArray_.clear(); + userScreenInfo_ = userScreenInfo; auto cnt = 0; - for (auto &it : displayGroupInfos) { - displayGroupInfoArray_.emplace_back(it); + for (auto &it : userScreenInfo.displayGroups) { cnt += it.windowsInfo.size(); } if (cnt < static_cast(MAX_WINDOW_SIZE)) { windowGroupInfo_.windowsInfo.clear(); } } - for (const auto &item : displayGroupInfos) { - int32_t ret = SendDisplayInfo(item); - if (ret != RET_OK) { - MMI_HILOGE("Failed to send display information to service"); - return ret; - } - PrintDisplayInfo(item); + int32_t ret = SendDisplayInfo(userScreenInfo); + if (ret != RET_OK) { + MMI_HILOGE("Failed to send user screen info, ret:%{public}d", ret); + return ret; } + PrintDisplayInfo(userScreenInfo); return RET_OK; } @@ -667,20 +640,23 @@ void InputManagerImpl::OnPointerEvent(std::shared_ptr pointerEvent } #endif // OHOS_BUILD_ENABLE_POINTER || OHOS_BUILD_ENABLE_TOUCH -int32_t InputManagerImpl::PackDisplayData(NetPacket &pkt, const DisplayGroupInfo &displayGroupInfo) +int32_t InputManagerImpl::PackDisplayData(NetPacket &pkt, const UserScreenInfo &userScreenInfo) { CALL_DEBUG_ENTER; - pkt << displayGroupInfo.groupId << displayGroupInfo.isMainGroup << displayGroupInfo.width << displayGroupInfo.height - << displayGroupInfo.focusWindowId << displayGroupInfo.currentUserId; - if (pkt.ChkRWError()) { - MMI_HILOGE("Packet write logical data failed"); + pkt << userScreenInfo.userId; + if (PackScreensInfo(pkt, userScreenInfo.screens) != RET_OK) { + MMI_HILOGE("Packet write screens info failed"); return RET_ERR; } - if (PackWindowInfo(pkt, displayGroupInfo) != RET_OK) { - MMI_HILOGE("Packet write windows info failed"); + if (PackDisplayGroupsInfo(pkt, userScreenInfo.displayGroups) != RET_OK) { + MMI_HILOGE("Packet write display group failed"); return RET_ERR; } - return PackDisplayInfo(pkt, const_cast(displayGroupInfo)); + if (pkt.ChkRWError()) { + MMI_HILOGE("Packet write logical data failed"); + return RET_ERR; + } + return RET_OK; } int32_t InputManagerImpl::PackWindowGroupInfo(NetPacket &pkt) @@ -752,13 +728,70 @@ int32_t InputManagerImpl::PackUiExtentionWindowInfo(const std::vector& screens) __attribute__((no_sanitize("cfi"))) +{ + CALL_DEBUG_ENTER; + uint32_t num = static_cast(screens.size()); + pkt << num; + for (const auto &item : screens) { + pkt << item.id << item.uniqueId << item.screenType << item.width << item.height << item.physicalWidth + << item.physicalHeight << item.tpDirection << item.dpi << item.ppi << item.rotation; + } + if (pkt.ChkRWError()) { + MMI_HILOGE("Packet write screens data failed"); + return RET_ERR; + } + return RET_OK; +} + + +int32_t InputManagerImpl::PackDisplayGroupsInfo(NetPacket &pkt, + const std::vector& displayGroups) __attribute__((no_sanitize("cfi"))) +{ + CALL_DEBUG_ENTER; + uint32_t num = static_cast(displayGroups.size()); + pkt << num; + for (const auto &item : displayGroups) { + pkt << item.id << item.name << item.type << item.mainDisplayId << item.focusWindowId; + PackDisplaysInfo(pkt, item.displaysInfo); + PackWindowInfo(pkt, item.windowsInfo); + } + if (pkt.ChkRWError()) { + MMI_HILOGE("Packet write display groups data failed"); + return RET_ERR; + } + return RET_OK; +} + +int32_t InputManagerImpl::PackDisplaysInfo(NetPacket &pkt, + const std::vector& displaysInfo) __attribute__((no_sanitize("cfi"))) +{ + CALL_DEBUG_ENTER; + uint32_t num = static_cast(displaysInfo.size()); + pkt << num; + for (const auto &item : displaysInfo) { + pkt << item.id << item.x << item.y << item.width << item.height + << item.dpi << item.name << item.direction << item.displayDirection + << item.displayMode << item.transform << item.scalePercent << item.expandHeight + << item.isCurrentOffScreenRendering << item.displaySourceMode << item.oneHandX + << item.oneHandY << item.screenArea << item.rsId << item.offsetX << item.offsetY + << item.pointerActiveWidth << item.pointerActiveHeight; + } + if (pkt.ChkRWError()) { + MMI_HILOGE("Packet write displays data failed"); + return RET_ERR; + } + return RET_OK; +} + int32_t InputManagerImpl::PackWindowInfo(NetPacket &pkt, - const DisplayGroupInfo &displayGroupInfo) __attribute__((no_sanitize("cfi"))) + const std::vector &windowsInfo) __attribute__((no_sanitize("cfi"))) { CALL_DEBUG_ENTER; - uint32_t num = static_cast(displayGroupInfo.windowsInfo.size()); + uint32_t num = static_cast(windowsInfo.size()); pkt << num; - for (const auto &item : displayGroupInfo.windowsInfo) { + for (const auto &item : windowsInfo) { int32_t byteCount = 0; pkt << item.id << item.pid << item.uid << item.area << item.defaultHotAreas << item.pointerHotAreas << item.agentWindowId << item.flags << item.action @@ -842,47 +875,6 @@ bool InputManagerImpl::IsGRLOrHopper() return false; } -int32_t InputManagerImpl::PackDisplayInfo(NetPacket &pkt, DisplayGroupInfo &displayGroupInfo) -{ - CALL_DEBUG_ENTER; - uint32_t num = static_cast(displayGroupInfo.displaysInfo.size()); - pkt << num; - int32_t hprId = 999; - for (auto &item : displayGroupInfo.displaysInfo) { - if (!IsGRLOrHopper() || !(item.id == 0 || item.id == hprId) || item.validWidth == 0 || item.validHeight == 0) { - int32_t validW = item.validWidth; - int32_t validH = item.validHeight; - item.validWidth = item.width; - item.validHeight = item.height; - MMI_HILOGD("id:%{private}d not grl or hopper, " - "change validWH:{%{private}d %{private}d}->{%{private}d %{private}d}", - item.id, - validW, - validH, - item.validWidth, - item.validHeight); - } - pkt << item.id << item.x << item.y << item.width - << item.height << item.dpi << item.name << item.uniq << item.direction - << item.displayDirection << item.displayMode << item.transform << item.ppi << item.offsetX - << item.offsetY << item.isCurrentOffScreenRendering << item.screenRealWidth - << item.screenRealHeight << item.screenRealPPI << item.screenRealDPI << item.screenCombination - << item.validWidth << item.validHeight << item.fixedDirection - << item.physicalWidth << item.physicalHeight << item.scalePercent << item.expandHeight << item.uniqueId; -#ifdef OHOS_BUILD_ENABLE_ONE_HAND_MODE - pkt << item.oneHandX << item.oneHandY; -#endif -#ifdef OHOS_BUILD_ENABLE_VKEYBOARD - pkt << item.pointerActiveWidth << item.pointerActiveHeight; -#endif // OHOS_BUILD_ENABLE_VKEYBOARD - } - if (pkt.ChkRWError()) { - MMI_HILOGE("Packet write display data failed"); - return RET_ERR; - } - return RET_OK; -} - void InputManagerImpl::PrintWindowInfo(const std::vector &windowsInfo) { if (!HiLogIsLoggable(MMI_LOG_DOMAIN, MMI_LOG_TAG, LOG_DEBUG)) { @@ -924,65 +916,60 @@ void InputManagerImpl::PrintWindowInfo(const std::vector &windowsInf } } -void InputManagerImpl::PrintForemostThreeWindowInfo(const std::vector &windowsInfo) +void InputManagerImpl::PrintDisplayInfo(const UserScreenInfo &userScreenInfo) { - uint8_t times = 0; - for (const auto &item : windowsInfo) { - if (times > LOOP_COND) { - return; - } - MMI_HILOGD("WindowInfo[%{public}d,%{public}d,%{public}d,%{public}d,%{public}d,%{public}d,%{public}f]", - item.id, item.pid, item.area.x, item.area.y, item.area.width, item.area.height, item.zOrder); - for (const auto &pointer : item.pointerHotAreas) { - MMI_HILOGD("pointerHotAreas:x:%{public}d,y:%{public}d,width:%{public}d,height:%{public}d", - pointer.x, pointer.y, pointer.width, pointer.height); - } - times++; + if (!HiLogIsLoggable(MMI_LOG_DOMAIN, MMI_LOG_TAG, LOG_DEBUG)) { + return; } + MMI_HILOGD("userId:%{public}d", userScreenInfo.userId); + PrintScreens(userScreenInfo.screens); + PrintDisplayGroups(userScreenInfo.displayGroups); } -void InputManagerImpl::PrintDisplayInfo(const DisplayGroupInfo &displayGroupInfo) +void InputManagerImpl::PrintScreens(const std::vector& screens) { - MMI_HILOGD("displayGroupId:%{public}d,windowsInfos,num:%{public}zu,focusWindowId:%{public}d", - displayGroupInfo.groupId, displayGroupInfo.windowsInfo.size(), - displayGroupInfo.focusWindowId); - PrintForemostThreeWindowInfo(displayGroupInfo.windowsInfo); - if (!HiLogIsLoggable(MMI_LOG_DOMAIN, MMI_LOG_TAG, LOG_DEBUG)) { - return; + MMI_HILOGD("screens size:%{public}zu", screens.size()); + int32_t i = 0; + for (const auto &item : screens) { + MMI_HILOGD("screen %{public}d: id:%{public}d, uniqueId:%{public}s, screenType:%{public}d,width:%{public}d," + "height:%{public}d, physicalWidth:%{public}d, physicalHeight:%{public}d,tpDirection:%{public}d" + "dpi:%{public}d, ppi:%{public}d", + i, item.id, item.uniqueId.c_str(), item.screenType, item.width, item.height, item.physicalWidth, + item.physicalHeight, item.tpDirection, item.dpi, item.ppi); + i++; } - MMI_HILOGD("logicalInfo,width:%{public}d,height:%{public}d,focusWindowId:%{public}d", - displayGroupInfo.width, displayGroupInfo.height, displayGroupInfo.focusWindowId); - PrintWindowInfo(displayGroupInfo.windowsInfo); +} - MMI_HILOGD("displayInfos,num:%{public}zu", displayGroupInfo.displaysInfo.size()); - for (const auto &item : displayGroupInfo.displaysInfo) { - MMI_HILOGD("displayInfos,id:%{public}d,x:%{private}d,y:%{private}d,width:%{public}d,height:%{public}d," - "dpi:%{public}d,name:%{public}s,uniq:%{public}s,direction:%{public}d,displayDirection:%{public}d," +void InputManagerImpl::PrintDisplayGroups(const std::vector& displayGroups) +{ + MMI_HILOGD("displayGroups size:%{public}zu", displayGroups.size()); + int32_t i = 0; + for (const auto &item : displayGroups) { + MMI_HILOGD("displayGroups %{public}d: id:%{public}d, name:%{public}s, type:%{public}d," + "mainDisplayId:%{public}d, focusWindowId:%{public}d", + i, item.id, item.name.c_str(), item.type, item.mainDisplayId, item.focusWindowId); + PrintDisplaysInfo(item.displaysInfo); + PrintWindowInfo(item.windowsInfo); + } +} + +void InputManagerImpl::PrintDisplaysInfo(const std::vector& displaysInfo) +{ + MMI_HILOGD("displaysInfo size:%{public}zu", displaysInfo.size()); + int32_t i = 0; + for (const auto &item : displaysInfo) { + MMI_HILOGD("displayInfos %{public}d,id:%{public}d,x:%{private}d,y:%{private}d,width:%{public}d," + "height:%{public}d,dpi:%{public}d,name:%{public}s,direction:%{public}d,displayDirection:%{public}d," "displayMode:%{public}d,oneHandX:%{private}d,oneHandY:%{private}d,scalePercent:%{public}d," - "expandHeight:%{public}d,validWH:{%{private}d %{private}d},fixedDirection:%{public}d," - "physicalWH:{%{private}d %{private}d},pActiveWH:{%{private}d %{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, - item.scalePercent, - item.expandHeight, - item.validWidth, - item.validHeight, - item.fixedDirection, - item.physicalWidth, - item.physicalHeight, - item.pointerActiveWidth, - item.pointerActiveHeight); + "expandHeight:%{public}d,isCurrentOffScreenRendering:%{public}d,displaySourceMode:%{public}d" + "screenArea{id:%{public}d, x:%{private}d, y:%{private}d, width:%{private}d, height:%{private}d}," + "rsId:%{public}d", + i, item.id, item.x, item.y, item.width, item.height, item.dpi, item.name.c_str(), item.direction, + item.displayDirection, item.displayMode, item.oneHandX, item.oneHandY, item.scalePercent, + item.expandHeight, item.isCurrentOffScreenRendering, item.displaySourceMode, item.screenArea.id, + item.screenArea.area.x, item.screenArea.area.y, item.screenArea.area.width, + item.screenArea.area.height, item.rsId); + i++; } } @@ -1630,14 +1617,8 @@ void InputManagerImpl::OnConnected() ReAddInputEventFilter(); { std::lock_guard guard(mtx_); - for (auto &iter : displayGroupInfoArray_) { - if (!iter.windowsInfo.empty() && !iter.displaysInfo.empty()) { - MMI_HILOGD("displayGroupInfo: windowsInfo size:%{public}zu, displaysInfo size:%{public}zu", - iter.windowsInfo.size(), iter.displaysInfo.size()); - SendDisplayInfo(iter); - PrintDisplayInfo(iter); - } - } + SendDisplayInfo(userScreenInfo_); + PrintDisplayInfo(userScreenInfo_); if (!windowGroupInfo_.windowsInfo.empty()) { MMI_HILOGD("windowGroupInfo_: windowsInfo size:%{public}zu", windowGroupInfo_.windowsInfo.size()); SendWindowInfo(); @@ -1737,13 +1718,13 @@ void InputManagerImpl::OnDisconnected() #endif // OHOS_BUILD_ENABLE_POINTER || OHOS_BUILD_ENABLE_TOUCH } -int32_t InputManagerImpl::SendDisplayInfo(const DisplayGroupInfo &displayGroupInfo) +int32_t InputManagerImpl::SendDisplayInfo(const UserScreenInfo &userScreenInfo) { CALL_DEBUG_ENTER; MMIClientPtr client = MMIEventHdl.GetMMIClient(); CHKPR(client, RET_ERR); NetPacket pkt(MmiMessageId::DISPLAY_INFO); - int32_t ret = PackDisplayData(pkt, displayGroupInfo); + int32_t ret = PackDisplayData(pkt, userScreenInfo); if (ret != RET_OK) { MMI_HILOGE("Pack display info failed"); return ret; diff --git a/frameworks/proxy/events/src/input_manager.cpp b/frameworks/proxy/events/src/input_manager.cpp index e59c19fae094b01d69c3e10dd07cf98a24f88c15..c96d43748515d9496dc60616a92337ff11b02bd3 100644 --- a/frameworks/proxy/events/src/input_manager.cpp +++ b/frameworks/proxy/events/src/input_manager.cpp @@ -65,14 +65,9 @@ int32_t InputManager::GetWindowPid(int32_t windowId) return InputMgrImpl.GetWindowPid(windowId); } -int32_t InputManager::UpdateDisplayInfo(const DisplayGroupInfo &displayGroupInfo) +int32_t InputManager::UpdateDisplayInfo(const UserScreenInfo &userScreenInfo) { - return InputMgrImpl.UpdateDisplayInfo(displayGroupInfo); -} - -int32_t InputManager::UpdateDisplayInfo(const std::vector &displayGroupInfo) -{ - return InputMgrImpl.UpdateDisplayInfo(displayGroupInfo); + return InputMgrImpl.UpdateDisplayInfo(userScreenInfo); } int32_t InputManager::UpdateWindowInfo(const WindowGroupInfo &windowGroupInfo) diff --git a/interfaces/native/innerkits/event/include/pointer_event.h b/interfaces/native/innerkits/event/include/pointer_event.h index 48ad68c9e7a016d01e9a417f2e6e15583c54749e..f37615bba6380834eb081d281ea6ae0dd3991af1 100644 --- a/interfaces/native/innerkits/event/include/pointer_event.h +++ b/interfaces/native/innerkits/event/include/pointer_event.h @@ -17,6 +17,7 @@ #define POINTER_EVENT_H #include +#include #include #include #include @@ -1318,8 +1319,8 @@ public: bool pressed_ { false }; int32_t displayX_ {}; int32_t displayY_ {}; - double globalX_ { 0.0f }; - double globalY_ { 0.0f }; + double globalX_ { DBL_MAX }; + double globalY_ { DBL_MAX }; int32_t fixedDisplayX_ {}; int32_t fixedDisplayY_ {}; int32_t windowX_ {}; diff --git a/interfaces/native/innerkits/proxy/include/input_manager.h b/interfaces/native/innerkits/proxy/include/input_manager.h index 09a88b5e3b936ad764145bbd1760abf7ffc3c01a..b0153bde9419d847af352f8f3533ea3fdee74e5b 100644 --- a/interfaces/native/innerkits/proxy/include/input_manager.h +++ b/interfaces/native/innerkits/proxy/include/input_manager.h @@ -51,19 +51,12 @@ public: int32_t GetDisplayBindInfo(DisplayBindInfos &infos); int32_t SetDisplayBind(int32_t deviceId, int32_t displayId, std::string &msg); - /** - * @brief Updates the screen and window information. - * @param displayGroupInfo Indicates the logical screen information. - * @since 9 - */ - int32_t UpdateDisplayInfo(const DisplayGroupInfo &displayGroupInfo); - - /** - * @brief Updates the screen and window information array. - * @param displayGroupInfo Indicates the logical screen information array. - * @since 9 - */ - int32_t UpdateDisplayInfo(const std::vector &displayGroupInfo); + /** + * @brief Updates the screen、display and window information array. + * @param userScreenInfo Indicates the user screen、display and window information. + * @since 20 + */ + int32_t UpdateDisplayInfo(const UserScreenInfo &userScreenInfo); /** * @brief Updates the windows information. diff --git a/interfaces/native/innerkits/proxy/include/window_info.h b/interfaces/native/innerkits/proxy/include/window_info.h index f47de066ac198791905cf0edfd0ed186f04729ea..c738cb4f79fe4206b959f0c4616070d4c1174fbe 100644 --- a/interfaces/native/innerkits/proxy/include/window_info.h +++ b/interfaces/native/innerkits/proxy/include/window_info.h @@ -354,81 +354,119 @@ struct WindowInfo { * * @since 9 */ -enum class ScreenCombination : uint32_t { +enum class DisplaySourceMode : uint32_t { SCREEN_ALONE, SCREEN_EXPAND, + /** + * mirror screen + * + * @since 20 + */ SCREEN_MIRROR, + /** + * different source screen + * + * @since 20 + */ SCREEN_UNIQUE, + /** + * extend screen + * + * @since 20 + */ SCREEN_EXTEND, + /** + * main screen + * + * @since 20 + */ SCREEN_MAIN }; -struct DisplayInfo { +/** +* The area of ​​the logical screen on the physical screen +* Based on screen 0°, not affected by display rotation angle +* @since 20 +*/ +struct ScreenArea { /** - * Unique ID of the physical display + * The unique ID of the physical screen. * - * @since 9 + * @since 20 */ int32_t id; + /** + * The area of ​​the logical screen on the physical screen + * The upper left corner of the screen is the origin + * Based on screen 0°, not affected by display rotation angle + * @since 20 + */ + Rect area; +}; +struct DisplayInfo { /** - * X coordinate of the upper left corner on the logical screen + * Unique ID of the logical display, this value is greater than or equal to 0 and is unique in user space. * - * @since 9 + * @since 9 20 + */ + int32_t id; + + /** + * The x offset of the upper left corner of the current rotation angle of the screen relative to the upper + * left corner of the main screen, in px, changes with the rotation + * @since 9 20 */ int32_t x; /** - * Y coordinate of the upper left corner on the logical screen + * The y offset of the upper left corner of the current rotation angle of the screen relative to the upper + * left corner of the main screen, changes with the rotation. in px. * - * @since 9 + * @since 9 20 */ int32_t y; /** * Display width, which is the logical width of the original screen when the rotation angle is 0. - * The value remains unchanged even if the display screen is rotated. + * The value remains unchanged even if the display screen is rotated. in px. * - * @since 9 + * @since 9 20 */ int32_t width; /** * Display height, which is the logical height of the original screen when the rotation angle is 0. - * The value remains unchanged even if the display screen is rotated. + * The value remains unchanged even if the display screen is rotated. in px. * * @since 9 */ int32_t height; /** - * Pixel density, which indicates the number of pixels in an inch + * Pixel density, which indicates the number of pixels in an inch,changes with resolution adjustment * * @since 10 */ int32_t dpi; /** - * Name of the physical display, which is used for debugging + * Name of the logical display, which is used for debugging * * @since 9 */ std::string name; - /** - * Unique screen ID, which is used to associate the corresponding touchscreen. The default value is default0. + * The angle increment from the logical screen orientation of 0° clockwise to the current screen orientation. * - * @since 9 + * @since 9 20 */ - std::string uniq; - + Direction direction; /** - * Orientation of the physical display - * - * @since 9 + * The angle increment from the current rotation angle of the logical screen to the rotation angle of + * its window content display clockwise. + * @since 20 */ - Direction direction; - Direction displayDirection; /** @@ -446,14 +484,6 @@ struct DisplayInfo { */ std::vector transform; - /** - * Orientation of the physical display - * - * @since 12 - */ - int32_t offsetX = 0; - int32_t offsetY = 0; - float ppi; /** * Coordinate of the upper left corner of the virtual screen in one-hand mode. * If oneHandX is 0, the virtual screen is in the lower left corner. @@ -477,47 +507,37 @@ struct DisplayInfo { * @since 12 */ bool isCurrentOffScreenRendering = false; - int32_t screenRealWidth = 0; - int32_t screenRealHeight = 0; - float screenRealPPI = 0.0f; - int32_t screenRealDPI = 0; - ScreenCombination screenCombination = ScreenCombination::SCREEN_MAIN; /** - * Width of the effective area of the screen. When the screen is rotated, the value changes accordingly. + * logical screen mode * - * @since 12 + * @since 12 20 */ - int32_t validWidth = 0; - + DisplaySourceMode displaySourceMode = DisplaySourceMode::SCREEN_MAIN; /** - * Height of the effective area of the screen. When the screen is rotated, the value changes accordingly. - * - * @since 12 - */ - int32_t validHeight = 0; - + * The area of ​​the logical screen on the physical screen + * Based on screen 0°, not affected by display rotation angle + * @since 20 + */ + ScreenArea screenArea; /** - * Rotation angle of the TP patch offset correction. + * rs id. * - * @since 12 + * @since 20 */ - Direction fixedDirection; - + int32_t rsId; /** - * The physical width of the screen, in millimeters. + * The x coordinate of the valid area relative to the entire logical screen * * @since 12 */ - int32_t physicalWidth { 0 }; - + int32_t offsetX = 0; /** - * The physical height of the screen, in millimeters. + * The y coordinate of the valid area relative to the entire logical screen * * @since 12 */ - int32_t physicalHeight { 0 }; - + int32_t offsetY = 0; /** * The Pointer Active Width * @@ -531,57 +551,169 @@ struct DisplayInfo { * @since 12 */ int32_t pointerActiveHeight { 0 }; - - /** Unique ID of the physical display +}; +/** +* Screen type. +* +* @since 20 +*/ +enum class ScreenType : uint32_t { + UNDEFINED, + /** + * real screen. * - * @since 12 + * @since 20 + */ + REAL, + /** + * virtual screen. + * + * @since 20 */ - int32_t uniqueId { 0 }; + VIRTUAL }; - /** - * Logical screen information +* The angle of the physical screen relative to the sensor 0 degrees. +* +* @since 20 +*/ +enum class Rotation : uint32_t { + ROTATION_0, + ROTATION_90, + ROTATION_180, + ROTATION_270, +}; +/** + * physical screen information * - * @since 9 + * @since 20 */ -struct DisplayGroupInfo { + struct ScreenInfo { /** - * index of group. default=-1 + * The unique ID of the physical screen. * - * @since 16 + * @since 20 */ - int32_t groupId { DEFAULT_GROUP_ID }; - + int32_t id; /** - * main group flag. default=true + * Unique screen ID, which is used to associate the corresponding touchscreen. + * The default value is default0. * - * @since 16 + * @since 20 */ - bool isMainGroup { false }; - + std::string uniqueId; /** - * Width of the logical display + * Screen type. * - * @since 9 + * @since 20 + */ + ScreenType screenType { ScreenType::REAL }; + /** + * The width of the physical screen, in px. Does not follow rotation. Does not change for + * the same physical screen. + * + * @since 20 */ int32_t width; - /** - * Height of the logical display + * The height of the physical screen, in px. Does not follow rotation. Does not change for + * the same physical screen. * - * @since 9 + * @since 20 */ int32_t height; + /** + * The width of the physical screen, in mm. Does not follow the rotation. Does not change for + * the same physical screen. + * + * @since 20 + */ + int32_t physicalWidth; + /** + * The width of the physical height, in mm. Does not follow the rotation. Does not change for + * the same physical screen. + * + * @since 20 + */ + int32_t physicalHeight; + /** + * The angle from the screen default origin to the TP origin clockwise. + * + * @since 20 + */ + Direction tpDirection; + /** + * Physical pixel density does not change with resolution. + * + * @since 20 + */ + int32_t dpi; + /** + * The number of pixels per inch is a physical property and does not change. + * + * @since 20 + */ + int32_t ppi; + /** + * The angle of the physical screen relative to the sensor 0 degrees. + * + * @since 20 + */ + Rotation rotation; +}; +/** + * Logical screen group type + * + * @since 20 + */ +enum GroupType { + /** + * The default group, the group that receives input events. This group can only have one + * + * @since 20 + */ + GROUP_DEFAULT = 0, + /** + * The special group, the group can have multiple. + * + * @since 20 + */ + GROUP_SPECIAL = 1, +}; +/** + * Logical screen information + * + * @since 20 + */ +struct DisplayGroupInfo { /** - * ID of the focus window + * Logical screen group id, at least the user space level guarantees uniqueness. + * The range is greater than or equal to 0 * - * @since 9 + * @since 20 + */ + int32_t id; + /** + * Logical screen group name + * + * @since 20 + */ + std::string name; + /** + * Logical screen group type + * + * @since 20 + */ + GroupType type; + /** + * ID of the focus window, The value -1 indicates that there is no focused window in the current screen group. + * The default screen group must have a focused window. + * + * @since 20 */ int32_t focusWindowId; - int32_t currentUserId { -1 }; - /** * List of window information of the logical display arranged in Z order, with the top window at the top * @@ -590,13 +722,39 @@ struct DisplayGroupInfo { std::vector windowsInfo; /** - * Physical screen information list + * logical screen information list * - * @since 9 + * @since 9 20 */ std::vector displaysInfo; }; +/** + * user's screen information + * + * @since 20 + */ +struct UserScreenInfo { + /** + * user id. + * + * @since 20 + */ + int32_t userId; + /** + * Physical screen information. + * + * @since 20 + */ + std::vector screens; + /** + * Logical screen information. + * + * @since 20 + */ + std::vector displayGroups; +}; + struct WindowGroupInfo { /** * ID of the focus window diff --git a/multimodalinput_mini.gni b/multimodalinput_mini.gni index 8366b951f5fca052b9e103da88de2dd495d22be1..f9043e550b6389266ff5399850c9f6caab32b05c 100644 --- a/multimodalinput_mini.gni +++ b/multimodalinput_mini.gni @@ -118,6 +118,7 @@ declare_args() { "$mmi_path/frameworks/proxy/event_handler/src/scene_board_judgement.cpp", "$mmi_path/service/touch_event_normalize/src/input_device_consumer_handler.cpp", "app_state_manager/src/app_state_observer.cpp", + "coordinates_transformer/src/coordinates_transformer.cpp", "delegate_task/src/delegate_interface.cpp", "delegate_task/src/delegate_tasks.cpp", "device_manager/src/input_device_manager.cpp", diff --git a/service/BUILD.gn b/service/BUILD.gn index 9c20ce46404922c8ff17ee4c80217af644db8f36..e964b0ffbacf411d8557b3086b2dedd2dd4baaf7 100644 --- a/service/BUILD.gn +++ b/service/BUILD.gn @@ -70,6 +70,7 @@ config("libmmi_server_config") { "message_handle/include", "module_loader/include", "window_manager/include", + "coordinates_transformer/include", "touch_event_normalize/include", "key_command/include", "subscriber/include", diff --git a/service/coordinates_transformer/include/coordinates_transformer.h b/service/coordinates_transformer/include/coordinates_transformer.h new file mode 100644 index 0000000000000000000000000000000000000000..5117a978aaef9a89d6b37c046c73362eb2a0e4e2 --- /dev/null +++ b/service/coordinates_transformer/include/coordinates_transformer.h @@ -0,0 +1,118 @@ +/* + * Copyright (c) 2025 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 COORDINATES_TRANSFORMER_H +#define COORDINATES_TRANSFORMER_H + +#include + +#include "window_info.h" +#include "struct_multimodal.h" + +namespace OHOS { +namespace MMI { +class CoordinatesTransformer { +public: + struct Screen { + // 固定不变的属性, Screen 原点固定,横向为 width, 纵向未 height + int32_t width { 0 }; // 物理屏幕的宽度, 固有属性,始终不变 + int32_t height { 0 }; // 物理屏幕的高度,固有属性,始终不变 + }; + + struct DefaultDisplay { + // 屏幕默认原点作为左上角时,横向为 width, 纵向为 height + int32_t width { 0 }; // 逻辑屏幕的宽度,逻辑概念,与其所对应的ScreenArea的 width 量纲不同 + int32_t height { 0 }; // 逻辑屏幕的高度,逻辑概念,与其所对应的ScreenArea的 height 量纲不同 + ScreenArea screenArea; + }; + + +/** 定义 + 屏幕默认原点 --- 人为定义的旋转角度为 0, 且坐标为(0, 0) 的原点 + 屏幕原点 --- 屏幕当前目之所及的左上角 + TP原点 --- TP 上报的 (xmin, ymin) 的点 + RS原点 --- RS 绘制渲染时的原点,坐标换算中不涉及 +*/ + +public: + /** + * @brief 获取原始TP报点 + * @param touch lininput 触屏事件. + * @return 原始TP报点信息. + * @since 20 + */ + static OriginalTPCoords GetOriginalTPCoords(struct libinput_event_touch *touch); + + /** + * @brief 获取规约后的TP坐标 + * @param touch lininput 触屏事件. + * @param screen 当前物理屏幕的宽高信息. + * @param tpDirection 屏幕默认原点顺时针旋转到TP原点重合所经过的角度. + * @return 规约在屏幕宽高范围内的TP坐标,即以TP(x_min, y_min) 作为原点,且规约在物理屏范围内的坐标. + * @since 20 + */ + static TouchPanelCoords GetTouchPanelCoords(struct libinput_event_touch *touch, + const Screen &screen, Direction tpDirection); + + /** + * @brief 将TP坐标转换为Screen坐标 + * @param touchPanelCoords TP坐标. + * @param screenCoords 出参,Screen坐标,以当前物理屏幕默认原点作为(0,0)的坐标. + * @param screen 当前物理屏幕的宽高信息. + * @param tpDirection 屏幕默认原点顺时针旋转到TP原点重合所经过的角度. + * @return 规约在屏幕宽高范围内的TP坐标. + * @return void + * @since 20 + */ + static void TouchPanel2Screen(const TouchPanelCoords &touchPanelCoords, ScreenCoords &screenCoords, + const Screen &screen, Direction tpDirection); // 当前TP报点 -> 以宽高信息规约之后的坐标,即 Screen 坐标 + + /** + * @brief 将Screen坐标转换为默认Display坐标,未旋转 + * @param screenCoords Screen坐标,以当前物理屏幕默认原点作为(0,0)的坐标. + * @param defaultDisplayCoords 屏幕默认坐标,未旋转,即以逻辑屏幕的屏幕默认原点作为(0,0) 的坐标. + * @param defaultDisplay 当前逻辑屏幕的定义,其中包含关键属性 ScreenArea, 逻辑屏幕默认原点作为左上角时,横向定义为 width, 纵向定义为 height + * @since 20 + */ + static void Screen2DefaultDisplay(const ScreenCoords &screenCoords, DefaultDisplayCoords &defaultDisplayCoords, + const DefaultDisplay &defaultDisplay); + + /** + * @brief 将未旋转的屏幕Display坐标转换为当前姿态下Display坐标(已旋转) + * @param defaultDisplayCoords 屏幕默认坐标,未旋转,即以逻辑屏幕的屏幕默认原点作为(0,0) 的坐标. + * @param rotatedDisplayCoords 当前屏幕坐标,已旋转,即以当前屏幕摆放姿态左上角为(0,0)的坐标. + * @param direction 屏幕旋转角度,屏幕默认方向顺时针旋转到当前屏幕方向的转角. + * @param defaultDisplay 当前逻辑屏幕的定义,其中包含关键属性 ScreenArea, 逻辑屏幕默认原点作为左上角时,横向定义为 width, 纵向定义为 height + * @since 20 + */ + static void DefaultDisplay2RotatedDisplay(const DefaultDisplayCoords &defaultDisplayCoords, + RotatedDisplayCoords &rotatedDisplayCoords, Direction direction, const DefaultDisplay &defaultDisplay); + + /** + * @brief 将当前Display坐标(旋转后) 转换为全局坐标 + * @param rotatedDisplayCoords 当前屏幕坐标,已旋转,即以当前屏幕摆放姿态左上角为(0,0)的坐标. + * @param displayOriginGlobalCoord 当前摆放姿态下左上角,即当前display原点 的全局坐标, 这个是谁传递下来的呢,怎么保证正确性呢。 + * @param globalCoords 当前报点的全局坐标. + * @since 20 + */ + static void RotatedDisplay2Global(const RotatedDisplayCoords &rotatedDisplayCoords, + const MMICoordinate2D &displayOriginGlobalCoord, GlobalCoords &globalCoords); + +private: + static void DispCoords(const std::string &name, const MMICoordinate2D &coords); +}; +} // namespace MMI +} // namespace OHOS +#endif // COORDINATES_TRANSFORMER_H \ No newline at end of file diff --git a/service/coordinates_transformer/src/coordinates_transformer.cpp b/service/coordinates_transformer/src/coordinates_transformer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..3a43fbe8130d99c5837a2f6cc5cfa99b570c6638 --- /dev/null +++ b/service/coordinates_transformer/src/coordinates_transformer.cpp @@ -0,0 +1,201 @@ +/* + * Copyright (c) 2025 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. + */ + +#include "coordinates_transformer.h" + +#include + +#include "mmi_log.h" + +#define MMI_LOG_TAG "CoordinatesTransformer" + +namespace OHOS { +namespace MMI { + +OriginalTPCoords CoordinatesTransformer::GetOriginalTPCoords(struct libinput_event_touch *touch) +{ + // 从 libinput_event_touch 中获取 TP 原始报点数据 + OriginalTPCoords originalCoords { + .x = libinput_event_touch_get_x(touch), + .y = libinput_event_touch_get_y(touch) + }; + DispCoords("originalCoords", originalCoords); + return originalCoords; +} + +TouchPanelCoords CoordinatesTransformer::GetTouchPanelCoords(struct libinput_event_touch *touch, + const Screen &screen, Direction tpDirection) +{ + // 当前TP原始报点信息 -> 以宽高信息规约之后的坐标信息,即 Screen 坐标(原点依旧是TP原点) + // screen --- 以屏幕默认原点作为(0,0),横向长度即未width,纵向长度即为height + // tpDirection TP 原点和 Screen 的默认原点之间的角度差,与旋转无关,因为 TP 感知的宽高可能和屏幕本身的宽高不是一样的 + // tpDirection --- 屏幕默认原点顺时针旋转到TP原点重合锁经过的角度 + int32_t fixedWidth = screen.width; + int32_t fixedHeight = screen.height; + if (tpDirection == DIRECTION90 || tpDirection == DIRECTION270) { + fixedWidth = screen.height; + fixedHeight = screen.width; + } + TouchPanelCoords touchPanelCoords; + touchPanelCoords.x = libinput_event_touch_get_x_transformed(touch, fixedWidth); + touchPanelCoords.y = libinput_event_touch_get_y_transformed(touch, fixedHeight); + DispCoords("touchPanelCoords", touchPanelCoords); + return touchPanelCoords; +} + +void CoordinatesTransformer::TouchPanel2Screen(const TouchPanelCoords &touchPanelCoords, ScreenCoords &screenCoords, + const Screen &screen, Direction tpDirection) // 当前TP报点 -> 以宽高信息规约之后的坐标信息,即 Screen 坐标 +{ + // touchPanelCoords --- 以TP原点作为原点,并且经过规约之后,坐标值在屏幕宽高范围内的坐标信息 + // ScreenCoords --- 以屏幕默认原点作为坐标原点的坐标信息 + // screen --- 以屏幕默认原点作为(0,0),横向长度即未width,纵向长度即为height + // tpDirection TP 原点和 Screen 的默认原点之间的角度差,与旋转无关,因为 TP 感知的宽高可能和屏幕本身的宽高不是一样的 + // tpDirection --- 屏幕默认原点顺时针旋转到TP原点重合锁经过的角度 + switch (tpDirection) { + case DIRECTION0: { + screenCoords = touchPanelCoords; + break; + } + case DIRECTION90: { + screenCoords.x = screen.width - touchPanelCoords.y; + screenCoords.y = touchPanelCoords.x; + break; + } + case DIRECTION180: { + screenCoords.x = screen.width - touchPanelCoords.x; + screenCoords.y = screen.height - touchPanelCoords.y; + break; + } + case DIRECTION270: { + screenCoords.x = touchPanelCoords.y; + screenCoords.y = screen.height - touchPanelCoords.x; + break; + } + default: { + MMI_HILOGW("Unknown tpDirection:%{public}d", tpDirection); + } + } + DispCoords("screenCoords", screenCoords); +} + +void CoordinatesTransformer::Screen2DefaultDisplay(const ScreenCoords &screenCoords, + DefaultDisplayCoords &defaultDisplayCoords, const DefaultDisplay &defaultDisplay) +{ + // ScreenCoords --- 以屏幕默认原点作为坐标原点的坐标信息 + // defaultDisplayCoords --- 以逻辑屏幕的屏幕默认原点作为(0,0) 的坐标信息 + + // screenArea 内部坐标 + MMICoordinate2D innerScreenAreaCoords { + .x = screenCoords.x - defaultDisplay.screenArea.area.x, + .y = screenCoords.y - defaultDisplay.screenArea.area.y + }; + DispCoords("innerScreenAreaCoords", innerScreenAreaCoords); + defaultDisplayCoords.x = (innerScreenAreaCoords.x / defaultDisplay.screenArea.area.width) * defaultDisplay.width; + defaultDisplayCoords.y = (innerScreenAreaCoords.y / defaultDisplay.screenArea.area.height) * defaultDisplay.width; + DispCoords("defaultDisplayCoords", defaultDisplayCoords); +} + +void CoordinatesTransformer::DefaultDisplay2RotatedDisplay(const DefaultDisplayCoords &defaultDisplayCoords, + RotatedDisplayCoords &rotatedDisplayCoords, Direction direction, const DefaultDisplay &defaultDisplay) +{ + // defaultDisplayCoords + // 以屏幕默认原点作为基准点(0, 0) 的坐标信息 -> 以屏幕当前旋转角度下的左上角作为(0, 0) 的坐标信息 + // rotatedDisplayCoords --- 以当前屏幕摆放姿态下左上角作为原点的坐标信息 + // direction --- 屏幕默认方向顺时针旋转到当前屏幕方向的转角 + // screen 信息是和 defaultDisplayCoords 保持一致的 + switch (direction) { + case DIRECTION0: { + rotatedDisplayCoords = defaultDisplayCoords; + break; + } + case DIRECTION90: { + rotatedDisplayCoords.x = defaultDisplayCoords.y; + rotatedDisplayCoords.y = defaultDisplay.width - defaultDisplayCoords.x; + break; + } + case DIRECTION180: { + rotatedDisplayCoords.x = defaultDisplay.width - defaultDisplayCoords.x; + rotatedDisplayCoords.y = defaultDisplay.height - defaultDisplayCoords.y; + break; + } + case DIRECTION270: { + rotatedDisplayCoords.x = defaultDisplay.height - defaultDisplayCoords.y; + rotatedDisplayCoords.y = defaultDisplayCoords.x; + break; + } + default: { + MMI_HILOGW("Unknown direction:%{public}d", direction); + } + } + DispCoords("rotatedDisplayCoords", rotatedDisplayCoords); +} + +void CoordinatesTransformer::RotatedDisplay2Global(const RotatedDisplayCoords &rotatedDisplayCoords, + const MMICoordinate2D &displayOriginGlobalCoord, GlobalCoords &globalCoords) +{ + // rotatedDisplayCoords --- 当前 display 的旋转后的display坐标 + // displayOriginGlobalCoord --- 逻辑 display 当前原点的全局坐标信息 + // 以屏幕当前旋转角度下的左上角作为(0, 0) 的坐标信息 -> 全局坐标系下的坐标信息 + globalCoords.x = displayOriginGlobalCoord.x + rotatedDisplayCoords.x; + globalCoords.y = displayOriginGlobalCoord.y + rotatedDisplayCoords.y; + DispCoords("globalCoords", globalCoords); +} + +void CoordinatesTransformer::DispCoords(const std::string &name, const MMICoordinate2D &coords) +{ + MMI_HILOGI("name:%{public}s, x:%{public}f, y:%{public}f", name.c_str(), coords.x, coords.y); +} + + +/** + { + // Global coordinates calculation process for debug + OriginalTPCoords originTPCoords = CoordinatesTransformer::GetOriginalTPCoords(touch); + + CoordinatesTransformer::Screen screen { + .width = info.width, + .height = info.height + }; + + Direction tpDirection { DIRECTION0 }; + TouchPanelCoords touchPanelCoords = CoordinatesTransformer::GetTouchPanelCoords(touch, screen, tpDirection); + + ScreenCoords screenCoords; + CoordinatesTransformer::TouchPanel2Screen(touchPanelCoords, screenCoords, screen, tpDirection); + + CoordinatesTransformer::DefaultDisplay defaultDisplay { + .width = info.width, + .height = info.height + }; + + DefaultDisplayCoords defaultDisplayCoords; + CoordinatesTransformer::Screen2DefaultDisplay(screenCoords, defaultDisplayCoords, defaultDisplay); + + RotatedDisplayCoords rotatedDisplayCoords; + CoordinatesTransformer::DefaultDisplay2RotatedDisplay(defaultDisplayCoords, rotatedDisplayCoords, DIRECTION0, + defaultDisplay); + + GlobalCoords globalCoords; + + MMICoordinate2D displayOriginCoords; + CoordinatesTransformer::RotatedDisplay2Global(rotatedDisplayCoords, displayOriginCoords, globalCoords); + + touchInfo.globalCoord.x = globalCoords.x; + touchInfo.globalCoord.y = globalCoords.y; + } + +*/ +} // namespace MMI +} // namespace OHOS \ No newline at end of file diff --git a/service/key_command/include/key_command_handler.h b/service/key_command/include/key_command_handler.h index da9d113a1ef7f9e0819a86063973a0d4c75ffefd..a36303074d32da967e3d8457b6e70ac63fc39295 100755 --- a/service/key_command/include/key_command_handler.h +++ b/service/key_command/include/key_command_handler.h @@ -16,7 +16,7 @@ #ifndef KEY_COMMAND_HANDLER_H #define KEY_COMMAND_HANDLER_H -#include "window_info.h" +#include "old_display_info.h" #include "i_input_event_handler.h" #include "input_handler_type.h" @@ -290,7 +290,7 @@ private: void HandleFingerGestureUpEvent(const std::shared_ptr touchEvent); void HandleKnuckleGestureDownEvent(const std::shared_ptr touchEvent); void HandleKnuckleGestureUpEvent(const std::shared_ptr touchEvent); - std::pair CalcDrawCoordinate(const DisplayInfo& displayInfo, + std::pair CalcDrawCoordinate(const OLD::DisplayInfo& displayInfo, PointerEvent::PointerItem pointerItem); void SingleKnuckleGestureProcesser(const std::shared_ptr touchEvent); void DoubleKnuckleGestureProcesser(const std::shared_ptr touchEvent); diff --git a/service/key_command/src/key_command_handler.cpp b/service/key_command/src/key_command_handler.cpp index 9e7bfbe82a436eaca2d4b24172af6df7869d6602..6f8eec5c15e42172b86c75dfa4bf31ba657f144d 100644 --- a/service/key_command/src/key_command_handler.cpp +++ b/service/key_command/src/key_command_handler.cpp @@ -769,7 +769,7 @@ bool KeyCommandHandler::IsValidAction(int32_t action) return false; } -std::pair KeyCommandHandler::CalcDrawCoordinate(const DisplayInfo& displayInfo, +std::pair KeyCommandHandler::CalcDrawCoordinate(const OLD::DisplayInfo& displayInfo, PointerEvent::PointerItem pointerItem) { CALL_DEBUG_ENTER; diff --git a/service/libinput_adapter/src/libinput_adapter.cpp b/service/libinput_adapter/src/libinput_adapter.cpp index 79298b0662fe093224d4eeb081ba58b9345108c3..5334067f680bc81e3024081e5fe0bdd06924c68a 100644 --- a/service/libinput_adapter/src/libinput_adapter.cpp +++ b/service/libinput_adapter/src/libinput_adapter.cpp @@ -339,6 +339,26 @@ bool LibinputAdapter::GetIsCaptureMode() isCaptureMode = inputWindowsManager->IsCaptureMode() && isFloating; MMI_HILOGD("Currently keyboard will %s consume touch points", (isCaptureMode ? "not" : "")); + OLD::DisplayGroupInfo displayGroupInfo = inputWindowsManager->GetDisplayGroupInfo(); + + auto screenshotWindow = std::find_if(displayGroupInfo.windowsInfo.begin(), + displayGroupInfo.windowsInfo.end(), [](const WindowInfo& windowInfo) { + return windowInfo.windowNameType == WINDOW_NAME_TYPE_SCHREENSHOT; + }); + if (screenshotWindow != displayGroupInfo.windowsInfo.end()) { + return false; + } + + auto captureWindow = std::find_if(displayGroupInfo.windowsInfo.begin(), + displayGroupInfo.windowsInfo.end(), [](const WindowInfo& windowInfo) { + return windowInfo.zOrder == SCREEN_CAPTURE_WINDOW_ZORDER; + }); + if (captureWindow != displayGroupInfo.windowsInfo.end()) { + isCaptureMode = (captureWindow->area.width > SCREEN_RECORD_WINDOW_WIDTH || + captureWindow->area.height > SCREEN_RECORD_WINDOW_HEIGHT) && isFloating; + MMI_HILOGD("#####Currently keyboard will %s consume touch points", (isCaptureMode ? "not" : "")); + } + return isCaptureMode; } #endif // OHOS_BUILD_ENABLE_VKEYBOARD @@ -503,7 +523,20 @@ bool LibinputAdapter::IsCursorInCastWindow() if (inputWindowsManager == nullptr) { return false; } - return inputWindowsManager->IsMouseInCastWindow(); + OLD::DisplayGroupInfo displayGroupInfo = inputWindowsManager->GetDisplayGroupInfo(); + for (const auto &windowInfo : displayGroupInfo.windowsInfo) { + if (windowInfo.windowType == CAST_WINDOW_TYPE) { + auto mouseInfo = WIN_MGR->GetMouseInfo(); + int32_t x = mouseInfo.physicalX; + int32_t y = mouseInfo.physicalY; + if ((x > windowInfo.area.x && x < (windowInfo.area.x + windowInfo.area.width)) && + (y > windowInfo.area.y && y < (windowInfo.area.y + windowInfo.area.height))) { + return true; + } + } + } + + return false; } int32_t LibinputAdapter::ConvertToTouchEventType( diff --git a/service/message_handle/include/server_msg_handler.h b/service/message_handle/include/server_msg_handler.h index 38809573ed042ec6d8c81ee1ddf58a092c6e6777..7e7cd09e46808e26eca2a41f02e1a003f9f2f936 100644 --- a/service/message_handle/include/server_msg_handler.h +++ b/service/message_handle/include/server_msg_handler.h @@ -161,8 +161,16 @@ private: bool CloseInjectNotice(int32_t pid); bool IsNavigationWindowInjectEvent(std::shared_ptr pointerEvent); int32_t NativeInjectCheck(int32_t pid); - int32_t ReadDisplayInfo(NetPacket &pkt, DisplayGroupInfo &displayGroupInfo); + int32_t ReadScreensInfo(NetPacket &pkt, UserScreenInfo &userScreenInfo); + int32_t ReadDisplayGroupsInfo(NetPacket &pkt, UserScreenInfo &userScreenInfo); + int32_t ReadDisplaysInfo(NetPacket &pkt, DisplayGroupInfo &displayGroupInfo); + int32_t ReadWindowsInfo(NetPacket &pkt, DisplayGroupInfo &displayGroupInfo, + OLD::DisplayGroupInfo &oldDisplayGroupInfo); bool IsCastInject(int32_t deviceid); + bool ChangeToOld(const UserScreenInfo& userScreenInfo); + void ChangeToOld(size_t num, const std::vector& displaysInfo, + const std::vector& screens); + void Printf(const UserScreenInfo& userScreenInfo); private: UDSServer *udsServer_ { nullptr }; std::map nativeTargetWindowIds_; @@ -179,6 +187,7 @@ private: ClientDeathHandler clientDeathHandler_; std::mutex mutexMapQueryAuthorizeLastTimestamp_; std::map mapQueryAuthorizeLastTimestamp_; + std::vector oldDisplayGroupInfos_; }; } // namespace MMI } // namespace OHOS diff --git a/service/message_handle/src/server_msg_handler.cpp b/service/message_handle/src/server_msg_handler.cpp index 3fe2e1f810f956fe3b0ceabe4be90c95891ac266..5f051302a636a73379a68880e82f3a702fd96176 100644 --- a/service/message_handle/src/server_msg_handler.cpp +++ b/service/message_handle/src/server_msg_handler.cpp @@ -742,40 +742,6 @@ int32_t ServerMsgHandler::OnUiExtentionWindowInfo(NetPacket &pkt, WindowInfo& in return RET_OK; } -int32_t ServerMsgHandler::ReadDisplayInfo(NetPacket &pkt, DisplayGroupInfo &displayGroupInfo) -{ - uint32_t num = 0; - pkt >> num; - for (uint32_t i = 0; i < num; i++) { - DisplayInfo info; - pkt >> info.id >> info.x >> info.y >> info.width >> info.height >> info.dpi >> info.name - >> info.uniq >> info.direction >> info.displayDirection >> info.displayMode >> info.transform >> info.ppi - >> info.offsetX >> info.offsetY >> info.isCurrentOffScreenRendering >> info.screenRealWidth - >> info.screenRealHeight >> info.screenRealPPI >> info.screenRealDPI >> info.screenCombination - >> info.validWidth >> info.validHeight >> info.fixedDirection - >> info.physicalWidth >> info.physicalHeight >> info.scalePercent >> info.expandHeight >> info.uniqueId; -#ifdef OHOS_BUILD_ENABLE_ONE_HAND_MODE - pkt >> info.oneHandX >> info.oneHandY; -#endif // OHOS_BUILD_ENABLE_ONE_HAND_MODE -#ifdef OHOS_BUILD_ENABLE_VKEYBOARD - pkt >> info.pointerActiveWidth >> info.pointerActiveHeight; -#endif // OHOS_BUILD_ENABLE_VKEYBOARD - if (PRODUCT_TYPE != PRODUCT_TYPE_PC) { - info.uniq = "default" + std::to_string(info.id); - } - displayGroupInfo.displaysInfo.push_back(info); - if (pkt.ChkRWError()) { - MMI_HILOGE("Packet read display info failed"); - return RET_ERR; - } - } - if (pkt.ChkRWError()) { - MMI_HILOGE("Packet read display info failed"); - return RET_ERR; - } - return RET_OK; -} - bool ServerMsgHandler::IsCastInject(int32_t deviceid) { return (deviceid == CAST_INPUT_DEVICEID || deviceid == CAST_SCREEN_DEVICEID); @@ -791,39 +757,220 @@ int32_t ServerMsgHandler::OnDisplayInfo(SessionPtr sess, NetPacket &pkt) MMI_HILOGW("Not native or systemapp skip, pid:%{public}d tokenType:%{public}d", sess->GetPid(), tokenType); return RET_ERR; } - DisplayGroupInfo displayGroupInfo; - pkt >> displayGroupInfo.groupId >> displayGroupInfo.isMainGroup >> displayGroupInfo.width >> - displayGroupInfo.height >> displayGroupInfo.focusWindowId >> displayGroupInfo.currentUserId; + UserScreenInfo userScreenInfo; + oldDisplayGroupInfos_.clear(); + pkt >> userScreenInfo.userId; + if (ReadScreensInfo(pkt, userScreenInfo) != RET_OK) { + return RET_ERR; + } + if (ReadDisplayGroupsInfo(pkt, userScreenInfo) != RET_OK ) { + return RET_ERR; + } + if (!ChangeToOld(userScreenInfo)) { + return RET_ERR; + } + Printf(userScreenInfo); + for (auto &displayGroupInfo : oldDisplayGroupInfos_) { + WIN_MGR->UpdateDisplayInfoExtIfNeed(displayGroupInfo, true); // 入口 + } + return RET_OK; +} +int32_t ServerMsgHandler::ReadScreensInfo(NetPacket &pkt, UserScreenInfo &userScreenInfo) +{ uint32_t num = 0; pkt >> num; - if (pkt.ChkRWError()) { - MMI_HILOGE("Packet read display info failed"); + for (uint32_t i = 0; i < num; i++) { + ScreenInfo info; + pkt >> info.id >> info.uniqueId >> info.screenType >> info.width >> info.height >> info.physicalWidth + >> info.physicalHeight >> info.tpDirection >> info.dpi >> info.ppi >> info.rotation; + userScreenInfo.screens.push_back(info); + } + if (pkt.ChkRWError()) { + MMI_HILOGE("Read screens info error"); return RET_ERR; } + return RET_OK; +} + +int32_t ServerMsgHandler::ReadDisplayGroupsInfo(NetPacket &pkt, UserScreenInfo &userScreenInfo) +{ + uint32_t num = 0; + pkt >> num; + for (uint32_t i = 0; i < num; i++) { - WindowInfo info; - int32_t byteCount = 0; - pkt >> info.id >> info.pid >> info.uid >> info.area >> info.defaultHotAreas - >> info.pointerHotAreas >> info.agentWindowId >> info.flags >> info.action - >> info.displayId >> info.groupId >> info.zOrder >> info.pointerChangeAreas >> info.transform - >> info.windowInputType >> info.privacyMode >> info.windowType - >> info.isSkipSelfWhenShowOnVirtualScreen >> info.windowNameType >> byteCount; + DisplayGroupInfo info; + OLD::DisplayGroupInfo oldInfo; + pkt >> info.id >> info.name >> info.type >> info.mainDisplayId >> info.focusWindowId; + if (ReadDisplaysInfo(pkt, info) != RET_OK) { + return RET_ERR; + } + if (ReadWindowsInfo(pkt, info, oldInfo) != RET_OK) { + return RET_ERR; + } + userScreenInfo.displayGroups.push_back(info); + oldDisplayGroupInfos_.push_back(oldInfo); + } + return RET_OK; +} - OnUiExtentionWindowInfo(pkt, info); - pkt >> info.rectChangeBySystem; - displayGroupInfo.windowsInfo.push_back(info); +int32_t ServerMsgHandler::ReadDisplaysInfo(NetPacket &pkt, DisplayGroupInfo &displayGroupInfo) +{ + uint32_t num = 0; + pkt >> num; + for (uint32_t i = 0; i < num; i++) { + DisplayInfo info; + pkt >> info.id >> info.x >> info.y >> info.width >> info.height >> info.dpi >> info.name + >> info.direction >> info.displayDirection >> info.displayMode >> info.transform + >> info.scalePercent >> info.expandHeight >> info.isCurrentOffScreenRendering + >> info.displaySourceMode >> info.oneHandX >> info.oneHandY >> info.screenArea >> info.rsId + >> info.offsetX >> info.offsetY >> info.pointerActiveWidth >> info.pointerActiveHeight; + displayGroupInfo.displaysInfo.push_back(info); if (pkt.ChkRWError()) { MMI_HILOGE("Packet read display info failed"); return RET_ERR; } } - if (ReadDisplayInfo(pkt, displayGroupInfo) != RET_OK) { - return RET_ERR; - } - WIN_MGR->UpdateDisplayInfoExtIfNeed(displayGroupInfo, true); return RET_OK; } +int32_t ServerMsgHandler::ReadWindowsInfo(NetPacket &pkt, DisplayGroupInfo &displayGroupInfo, + OLD::DisplayGroupInfo &oldDisplayGroupInfo) +{ + uint32_t num = 0; + pkt >> num; + for (uint32_t i = 0; i < num; i++) { + WindowInfo info; + int32_t byteCount = 0; + pkt >> info.id >> info.pid >> info.uid >> info.area >> info.defaultHotAreas + >> info.pointerHotAreas >> info.agentWindowId >> info.flags >> info.action + >> info.displayId >> info.groupId >> info.zOrder >> info.pointerChangeAreas >> info.transform + >> info.windowInputType >> info.privacyMode >> info.windowType + >> info.isSkipSelfWhenShowOnVirtualScreen >> info.windowNameType >> byteCount; + + OnUiExtentionWindowInfo(pkt, info); + pkt >> info.rectChangeBySystem; + displayGroupInfo.windowsInfo.push_back(info); + oldDisplayGroupInfo.windowsInfo.push_back(info); + if (pkt.ChkRWError()) { + MMI_HILOGE("read window info failed"); + return RET_ERR; + } + } + return RET_OK; +} + +bool ServerMsgHandler::ChangeToOld(const UserScreenInfo& userScreenInfo) +{ + if (userScreenInfo.displayGroups.size() != oldDisplayGroupInfos_.size()) { + MMI_HILOGE("ChangeToOld size inconsistent, new size:%{public}zu, old size:%{public}zu", + userScreenInfo.displayGroups.size(), oldDisplayGroupInfos_.size()); + return false; + } + size_t num = 0; + for (auto &displayGroupInfo : userScreenInfo.displayGroups) { + oldDisplayGroupInfos_[num].groupId = displayGroupInfo.id; + oldDisplayGroupInfos_[num].type = displayGroupInfo.type; + oldDisplayGroupInfos_[num].mainDisplayId = displayGroupInfo.mainDisplayId; + oldDisplayGroupInfos_[num].focusWindowId = displayGroupInfo.focusWindowId; + oldDisplayGroupInfos_[num].currentUserId = userScreenInfo.userId; + ChangeToOld(num, displayGroupInfo.displaysInfo, userScreenInfo.screens); // 全局坐标系相关信息存在这里,Display 左上角的全局坐标在这里存储转化 + num++; + } + return true; +} + +void ServerMsgHandler::ChangeToOld(size_t num, const std::vector& displaysInfo, + const std::vector& screens) +{ + for (auto &display : displaysInfo) { + OLD::DisplayInfo oldDisplay; + oldDisplay = { + .id = display.id, + .x = display.x, // 全局坐标, 没有随着设备旋转改变,Aln 都是当前左上角的坐标(0, 0) + .y = display.y, // 全局坐标, 没有随着设备旋转改变,Aln 都是当前左上角的坐标(0, 0) + .width = display.width, + .height = display.height, + .dpi = display.dpi, + .name = display.name, + .direction = display.direction, + .displayDirection = display.displayDirection, + .displayMode = display.displayMode, + .transform = display.transform, + .offsetX = display.offsetX, + .offsetY = display.offsetY, + .scalePercent = display.scalePercent, + .expandHeight = display.expandHeight, + .isCurrentOffScreenRendering = display.isCurrentOffScreenRendering, + .displaySourceMode = display.displaySourceMode, + .oneHandX = display.oneHandX, + .oneHandY = display.oneHandY, + .validWidth = display.width, + .validHeight = display.height, + .pointerActiveWidth = display.pointerActiveWidth, + .pointerActiveHeight = display.pointerActiveHeight, + .rsId = display.rsId, + // 这里缺少 screenArea 的相关信息 + }; + for (auto &screen : screens) { + if (screen.id == display.screenArea.id) { // 这块逻辑之外的场景怎么考虑的呢 + oldDisplay.uniq = screen.uniqueId; + oldDisplay.ppi = screen.ppi; + oldDisplay.screenRealWidth = screen.width; + oldDisplay.screenRealHeight = screen.height; + oldDisplay.screenRealDPI = screen.dpi; + oldDisplay.fixedDirection = screen.tpDirection; + oldDisplay.physicalWidth = screen.physicalWidth; + oldDisplay.physicalHeight = screen.physicalHeight; + } + } + oldDisplayGroupInfos_[num].displaysInfo.emplace_back(oldDisplay); + } +} + +void ServerMsgHandler::Printf(const UserScreenInfo& userScreenInfo) +{ + MMI_HILOGI("userScreenInfo-----------"); + MMI_HILOGI("userId:%{public}d, ", userScreenInfo.userId); + size_t num = 0; + for (const auto &item : userScreenInfo.screens) { + MMI_HILOGI("screen%{public}zu, id:%{public}d, uniqueId:%{public}s, screenType:%{public}d,width:%{public}d" + "height:%{public}d, physicalWidth:%{public}d, physicalHeight:%{public}d, tpDirection:%{public}d," + "dpi%{public}d,ppi%{public}d,rotation%{public}d",num, item.id, item.uniqueId.c_str(), item.screenType, + item.width,item.height,item.physicalWidth, item.physicalHeight, item.tpDirection, item.dpi, item.ppi, + item.rotation); + num++; + } + num = 0; + for (const auto &item : userScreenInfo.displayGroups) { + MMI_HILOGI("displayGroups%{public}zu,id:%{public}d,name:%{public}s,type:%{public}d, mainDisplayId:%{public}d," + "focusWindowId:%{public}d", + num, item.id, item.name.c_str(), item.type, item.mainDisplayId, item.focusWindowId); + size_t numDisplayInfo = 0; + for (const auto &itemDisplay : item.displaysInfo) { + MMI_HILOGI("displays%{public}zu,id:%{public}d,x:%{public}d,y:%{public}d,width:%{public}d," + "height:%{public}d,dpi:%{public}d,name:%{public}s,direction:%{public}d,displayDirection:%{public}d," + "displayMode:%{public}d,scalePercent:%{public}d, expandHeight:%{public}d," + "isCurrentOffScreenRendering:%{public}d,displaySourceMode:%{public}d,oneHandX:%{public}d," + "oneHandY:%{public}d, screenArea:{%{public}d:{%{public}d,%{public}d,%{public}d,%{public}d}," + "rsId:%{public}d},offsetX:%{public}d,offsetY:%{public}d,pointerActiveWidth:%{public}d," + "pointerActiveHeight:%{public}d,transform:", + numDisplayInfo, itemDisplay.id, itemDisplay.x, itemDisplay.y, itemDisplay.width, itemDisplay.height, + itemDisplay.dpi, itemDisplay.name.c_str(), itemDisplay.direction, itemDisplay.displayDirection, + itemDisplay.displayMode, itemDisplay.scalePercent, itemDisplay.expandHeight, + itemDisplay.isCurrentOffScreenRendering, itemDisplay.displaySourceMode, itemDisplay.oneHandX, + itemDisplay.oneHandY, itemDisplay.screenArea.id, itemDisplay.screenArea.area.x, + itemDisplay.screenArea.area.y, itemDisplay.screenArea.area.width, itemDisplay.screenArea.area.height, + itemDisplay.rsId, itemDisplay.offsetX, itemDisplay.offsetY, + itemDisplay.pointerActiveWidth, itemDisplay.pointerActiveHeight); + for (auto& transform : itemDisplay.transform) { + MMI_HILOGI("%{public}f,", transform); + } + numDisplayInfo++; + } + num++; + } +} + int32_t ServerMsgHandler::OnWindowGroupInfo(SessionPtr sess, NetPacket &pkt) { CALL_DEBUG_ENTER; diff --git a/service/mouse_event_normalize/include/mouse_transform_processor.h b/service/mouse_event_normalize/include/mouse_transform_processor.h index ff155b14709a6ba3760a894552ee2615617a326f..0626ee80af3e2a514725c537cc30578aef13f041 100644 --- a/service/mouse_event_normalize/include/mouse_transform_processor.h +++ b/service/mouse_event_normalize/include/mouse_transform_processor.h @@ -22,7 +22,7 @@ #include "timer_manager.h" #include "pointer_event.h" #include "touchpad_control_display_gain.h" -#include "window_info.h" +#include "old_display_info.h" #include namespace OHOS { @@ -119,9 +119,9 @@ private: bool HandlePostInner(struct libinput_event_pointer* data, PointerEvent::PointerItem &pointerItem); void HandleTouchPadAxisState(libinput_pointer_axis_source source, int32_t& direction, bool& tpScrollSwitch); void HandleTouchPadButton(enum libinput_button_state state, int32_t type); - int32_t UpdateMouseMoveLocation(const DisplayInfo* displayInfo, Offset &offset, + int32_t UpdateMouseMoveLocation(const OLD::DisplayInfo* displayInfo, Offset &offset, double &abs_x, double &abs_y, int32_t deviceType); - int32_t UpdateTouchpadMoveLocation(const DisplayInfo* displayInfo, struct libinput_event* event, + int32_t UpdateTouchpadMoveLocation(const OLD::DisplayInfo* displayInfo, struct libinput_event* event, Offset &offset, double &abs_x, double &abs_y, int32_t deviceType); #ifndef OHOS_BUILD_ENABLE_WATCH void HandleTouchpadRightButton(struct libinput_event_pointer* data, const int32_t evenType, uint32_t &button); @@ -134,9 +134,9 @@ private: void TransTouchpadRightButton(struct libinput_event_pointer* data, const int32_t type, uint32_t &button); double HandleAxisAccelateTouchPad(double axisValue); #endif // OHOS_BUILD_ENABLE_WATCH - void CalculateOffset(const DisplayInfo* displayInfo, Offset &offset); - bool IsWindowRotation(const DisplayInfo* displayInfo); - Direction GetDisplayDirection(const DisplayInfo *displayInfo); + void CalculateOffset(const OLD::DisplayInfo* displayInfo, Offset &offset); + bool IsWindowRotation(const OLD::DisplayInfo* displayInfo); + Direction GetDisplayDirection(const OLD::DisplayInfo *displayInfo); void HandleReportMouseResponseTime(std::string &connectType, std::map &curMap); void CalculateMouseResponseTimeProbability(struct libinput_event *event); std::map> mouseResponseMap = {}; diff --git a/service/mouse_event_normalize/src/mouse_transform_processor.cpp b/service/mouse_event_normalize/src/mouse_transform_processor.cpp index b15a18830da7ce03ef9efe9d3958c922dc531cb5..421c1dcf7809677b04106d54a139f6af6dcc6148 100644 --- a/service/mouse_event_normalize/src/mouse_transform_processor.cpp +++ b/service/mouse_event_normalize/src/mouse_transform_processor.cpp @@ -114,7 +114,7 @@ std::shared_ptr MouseTransformProcessor::GetPointerEvent() const } #ifdef OHOS_BUILD_EMULATOR -static Coordinate2D CalculateCursorPosFromOffset(Offset offset, const DisplayInfo &displayInfo) +static Coordinate2D CalculateCursorPosFromOffset(Offset offset, const OLD::DisplayInfo &displayInfo) { auto direction = displayInfo.displayDirection; auto width = displayInfo.width; @@ -205,7 +205,7 @@ int32_t MouseTransformProcessor::HandleMotionInner(struct libinput_event_pointer return RET_OK; } -int32_t MouseTransformProcessor::UpdateMouseMoveLocation(const DisplayInfo* displayInfo, Offset &offset, +int32_t MouseTransformProcessor::UpdateMouseMoveLocation(const OLD::DisplayInfo* displayInfo, Offset &offset, double &abs_x, double &abs_y, int32_t deviceType) { CHKPR(displayInfo, ERROR_NULL_POINTER); @@ -262,7 +262,7 @@ int32_t MouseTransformProcessor::UpdateMouseMoveLocation(const DisplayInfo* disp } } -int32_t MouseTransformProcessor::UpdateTouchpadMoveLocation(const DisplayInfo* displayInfo, +int32_t MouseTransformProcessor::UpdateTouchpadMoveLocation(const OLD::DisplayInfo* displayInfo, struct libinput_event* event, Offset &offset, double &abs_x, double &abs_y, int32_t deviceType) { CHKPR(displayInfo, ERROR_NULL_POINTER); @@ -411,7 +411,7 @@ void MouseTransformProcessor::HandleReportMouseResponseTime( MMI_HILOGI("Mouse write end , ret:%{public}d", ret); } -bool MouseTransformProcessor::IsWindowRotation(const DisplayInfo* displayInfo) +bool MouseTransformProcessor::IsWindowRotation(const OLD::DisplayInfo* displayInfo) { MMI_HILOGD("ROTATE_POLICY: %{public}d, FOLDABLE_DEVICE_POLICY:%{public}s", ROTATE_POLICY, FOLDABLE_DEVICE_POLICY.c_str()); @@ -431,7 +431,7 @@ bool MouseTransformProcessor::IsWindowRotation(const DisplayInfo* displayInfo) (displayInfo->displayMode == DisplayMode::FULL && foldableDevicePolicyFull)))); } -Direction MouseTransformProcessor::GetDisplayDirection(const DisplayInfo *displayInfo) +Direction MouseTransformProcessor::GetDisplayDirection(const OLD::DisplayInfo *displayInfo) { Direction displayDirection = DIRECTION0; if (Rosen::SceneBoardJudgement::IsSceneBoardEnabled()) { @@ -449,7 +449,7 @@ Direction MouseTransformProcessor::GetDisplayDirection(const DisplayInfo *displa return displayDirection; } -void MouseTransformProcessor::CalculateOffset(const DisplayInfo *displayInfo, Offset &offset) +void MouseTransformProcessor::CalculateOffset(const OLD::DisplayInfo* displayInfo, Offset &offset) { #ifndef OHOS_BUILD_EMULATOR if (Rosen::SceneBoardJudgement::IsSceneBoardEnabled()) { diff --git a/service/touch_event_normalize/include/touch_transform_processor.h b/service/touch_event_normalize/include/touch_transform_processor.h index bce7e6efb489732f5708c9c214a8998ed3ed4904..dbe683734922a9ed7cb0b777375456d0a28fc0ed 100644 --- a/service/touch_event_normalize/include/touch_transform_processor.h +++ b/service/touch_event_normalize/include/touch_transform_processor.h @@ -40,7 +40,7 @@ private: int32_t GetTouchToolType(struct libinput_device *device); void TransformTouchProperties(TouchType &rawTouch, PointerEvent::PointerItem &pointerItem); void NotifyFingersenseProcess(PointerEvent::PointerItem &pointerItem, int32_t &toolType); - void UpdatePointerItemProperties(PointerEvent::PointerItem &item, EventTouch &touchInfo); + void UpdatePointerItemByTouchInfo(PointerEvent::PointerItem &item, EventTouch &touchInfo); void InitToolTypes(); bool DumpInner(); private: diff --git a/service/touch_event_normalize/src/touch_transform_processor.cpp b/service/touch_event_normalize/src/touch_transform_processor.cpp index 6fb3184e647a7191081c2631eb58a6c08a78908a..0ed7a2e61c26bb752b111c35dc1a2be3e0b84d08 100644 --- a/service/touch_event_normalize/src/touch_transform_processor.cpp +++ b/service/touch_event_normalize/src/touch_transform_processor.cpp @@ -116,7 +116,7 @@ bool TouchTransformProcessor::OnEventTouchDown(struct libinput_event *event) item.SetPointerId(seatSlot); item.SetDownTime(time); item.SetPressed(true); - UpdatePointerItemProperties(item, touchInfo); + UpdatePointerItemByTouchInfo(item, touchInfo); item.SetDeviceId(deviceId_); int32_t toolType = GetTouchToolType(touch, device); #ifdef OHOS_BUILD_ENABLE_FINGERSENSE_WRAPPER @@ -135,11 +135,13 @@ bool TouchTransformProcessor::OnEventTouchDown(struct libinput_event *event) return true; } -void TouchTransformProcessor::UpdatePointerItemProperties(PointerEvent::PointerItem &item, EventTouch &touchInfo) +void TouchTransformProcessor::UpdatePointerItemByTouchInfo(PointerEvent::PointerItem &item, EventTouch &touchInfo) { CALL_DEBUG_ENTER; item.SetDisplayX(touchInfo.point.x); item.SetDisplayY(touchInfo.point.y); + item.SetGlobalX(touchInfo.globalCoord.x); + item.SetGlobalX(touchInfo.globalCoord.y); item.SetDisplayXPos(touchInfo.coordF.x); item.SetDisplayYPos(touchInfo.coordF.y); item.SetRawDisplayX(touchInfo.point.x); @@ -221,16 +223,7 @@ bool TouchTransformProcessor::OnEventTouchMotion(struct libinput_event *event) item.SetPressure(pressure); item.SetLongAxis(longAxis); item.SetShortAxis(shortAxis); - item.SetDisplayX(touchInfo.point.x); - item.SetDisplayY(touchInfo.point.y); - item.SetDisplayXPos(touchInfo.coordF.x); - item.SetDisplayYPos(touchInfo.coordF.y); - item.SetRawDisplayX(touchInfo.point.x); - item.SetRawDisplayY(touchInfo.point.y); - item.SetToolDisplayX(touchInfo.toolRect.point.x); - item.SetToolDisplayY(touchInfo.toolRect.point.y); - item.SetToolWidth(touchInfo.toolRect.width); - item.SetToolHeight(touchInfo.toolRect.height); + UpdatePointerItemByTouchInfo(item, touchInfo); pointerEvent_->UpdatePointerItem(seatSlot, item); pointerEvent_->SetPointerId(seatSlot); pointerEvent_->ClearFlag(InputEvent::EVENT_FLAG_ACCESSIBILITY); diff --git a/service/touch_event_normalize/test/src/touch_event_normalize_test.cpp b/service/touch_event_normalize/test/src/touch_event_normalize_test.cpp index 0945fbad7622f06ee9ec21eb955200bd97114c80..d7155a3a7300f3e40f7b8dd7e9287dc94b326dd5 100644 --- a/service/touch_event_normalize/test/src/touch_event_normalize_test.cpp +++ b/service/touch_event_normalize/test/src/touch_event_normalize_test.cpp @@ -73,7 +73,7 @@ void TouchEventNormalizeTest::TearDown() /** * @tc.name: TouchTransformProcessorTest_UpdatePointerItemProperties - * @tc.desc: Test UpdatePointerItemProperties + * @tc.desc: Test UpdatePointerItemByTouchInfo * @tc.type: FUNC * @tc.require: */ @@ -90,7 +90,7 @@ HWTEST_F(TouchTransformProcessorTest, TouchTransformProcessorTest_UpdatePointerI touchInfo.toolRect.point.y = 600; touchInfo.toolRect.width = 720; touchInfo.toolRect.height = 1000; - ASSERT_NO_FATAL_FAILURE(touchTransformProcessor.UpdatePointerItemProperties(item, touchInfo)); + ASSERT_NO_FATAL_FAILURE(touchTransformProcessor.UpdatePointerItemByTouchInfo(item, touchInfo)); } /** diff --git a/service/touch_event_normalize/test/src/touch_transform_processor_test.cpp b/service/touch_event_normalize/test/src/touch_transform_processor_test.cpp index f0aed38929875fea8a1539057c46a5b4e69517b2..6dc46b8372735d5072c0f6368597695cdc43cb34 100644 --- a/service/touch_event_normalize/test/src/touch_transform_processor_test.cpp +++ b/service/touch_event_normalize/test/src/touch_transform_processor_test.cpp @@ -127,7 +127,7 @@ HWTEST_F(TouchTransformProcessorTest, OnEventTouchDown_001, TestSize.Level1) /** * @tc.name: TouchTransformProcessorTest_UpdatePointerItemProperties_001 - * @tc.desc: Test the funcation UpdatePointerItemProperties + * @tc.desc: Test the funcation UpdatePointerItemByTouchInfo * @tc.type: FUNC * @tc.require: */ @@ -143,7 +143,7 @@ HWTEST_F(TouchTransformProcessorTest, UpdatePointerItemProperties_001, TestSize. touchInfo.toolRect.height = 60; int32_t deviceId = 6; TouchTransformProcessor processor(deviceId); - processor.UpdatePointerItemProperties(item, touchInfo); + processor.UpdatePointerItemByTouchInfo(item, touchInfo); ASSERT_EQ(item.GetDisplayX(), touchInfo.point.x); ASSERT_EQ(item.GetDisplayY(), touchInfo.point.y); ASSERT_EQ(item.GetDisplayXPos(), touchInfo.point.x); diff --git a/service/window_manager/include/i_input_windows_manager.h b/service/window_manager/include/i_input_windows_manager.h index 32081a1c2ac4a9cf884d7d3df5b00ce0704e562b..1d15fa1ffc125046b9e03f89bba00113ba378da2 100644 --- a/service/window_manager/include/i_input_windows_manager.h +++ b/service/window_manager/include/i_input_windows_manager.h @@ -32,7 +32,7 @@ #include "touch_gesture_manager.h" #endif // defined(OHOS_BUILD_ENABLE_TOUCH) && defined(OHOS_BUILD_ENABLE_MONITOR) #include "uds_server.h" -#include "window_info.h" +#include "old_display_info.h" #include "shift_info.h" namespace OHOS { @@ -75,8 +75,8 @@ public: virtual void PrintEnterEventInfo(std::shared_ptr pointerEvent) = 0; #endif // OHOS_BUILD_ENABLE_POINTER || OHOS_BUILD_ENABLE_TOUCH virtual bool IsFocusedSession(int32_t session) const = 0; - virtual void UpdateDisplayInfo(DisplayGroupInfo &displayGroupInfo) = 0; - virtual void UpdateDisplayInfoExtIfNeed(DisplayGroupInfo &displayGroupInfo, bool needUpdateDisplayExt) = 0; + virtual void UpdateDisplayInfo(OLD::DisplayGroupInfo &displayGroupInfo) = 0; + virtual void UpdateDisplayInfoExtIfNeed(OLD::DisplayGroupInfo &displayGroupInfo, bool needUpdateDisplayExt) = 0; virtual void UpdateWindowInfo(const WindowGroupInfo &windowGroupInfo) = 0; virtual int32_t ClearWindowPointerStyle(int32_t pid, int32_t windowId) = 0; virtual void Dump(int32_t fd, const std::vector &args) = 0; @@ -91,7 +91,7 @@ public: virtual const std::vector GetWindowGroupInfoByDisplayIdCopy(int32_t displayId) const = 0; virtual std::pair TransformWindowXY(const WindowInfo &, double, double) const = 0; virtual void ClearTargetWindowId(int32_t pointerId) = 0; - virtual std::pair TransformDisplayXY(const DisplayInfo &info, + virtual std::pair TransformDisplayXY(const OLD::DisplayInfo &info, double logicX, double logicY) const = 0; virtual int32_t SetPixelMapData(int32_t infoId, void *pixelMap) = 0; virtual int32_t GetCurrentUserId() = 0; @@ -139,7 +139,7 @@ public: EventTouch& touchInfo, int32_t& targetDisplayId, bool isNeedClear = false) = 0; virtual bool CalculateTipPoint(struct libinput_event_tablet_tool* tip, int32_t& targetDisplayId, PhysicalCoordinate& coord) = 0; - virtual const std::shared_ptr GetDefaultDisplayInfo() const = 0; + virtual const std::shared_ptr GetDefaultDisplayInfo() const = 0; virtual void ReverseXY(int32_t &x, int32_t &y) = 0; virtual void FoldScreenRotation(std::shared_ptr pointerEvent) = 0; virtual void SendCancelEventWhenLock() = 0; @@ -148,7 +148,7 @@ public: #if defined(OHOS_BUILD_ENABLE_POINTER) || defined(OHOS_BUILD_ENABLE_TOUCH) virtual void DrawTouchGraphic(std::shared_ptr pointerEvent) = 0; virtual int32_t UpdateTargetPointer(std::shared_ptr pointerEvent) = 0; - virtual const std::shared_ptr GetPhysicalDisplay(int32_t id) const = 0; + virtual const std::shared_ptr GetPhysicalDisplay(int32_t id) const = 0; #endif // OHOS_BUILD_ENABLE_POINTER || OHOS_BUILD_ENABLE_TOUCH #if defined(OHOS_BUILD_ENABLE_POINTER) || defined(OHOS_BUILD_ENABLE_TOUCH) @@ -172,7 +172,7 @@ public: #endif // OHOS_BUILD_ENABLE_ANCO #if defined(OHOS_BUILD_ENABLE_POINTER) || defined(OHOS_BUILD_ENABLE_TOUCH) virtual int32_t ShiftAppPointerEvent(const ShiftWindowParam ¶m, bool autoGenDown) = 0; - virtual Direction GetDisplayDirection(const DisplayInfo *displayInfo) = 0; + virtual Direction GetDisplayDirection(const OLD::DisplayInfo *displayInfo) = 0; #endif // OHOS_BUILD_ENABLE_POINTER || OHOS_BUILD_ENABLE_TOUCH #if defined(OHOS_BUILD_ENABLE_TOUCH) && defined(OHOS_BUILD_ENABLE_MONITOR) virtual void AttachTouchGestureMgr(std::shared_ptr touchGestureMgr) = 0; @@ -181,7 +181,7 @@ public: #ifdef OHOS_BUILD_ENABLE_TOUCH virtual std::shared_ptr GetLastPointerEventForGesture() = 0; #endif // OHOS_BUILD_ENABLE_TOUCH - virtual std::pair CalcDrawCoordinate(const DisplayInfo& displayInfo, + virtual std::pair CalcDrawCoordinate(const OLD::DisplayInfo& displayInfo, PointerEvent::PointerItem pointerItem) = 0; virtual void SwitchTouchTracking(bool touchTracking) = 0; @@ -197,4 +197,4 @@ private: #define WIN_MGR ::OHOS::MMI::IInputWindowsManager::GetInstance() } // namespace MMI } // namespace OHOS -#endif // I_INPUT_WINDOWS_MANAGER_H +#endif // I_INPUT_WINDOWS_MANAGER_H \ No newline at end of file diff --git a/service/window_manager/include/i_pointer_drawing_manager.h b/service/window_manager/include/i_pointer_drawing_manager.h index f27123471512e55f4e483ca22a952d754990ca60..17282f2d236b24b246e22abeaa0ea6632c45f445 100644 --- a/service/window_manager/include/i_pointer_drawing_manager.h +++ b/service/window_manager/include/i_pointer_drawing_manager.h @@ -17,7 +17,7 @@ #define I_POINTER_DRAWING_MANAGER_H #include "pointer_style.h" -#include "window_info.h" +#include "old_display_info.h" #include "delegate_interface.h" namespace OHOS { @@ -28,10 +28,10 @@ public: virtual ~IPointerDrawingManager() = default; static IPointerDrawingManager* GetInstance(); - virtual void DrawPointer(int32_t displayId, int32_t physicalX, int32_t physicalY, + virtual void DrawPointer(int32_t rsId, int32_t physicalX, int32_t physicalY, const PointerStyle pointerStyle, Direction direction) {} - virtual void UpdateDisplayInfo(const DisplayInfo& displayInfo) {} - virtual void OnDisplayInfo(const DisplayGroupInfo& displayGroupInfo) {} + virtual void UpdateDisplayInfo(const OLD::DisplayInfo& displayInfo) {} + virtual void OnDisplayInfo(const OLD::DisplayGroupInfo& displayGroupInfo) {} virtual void OnWindowInfo(const WinInfo &info) {} virtual bool Init() { @@ -128,7 +128,7 @@ public: { return 0; } - virtual void DrawMovePointer(int32_t displayId, int32_t physicalX, int32_t physicalY) {} + virtual void DrawMovePointer(int32_t rsId, int32_t physicalX, int32_t physicalY) {} virtual void Dump(int32_t fd, const std::vector &args) {} virtual void InitPointerCallback() {} virtual void InitScreenInfo() {} @@ -140,7 +140,7 @@ public: { return 0; } - virtual DisplayInfo GetCurrentDisplayInfo() + virtual OLD::DisplayInfo GetCurrentDisplayInfo() { return {}; } @@ -166,7 +166,7 @@ public: virtual void DrawScreenCenterPointer(const PointerStyle &pointerStyle) {} virtual void SubscribeScreenModeChange() {} virtual int32_t UpdateMouseLayer(const PointerStyle& pointerStyle, - int32_t displayId, int32_t physicalX, int32_t physicalY) + int32_t physicalX, int32_t physicalY) { return 0; } diff --git a/service/window_manager/include/input_windows_manager.h b/service/window_manager/include/input_windows_manager.h index 8aaba17ee8db50d67c2a2eebc4cd1a245e8de563..b99f70fa0c5c7abc4855283c5b20fa4d7884a30c 100644 --- a/service/window_manager/include/input_windows_manager.h +++ b/service/window_manager/include/input_windows_manager.h @@ -68,14 +68,14 @@ public: void PrintEnterEventInfo(std::shared_ptr pointerEvent); #endif // OHOS_BUILD_ENABLE_POINTER || OHOS_BUILD_ENABLE_TOUCH bool HandleWindowInputType(const WindowInfo &window, std::shared_ptr pointerEvent); - void UpdateCaptureMode(const DisplayGroupInfo &displayGroupInfo); + void UpdateCaptureMode(const OLD::DisplayGroupInfo &displayGroupInfo); bool IsFocusedSession(int32_t session) const; - void UpdateDisplayInfo(DisplayGroupInfo &displayGroupInfo); - void UpdateDisplayInfoExtIfNeed(DisplayGroupInfo &displayGroupInfo, bool needUpdateDisplayExt); + void UpdateDisplayInfo(OLD::DisplayGroupInfo &displayGroupInfo); + void UpdateDisplayInfoExtIfNeed(OLD::DisplayGroupInfo &displayGroupInfo, bool needUpdateDisplayExt); void UpdateWindowInfo(const WindowGroupInfo &windowGroupInfo); int32_t ClearWindowPointerStyle(int32_t pid, int32_t windowId); void Dump(int32_t fd, const std::vector &args); - void DumpDisplayInfo(int32_t fd, const std::vector& displaysInfo); + void DumpDisplayInfo(int32_t fd, const std::vector& displaysInfo); int32_t GetWindowPid(int32_t windowId, const std::vector &windowsInfo) const; int32_t GetWindowPid(int32_t windowId) const; int32_t SetMouseCaptureMode(int32_t windowId, bool isCaptureMode); @@ -89,7 +89,7 @@ public: ExtraData GetExtraData() const; const std::vector GetWindowGroupInfoByDisplayIdCopy(int32_t displayId) const; std::pair TransformWindowXY(const WindowInfo &window, double logicX, double logicY) const; - std::pair TransformDisplayXY(const DisplayInfo &info, double logicX, double logicY) const; + std::pair TransformDisplayXY(const OLD::DisplayInfo &info, double logicX, double logicY) const; int32_t GetCurrentUserId(); bool GetCancelEventFlag(std::shared_ptr pointerEvent); void SetFoldState (); @@ -114,7 +114,7 @@ public: void UpdateAndAdjustMouseLocation(int32_t& displayId, double& x, double& y, bool isRealData = true); #endif // OHOS_BUILD_ENABLE_POINTER || OHOS_BUILD_ENABLE_TOUCH #ifdef OHOS_BUILD_ENABLE_POINTER - const DisplayGroupInfo GetDisplayGroupInfo(int32_t groupId = DEFAULT_GROUP_ID); + const OLD::DisplayGroupInfo GetDisplayGroupInfo(int32_t groupId = DEFAULT_GROUP_ID); int32_t SetHoverScrollState(bool state); bool GetHoverScrollState() const; bool SelectPointerChangeArea(int32_t windowId, int32_t logicalX, int32_t logicalY); @@ -138,23 +138,24 @@ public: #endif // OHOS_BUILD_ENABLE_POINTER #ifdef OHOS_BUILD_ENABLE_TOUCH - void AdjustDisplayCoordinate(const DisplayInfo& displayInfo, double& physicalX, double& physicalY) const; + void AdjustDisplayCoordinate(const OLD::DisplayInfo& displayInfo, double& physicalX, double& physicalY) const; bool TouchPointToDisplayPoint(int32_t deviceId, struct libinput_event_touch* touch, EventTouch& touchInfo, int32_t& targetDisplayId, bool isNeedClear = false); #endif // OHOS_BUILD_ENABLE_TOUCH #if defined(OHOS_BUILD_ENABLE_POINTER) || defined(OHOS_BUILD_ENABLE_TOUCH) - void ReverseRotateScreen(const DisplayInfo& info, const double x, const double y, Coordinate2D& cursorPos) const; - void ReverseRotateDisplayScreen(const DisplayInfo& info, const double x, const double y, + void ReverseRotateScreen(const OLD::DisplayInfo& info, const double x, const double y, Coordinate2D& cursorPos) const; - void ScreenRotateAdjustDisplayXY(const DisplayInfo& info, PhysicalCoordinate& coord) const; - void RotateScreen(const DisplayInfo& info, PhysicalCoordinate& coord) const; - void RotateDisplayScreen(const DisplayInfo& info, PhysicalCoordinate& coord); + void ReverseRotateDisplayScreen(const OLD::DisplayInfo& info, const double x, const double y, + Coordinate2D& cursorPos) const; + void ScreenRotateAdjustDisplayXY(const OLD::DisplayInfo& info, PhysicalCoordinate& coord) const; + void RotateScreen(const OLD::DisplayInfo& info, PhysicalCoordinate& coord) const; + void RotateDisplayScreen(const OLD::DisplayInfo& info, PhysicalCoordinate& coord); #endif // OHOS_BUILD_ENABLE_POINTER || OHOS_BUILD_ENABLE_TOUCH #ifdef OHOS_BUILD_ENABLE_TOUCH bool TransformTipPoint(struct libinput_event_tablet_tool* tip, PhysicalCoordinate& coord, int32_t& displayId); bool CalculateTipPoint(struct libinput_event_tablet_tool* tip, int32_t& targetDisplayId, PhysicalCoordinate& coord); - const std::shared_ptr GetDefaultDisplayInfo() const; + const std::shared_ptr GetDefaultDisplayInfo() const; void ReverseXY(int32_t &x, int32_t &y); #if defined(OHOS_BUILD_ENABLE_POINTER) || defined(OHOS_BUILD_ENABLE_TOUCH) void FoldScreenRotation(std::shared_ptr pointerEvent); @@ -163,10 +164,10 @@ public: #endif // OHOS_BUILD_ENABLE_TOUCH #ifdef OHOS_BUILD_ENABLE_ANCO - void UpdateWindowInfoExt(const WindowGroupInfo &windowGroupInfo, const DisplayGroupInfo &displayGroupInfo); - void UpdateOneHandDataExt(const DisplayInfo &displayInfo); + void UpdateWindowInfoExt(const WindowGroupInfo &windowGroupInfo, const OLD::DisplayGroupInfo &displayGroupInfo); + void UpdateOneHandDataExt(const OLD::DisplayInfo &displayInfo); void UpdateShellWindow(const WindowInfo &window); - void UpdateDisplayInfoExt(const DisplayGroupInfo &displayGroupInfo); + void UpdateDisplayInfoExt(const OLD::DisplayGroupInfo &displayGroupInfo); bool IsInAncoWindow(const WindowInfo &window, int32_t x, int32_t y) const; bool IsAncoWindow(const WindowInfo &window) const; bool IsAncoWindowFocus(const WindowInfo &window) const; @@ -174,7 +175,7 @@ public: void DumpAncoWindows(std::string& out) const; void CleanShellWindowIds(); bool IsKnuckleOnAncoWindow(std::shared_ptr pointerEvent); - void SendOneHandData(onst DisplayInfo &displayInfo, std::shared_ptr &pointerEvent); + void SendOneHandData(const OLD::DisplayInfo &displayInfo, std::shared_ptr &pointerEvent); bool IsAncoGameActive(); #endif // OHOS_BUILD_ENABLE_ANCO @@ -183,8 +184,8 @@ public: void DrawTouchGraphic(std::shared_ptr pointerEvent); int32_t UpdateTargetPointer(std::shared_ptr pointerEvent); #endif // OHOS_BUILD_ENABLE_POINTER || OHOS_BUILD_ENABLE_TOUCH - const std::shared_ptr GetPhysicalDisplay(int32_t id) const; - const std::shared_ptr GetPhysicalDisplay(int32_t id, const DisplayGroupInfo &displayGroupInfo) const; + const std::shared_ptr GetPhysicalDisplay(int32_t id) const; + const std::shared_ptr GetPhysicalDisplay(int32_t id, const OLD::DisplayGroupInfo &displayGroupInfo) const; #if defined(OHOS_BUILD_ENABLE_POINTER) || defined(OHOS_BUILD_ENABLE_TOUCH) void UpdatePointerChangeAreas(); @@ -209,12 +210,12 @@ public: int32_t SetPixelMapData(int32_t infoId, void *pixelMap); void CleanInvalidPiexMap(int32_t groupId = DEFAULT_GROUP_ID); - void HandleWindowPositionChange(const DisplayGroupInfo &displayGroupInfo); + void HandleWindowPositionChange(const OLD::DisplayGroupInfo &displayGroupInfo); void SendCancelEventWhenWindowChange(int32_t pointerId, int32_t groupId = DEFAULT_GROUP_ID); bool GetHardCursorEnabled(); #if defined(OHOS_BUILD_ENABLE_POINTER) || defined(OHOS_BUILD_ENABLE_TOUCH) int32_t ShiftAppPointerEvent(const ShiftWindowParam ¶m, bool autoGenDown); - Direction GetDisplayDirection(const DisplayInfo *displayInfo); + Direction GetDisplayDirection(const OLD::DisplayInfo *displayInfo); #endif // OHOS_BUILD_ENABLE_POINTER || OHOS_BUILD_ENABLE_TOUCH #if defined(OHOS_BUILD_ENABLE_TOUCH) && defined(OHOS_BUILD_ENABLE_MONITOR) void AttachTouchGestureMgr(std::shared_ptr touchGestureMgr); @@ -222,7 +223,7 @@ public: #endif // defined(OHOS_BUILD_ENABLE_TOUCH) && defined(OHOS_BUILD_ENABLE_MONITOR) #ifdef OHOS_BUILD_ENABLE_TOUCH std::shared_ptr GetLastPointerEventForGesture() { return lastPointerEventforGesture_; }; - std::pair CalcDrawCoordinate(const DisplayInfo& displayInfo, + std::pair CalcDrawCoordinate(const OLD::DisplayInfo& displayInfo, PointerEvent::PointerItem pointerItem); #endif // OHOS_BUILD_ENABLE_TOUCH void SwitchTouchTracking(bool touchTracking); @@ -242,19 +243,19 @@ private: int32_t targetWindowId, int32_t logicalX, int32_t logicalY); void PrintZorderInfo(const WindowInfo &windowInfo, std::string &window); void PrintWindowInfo(const std::vector &windowsInfo); - void PrintDisplayGroupInfo(const DisplayGroupInfo displayGroupInfo); - void PrintDisplayInfo(const DisplayInfo displayInfo); + void PrintDisplayGroupInfo(const OLD::DisplayGroupInfo displayGroupInfo); + void PrintDisplayInfo(const OLD::DisplayInfo displayInfo); void PrintWindowGroupInfo(const WindowGroupInfo &windowGroupInfo); void PrintWindowNavbar(int32_t groupId = DEFAULT_GROUP_ID); - void CheckFocusWindowChange(const DisplayGroupInfo &displayGroupInfo); + void CheckFocusWindowChange(const OLD::DisplayGroupInfo &displayGroupInfo); void CheckZorderWindowChange(const std::vector &oldWindowsInfo, const std::vector &newWindowsInfo); void UpdateDisplayIdAndName(); void UpdateCustomStyle(int32_t windowId, PointerStyle pointerStyle); void UpdatePointerAction(std::shared_ptr pointerEvent); bool IsNeedDrawPointer(PointerEvent::PointerItem &pointerItem) const; - void UpdateDisplayInfoByIncrementalInfo(const WindowInfo &window, DisplayGroupInfo &displayGroupInfo); - void UpdateWindowsInfoPerDisplay(const DisplayGroupInfo &displayGroupInfo); + void UpdateDisplayInfoByIncrementalInfo(const WindowInfo &window, OLD::DisplayGroupInfo &displayGroupInfo); + void UpdateWindowsInfoPerDisplay(const OLD::DisplayGroupInfo &displayGroupInfo); std::pair TransformSampleWindowXY(int32_t logicX, int32_t logicY) const; bool IsValidZorderWindow(const WindowInfo &window, const std::shared_ptr& pointerEvent); bool SkipPrivacyProtectionWindow(const std::shared_ptr& pointerEvent, const bool &isSkip); @@ -266,12 +267,12 @@ private: void UpdateInnerAngleArea(const Rect &windowArea, std::vector &pointerChangeAreas, std::vector &windowHotAreas); void CoordinateCorrection(int32_t width, int32_t height, int32_t &integerX, int32_t &integerY); - void GetWidthAndHeight(const DisplayInfo* displayInfo, int32_t &width, int32_t &height, bool isRealData = true); + void GetWidthAndHeight(const OLD::DisplayInfo* displayInfo, int32_t &width, int32_t &height, bool isRealData = true); void UpdateCurrentDisplay(int32_t displayId) const; #endif // OHOS_BUILD_ENABLE_POINTER || OHOS_BUILD_ENABLE_TOUCH void SetPrivacyModeFlag(SecureFlag privacyMode, std::shared_ptr event); void PrintChangedWindowByEvent(int32_t eventType, const WindowInfo &newWindowInfo); - void PrintChangedWindowBySync(const DisplayGroupInfo &newDisplayInfo); + void PrintChangedWindowBySync(const OLD::DisplayGroupInfo &newDisplayInfo); bool IsMouseDrawing(int32_t currentAction); bool ParseConfig(); bool ParseJson(const std::string &configFile); @@ -282,7 +283,7 @@ private: std::shared_ptr pointerEvent); #endif // OHOS_BUILD_ENABLE_POINTER || OHOS_BUILD_ENABLE_TOUCH #ifdef OHOS_BUILD_ENABLE_POINTER - std::vector HandleHardwareCursor(std::shared_ptr &physicalDisplayInfo, + std::vector HandleHardwareCursor(std::shared_ptr &physicalDisplayInfo, int32_t physicalX, int32_t physicalY); int32_t UpdateMouseTarget(std::shared_ptr pointerEvent); void UpdatePointerEvent(int32_t logicalX, int32_t logicalY, @@ -291,7 +292,7 @@ private: void OnSessionLost(SessionPtr session); void InitPointerStyle(int32_t groupId = DEFAULT_GROUP_ID); const std::vector& GetWindowGroupInfoByDisplayId(int32_t displayId) const; - const std::vector& GetDisplayInfoVector(int32_t groupId = DEFAULT_GROUP_ID) const; + const std::vector& GetDisplayInfoVector(int32_t groupId = DEFAULT_GROUP_ID) const; const std::vector& GetWindowInfoVector(int32_t groupId = DEFAULT_GROUP_ID) const; int32_t GetFocusWindowId(int32_t groupId = DEFAULT_GROUP_ID) const; int32_t GetLogicalPositionX(int32_t id); @@ -313,19 +314,20 @@ private: void CheckUIExtentionWindowPointerHotArea(int32_t logicalX, int32_t logicalY, const std::vector& windowInfos, int32_t& windowId); std::optional GetWindowInfo(int32_t logicalX, int32_t logicalY, int32_t groupId = DEFAULT_GROUP_ID); - bool IsInsideDisplay(const DisplayInfo& displayInfo, double physicalX, double physicalY); - bool CalculateLayout(const DisplayInfo& displayInfo, const Vector2D &physical, Vector2D& layout); - void FindPhysicalDisplay(const DisplayInfo& displayInfo, double& physicalX, + bool IsInsideDisplay(const OLD::DisplayInfo& displayInfo, double physicalX, double physicalY); + bool CalculateLayout(const OLD::DisplayInfo& displayInfo, const Vector2D &physical, + Vector2D& layout); + void FindPhysicalDisplay(const OLD::DisplayInfo& displayInfo, double& physicalX, double& physicalY, int32_t& displayId); - bool AcrossDisplay(const DisplayInfo &displayInfoDes, const DisplayInfo &displayInfoOri, Vector2D &logical, - Vector2D &layout, const AcrossDirection &acrossDirection); - AcrossDirection CalculateAcrossDirection(const DisplayInfo &displayInfo, const Vector2D &layout); + bool AcrossDisplay(const OLD::DisplayInfo &displayInfoDes, const OLD::DisplayInfo &displayInfoOri, + Vector2D &logical, Vector2D &layout, const AcrossDirection &acrossDirection); + AcrossDirection CalculateAcrossDirection(const OLD::DisplayInfo &displayInfo, const Vector2D &layout); #endif // OHOS_BUILD_ENABLE_POINTER || OHOS_BUILD_ENABLE_TOUCH #if defined(OHOS_BUILD_ENABLE_POINTER) || defined(OHOS_BUILD_ENABLE_TOUCH) void InitMouseDownInfo(); bool SelectPointerChangeArea(const WindowInfo &windowInfo, PointerStyle &pointerStyle, int32_t logicalX, int32_t logicalY); - void UpdatePointerChangeAreas(const DisplayGroupInfo &displayGroupInfo); + void UpdatePointerChangeAreas(const OLD::DisplayGroupInfo &displayGroupInfo); #ifdef OHOS_BUILD_ENABLE_POINTER_DRAWING void AdjustDisplayRotation(int32_t groupId = DEFAULT_GROUP_ID); void SetPointerEvent(int32_t pointerAction, std::shared_ptr pointerEvent); @@ -335,17 +337,18 @@ private: #endif // OHOS_BUILD_ENABLE_POINTER || OHOS_BUILD_ENABLE_TOUCH #if defined(OHOS_BUILD_ENABLE_POINTER) && defined(OHOS_BUILD_ENABLE_POINTER_DRAWING) -void PointerDrawingManagerOnDisplayInfo(const DisplayGroupInfo &displayGroupInfo, bool isDisplayRemoved = false); -void DrawPointer(bool isDisplayRemoved); -bool NeedUpdatePointDrawFlag(const std::vector &windows); + void PointerDrawingManagerOnDisplayInfo(const OLD::DisplayGroupInfo &displayGroupInfo, + bool isDisplayRemoved = false); + void DrawPointer(bool isDisplayRemoved); + bool NeedUpdatePointDrawFlag(const std::vector &windows); #endif // OHOS_BUILD_ENABLE_POINTER && OHOS_BUILD_ENABLE_POINTER_DRAWING - void UpdateFixedXY(const DisplayInfo& displayInfo, std::shared_ptr &pointerEvent); + void UpdateFixedXY(const OLD::DisplayInfo& displayInfo, std::shared_ptr &pointerEvent); #ifdef OHOS_BUILD_ENABLE_ONE_HAND_MODE -void UpdatePointerItemInOneHandMode(const DisplayInfo &displayInfo, std::shared_ptr &pointerEvent); -void UpdateDisplayXYInOneHandMode(double& physicalX, double& physicalY, const DisplayInfo &displayInfo, +void UpdatePointerItemInOneHandMode(const OLD::DisplayInfo &displayInfo, std::shared_ptr &pointerEvent); +void UpdateDisplayXYInOneHandMode(double& physicalX, double& physicalY, const OLD::DisplayInfo &displayInfo, float oneHandScale); -void HandleOneHandMode(const DisplayInfo &displayInfo, std::shared_ptr &pointerEvent, +void HandleOneHandMode(const OLD::DisplayInfo &displayInfo, std::shared_ptr &pointerEvent, PointerEvent::PointerItem &pointerItem); #endif // OHOS_BUILD_ENABLE_ONE_HAND_MODE @@ -363,16 +366,16 @@ void HandleOneHandMode(const DisplayInfo &displayInfo, std::shared_ptr pointerEvent); void UpdateTransformDisplayXY(std::shared_ptr pointerEvent, - const std::vector& windowsInfo, const DisplayInfo& displayInfo); + const std::vector& windowsInfo, const OLD::DisplayInfo& displayInfo); void HandlePullEvent(std::shared_ptr pointerEvent); #endif // OHOS_BUILD_ENABLE_POINTER || OHOS_BUILD_ENABLE_TOUCH #ifdef OHOS_BUILD_ENABLE_TOUCH void PullEnterLeaveEvent(int32_t logicalX, int32_t logicalY, const std::shared_ptr pointerEvent, const WindowInfo* touchWindow); void DispatchTouch(int32_t pointerAction, int32_t groupId = DEFAULT_GROUP_ID); - const std::shared_ptr FindPhysicalDisplayInfo(const std::string& uniq) const; + const std::shared_ptr FindPhysicalDisplayInfo(const std::string& uniq) const; bool GetPhysicalDisplayCoord(struct libinput_event_touch* touch, - const DisplayInfo& info, EventTouch& touchInfo, bool isNeedClear = false); + const OLD::DisplayInfo& info, EventTouch& touchInfo, bool isNeedClear = false); void TriggerTouchUpOnInvalidAreaEntry(int32_t pointerId); void SetAntiMisTake(bool state); void SetAntiMisTakeStatus(bool state); @@ -406,46 +409,48 @@ void HandleOneHandMode(const DisplayInfo &displayInfo, std::shared_ptr pointerEvent); #endif // OHOS_BUILD_ENABLE_POINTER && OHOS_BUILD_ENABLE_CROWN void UpdateDisplayMode(int32_t groupId = DEFAULT_GROUP_ID); - void HandleValidDisplayChange(const DisplayGroupInfo &displayGroupInfo); - void ResetPointerPositionIfOutValidDisplay(const DisplayGroupInfo &displayGroupInfo); + void HandleValidDisplayChange(const OLD::DisplayGroupInfo &displayGroupInfo); + void ResetPointerPositionIfOutValidDisplay(const OLD::DisplayGroupInfo &displayGroupInfo); void CancelMouseEvent(); bool IsPositionOutValidDisplay( - Coordinate2D &position, const DisplayInfo ¤tDisplay, bool isPhysicalPos = false); - void CancelTouchScreenEventIfValidDisplayChange(const DisplayGroupInfo &displayGroupInfo); - bool IsValidDisplayChange(const DisplayInfo &displayInfo); + Coordinate2D &position, const OLD::DisplayInfo ¤tDisplay, bool isPhysicalPos = false); + void CancelTouchScreenEventIfValidDisplayChange(const OLD::DisplayGroupInfo &displayGroupInfo); + bool IsValidDisplayChange(const OLD::DisplayInfo &displayInfo); void UpdateKeyEventDisplayId(std::shared_ptr keyEvent, int32_t focusWindowId, int32_t groupId = DEFAULT_GROUP_ID); - bool OnDisplayRemovedOrCombinationChanged(const DisplayGroupInfo &displayGroupInfo); + bool OnDisplayRemovedOrCombinationChanged(const OLD::DisplayGroupInfo &displayGroupInfo); void ChangeWindowArea(int32_t x, int32_t y, WindowInfo &windowInfo); - void ResetPointerPosition(const DisplayGroupInfo &displayGroupInfo); - int32_t GetMainScreenDisplayInfo(const std::vector &displaysInfo, - DisplayInfo &mainScreenDisplayInfo) const; - bool IsPointerOnCenter(const CursorPosition ¤tPos, const DisplayInfo ¤tDisplay); + void ResetPointerPosition(const OLD::DisplayGroupInfo &displayGroupInfo); + int32_t GetMainScreenDisplayInfo(const std::vector &displaysInfo, + OLD::DisplayInfo &mainScreenDisplayInfo) const; + bool IsPointerOnCenter(const CursorPosition ¤tPos, const OLD::DisplayInfo ¤tDisplay); void SendBackCenterPointerEevent(const CursorPosition &cursorPos); - WINDOW_UPDATE_ACTION UpdateWindowInfo(DisplayGroupInfo &displayGroupInfo); + WINDOW_UPDATE_ACTION UpdateWindowInfo(OLD::DisplayGroupInfo &displayGroupInfo); #if defined(OHOS_BUILD_ENABLE_POINTER) || defined(OHOS_BUILD_ENABLE_TOUCH) std::optional GetWindowInfoById(int32_t windowId) const; int32_t ShiftAppMousePointerEvent(const ShiftWindowInfo &shiftWindowInfo, bool autoGenDown); int32_t ShiftAppTouchPointerEvent(const ShiftWindowInfo &shiftWindowInfo); - int32_t ShiftAppSimulateTouchPointerEvent(const ShiftWindowInfo &shiftWindowInfo); - CursorPosition GetCursorPos(const DisplayGroupInfo &displayGroupInfo); - CursorPosition ResetCursorPos(const DisplayGroupInfo &displayGroupInfo); + CursorPosition GetCursorPos(const OLD::DisplayGroupInfo &displayGroupInfo); + CursorPosition ResetCursorPos(const OLD::DisplayGroupInfo &displayGroupInfo); #endif // OHOS_BUILD_ENABLE_POINTER || OHOS_BUILD_ENABLE_TOUCH #if defined(OHOS_BUILD_ENABLE_TOUCH) && defined(OHOS_BUILD_ENABLE_MONITOR) bool CancelTouch(int32_t touch); #endif // defined(OHOS_BUILD_ENABLE_TOUCH) && defined(OHOS_BUILD_ENABLE_MONITOR) #ifdef OHOS_BUILD_ENABLE_VKEYBOARD - bool IsPointerActiveRectValid(const DisplayInfo ¤tDisplay); + bool IsPointerActiveRectValid(const OLD::DisplayInfo ¤tDisplay); #endif // OHOS_BUILD_ENABLE_VKEYBOARD bool IsAccessibilityFocusEvent(std::shared_ptr pointerEvent); bool IsAccessibilityEventWithZorderInjected(std::shared_ptr pointerEvent); private: - DisplayGroupInfo& FindTargetDisplayGroupInfo(int32_t displayId); + OLD::DisplayGroupInfo& FindTargetDisplayGroupInfo(int32_t displayId); int32_t FindDisplayGroupId(int32_t displayId) const; - DisplayGroupInfo& GetMainDisplayGroupInfo(); - const DisplayGroupInfo& GetConstMainDisplayGroupInfo() const; - const DisplayGroupInfo& FindDisplayGroupInfo(int32_t displayId) const; - void RotateScreen90(const DisplayInfo& info, PhysicalCoordinate& coord) const; - void InitDisplayGroupInfo(DisplayGroupInfo &displayGroupInfo); + OLD::DisplayGroupInfo& GetDefaultDisplayGroupInfo(); + const OLD::DisplayGroupInfo& GetConstMainDisplayGroupInfo() const; + void RotateScreen90(const OLD::DisplayInfo& info, PhysicalCoordinate& coord) const; + void RotateScreen0(const OLD::DisplayInfo& info, PhysicalCoordinate& coord) const; + void InitDisplayGroupInfo(OLD::DisplayGroupInfo &displayGroupInfo); + void SetPointerLocation(const OLD::DisplayInfo& displayInfo, const PhysicalCoordinate& coord, + int32_t groupId) const; + void ProcessInjectEventGlobalXY(std::shared_ptr pointerEvent); private: UDSServer* udsServer_ { nullptr }; #if defined(OHOS_BUILD_ENABLE_POINTER) || defined(OHOS_BUILD_ENABLE_TOUCH) @@ -473,13 +478,13 @@ private: #if defined(OHOS_BUILD_ENABLE_TOUCH) && defined(OHOS_BUILD_ENABLE_MONITOR) std::weak_ptr touchGestureMgr_; #endif // defined(OHOS_BUILD_ENABLE_TOUCH) && defined(OHOS_BUILD_ENABLE_MONITOR) - std::map displayGroupInfoMap_; - std::map displayGroupInfoMapTmp_; + std::map displayGroupInfoMap_; + std::map displayGroupInfoMapTmp_; bool mainGroupExisted_; - DisplayGroupInfo displayGroupInfoTmp_; + OLD::DisplayGroupInfo displayGroupInfoTmp_; std::mutex tmpInfoMutex_; - DisplayGroupInfo displayGroupInfo_; - DisplayGroupInfo displayGroupInfoCurr_; + OLD::DisplayGroupInfo displayGroupInfo_; + OLD::DisplayGroupInfo displayGroupInfoCurr_; std::map windowsPerDisplay_; std::map> windowsPerDisplayMap_; PointerStyle lastPointerStyle_; @@ -562,4 +567,4 @@ private: }; } // namespace MMI } // namespace OHOS -#endif // INPUT_WINDOWS_MANAGER_H +#endif // INPUT_WINDOWS_MANAGER_H \ No newline at end of file diff --git a/service/window_manager/include/knuckle_drawing_manager.h b/service/window_manager/include/knuckle_drawing_manager.h index 64ca9b06ea706560d458a5f5a62d544bfafd4ccb..4b2ccfb9285a49ffe4915490319394ef14e94944 100644 --- a/service/window_manager/include/knuckle_drawing_manager.h +++ b/service/window_manager/include/knuckle_drawing_manager.h @@ -21,7 +21,7 @@ #include "ui/rs_surface_node.h" #include "pointer_event.h" -#include "window_info.h" +#include "old_display_info.h" namespace OHOS { namespace MMI { @@ -37,16 +37,16 @@ struct ScreenReadState { class KnuckleDrawingManager { public: - void KnuckleDrawHandler(std::shared_ptr touchEvent, int32_t displayId = -1); - void UpdateDisplayInfo(const DisplayInfo& displayInfo); + void KnuckleDrawHandler(std::shared_ptr touchEvent, int32_t rsId = -1); + void UpdateDisplayInfo(const OLD::DisplayInfo& displayInfo); KnuckleDrawingManager(); ~KnuckleDrawingManager() = default; - void RotationCanvasNode(std::shared_ptr canvasNode, const DisplayInfo& displayInfo); + void RotationCanvasNode(std::shared_ptr canvasNode, const OLD::DisplayInfo& displayInfo); std::string GetScreenReadState(); void SetMultiWindowScreenId(uint64_t screenId, uint64_t displayNodeScreenId); private: bool IsValidAction(int32_t action); - void CreateTouchWindow(int32_t displayId); + void CreateTouchWindow(int32_t rsId); void StartTouchDraw(std::shared_ptr touchEvent); int32_t DrawGraphic(std::shared_ptr touchEvent); int32_t GetPointerPos(std::shared_ptr touchEvent); @@ -87,7 +87,7 @@ private: std::vector pointerInfos_; Rosen::Drawing::Paint paint_; Rosen::Drawing::Path path_; - DisplayInfo displayInfo_ {}; + OLD::DisplayInfo displayInfo_ {}; uint64_t screenId_ { 0 }; bool isActionUp_ { false }; bool isNeedInitParticleEmitter_ { true }; diff --git a/service/window_manager/include/knuckle_dynamic_drawing_manager.h b/service/window_manager/include/knuckle_dynamic_drawing_manager.h index 1e7c12425cd5f85636035e4fe6535a6c7da7eb44..d99974b3a3421c7e822194ec0617c8fb57ee1e29 100644 --- a/service/window_manager/include/knuckle_dynamic_drawing_manager.h +++ b/service/window_manager/include/knuckle_dynamic_drawing_manager.h @@ -28,12 +28,12 @@ public: KnuckleDynamicDrawingManager(); ~KnuckleDynamicDrawingManager() = default; void KnuckleDynamicDrawHandler(std::shared_ptr pointerEvent, int32_t displayId = -1); - void UpdateDisplayInfo(const DisplayInfo& displayInfo); + void UpdateDisplayInfo(const OLD::DisplayInfo& displayInfo); void SetKnuckleDrawingManager(std::shared_ptr knuckleDrawMgr); private: void StartTouchDraw(std::shared_ptr pointerEvent); - void CreateTouchWindow(const int32_t displayId); + void CreateTouchWindow(const int32_t rsId); void CreateCanvasNode(); int32_t DrawGraphic(std::shared_ptr pointerEvent); @@ -50,7 +50,7 @@ private: private: std::shared_ptr surfaceNode_ { nullptr }; std::shared_ptr canvasNode_ { nullptr }; - DisplayInfo displayInfo_ {}; + OLD::DisplayInfo displayInfo_ {}; uint64_t screenId_ { 0 }; Rosen::Drawing::Brush brush_; Rosen::Drawing::Pen pen_; diff --git a/service/window_manager/include/old_display_info.h b/service/window_manager/include/old_display_info.h new file mode 100644 index 0000000000000000000000000000000000000000..379762bd22fe49cdcbd282c90dbc8c78e6f4261d --- /dev/null +++ b/service/window_manager/include/old_display_info.h @@ -0,0 +1,248 @@ +/* + * Copyright (c) 2025 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 OLD_DISPLAY_INFO_H +#define OLD_DISPLAY_INFO_H +#include "window_info.h" +namespace OHOS { +namespace MMI { +namespace OLD { +struct DisplayInfo { + /** + * Unique ID of the physical display + * + * @since 9 + */ + int32_t id; + + /** + * X coordinate of the upper left corner on the logical screen + * + * @since 9 + */ + int32_t x; + + /** + * Y coordinate of the upper left corner on the logical screen + * + * @since 9 + */ + int32_t y; + + /** + * Display width, which is the logical width of the original screen when the rotation angle is 0. + * The value remains unchanged even if the display screen is rotated. + * + * @since 9 + */ + int32_t width; + + /** + * Display height, which is the logical height of the original screen when the rotation angle is 0. + * The value remains unchanged even if the display screen is rotated. + * + * @since 9 + */ + int32_t height; + + /** + * Pixel density, which indicates the number of pixels in an inch + * + * @since 10 + */ + int32_t dpi; + + /** + * Name of the physical display, which is used for debugging + * + * @since 9 + */ + std::string name; + + /** + * Unique screen ID, which is used to associate the corresponding touchscreen. The default value is default0. + * + * @since 9 + */ + std::string uniq; + + /** + * Orientation of the physical display + * + * @since 9 + */ + OHOS::MMI::Direction direction; + + OHOS::MMI::Direction displayDirection; + + /** + * DisplayMode of the display + * + * @since 9 + */ + OHOS::MMI::DisplayMode displayMode { OHOS::MMI::DisplayMode::UNKNOWN }; + + /** + * Number of transform in the screen which is used to calculate the display x and display y by logic x and logic y. + * The value must be POINTER_CHANGEAREA_COUNT. + * + * @since 12 + */ + std::vector transform; + + /** + * Orientation of the physical display + * + * @since 12 + */ + int32_t offsetX = 0; + int32_t offsetY = 0; + float ppi; + + /** + * Scale percent of oneHand rect to display rect. + * If 'scalePercent < 100', it means one hand mode. + * If 'scalePercent == 100', it means not in one hand mode. + */ + int32_t scalePercent = 100; + /** + * Expand height from bottom. + */ + int32_t expandHeight = 0; + /** + * Use for off screen policy + * + * @since 12 + */ + bool isCurrentOffScreenRendering = false; + int32_t screenRealWidth = 0; + int32_t screenRealHeight = 0; + int32_t screenRealDPI = 0; + /** + * logical screen mode + * + * @since 12 20 + */ + OHOS::MMI::DisplaySourceMode displaySourceMode = OHOS::MMI::DisplaySourceMode::SCREEN_MAIN; + /** + * Coordinate of the upper left corner of the virtual screen in one-hand mode. + * If oneHandX is 0, the virtual screen is in the lower left corner. + * If oneHandX is greater than 0, the virtual screen is in the lower right corner. + */ + int32_t oneHandX = 0; + int32_t oneHandY = 0; + + /** + * Width of the effective area of the screen. When the screen is rotated, the value changes accordingly. + * + * @since 12 + */ + int32_t validWidth = 0; + + /** + * Height of the effective area of the screen. When the screen is rotated, the value changes accordingly. + * + * @since 12 + */ + int32_t validHeight = 0; + + /** + * Rotation angle of the TP patch offset correction. + * + * @since 12 + */ + OHOS::MMI::Direction fixedDirection; + + /** + * The physical width of the screen, in millimeters. + * + * @since 12 + */ + int32_t physicalWidth { 0 }; + + /** + * The physical height of the screen, in millimeters. + * + * @since 12 + */ + int32_t physicalHeight { 0 }; + + /** + * The Pointer Active Width + * + * @since 18 + */ + int32_t pointerActiveWidth { 0 }; + + /** + * The Pointer Active Height + * + * @since 18 + */ + int32_t pointerActiveHeight { 0 }; + + /** Unique ID of the physical display + * + * @since 18 + */ + int32_t rsId { 0 }; +}; + +struct DisplayGroupInfo { + /** + * index of group. default=-1 + * + * @since 19 + */ + int32_t groupId { DEFAULT_GROUP_ID }; + /** + * Logical screen group type + * + * @since 20 + */ + OHOS::MMI::GroupType type; + /** + * The main logical screen ID. The logical screen with this ID must be in the displaysInfo. + * + * @since 20 + */ + int32_t mainDisplayId; + + /** + * ID of the focus window + * + * @since 9 + */ + int32_t focusWindowId; + + int32_t currentUserId { -1 }; + + /** + * List of window information of the logical display arranged in Z order, with the top window at the top + * + * @since 9 + */ + std::vector windowsInfo; + + /** + * Physical screen information list + * + * @since 9 + */ + std::vector displaysInfo; +}; +} // namespace OLD +} // namespace MMI +} // namespace OHOS +#endif // DISPLAY_INFO_H \ No newline at end of file diff --git a/service/window_manager/include/pointer_drawing_manager.h b/service/window_manager/include/pointer_drawing_manager.h index a42178dd0c428a28945964865d8f033b3909c72c..847c139317ddc5899a7d1d23094df17cea36d9af 100644 --- a/service/window_manager/include/pointer_drawing_manager.h +++ b/service/window_manager/include/pointer_drawing_manager.h @@ -73,10 +73,10 @@ public: PointerDrawingManager(); DISALLOW_COPY_AND_MOVE(PointerDrawingManager); ~PointerDrawingManager(); - void DrawPointer(int32_t displayId, int32_t physicalX, int32_t physicalY, + void DrawPointer(int32_t rsId, int32_t physicalX, int32_t physicalY, const PointerStyle pointerStyle, Direction direction) override; - void UpdateDisplayInfo(const DisplayInfo& displayInfo) override; - void OnDisplayInfo(const DisplayGroupInfo& displayGroupInfo) override; + void UpdateDisplayInfo(const OLD::DisplayInfo& displayInfo) override; + void OnDisplayInfo(const OLD::DisplayGroupInfo& displayGroupInfo) override; void OnWindowInfo(const WinInfo &info) override; void UpdatePointerDevice(bool hasPointerDevice, bool isPointerVisible, bool isHotPlug) override; bool Init() override; @@ -111,14 +111,14 @@ public: bool HasMagicCursor(); int32_t DrawCursor(const MOUSE_ICON mouseStyle); int32_t SwitchPointerStyle() override; - void DrawMovePointer(int32_t displayId, int32_t physicalX, int32_t physicalY) override; - std::vector> GetDisplayInfo(DisplayInfo &di); + void DrawMovePointer(int32_t rsId, int32_t physicalX, int32_t physicalY) override; + std::vector> GetDisplayInfo(OLD::DisplayInfo &di); void Dump(int32_t fd, const std::vector &args) override; void AttachToDisplay(); int32_t EnableHardwareCursorStats(int32_t pid, bool enable) override; int32_t GetHardwareCursorStats(int32_t pid, uint32_t &frameCount, uint32_t &vsyncCount) override; void SubscribeScreenModeChange() override; - DisplayInfo GetCurrentDisplayInfo() override; + OLD::DisplayInfo GetCurrentDisplayInfo() override; #ifdef OHOS_BUILD_ENABLE_MAGICCURSOR int32_t GetPointerSnapshot(void *pixelMapPtr) override; #endif // OHOS_BUILD_ENABLE_MAGICCURSOR @@ -138,7 +138,7 @@ public: void DrawScreenCenterPointer(const PointerStyle& pointerStyle) override; void OnScreenModeChange(const std::vector> &screens); int32_t UpdateMouseLayer(const PointerStyle& pointerStyle, - int32_t displayId, int32_t physicalX, int32_t physicalY) override; + int32_t physicalX, int32_t physicalY) override; private: struct PixelMapInfo { @@ -151,9 +151,9 @@ private: void GetPreferenceKey(std::string &name); void DrawLoadingPointerStyle(const MOUSE_ICON mouseStyle); void DrawRunningPointerAnimate(const MOUSE_ICON mouseStyle); - void CreatePointerWindow(int32_t displayId, int32_t physicalX, int32_t physicalY, Direction direction); - int32_t CreatePointerWindowForScreenPointer(int32_t displayId, int32_t physicalX, int32_t physicalY); - int32_t CreatePointerWindowForNoScreenPointer(int32_t displayId, int32_t physicalX, int32_t physicalY); + void CreatePointerWindow(int32_t rsId, int32_t physicalX, int32_t physicalY, Direction direction); + int32_t CreatePointerWindowForScreenPointer(int32_t rsId, int32_t physicalX, int32_t physicalY); + int32_t CreatePointerWindowForNoScreenPointer(int32_t physicalX, int32_t physicalY); sptr GetLayer(); sptr GetSurfaceBuffer(sptr layer); sptr RetryGetSurfaceBuffer(sptr layer); @@ -183,8 +183,8 @@ private: int32_t CreatePointerSwitchObserver(isMagicCursor& item); void UpdateStyleOptions(); int32_t GetIndependentPixels(); - bool IsWindowRotation(const DisplayInfo *displayInfo); - Direction GetDisplayDirection(const DisplayInfo *displayInfo); + bool IsWindowRotation(const OLD::DisplayInfo *displayInfo); + Direction GetDisplayDirection(const OLD::DisplayInfo *displayInfo); bool CheckPointerStyleParam(int32_t windowId, PointerStyle pointerStyle); std::map& GetMouseIcons(); void UpdateIconPath(const MOUSE_ICON mouseStyle, std::string iconPath); @@ -201,8 +201,8 @@ private: void ForceClearPointerVisiableStatus() override; int32_t UpdateSurfaceNodeBounds(int32_t physicalX, int32_t physicalY); void CreateCanvasNode(); - bool SetCursorLocation(int32_t displayId, int32_t physicalX, int32_t physicalY, ICON_TYPE iconType); - void SetHardwareCursorPosition(int32_t displayId, int32_t physicalX, int32_t physicalY, + bool SetCursorLocation(int32_t physicalX, int32_t physicalY, ICON_TYPE iconType); + void SetHardwareCursorPosition(int32_t physicalX, int32_t physicalY, PointerStyle pointerStyle); std::shared_ptr GetUserIconCopy(); ICON_TYPE MouseIcon2IconType(MOUSE_ICON m); @@ -219,7 +219,7 @@ private: void PostMoveRetryTask(std::function task); int32_t FlushBuffer(); int32_t GetSurfaceInformation(); - void UpdateBindDisplayId(int32_t displayId); + void UpdateBindDisplayId(int32_t rsId); void PostTaskRSLocation(int32_t physicalX, int32_t physicalY, std::shared_ptr surfaceNode); int32_t InitVsync(MOUSE_ICON mouseStyle); void DumpScreenInfo(std::ostringstream& oss); @@ -236,13 +236,13 @@ private: void ResetMoveRetryTimer(); int32_t HardwareCursorMove(int32_t x, int32_t y, ICON_TYPE align); void HideHardwareCursors(); - int32_t GetMainScreenDisplayInfo(const DisplayGroupInfo &displayGroupInfo, - DisplayInfo &mainScreenDisplayInfo) const; + int32_t GetMainScreenDisplayInfo(const OLD::DisplayGroupInfo &displayGroupInfo, + OLD::DisplayInfo &mainScreenDisplayInfo) const; int32_t DrawDynamicHardwareCursor(std::shared_ptr sp, const RenderConfig &cfg); int32_t DrawDynamicSoftCursor(std::shared_ptr sn, const RenderConfig &cfg); void HardwareCursorDynamicRender(MOUSE_ICON mouseStyle); void SoftwareCursorDynamicRender(MOUSE_ICON mouseStyle); - void UpdateMirrorScreens(std::shared_ptr sp, DisplayInfo displayInfo); + void UpdateMirrorScreens(std::shared_ptr sp, OLD::DisplayInfo displayInfo); void AttachAllSurfaceNode() override; void DetachAllSurfaceNode() override; int32_t CheckHwcReady() override; @@ -257,7 +257,7 @@ private: bool visible { false }; }; bool hasDisplay_ { false }; - DisplayInfo displayInfo_ {}; + OLD::DisplayInfo displayInfo_ {}; bool hasPointerDevice_ { false }; int32_t lastPhysicalX_ { -1 }; int32_t lastPhysicalY_ { -1 }; diff --git a/service/window_manager/include/screen_pointer.h b/service/window_manager/include/screen_pointer.h index 948b2cb18ca1426553dd86242ff70053d73da900..27ea372f6635224975af4665f9e658811aa4775f 100644 --- a/service/window_manager/include/screen_pointer.h +++ b/service/window_manager/include/screen_pointer.h @@ -20,7 +20,7 @@ #include "hardware_cursor_pointer_manager.h" #include "pointer_renderer.h" -#include "window_info.h" +#include "old_display_info.h" namespace OHOS::MMI { using hwcmgr_ptr_t = std::shared_ptr; @@ -36,7 +36,7 @@ uint32_t GetScreenInfoHeight(const screen_info_ptr_t); class ScreenPointer final { public: DISALLOW_COPY_AND_MOVE(ScreenPointer); - ScreenPointer(hwcmgr_ptr_t hwcmgr, handler_ptr_t handler, const DisplayInfo &di); + ScreenPointer(hwcmgr_ptr_t hwcmgr, handler_ptr_t handler, const OLD::DisplayInfo &di); ScreenPointer(hwcmgr_ptr_t hwcmgr, handler_ptr_t handler, screen_info_ptr_t si); ~ScreenPointer() = default; @@ -44,7 +44,7 @@ public: bool InitSurface(); void UpdateScreenInfo(screen_info_ptr_t si); bool UpdatePadding(uint32_t mainWidth, uint32_t mainHeight); - void OnDisplayInfo(const DisplayInfo &di, bool isWindowRotation); + void OnDisplayInfo(const OLD::DisplayInfo &di, bool isWindowRotation); buffer_ptr_t GetDefaultBuffer(); buffer_ptr_t GetTransparentBuffer(); diff --git a/service/window_manager/include/touch_drawing_manager.h b/service/window_manager/include/touch_drawing_manager.h index 0729a9f7a9fe8414ca4c0e93c3638acfbc3d6dc9..556131a3257d455f87771e2a5041341c74cf6161 100644 --- a/service/window_manager/include/touch_drawing_manager.h +++ b/service/window_manager/include/touch_drawing_manager.h @@ -32,7 +32,7 @@ #endif // USE_ROSEN_DRAWING #include "pointer_event.h" -#include "window_info.h" +#include "old_display_info.h" namespace OHOS { namespace MMI { @@ -61,7 +61,7 @@ public: void SetupSettingObserver(int32_t nRetries); void TouchDrawHandler(std::shared_ptr pointerEvent); int32_t UpdateLabels(); - void UpdateDisplayInfo(const DisplayInfo& displayInfo); + void UpdateDisplayInfo(const OLD::DisplayInfo& displayInfo); void GetOriginalTouchScreenCoordinates(Direction direction, int32_t width, int32_t height, int32_t &physicalX, int32_t &physicalY); int32_t UpdateBubbleData(); @@ -116,7 +116,7 @@ private: std::shared_ptr trackerCanvasNode_ { nullptr }; std::shared_ptr crosshairCanvasNode_ { nullptr }; std::shared_ptr labelsCanvasNode_ { nullptr }; - DisplayInfo displayInfo_ {}; + OLD::DisplayInfo displayInfo_ {}; Bubble bubble_; Rosen::Drawing::Point firstPt_; Rosen::Drawing::Point currentPt_; diff --git a/service/window_manager/src/input_windows_manager.cpp b/service/window_manager/src/input_windows_manager.cpp index d13b3b3901f51bc3bbab0f54e6580c605950acdd..d67ee0497cc976f401dc56f13b970126ccf7ea1e 100644 --- a/service/window_manager/src/input_windows_manager.cpp +++ b/service/window_manager/src/input_windows_manager.cpp @@ -19,6 +19,7 @@ #include "display_manager.h" #include "event_log_helper.h" #include "i_pointer_drawing_manager.h" +#include "coordinates_transformer.h" #include "key_command_handler_util.h" #include "mmi_matrix3.h" #include "scene_board_judgement.h" @@ -165,10 +166,8 @@ InputWindowsManager::InputWindowsManager() : bindInfo_(BIND_CFG_FILE_NAME) lastTouchWindowInfo_.windowNameType = 0; #endif // OHOS_BUILD_ENABLE_TOUCH displayGroupInfo_.groupId = MAIN_GROUPID; - displayGroupInfo_.isMainGroup = true; + displayGroupInfo_.type = GroupType::GROUP_DEFAULT; displayGroupInfo_.focusWindowId = -1; - displayGroupInfo_.width = 0; - displayGroupInfo_.height = 0; displayGroupInfoMap_[MAIN_GROUPID] = displayGroupInfo_; displayGroupInfoMapTmp_[MAIN_GROUPID] = displayGroupInfo_; captureModeInfoMap_[MAIN_GROUPID] = captureModeInfo_; @@ -568,7 +567,7 @@ void InputWindowsManager::FoldScreenRotation(std::shared_ptr point } #endif // OHOS_BUILD_ENABLE_POINTER || OHOS_BUILD_ENABLE_TOUCH -DisplayGroupInfo& InputWindowsManager::FindTargetDisplayGroupInfo(int32_t displayId) +OLD::DisplayGroupInfo& InputWindowsManager::FindTargetDisplayGroupInfo(int32_t displayId) { for (auto& it : displayGroupInfoMap_) { @@ -578,7 +577,7 @@ DisplayGroupInfo& InputWindowsManager::FindTargetDisplayGroupInfo(int32_t displa } } } - return GetMainDisplayGroupInfo(); + return GetDefaultDisplayGroupInfo(); } int32_t InputWindowsManager::FindDisplayGroupId(int32_t displayId) const @@ -593,11 +592,12 @@ int32_t InputWindowsManager::FindDisplayGroupId(int32_t displayId) const return DEFAULT_GROUP_ID; } -DisplayGroupInfo& InputWindowsManager::GetMainDisplayGroupInfo() +OLD::DisplayGroupInfo& InputWindowsManager::GetDefaultDisplayGroupInfo() { - const auto& iter = displayGroupInfoMap_.find(MAIN_GROUPID); - if (iter != displayGroupInfoMap_.end()) { - return iter->second; + for (auto &item : displayGroupInfoMap_) { + if (item.second.type == GroupType::GROUP_DEFAULT) { + return item.second; + } } return displayGroupInfo_; } @@ -856,7 +856,7 @@ int32_t InputWindowsManager::GetWindowPid(int32_t windowId, const std::vectorsecond : GetMainDisplayGroupInfo(); + displayGroupInfo = (iter != displayGroupInfoMapTmp_.end()) ? iter->second : GetDefaultDisplayGroupInfo(); if (it.first != MAIN_GROUPID) { displayGroupInfo.focusWindowId = focusWid; } @@ -1015,7 +1015,7 @@ void InputWindowsManager::UpdateWindowInfo(const WindowGroupInfo &windowGroupInf } } -void InputWindowsManager::UpdateDisplayInfoExtIfNeed(DisplayGroupInfo &displayGroupInfo, bool needUpdateDisplayExt) +void InputWindowsManager::UpdateDisplayInfoExtIfNeed(OLD::DisplayGroupInfo &displayGroupInfo, bool needUpdateDisplayExt) { UpdateDisplayInfo(displayGroupInfo); #ifdef OHOS_BUILD_ENABLE_ANCO @@ -1040,7 +1040,7 @@ void InputWindowsManager::UpdateDisplayInfoExtIfNeed(DisplayGroupInfo &displayGr } void InputWindowsManager::UpdateDisplayInfoByIncrementalInfo(const WindowInfo &window, - DisplayGroupInfo &displayGroupInfo) + OLD::DisplayGroupInfo &displayGroupInfo) { CALL_DEBUG_ENTER; switch (window.action) { @@ -1083,7 +1083,7 @@ void InputWindowsManager::UpdateDisplayInfoByIncrementalInfo(const WindowInfo &w } } -void InputWindowsManager::UpdateWindowsInfoPerDisplay(const DisplayGroupInfo &displayGroupInfo) +void InputWindowsManager::UpdateWindowsInfoPerDisplay(const OLD::DisplayGroupInfo &displayGroupInfo) { CALL_DEBUG_ENTER; std::map windowsPerDisplay; @@ -1131,7 +1131,7 @@ void InputWindowsManager::UpdateWindowsInfoPerDisplay(const DisplayGroupInfo &di #endif // defined(OHOS_BUILD_ENABLE_TOUCH) && defined(OHOS_BUILD_ENABLE_MONITOR) } -WINDOW_UPDATE_ACTION InputWindowsManager::UpdateWindowInfo(DisplayGroupInfo &displayGroupInfo) +WINDOW_UPDATE_ACTION InputWindowsManager::UpdateWindowInfo(OLD::DisplayGroupInfo &displayGroupInfo) { auto action = WINDOW_UPDATE_ACTION::ADD_END; if (!displayGroupInfo.windowsInfo.empty()) { @@ -1183,16 +1183,16 @@ void InputWindowsManager::ChangeWindowArea(int32_t x, int32_t y, WindowInfo &win } } -int32_t InputWindowsManager::GetMainScreenDisplayInfo(const std::vector &displaysInfo, - DisplayInfo &mainScreenDisplayInfo) const +int32_t InputWindowsManager::GetMainScreenDisplayInfo(const std::vector &displaysInfo, + OLD::DisplayInfo &mainScreenDisplayInfo) const { CALL_DEBUG_ENTER; if (displaysInfo.empty()) { MMI_HILOGE("displaysInfo doesn't contain displayInfo"); return RET_ERR; } - for (const DisplayInfo& display : displaysInfo) { - if (display.screenCombination == OHOS::MMI::ScreenCombination::SCREEN_MAIN) { + for (const OLD::DisplayInfo& display : displaysInfo) { + if (display.displaySourceMode == OHOS::MMI::DisplaySourceMode::SCREEN_MAIN) { mainScreenDisplayInfo = display; return RET_OK; } @@ -1240,11 +1240,11 @@ void InputWindowsManager::SendBackCenterPointerEevent(const CursorPosition &curs InputHandler->GetFilterHandler()->HandlePointerEvent(pointerBackCenterEvent); } -CursorPosition InputWindowsManager::ResetCursorPos(const DisplayGroupInfo &displayGroupInfo) +CursorPosition InputWindowsManager::ResetCursorPos(const OLD::DisplayGroupInfo &displayGroupInfo) { int32_t groupId = displayGroupInfo.groupId; if (!displayGroupInfo.displaysInfo.empty()) { - DisplayInfo displayInfo = displayGroupInfo.displaysInfo[0]; + OLD::DisplayInfo displayInfo = displayGroupInfo.displaysInfo[0]; int32_t x = displayInfo.validWidth * HALF_RATIO; int32_t y = displayInfo.validHeight * HALF_RATIO; if (GetHardCursorEnabled()) { @@ -1268,7 +1268,7 @@ CursorPosition InputWindowsManager::ResetCursorPos(const DisplayGroupInfo &disp return cursorPosMap_[groupId]; } -void InputWindowsManager::ResetPointerPosition(const DisplayGroupInfo &displayGroupInfo) +void InputWindowsManager::ResetPointerPosition(const OLD::DisplayGroupInfo &displayGroupInfo) { CALL_DEBUG_ENTER; if (displayGroupInfo.displaysInfo.empty()) { @@ -1277,12 +1277,12 @@ void InputWindowsManager::ResetPointerPosition(const DisplayGroupInfo &displayGr CursorPosition oldPtrPos = GetCursorPos(); CursorPosition cursorPos; for (auto ¤tDisplay : displayGroupInfo.displaysInfo) { - if ((currentDisplay.screenCombination == OHOS::MMI::ScreenCombination::SCREEN_MAIN)) { + if ((currentDisplay.displaySourceMode == OHOS::MMI::DisplaySourceMode::SCREEN_MAIN)) { auto displayInfo = GetPhysicalDisplay(oldPtrPos.displayId); CHKPV(displayInfo); MMI_HILOGI("CurDisplayId:%{public}d, oldDisplayId:%{public}d", - currentDisplay.uniqueId, displayInfo->uniqueId); - if ((displayInfo->uniqueId != currentDisplay.uniqueId) || (!IsPointerOnCenter(oldPtrPos, currentDisplay))) { + currentDisplay.rsId, displayInfo->rsId); + if ((displayInfo->rsId != currentDisplay.rsId) || (!IsPointerOnCenter(oldPtrPos, currentDisplay))) { cursorPos = ResetCursorPos(displayGroupInfo); UpdateAndAdjustMouseLocation(cursorPos.displayId, cursorPos.cursorPos.x, cursorPos.cursorPos.y); } @@ -1299,7 +1299,7 @@ void InputWindowsManager::ResetPointerPosition(const DisplayGroupInfo &displayGr (void)SendBackCenterPointerEevent(cursorPos); } -bool InputWindowsManager::IsPointerOnCenter(const CursorPosition ¤tPos, const DisplayInfo ¤tDisplay) +bool InputWindowsManager::IsPointerOnCenter(const CursorPosition ¤tPos, const OLD::DisplayInfo ¤tDisplay) { auto displayCenterX = currentDisplay.validWidth * HALF_RATIO; auto displayCenterY = currentDisplay.validHeight * HALF_RATIO; @@ -1310,17 +1310,17 @@ bool InputWindowsManager::IsPointerOnCenter(const CursorPosition ¤tPos, co return false; } -void InputWindowsManager::HandleValidDisplayChange(const DisplayGroupInfo &displayGroupInfo) +void InputWindowsManager::HandleValidDisplayChange(const OLD::DisplayGroupInfo &displayGroupInfo) { ResetPointerPositionIfOutValidDisplay(displayGroupInfo); CancelTouchScreenEventIfValidDisplayChange(displayGroupInfo); } -CursorPosition InputWindowsManager::GetCursorPos(const DisplayGroupInfo &displayGroupInfo) +CursorPosition InputWindowsManager::GetCursorPos(const OLD::DisplayGroupInfo &displayGroupInfo) { int32_t groupId = displayGroupInfo.groupId; if ((cursorPosMap_[groupId].displayId < 0) && !displayGroupInfoMap_[groupId].displaysInfo.empty()) { - DisplayInfo displayInfo = displayGroupInfo.displaysInfo[0]; + OLD::DisplayInfo displayInfo = displayGroupInfo.displaysInfo[0]; if (GetHardCursorEnabled()) { (void)GetMainScreenDisplayInfo(displayGroupInfo.displaysInfo, displayInfo); } @@ -1331,10 +1331,10 @@ CursorPosition InputWindowsManager::GetCursorPos(const DisplayGroupInfo &display return cursorPosMap_[groupId]; } -void InputWindowsManager::ResetPointerPositionIfOutValidDisplay(const DisplayGroupInfo &displayGroupInfo) +void InputWindowsManager::ResetPointerPositionIfOutValidDisplay(const OLD::DisplayGroupInfo &displayGroupInfo) { if (displayGroupInfo.displaysInfo.empty()) { - MMI_HILOGD("DisplayInfo empty"); + MMI_HILOGD("OLD::DisplayInfo empty"); return; } CursorPosition cursorPos = GetCursorPos(displayGroupInfo); @@ -1381,7 +1381,7 @@ void InputWindowsManager::ResetPointerPositionIfOutValidDisplay(const DisplayGro CHKPV(displayInfo); IPointerDrawingManager::GetInstance()->SetPointerLocation( static_cast(cursorPosx), - static_cast(cursorPosy), displayInfo->uniqueId); + static_cast(cursorPosy), displayInfo->rsId); } if (isChange) { CancelMouseEvent(); @@ -1393,7 +1393,7 @@ void InputWindowsManager::ResetPointerPositionIfOutValidDisplay(const DisplayGro } bool InputWindowsManager::IsPositionOutValidDisplay( - Coordinate2D &position, const DisplayInfo ¤tDisplay, bool isPhysicalPos) + Coordinate2D &position, const OLD::DisplayInfo ¤tDisplay, bool isPhysicalPos) { double posX = position.x; double posY = position.y; @@ -1488,7 +1488,7 @@ bool InputWindowsManager::IsPositionOutValidDisplay( } #ifdef OHOS_BUILD_ENABLE_VKEYBOARD -bool InputWindowsManager::IsPointerActiveRectValid(const DisplayInfo ¤tDisplay) +bool InputWindowsManager::IsPointerActiveRectValid(const OLD::DisplayInfo ¤tDisplay) { return currentDisplay.pointerActiveWidth > 0 && currentDisplay.pointerActiveHeight > 0; } @@ -1551,7 +1551,7 @@ bool InputWindowsManager::IsCaptureMode() } #endif // OHOS_BUILD_ENABLE_VKEYBOARD -void InputWindowsManager::CancelTouchScreenEventIfValidDisplayChange(const DisplayGroupInfo &displayGroupInfo) +void InputWindowsManager::CancelTouchScreenEventIfValidDisplayChange(const OLD::DisplayGroupInfo &displayGroupInfo) { if (lastPointerEventforGesture_ == nullptr) { MMI_HILOGD("lastPointerEventforGesture_ is null"); @@ -1605,7 +1605,7 @@ void InputWindowsManager::CancelMouseEvent() } } -bool InputWindowsManager::IsValidDisplayChange(const DisplayInfo &displayInfo) +bool InputWindowsManager::IsValidDisplayChange(const OLD::DisplayInfo &displayInfo) { int32_t touchDisplayId = displayInfo.id; int32_t groupId = FindDisplayGroupId(touchDisplayId); @@ -1654,7 +1654,7 @@ bool InputWindowsManager::IsValidDisplayChange(const DisplayInfo &displayInfo) return false; } -void InputWindowsManager::HandleWindowPositionChange(const DisplayGroupInfo &displayGroupInfo) +void InputWindowsManager::HandleWindowPositionChange(const OLD::DisplayGroupInfo &displayGroupInfo) { CALL_DEBUG_ENTER; int32_t groupId = displayGroupInfo.groupId; @@ -1753,10 +1753,10 @@ bool InputWindowsManager::JudgeCaramaInFore() return programName.find(".camera") != std::string::npos; } -void InputWindowsManager::InitDisplayGroupInfo(DisplayGroupInfo &displayGroupInfo) +void InputWindowsManager::InitDisplayGroupInfo(OLD::DisplayGroupInfo &displayGroupInfo) { int32_t groupId = displayGroupInfo.groupId; - if (displayGroupInfo.isMainGroup) { + if (displayGroupInfo.type == GroupType::GROUP_DEFAULT) { if (groupId != MAIN_GROUPID) { MMI_HILOGE("The groupId is incorrect, groupId:%{public}d", groupId); return; @@ -1765,7 +1765,7 @@ void InputWindowsManager::InitDisplayGroupInfo(DisplayGroupInfo &displayGroupInf displayGroupInfoMap_[groupId] = displayGroupInfo; } -void InputWindowsManager::UpdateDisplayInfo(DisplayGroupInfo &displayGroupInfo) +void InputWindowsManager::UpdateDisplayInfo(OLD::DisplayGroupInfo &displayGroupInfo) { InitDisplayGroupInfo(displayGroupInfo); if (!mainGroupExisted_ && displayGroupInfo.isMainGroup) { @@ -1774,7 +1774,7 @@ void InputWindowsManager::UpdateDisplayInfo(DisplayGroupInfo &displayGroupInfo) int32_t groupId = displayGroupInfo.groupId; bool bFlag = false; #ifdef OHOS_BUILD_ENABLE_ANCO - bFlag = mainGroupExisted_ && !displayGroupInfo.displaysInfo.empty(); + bFlag = displayGroupInfo.type == GroupType::GROUP_DEFAULT && !displayGroupInfo.displaysInfo.empty(); if (bFlag) { const auto &displayInfo = displayGroupInfo.displaysInfo.front(); std::lock_guard lock(oneHandMtx_); @@ -1794,7 +1794,7 @@ void InputWindowsManager::UpdateDisplayInfo(DisplayGroupInfo &displayGroupInfo) if (GetHardCursorEnabled()) { isDisplayChanged = OnDisplayRemovedOrCombinationChanged(displayGroupInfo); } - DisplayGroupInfo displayGroupInfoTemp; + OLD::DisplayGroupInfo displayGroupInfoTemp; displayGroupInfoMapTmp_[displayGroupInfo.groupId] = displayGroupInfo; bFlag = (!Rosen::SceneBoardJudgement::IsSceneBoardEnabled() || action == WINDOW_UPDATE_ACTION::ADD_END) && ((currentUserId_ < 0) || (currentUserId_ == displayGroupInfo.currentUserId)); @@ -1903,7 +1903,7 @@ void InputWindowsManager::AdjustDisplayRotation(int32_t groupId) auto displayInfoTmp = GetPhysicalDisplay(displayId); CHKPV(displayInfoTmp); IPointerDrawingManager::GetInstance()->SetPointerLocation( - static_cast(coord.x), static_cast(coord.y), displayInfoTmp->uniqueId); + static_cast(coord.x), static_cast(coord.y), displayInfoTmp->rsId); } } @@ -2012,7 +2012,7 @@ void InputWindowsManager::DrawPointer(bool isDisplayRemoved) } } -void InputWindowsManager::PointerDrawingManagerOnDisplayInfo(const DisplayGroupInfo &displayGroupInfo, +void InputWindowsManager::PointerDrawingManagerOnDisplayInfo(const OLD::DisplayGroupInfo &displayGroupInfo, bool isDisplayRemoved) { auto currentDisplayInfo = IPointerDrawingManager::GetInstance()->GetCurrentDisplayInfo(); @@ -2039,10 +2039,10 @@ void InputWindowsManager::PointerDrawingManagerOnDisplayInfo(const DisplayGroupI lastDpiMap_[groupId] = lastDpiTmp; } for (auto displayInfo : displayGroupInfo.displaysInfo) { - if (displayInfo.uniqueId == currentDisplayInfo.uniqueId && displayInfo.dpi != currentDisplayInfo.dpi) { + if (displayInfo.rsId == currentDisplayInfo.rsId && displayInfo.dpi != currentDisplayInfo.dpi) { MMI_HILOGD("dpi changed, current displayId: %{public}d, dpi: %{public}d, " "latest displayId: %{public}d, dpi: %{public}d", - currentDisplayInfo.uniqueId, currentDisplayInfo.dpi, displayInfo.uniqueId, displayInfo.dpi); + currentDisplayInfo.rsId, currentDisplayInfo.dpi, displayInfo.rsId, displayInfo.dpi); auto drawNewDpiRes = IPointerDrawingManager::GetInstance()->DrawNewDpiPointer(); if (drawNewDpiRes != RET_OK) { MMI_HILOGE("Draw New Dpi pointer failed."); @@ -2413,7 +2413,7 @@ void InputWindowsManager::DispatchPointer(int32_t pointerAction, int32_t windowI currentPointerItem.SetWindowXPos(lastLogicX_ - lastWindowInfo_.area.x); currentPointerItem.SetWindowYPos(lastLogicY_ - lastWindowInfo_.area.y); if (pointerAction == PointerEvent::POINTER_ACTION_ENTER_WINDOW && windowId > 0) { - auto displayGroupInfo = GetMainDisplayGroupInfo(); + auto displayGroupInfo = GetDefaultDisplayGroupInfo(); int32_t displayId = 0; double cursorPosx = 0.0; double cursorPosy = 0.0; @@ -2659,15 +2659,13 @@ void InputWindowsManager::PrintWindowGroupInfo(const WindowGroupInfo &windowGrou PrintWindowInfo(windowGroupInfo.windowsInfo); } -void InputWindowsManager::PrintDisplayGroupInfo(const DisplayGroupInfo displayGroupInfo) +void InputWindowsManager::PrintDisplayGroupInfo(const OLD::DisplayGroupInfo displayGroupInfo) { if (!HiLogIsLoggable(MMI_LOG_DOMAIN, MMI_LOG_TAG, LOG_DEBUG)) { return; } - MMI_HILOGD("logicalInfo,width:%{public}d,height:%{public}d,focusWindowId:%{public}d," + MMI_HILOGD("logicalInfo,focusWindowId:%{public}d," "windowsInfosNum:%{public}zu,displayInfosNum:%{public}zu", - displayGroupInfo.width, - displayGroupInfo.height, displayGroupInfo.focusWindowId, displayGroupInfo.windowsInfo.size(), displayGroupInfo.displaysInfo.size()); @@ -2677,7 +2675,7 @@ void InputWindowsManager::PrintDisplayGroupInfo(const DisplayGroupInfo displayGr } } -void InputWindowsManager::PrintDisplayInfo(const DisplayInfo displayInfo) +void InputWindowsManager::PrintDisplayInfo(const OLD::DisplayInfo displayInfo) { if (!HiLogIsLoggable(MMI_LOG_DOMAIN, MMI_LOG_TAG, LOG_DEBUG)) { return; @@ -2708,20 +2706,20 @@ void InputWindowsManager::PrintDisplayInfo(const DisplayInfo displayInfo) displayInfo.pointerActiveHeight); } -const std::shared_ptr InputWindowsManager::GetPhysicalDisplay(int32_t id) const +const std::shared_ptr InputWindowsManager::GetPhysicalDisplay(int32_t id) const { int32_t groupId = FindDisplayGroupId(id); const auto iter = displayGroupInfoMap_.find(groupId); if (iter != displayGroupInfoMap_.end()) { for (auto &it : iter->second.displaysInfo) { if (it.id == id) { - return std::make_shared(it); + return std::make_shared(it); } } } else { for (auto &it : displayGroupInfo_.displaysInfo) { if (it.id == id) { - return std::make_shared(it); + return std::make_shared(it); } } } @@ -2730,34 +2728,35 @@ const std::shared_ptr InputWindowsManager::GetPhysicalDisplay(int32 } #ifdef OHOS_BUILD_ENABLE_TOUCH -const std::shared_ptr InputWindowsManager::FindPhysicalDisplayInfo(const std::string& uniq) const +// 获取当前TP屏幕对应的 displayId +const std::shared_ptr InputWindowsManager::FindPhysicalDisplayInfo(const std::string& uniq) const { for (const auto &item : displayGroupInfoMap_) { for (const auto &it : item.second.displaysInfo) { if (it.uniq == uniq) { - return std::make_shared(it); + return std::make_shared(it); } } } MMI_HILOGD("Failed to search for Physical,uniq:%{public}s", uniq.c_str()); - DisplayGroupInfo displayGroupInfo; + OLD::DisplayGroupInfo displayGroupInfo; auto iter = displayGroupInfoMap_.find(MAIN_GROUPID); if (iter != displayGroupInfoMap_.end()) { if (iter->second.displaysInfo.size() > 0) { - return std::make_shared(iter->second.displaysInfo[0]); + return std::make_shared(iter->second.displaysInfo[0]); } } return nullptr; } -const std::shared_ptr InputWindowsManager::GetDefaultDisplayInfo() const +const std::shared_ptr InputWindowsManager::GetDefaultDisplayInfo() const { return FindPhysicalDisplayInfo("default0"); } #endif // OHOS_BUILD_ENABLE_TOUCH #if defined(OHOS_BUILD_ENABLE_POINTER) || defined(OHOS_BUILD_ENABLE_TOUCH) -void InputWindowsManager::ScreenRotateAdjustDisplayXY(const DisplayInfo& info, PhysicalCoordinate& coord) const +void InputWindowsManager::ScreenRotateAdjustDisplayXY(const OLD::DisplayInfo& info, PhysicalCoordinate& coord) const { int32_t groupId = FindDisplayGroupId(info.id); Direction rotation = info.direction; @@ -2784,7 +2783,7 @@ void InputWindowsManager::ScreenRotateAdjustDisplayXY(const DisplayInfo& info, P } } -void InputWindowsManager::RotateScreen90(const DisplayInfo& info, PhysicalCoordinate& coord) const +void InputWindowsManager::RotateScreen90(const OLD::DisplayInfo& info, PhysicalCoordinate& coord) const { double oldX = coord.x; double oldY = coord.y; @@ -2799,7 +2798,7 @@ void InputWindowsManager::RotateScreen90(const DisplayInfo& info, PhysicalCoordi return; } -void InputWindowsManager::RotateScreen(const DisplayInfo& info, PhysicalCoordinate& coord) const +void InputWindowsManager::RotateScreen(const OLD::DisplayInfo& info, PhysicalCoordinate& coord) const { double oldX = coord.x; double oldY = coord.y; @@ -2851,7 +2850,7 @@ void InputWindowsManager::RotateScreen(const DisplayInfo& info, PhysicalCoordina } } -void InputWindowsManager::RotateDisplayScreen(const DisplayInfo& info, PhysicalCoordinate& coord) +void InputWindowsManager::RotateDisplayScreen(const OLD::DisplayInfo& info, PhysicalCoordinate& coord) { Direction displayDirection = GetDisplayDirection(&info); bool isEnable = Rosen::SceneBoardJudgement::IsSceneBoardEnabled(); @@ -2896,11 +2895,16 @@ void InputWindowsManager::RotateDisplayScreen(const DisplayInfo& info, PhysicalC #ifdef OHOS_BUILD_ENABLE_TOUCH bool InputWindowsManager::GetPhysicalDisplayCoord(struct libinput_event_touch* touch, - const DisplayInfo& info, EventTouch& touchInfo, bool isNeedClear) + const OLD::DisplayInfo& info, EventTouch& touchInfo, bool isNeedClear) { PrintDisplayInfo(info); auto width = info.width; auto height = info.height; + auto dispDisplayInfo = [&info]() { + MMI_HILOGI("WLD width:%{public}d, height:%{public}d, x:%{public}d, y:%{public}d, direction:%{public}d", + info.width, info.height, info.x, info.y, static_cast(info.direction)); + }; + dispDisplayInfo(); if (Rosen::SceneBoardJudgement::IsSceneBoardEnabled()) { if (info.direction == DIRECTION90 || info.direction == DIRECTION270) { width = info.height; @@ -2931,6 +2935,14 @@ bool InputWindowsManager::GetPhysicalDisplayCoord(struct libinput_event_touch* t touchInfo.coordF = coord; touchInfo.point.x = static_cast(coord.x); touchInfo.point.y = static_cast(coord.y); + + // 若当前计算displayX的逻辑正确切勿 displayInfo.x, displayinfo.y正确,则全局坐标系计算过程即可如此 + touchInfo.globalCoord.x = info.x + touchInfo.point.x; + touchInfo.globalCoord.y = info.y + touchInfo.point.y; + + MMI_HILOGI("WLD point.x:%{public}f, point.y:%{public}f, global.x:%{public}f, global.y:%{public}f", + touchInfo.point.x, touchInfo.point.y, touchInfo.globalCoord.x, touchInfo.globalCoord.y); + touchInfo.toolRect.point.x = static_cast(libinput_event_touch_get_tool_x_transformed(touch, width)); touchInfo.toolRect.point.y = static_cast(libinput_event_touch_get_tool_y_transformed(touch, height - info.expandHeight)); @@ -3007,7 +3019,7 @@ bool InputWindowsManager::TouchPointToDisplayPoint(int32_t deviceId, struct libi CHKPF(info); physicalDisplayId = info->id; if ((info->width <= 0) || (info->height <= 0)) { - MMI_HILOGE("Get DisplayInfo is error"); + MMI_HILOGE("Get OLD::DisplayInfo is error"); return false; } return GetPhysicalDisplayCoord(touch, *info, touchInfo, isNeedClear); @@ -3061,7 +3073,7 @@ bool InputWindowsManager::CalculateTipPoint(struct libinput_event_tablet_tool* t #endif // OHOS_BUILD_ENABLE_TOUCH #ifdef OHOS_BUILD_ENABLE_POINTER -const DisplayGroupInfo InputWindowsManager::GetDisplayGroupInfo(int32_t groupId) +const OLD::DisplayGroupInfo InputWindowsManager::GetDisplayGroupInfo(int32_t groupId) { auto iter = displayGroupInfoMap_.find(groupId); if (iter != displayGroupInfoMap_.end()) { @@ -3070,7 +3082,7 @@ const DisplayGroupInfo InputWindowsManager::GetDisplayGroupInfo(int32_t groupId) return displayGroupInfo_; } -const std::vector& InputWindowsManager::GetDisplayInfoVector(int32_t groupId) const +const std::vector& InputWindowsManager::GetDisplayInfoVector(int32_t groupId) const { const auto &groupInfo = displayGroupInfoMap_.find(groupId); if (groupInfo != displayGroupInfoMap_.end()) { @@ -3624,7 +3636,7 @@ bool InputWindowsManager::InWhichHotArea(int32_t x, int32_t y, const std::vector #ifdef OHOS_BUILD_ENABLE_TOUCH void InputWindowsManager::AdjustDisplayCoordinate( - const DisplayInfo& displayInfo, double& physicalX, double& physicalY) const + const OLD::DisplayInfo& displayInfo, double& physicalX, double& physicalY) const { int32_t width = displayInfo.validWidth; int32_t height = displayInfo.validHeight; @@ -3890,7 +3902,7 @@ bool InputWindowsManager::SelectPointerChangeArea(int32_t windowId, int32_t logi return findFlag; } -void InputWindowsManager::UpdatePointerChangeAreas(const DisplayGroupInfo &displayGroupInfo) +void InputWindowsManager::UpdatePointerChangeAreas(const OLD::DisplayGroupInfo &displayGroupInfo) { CALL_DEBUG_ENTER; std::map> &winHotAreasTmp = windowsHotAreasMap_[displayGroupInfo.groupId]; @@ -4155,6 +4167,8 @@ int32_t InputWindowsManager::UpdateMouseTarget(std::shared_ptr poi return RET_ERR; } pointerEvent->SetTargetDisplayId(displayId); + ProcessInjectEventGlobalXY(pointerEvent); + displayId = pointerEvent->GetTargetDisplayId(); int32_t groupId = FindDisplayGroupId(displayId); auto physicalDisplayInfo = GetPhysicalDisplay(displayId); CHKPR(physicalDisplayInfo, ERROR_NULL_POINTER); @@ -4168,27 +4182,27 @@ int32_t InputWindowsManager::UpdateMouseTarget(std::shared_ptr poi } int32_t logicalX = 0; int32_t logicalY = 0; - if (!AddInt32(pointerItem.GetDisplayX(), DisplayInfoX, logicalX)) { + int32_t physicalX = pointerItem.GetDisplayX(); + int32_t physicalY = pointerItem.GetDisplayY(); + if (!AddInt32(physicalX, DisplayInfoX, logicalX)) { MMI_HILOGE("The addition of logicalX overflows"); return RET_ERR; } - if (!AddInt32(pointerItem.GetDisplayY(), DisplayInfoY, logicalY)) { + if (!AddInt32(physicalY, DisplayInfoY, logicalY)) { MMI_HILOGE("The addition of logicalY overflows"); return RET_ERR; } if (pointerEvent->GetPointerAction() == PointerEvent::POINTER_ACTION_DOWN) { ClearTargetWindowId(pointerId); } - int32_t physicalX = pointerItem.GetDisplayX(); - int32_t physicalY = pointerItem.GetDisplayY(); auto touchWindow = SelectWindowInfo(logicalX, logicalY, pointerEvent); if (pointerEvent->GetPointerAction() == PointerEvent::POINTER_ACTION_AXIS_BEGIN) { axisBeginWindowInfo_ = touchWindow; } if (!touchWindow) { MMI_HILOGI("UpdateMouseTarget id:%{public}d, logicalX:%{public}d, logicalY:%{public}d," - "displayX:%{public}d, displayY:%{public}d", physicalDisplayInfo->uniqueId, logicalX, logicalY, - pointerItem.GetDisplayX(), pointerItem.GetDisplayY()); + "displayX:%{public}d, displayY:%{public}d", physicalDisplayInfo->rsId, logicalX, logicalY, + physicalX, physicalY); if (pointerEvent->GetPointerAction() == PointerEvent::POINTER_ACTION_BUTTON_DOWN || (mouseDownInfo_.id == -1 && axisBeginWindowInfo_ == std::nullopt)) { MMI_HILOGE("touchWindow is nullptr, targetWindow:%{public}d", pointerEvent->GetTargetWindowId()); @@ -4219,8 +4233,8 @@ int32_t InputWindowsManager::UpdateMouseTarget(std::shared_ptr poi physicalX, physicalY); } MMI_HILOGI("UpdateMouseTarget id:%{public}d, logicalX:%{public}d, logicalY:%{public}d," - "displayX:%{public}d, displayY:%{public}d", physicalDisplayInfo->uniqueId, logicalX, logicalY, - pointerItem.GetDisplayX(), pointerItem.GetDisplayY()); + "displayX:%{public}d, displayY:%{public}d", physicalDisplayInfo->rsId, logicalX, logicalY, + physicalX, physicalY); #endif // OHOS_BUILD_ENABLE_POINTER_DRAWING int64_t endTime = GetSysClockTime(); if ((endTime - beginTime) > RS_PROCESS_TIMEOUT) { @@ -4349,7 +4363,7 @@ int32_t InputWindowsManager::UpdateMouseTarget(std::shared_ptr poi dragPointerStyle_.id, globalStyle_.id); dragPointerStyle_ = globalStyle_; } - IPointerDrawingManager::GetInstance()->DrawPointer(physicalDisplayInfo->uniqueId, physicalX, physicalY, + IPointerDrawingManager::GetInstance()->DrawPointer(physicalDisplayInfo->rsId, physicalX, physicalY, dragPointerStyle_, direction); } #endif // OHOS_BUILD_ENABLE_POINTER_DRAWING @@ -4380,10 +4394,18 @@ int32_t InputWindowsManager::UpdateMouseTarget(std::shared_ptr poi if (!(touchWindow->transform.empty())) { auto windowXY = TransformWindowXY(*touchWindow, logicalX, logicalY); } - pointerItem.SetWindowX(static_cast(windowX)); - pointerItem.SetWindowY(static_cast(windowY)); - pointerItem.SetWindowXPos(windowX); - pointerItem.SetWindowYPos(windowY); + windowX = static_cast(windowX); + windowY = static_cast(windowY); + pointerItem.SetWindowX(windowX); + pointerItem.SetWindowY(windowY); + pointerItem.SetGlobalX(logicalX); + pointerItem.SetGlobalY(logicalY); + MMI_HILOGI("(displayX:%{public}d, displayY:%{public}d)" + "(DisplayInfoX:%{public}d, DisplayInfoY:%{public}d)" + "(globalX:%{public}f, globalY:%{public}f)", + pointerItem.GetDisplayX(), pointerItem.GetDisplayY(), + DisplayInfoX, DisplayInfoY, + pointerItem.GetGlobalX(), pointerItem.GetGlobalY()); pointerEvent->UpdatePointerItem(pointerId, pointerItem); if ((extraData_.appended && (extraData_.sourceType == PointerEvent::SOURCE_TYPE_MOUSE)) || (pointerEvent->GetPointerAction() == PointerEvent::POINTER_ACTION_PULL_UP)) { @@ -4632,7 +4654,7 @@ bool InputWindowsManager::IsNavigationWindowInjectEvent(std::shared_ptr &pointerEvent, PointerEvent::PointerItem &pointerItem) { pointerEvent->SetFixedMode(PointerEvent::FixedMode::AUTO); @@ -4669,7 +4691,7 @@ void InputWindowsManager::HandleOneHandMode(const DisplayInfo &displayInfo, pointerItem.SetFixedDisplayY(static_cast(fixedDisplayY)); } -void InputWindowsManager::UpdatePointerItemInOneHandMode(const DisplayInfo &displayInfo, +void InputWindowsManager::UpdatePointerItemInOneHandMode(const OLD::DisplayInfo &displayInfo, std::shared_ptr &pointerEvent) { int32_t pointerId = pointerEvent->GetPointerId(); @@ -4706,7 +4728,8 @@ void InputWindowsManager::UpdatePointerItemInOneHandMode(const DisplayInfo &disp } #endif // OHOS_BUILD_ENABLE_ONE_HAND_MODE -void InputWindowsManager::UpdateFixedXY(const DisplayInfo& displayInfo, std::shared_ptr &pointerEvent) +void InputWindowsManager::UpdateFixedXY(const OLD::DisplayInfo& displayInfo, + std::shared_ptr &pointerEvent) { #ifdef OHOS_BUILD_ENABLE_ONE_HAND_MODE UpdatePointerItemInOneHandMode(displayInfo, pointerEvent); @@ -4724,7 +4747,7 @@ void InputWindowsManager::UpdateFixedXY(const DisplayInfo& displayInfo, std::sha } void InputWindowsManager::UpdateTransformDisplayXY(std::shared_ptr pointerEvent, - const std::vector& windowsInfo, const DisplayInfo& displayInfo) + const std::vector& windowsInfo, const OLD::DisplayInfo& displayInfo) { CHKPV(pointerEvent); bool isNavigationWindow = false; @@ -4853,6 +4876,38 @@ void InputWindowsManager::HandleGestureInjection(bool gestureInject) { } } +void InputWindowsManager::ProcessInjectEventGlobalXY(std::shared_ptr pointerEvent) +{ + if (!pointerEvent->HasFlag(InputEvent::EVENT_FLAG_SIMULATE)) { + return; + } + int32_t pointerId = pointerEvent->GetPointerId(); + PointerEvent::PointerItem pointerItem; + + if (!pointerEvent->GetPointerItem(pointerId, pointerItem)) { + MMI_HILOG_DISPATCHE("Can't find pointer item, pointer:%{public}d", pointerId); + return; + } + double globalX = pointerItem.GetGlobalX(); + double globalY = pointerItem.GetGlobalY(); + if (globalX == DBL_MAX || globalY == DBL_MAX) { + return; + } + // testing log, need delete + MMI_HILOG_DISPATCHI("ProcessInjectEventGlobalXY globalXY:{%{public}f,%{public}f}", globalX, globalY); + const auto& mainGroup = GetDefaultDisplayGroupInfo(); + for (const auto& display : mainGroup.displaysInfo) { + if (globalX >= display.x && globalX <= display.x + display.width && + globalY >= display.y && globalY <= display.y + display.height) { + pointerEvent->SetTargetDisplayId(display.id); + pointerItem.SetDisplayX(static_cast(globalX-display.x)); + pointerItem.SetDisplayY(static_cast(globalY-display.y)); + pointerEvent->UpdatePointerItem(pointerId, pointerItem); + return; + } + } +} + int32_t InputWindowsManager::UpdateTouchScreenTarget(std::shared_ptr pointerEvent) { CHKPR(pointerEvent, ERROR_NULL_POINTER); @@ -4867,8 +4922,10 @@ int32_t InputWindowsManager::UpdateTouchScreenTarget(std::shared_ptrSetTargetDisplayId(displayId); + pointerEvent->SetTargetDisplayId(displayId); + ProcessInjectEventGlobalXY(pointerEvent); + displayId = pointerEvent->GetTargetDisplayId(); int32_t groupId = FindDisplayGroupId(displayId); auto physicDisplayInfo = GetPhysicalDisplay(displayId); CHKPR(physicDisplayInfo, ERROR_NULL_POINTER); @@ -5295,7 +5352,7 @@ int32_t InputWindowsManager::UpdateTouchScreenTarget(std::shared_ptrUpdateDisplayInfo(*physicDisplayInfo); WinInfo info = { .windowPid = touchWindow->pid, .windowId = touchWindow->id }; IPointerDrawingManager::GetInstance()->OnWindowInfo(info); - IPointerDrawingManager::GetInstance()->DrawPointer(physicDisplayInfo->uniqueId, + IPointerDrawingManager::GetInstance()->DrawPointer(physicDisplayInfo->rsId, pointerItem.GetDisplayX(), pointerItem.GetDisplayY(), pointerStyle, physicDisplayInfo->direction); } else if (IPointerDrawingManager::GetInstance()->GetMouseDisplayState()) { if ((!checkExtraData) && (!(extraData_.appended && @@ -5620,10 +5677,10 @@ void InputWindowsManager::DrawTouchGraphic(std::shared_ptr pointer } if (!isInMethodWindow) { knuckleDrawMgr_->UpdateDisplayInfo(*physicDisplayInfo); - knuckleDrawMgr_->KnuckleDrawHandler(pointerEvent, physicDisplayInfo->uniqueId); + knuckleDrawMgr_->KnuckleDrawHandler(pointerEvent, physicDisplayInfo->rsId); #ifndef OHOS_BUILD_ENABLE_NEW_KNUCKLE_DYNAMIC knuckleDynamicDrawingManager_->UpdateDisplayInfo(*physicDisplayInfo); - knuckleDynamicDrawingManager_->KnuckleDynamicDrawHandler(pointerEvent, physicDisplayInfo->uniqueId); + knuckleDynamicDrawingManager_->KnuckleDynamicDrawHandler(pointerEvent, physicDisplayInfo->rsId); #endif // OHOS_BUILD_ENABLE_NEW_KNUCKLE_DYNAMIC } #endif // OHOS_BUILD_ENABLE_KEYBOARD && OHOS_BUILD_ENABLE_COMBINATION_KEY && OHOS_BUILD_ENABLE_GESTURESENSE_WRAPPER @@ -5731,7 +5788,7 @@ int32_t InputWindowsManager::UpdateTargetPointer(std::shared_ptr p return ret; } -bool InputWindowsManager::IsInsideDisplay(const DisplayInfo& displayInfo, double physicalX, double physicalY) +bool InputWindowsManager::IsInsideDisplay(const OLD::DisplayInfo& displayInfo, double physicalX, double physicalY) { auto displayDirection = GetDisplayDirection(&displayInfo); auto physicalRect = RotateRect(displayDirection, { displayInfo.validWidth, displayInfo.validHeight }); @@ -5748,7 +5805,7 @@ bool InputWindowsManager::IsInsideDisplay(const DisplayInfo& displayInfo, double return isInside; } -bool InputWindowsManager::CalculateLayout(const DisplayInfo &displayInfo, const Vector2D &physical, +bool InputWindowsManager::CalculateLayout(const OLD::DisplayInfo &displayInfo, const Vector2D &physical, Vector2D &layout) { Direction direction = GetDisplayDirection(&displayInfo); @@ -5770,7 +5827,7 @@ bool InputWindowsManager::CalculateLayout(const DisplayInfo &displayInfo, const return true; } -AcrossDirection InputWindowsManager::CalculateAcrossDirection(const DisplayInfo &displayInfo, +AcrossDirection InputWindowsManager::CalculateAcrossDirection(const OLD::DisplayInfo &displayInfo, const Vector2D &layout) { Vector2D layoutMax; @@ -5798,7 +5855,7 @@ AcrossDirection InputWindowsManager::CalculateAcrossDirection(const DisplayInfo return AcrossDirection::ACROSS_ERROR; } -bool InputWindowsManager::AcrossDisplay(const DisplayInfo &displayInfoDes, const DisplayInfo &displayInfoOri, +bool InputWindowsManager::AcrossDisplay(const OLD::DisplayInfo &displayInfoDes, const OLD::DisplayInfo &displayInfoOri, Vector2D &logical, Vector2D &layout, const AcrossDirection &acrossDirection) { Vector2D layoutMax; @@ -5840,7 +5897,7 @@ bool InputWindowsManager::AcrossDisplay(const DisplayInfo &displayInfoDes, const return re; } -void InputWindowsManager::FindPhysicalDisplay(const DisplayInfo& displayInfo, double& physicalX, +void InputWindowsManager::FindPhysicalDisplay(const OLD::DisplayInfo& displayInfo, double& physicalX, double& physicalY, int32_t& displayId) { CALL_DEBUG_ENTER; @@ -5904,7 +5961,7 @@ void InputWindowsManager::CoordinateCorrection(int32_t width, int32_t height, in } } -Direction InputWindowsManager::GetDisplayDirection(const DisplayInfo *displayInfo) +Direction InputWindowsManager::GetDisplayDirection(const OLD::DisplayInfo *displayInfo) { Direction displayDirection = static_cast(( ((displayInfo->direction - displayInfo->displayDirection) * ANGLE_90 + ANGLE_360) % ANGLE_360) / ANGLE_90); @@ -5922,7 +5979,7 @@ Direction InputWindowsManager::GetDisplayDirection(const DisplayInfo *displayInf return displayDirection; } -void InputWindowsManager::GetWidthAndHeight(const DisplayInfo* displayInfo, int32_t &width, int32_t &height, +void InputWindowsManager::GetWidthAndHeight(const OLD::DisplayInfo* displayInfo, int32_t &width, int32_t &height, bool isRealData) { auto displayDirection = GetDisplayDirection(displayInfo); @@ -5942,7 +5999,7 @@ void InputWindowsManager::GetWidthAndHeight(const DisplayInfo* displayInfo, int3 #endif // OHOS_BUILD_ENABLE_POINTER || OHOS_BUILD_ENABLE_TOUCH #if defined(OHOS_BUILD_ENABLE_POINTER) || defined(OHOS_BUILD_ENABLE_TOUCH) -void InputWindowsManager::ReverseRotateScreen(const DisplayInfo& info, const double x, const double y, +void InputWindowsManager::ReverseRotateScreen(const OLD::DisplayInfo& info, const double x, const double y, Coordinate2D& cursorPos) const { const Direction direction = info.direction; @@ -5988,7 +6045,7 @@ void InputWindowsManager::ReverseRotateScreen(const DisplayInfo& info, const dou } } -void InputWindowsManager::ReverseRotateDisplayScreen(const DisplayInfo& info, const double x, const double y, +void InputWindowsManager::ReverseRotateDisplayScreen(const OLD::DisplayInfo& info, const double x, const double y, Coordinate2D& cursorPos) const { Direction displayDirection = WIN_MGR->GetDisplayDirection(&info); @@ -6134,7 +6191,7 @@ MouseLocation InputWindowsManager::GetMouseInfo() MMI_HILOGD("Mouselocation start: displayId:%{public}d, X:%{public}d, Y:%{public}d", curMouseLocation.displayId, curMouseLocation.physicalX, curMouseLocation.physicalY); if ((curMouseLocation.displayId < 0) && !displaysInfoVector.empty()) { - DisplayInfo displayInfo = displaysInfoVector[0]; + OLD::DisplayInfo displayInfo = displaysInfoVector[0]; if (GetHardCursorEnabled()) { (void)GetMainScreenDisplayInfo(displaysInfoVector, displayInfo); } @@ -6164,7 +6221,7 @@ CursorPosition InputWindowsManager::GetCursorPos() cursorPos = iter->second; } if ((cursorPos.displayId < 0) && !displaysInfoVector.empty()) { - DisplayInfo displayInfo = displaysInfoVector[0]; + OLD::DisplayInfo displayInfo = displaysInfoVector[0]; if (GetHardCursorEnabled()) { (void)GetMainScreenDisplayInfo(displaysInfoVector, displayInfo); } @@ -6183,7 +6240,7 @@ CursorPosition InputWindowsManager::ResetCursorPos() CALL_DEBUG_ENTER; auto &displaysInfoVector = GetDisplayInfoVector(MAIN_GROUPID); if (!displaysInfoVector.empty()) { - DisplayInfo displayInfo = displaysInfoVector[0]; + OLD::DisplayInfo displayInfo = displaysInfoVector[0]; int32_t x = displayInfo.validWidth * HALF_RATIO; int32_t y = displayInfo.validHeight * HALF_RATIO; if (GetHardCursorEnabled()) { @@ -6310,17 +6367,19 @@ void InputWindowsManager::UpdatePointerAction(std::shared_ptr poin MMI_HILOG_DISPATCHD("pointerAction:%{public}s", pointerEvent->DumpPointerAction()); } -void InputWindowsManager::DumpDisplayInfo(int32_t fd, const std::vector& displaysInfo) +void InputWindowsManager::DumpDisplayInfo(int32_t fd, const std::vector& displaysInfo) { mprintf(fd, "Displays information:\t"); mprintf(fd, "displayInfos,num:%zu", displaysInfo.size()); for (const auto &item : displaysInfo) { - mprintf(fd, "\t displayInfos: uniqueId:%d | screenCombination:%d id:%d | x:%d" + mprintf(fd, "\t displayInfos: rsId:%d | displaySourceMode:%d id:%d | x:%d" "| y:%d | width:%d | height:%d | name:%s | uniq:%s | direction:%d" - "| displayDirection:%d | displayMode:%u \t", - item.uniqueId, item.screenCombination, item.id, item.x, item.y, item.width, + "| displayDirection:%d | displayMode:%u | offsetX:%d | offsetY:%d" + "| validWidth:%d | validHeight:%d | pointerActiveWidth:%d | pointerActiveHeight:%d\t", + item.rsId, item.displaySourceMode, item.id, item.x, item.y, item.width, item.height, item.name.c_str(), item.uniq.c_str(), item.direction, - item.displayDirection, item.displayMode); + item.displayDirection, item.displayMode, item.offsetX, item.offsetY, + item.validWidth, item.validHeight, item.pointerActiveWidth, item.pointerActiveHeight); if (item.transform.size() == MATRIX3_SIZE) { mprintf(fd, "\t transform: scaleX:%f | scaleY:%f | anchorPointX:%f | anchorPointY:%f \t", item.transform[SCALE_X], item.transform[SCALE_Y], item.transform[ANCHOR_POINT_X], @@ -6335,7 +6394,7 @@ void InputWindowsManager::Dump(int32_t fd, const std::vector &args) std::shared_ptr delegateProxy = IPointerDrawingManager::GetInstance()->GetDelegateProxy(); CHKPV(delegateProxy); - std::vector displaysInfo; + std::vector displaysInfo; std::vector windowsInfo; delegateProxy->OnPostSyncTask([this, &displaysInfo, &windowsInfo] { const auto& iter = displayGroupInfoMap_.find(MAIN_GROUPID); @@ -6406,7 +6465,7 @@ std::pair InputWindowsManager::TransformWindowXY(const WindowInf return { windowXY[0], windowXY[1] }; } -std::pair InputWindowsManager::TransformDisplayXY(const DisplayInfo &info, +std::pair InputWindowsManager::TransformDisplayXY(const OLD::DisplayInfo &info, double logicX, double logicY) const { Matrix3f transform(info.transform); @@ -6643,7 +6702,7 @@ void InputWindowsManager::PrintChangedWindowByEvent(int32_t eventType, const Win lastMatchedWindow_[eventType] = newWindowInfo; } -void InputWindowsManager::PrintChangedWindowBySync(const DisplayGroupInfo &newDisplayInfo) +void InputWindowsManager::PrintChangedWindowBySync(const OLD::DisplayGroupInfo &newDisplayInfo) { auto &WindowsInfo = GetWindowInfoVector(newDisplayInfo.groupId); auto &oldWindows = WindowsInfo; @@ -6884,7 +6943,7 @@ void InputWindowsManager::UpdateKeyEventDisplayId(std::shared_ptr keyE } } -bool InputWindowsManager::OnDisplayRemovedOrCombinationChanged(const DisplayGroupInfo &displayGroupInfo) +bool InputWindowsManager::OnDisplayRemovedOrCombinationChanged(const OLD::DisplayGroupInfo &displayGroupInfo) { auto &displaysInfoVector = GetDisplayInfoVector(displayGroupInfo.groupId); if (displayGroupInfo.displaysInfo.empty() || displaysInfoVector.empty()) { @@ -6894,14 +6953,14 @@ bool InputWindowsManager::OnDisplayRemovedOrCombinationChanged(const DisplayGrou MMI_HILOGD("display has been removed"); return true; } - DisplayInfo newMainDisplayInfo; - DisplayInfo oldMainDisplayInfo; + OLD::DisplayInfo newMainDisplayInfo; + OLD::DisplayInfo oldMainDisplayInfo; (void)GetMainScreenDisplayInfo(displayGroupInfo.displaysInfo, newMainDisplayInfo); (void)GetMainScreenDisplayInfo(displaysInfoVector, oldMainDisplayInfo); MMI_HILOGI("newMainDisplayInfo:%{public}d, oldMainDisplayInfo:%{public}d", - newMainDisplayInfo.uniqueId, oldMainDisplayInfo.uniqueId); + newMainDisplayInfo.rsId, oldMainDisplayInfo.rsId); if (displayGroupInfo.displaysInfo.size() == displaysInfoVector.size() && - newMainDisplayInfo.uniqueId != oldMainDisplayInfo.uniqueId) { + newMainDisplayInfo.rsId != oldMainDisplayInfo.rsId) { MMI_HILOGD("current mainScreenDisplayId changed"); return true; } @@ -6931,12 +6990,12 @@ void InputWindowsManager::SetFoldState() BytraceAdapter::StopFoldState(); } -const std::shared_ptr InputWindowsManager::GetPhysicalDisplay(int32_t id, - const DisplayGroupInfo &displayGroupInfo) const +const std::shared_ptr InputWindowsManager::GetPhysicalDisplay(int32_t id, + const OLD::DisplayGroupInfo &displayGroupInfo) const { for (const auto &it : displayGroupInfo.displaysInfo) { if (it.id == id) { - return std::make_shared(it); + return std::make_shared(it); } } MMI_HILOGW("Failed to obtain physical(%{public}d) display", id); @@ -7193,7 +7252,7 @@ std::shared_ptr InputWindowsManager::GetlastPointerEvent() return lastPointerEvent_; } -std::pair InputWindowsManager::CalcDrawCoordinate(const DisplayInfo& displayInfo, +std::pair InputWindowsManager::CalcDrawCoordinate(const OLD::DisplayInfo& displayInfo, PointerEvent::PointerItem pointerItem) { CALL_DEBUG_ENTER; @@ -7354,4 +7413,4 @@ int32_t InputWindowsManager::ClearMouseHideFlag(int32_t eventId) return RET_ERR; } } // namespace MMI -} // namespace OHOS +} // namespace OHOS \ No newline at end of file diff --git a/service/window_manager/src/knuckle_drawing_manager.cpp b/service/window_manager/src/knuckle_drawing_manager.cpp index 5db1b17be1d217c0ef8ab642e1e5982f25f5179d..9f5d704b977136cac68170a74afaeae0b05d93c4 100644 --- a/service/window_manager/src/knuckle_drawing_manager.cpp +++ b/service/window_manager/src/knuckle_drawing_manager.cpp @@ -155,7 +155,7 @@ KnuckleDrawingManager::KnuckleDrawingManager() displayInfo_.displayDirection = Direction::DIRECTION0; } -void KnuckleDrawingManager::KnuckleDrawHandler(std::shared_ptr touchEvent, int32_t displayId) +void KnuckleDrawingManager::KnuckleDrawHandler(std::shared_ptr touchEvent, int32_t rsId) { CALL_DEBUG_ENTER; CHKPV(touchEvent); @@ -165,10 +165,10 @@ void KnuckleDrawingManager::KnuckleDrawHandler(std::shared_ptr tou CreateObserver(); int32_t touchAction = touchEvent->GetPointerAction(); if (IsValidAction(touchAction) && IsSingleKnuckleDoubleClick(touchEvent)) { - if (displayId == DEFAULT_VALUE) { - displayId = touchEvent->GetTargetDisplayId(); + if (rsId == DEFAULT_VALUE) { + rsId = touchEvent->GetTargetDisplayId(); } - CreateTouchWindow(displayId); + CreateTouchWindow(rsId); StartTouchDraw(touchEvent); } } @@ -242,7 +242,7 @@ bool KnuckleDrawingManager::IsValidAction(const int32_t action) return false; } -void KnuckleDrawingManager::UpdateDisplayInfo(const DisplayInfo& displayInfo) +void KnuckleDrawingManager::UpdateDisplayInfo(const OLD::DisplayInfo& displayInfo) { CALL_DEBUG_ENTER; if (displayInfo_.direction != displayInfo.direction) { @@ -267,7 +267,7 @@ void KnuckleDrawingManager::StartTouchDraw(std::shared_ptr touchEv } void KnuckleDrawingManager::RotationCanvasNode( - std::shared_ptr canvasNode, const DisplayInfo& displayInfo) + std::shared_ptr canvasNode, const OLD::DisplayInfo& displayInfo) { CALL_DEBUG_ENTER; CHKPV(canvasNode); @@ -340,7 +340,7 @@ void KnuckleDrawingManager::InitParticleEmitter() isNeedInitParticleEmitter_ = false; } -void KnuckleDrawingManager::CreateTouchWindow(const int32_t displayId) +void KnuckleDrawingManager::CreateTouchWindow(const int32_t rsId) { CALL_DEBUG_ENTER; if (surfaceNode_ != nullptr) { @@ -365,7 +365,7 @@ void KnuckleDrawingManager::CreateTouchWindow(const int32_t displayId) surfaceNode_->SetBackgroundColor(Rosen::Drawing::Color::COLOR_TRANSPARENT); #endif // USE_ROSEN_DRAWING - screenId_ = static_cast(displayId); + screenId_ = static_cast(rsId); surfaceNode_->SetRotation(0); CreateBrushWorkCanvasNode(); CreateTrackCanvasNode(); @@ -377,6 +377,7 @@ void KnuckleDrawingManager::CreateTouchWindow(const int32_t displayId) MMI_HILOGI("g_WindowScreenId:%{public}" PRIu64 ", g_DisplayNodeScreenId:%{public}" PRIu64 ", screenId_:%{public}" PRIu64, g_WindowScreenId, g_DisplayNodeScreenId, screenId_); surfaceNode_->AttachToDisplay(screenId_); + MMI_HILOGI(">>>>>>>>KnuckleDrawingManager screenId_:%{public}" PRIu64, screenId_); RotationCanvasNode(brushCanvasNode_, displayInfo_); RotationCanvasNode(trackCanvasNode_, displayInfo_); brushCanvasNode_->ResetSurface(scaleW_, scaleH_); diff --git a/service/window_manager/src/knuckle_dynamic_drawing_manager.cpp b/service/window_manager/src/knuckle_dynamic_drawing_manager.cpp index 920a95da91305b2c8322e910d2c0387bc1e628cf..d770adc132eaff986198aaeec54b209f2758c465 100644 --- a/service/window_manager/src/knuckle_dynamic_drawing_manager.cpp +++ b/service/window_manager/src/knuckle_dynamic_drawing_manager.cpp @@ -110,17 +110,17 @@ void KnuckleDynamicDrawingManager::UpdateTrackColors() } void KnuckleDynamicDrawingManager::KnuckleDynamicDrawHandler(std::shared_ptr pointerEvent, - int32_t displayId) + int32_t rsId) { CALL_DEBUG_ENTER; CHKPV(pointerEvent); if (!IsSingleKnuckle(pointerEvent)) { return; } - if (displayId == DEFAULT_VALUE) { - displayId = pointerEvent->GetTargetDisplayId(); + if (rsId == DEFAULT_VALUE) { + rsId = pointerEvent->GetTargetDisplayId(); } - CreateTouchWindow(displayId); + CreateTouchWindow(rsId); if (CheckPointerAction(pointerEvent)) { StartTouchDraw(pointerEvent); } @@ -300,7 +300,7 @@ void KnuckleDynamicDrawingManager::ProcessMoveEvent(std::shared_ptr return RET_OK; } -void KnuckleDynamicDrawingManager::CreateTouchWindow(const int32_t displayId) +void KnuckleDynamicDrawingManager::CreateTouchWindow(const int32_t rsId) { CALL_DEBUG_ENTER; if (surfaceNode_ != nullptr) { @@ -372,7 +372,7 @@ void KnuckleDynamicDrawingManager::CreateTouchWindow(const int32_t displayId) surfaceNode_->SetBackgroundColor(Rosen::Drawing::Color::COLOR_TRANSPARENT); #endif // USE_ROSEN_DRAWING - screenId_ = static_cast(displayId); + screenId_ = static_cast(rsId); surfaceNode_->SetRotation(0); CreateCanvasNode(); @@ -382,6 +382,7 @@ void KnuckleDynamicDrawingManager::CreateTouchWindow(const int32_t displayId) } MMI_HILOGI("The screenId_:%{public}" PRIu64, screenId_); surfaceNode_->AttachToDisplay(screenId_); + MMI_HILOGI(">>>>>>>>KnuckleDynamicDrawingManager screenId_:%{public}" PRIu64, screenId_); CHKPV(knuckleDrawMgr_); knuckleDrawMgr_->RotationCanvasNode(canvasNode_, displayInfo_); canvasNode_->ResetSurface(scaleW_, scaleH_); diff --git a/service/window_manager/src/pointer_drawing_manager.cpp b/service/window_manager/src/pointer_drawing_manager.cpp index 4b3804e8645781e12e61ff8b8c5b17334aabb1d7..834ba8ca9ca465dfbe727f3878004b407611b903 100644 --- a/service/window_manager/src/pointer_drawing_manager.cpp +++ b/service/window_manager/src/pointer_drawing_manager.cpp @@ -334,8 +334,7 @@ ICON_TYPE PointerDrawingManager::MouseIcon2IconType(MOUSE_ICON m) return ICON_TYPE(mouseIcons_[m].alignmentWay); } -bool PointerDrawingManager::SetCursorLocation(int32_t displayId, int32_t physicalX, - int32_t physicalY, ICON_TYPE iconType) +bool PointerDrawingManager::SetCursorLocation(int32_t physicalX, int32_t physicalY, ICON_TYPE iconType) { bool magicCursorSetBounds = false; if (UpdateSurfaceNodeBounds(physicalX, physicalY) == RET_OK) { @@ -376,25 +375,25 @@ void PointerDrawingManager::ForceClearPointerVisiableStatus() } int32_t PointerDrawingManager::UpdateMouseLayer(const PointerStyle& pointerStyle, - int32_t displayId, int32_t physicalX, int32_t physicalY) + int32_t physicalX, int32_t physicalY) { if (InitLayer(MOUSE_ICON(lastMouseStyle_.id)) != RET_OK) { mouseIconUpdate_ = false; MMI_HILOGE("Init layer failed"); return RET_ERR; } - if (!SetCursorLocation(displayId, physicalX, physicalY, MouseIcon2IconType(MOUSE_ICON(lastMouseStyle_.id)))) { + if (!SetCursorLocation(physicalX, physicalY, MouseIcon2IconType(MOUSE_ICON(lastMouseStyle_.id)))) { return RET_ERR; } return RET_OK; } -int32_t PointerDrawingManager::DrawMovePointer(int32_t displayId, int32_t physicalX, int32_t physicalY, +int32_t PointerDrawingManager::DrawMovePointer(int32_t rsId, int32_t physicalX, int32_t physicalY, PointerStyle pointerStyle, Direction direction) { CHKPR(GetSurfaceNode(), RET_ERR); MMI_HILOGD("Pointer window move success, pointerStyle id:%{public}d", pointerStyle.id); - displayId_ = displayId; + displayId_ = rsId; #ifdef OHOS_BUILD_ENABLE_MAGICCURSOR bool cursorEnlarged = MAGIC_POINTER_VELOCITY_TRACKER->GetCursorEnlargedStatus(); if (cursorEnlarged) { @@ -406,10 +405,10 @@ int32_t PointerDrawingManager::DrawMovePointer(int32_t displayId, int32_t physic } #endif // OHOS_BUILD_ENABLE_MAGICCURSOR if (GetHardCursorEnabled()) { - UpdateBindDisplayId(displayId); + UpdateBindDisplayId(rsId); } if (lastMouseStyle_ == pointerStyle && !mouseIconUpdate_ && lastDirection_ == direction) { - if (!SetCursorLocation(displayId, physicalX, physicalY, MouseIcon2IconType(MOUSE_ICON(lastMouseStyle_.id)))) { + if (!SetCursorLocation(physicalX, physicalY, MouseIcon2IconType(MOUSE_ICON(lastMouseStyle_.id)))) { return RET_ERR; } MMI_HILOGD("The lastpointerStyle is equal with pointerStyle, id:%{public}d, size:%{public}d", @@ -424,15 +423,15 @@ int32_t PointerDrawingManager::DrawMovePointer(int32_t displayId, int32_t physic if (GetHardCursorEnabled()) { UpdatePointerVisible(); } else { - int32_t UpdateLayerRes = UpdateMouseLayer(pointerStyle, displayId, physicalX, physicalY); + int32_t UpdateLayerRes = UpdateMouseLayer(pointerStyle, physicalX, physicalY); if (UpdateLayerRes != RET_OK) { MMI_HILOGE("Update Mouse Layer failed."); } UpdatePointerVisible(); } mouseIconUpdate_ = false; - MMI_HILOGD("Leave, display:%{public}d, physicalX:%{public}d, physicalY:%{public}d", - displayId, physicalX, physicalY); + MMI_HILOGD("Leave, rsId:%{public}d, physicalX:%{private}d, physicalY:%{private}d", + rsId, physicalX, physicalY); return RET_OK; } @@ -461,7 +460,7 @@ void PointerDrawingManager::DrawMovePointer(int32_t displayId, int32_t physicalX UpdateBindDisplayId(displayId); } if (GetSurfaceNode() != nullptr) { - if (!SetCursorLocation(displayId, physicalX, physicalY, MouseIcon2IconType(MOUSE_ICON(lastMouseStyle_.id)))) { + if (!SetCursorLocation(physicalX, physicalY, MouseIcon2IconType(MOUSE_ICON(lastMouseStyle_.id)))) { MMI_HILOGE("SetCursorLocation failed"); return; } @@ -469,7 +468,7 @@ void PointerDrawingManager::DrawMovePointer(int32_t displayId, int32_t physicalX } } -void PointerDrawingManager::SetHardwareCursorPosition(int32_t displayId, int32_t physicalX, int32_t physicalY, +void PointerDrawingManager::SetHardwareCursorPosition(int32_t physicalX, int32_t physicalY, PointerStyle pointerStyle) { if (GetHardCursorEnabled() && lastMouseStyle_.id != MOUSE_ICON::LOADING && @@ -482,12 +481,12 @@ void PointerDrawingManager::SetHardwareCursorPosition(int32_t displayId, int32_t } } -void PointerDrawingManager::DrawPointer(int32_t displayId, int32_t physicalX, int32_t physicalY, +void PointerDrawingManager::DrawPointer(int32_t rsId, int32_t physicalX, int32_t physicalY, const PointerStyle pointerStyle, Direction direction) { CALL_DEBUG_ENTER; - MMI_HILOGD("Display:%{public}d, physicalX:%{public}d, physicalY:%{public}d, pointerStyle:%{public}d", - displayId, physicalX, physicalY, pointerStyle.id); + MMI_HILOGD("rsId:%{public}d, physicalX:%{private}d, physicalY:%{private}d, pointerStyle:%{public}d", + rsId, physicalX, physicalY, pointerStyle.id); FixCursorPosition(physicalX, physicalY); lastPhysicalX_ = physicalX; lastPhysicalY_ = physicalY; @@ -499,18 +498,18 @@ void PointerDrawingManager::DrawPointer(int32_t displayId, int32_t physicalX, in MMI_HILOGD("MagicCursor AdjustMouseFocus:%{public}d", ICON_TYPE(mouseIcons_[MOUSE_ICON(pointerStyle.id)].alignmentWay)); } - if (DrawMovePointer(displayId, physicalX, physicalY, pointerStyle, direction) == RET_OK) { + if (DrawMovePointer(rsId, physicalX, physicalY, pointerStyle, direction) == RET_OK) { return; } #ifdef OHOS_BUILD_ENABLE_MAGICCURSOR if (HasMagicCursor() && currentMouseStyle_.id != DEVELOPER_DEFINED_ICON) { MMI_HILOGD("magicCursor DrawPointer enter CreatePointerWindow"); - MAGIC_CURSOR->CreatePointerWindow(displayId, physicalX, physicalY, direction, surfaceNode_); + MAGIC_CURSOR->CreatePointerWindow(rsId, physicalX, physicalY, direction, surfaceNode_); } else { - CreatePointerWindow(displayId, physicalX, physicalY, direction); + CreatePointerWindow(rsId, physicalX, physicalY, direction); } #else - CreatePointerWindow(displayId, physicalX, physicalY, direction); + CreatePointerWindow(rsId, physicalX, physicalY, direction); #endif // OHOS_BUILD_ENABLE_MAGICCURSOR CHKPV(GetSurfaceNode()); UpdateMouseStyle(); @@ -519,8 +518,9 @@ void PointerDrawingManager::DrawPointer(int32_t displayId, int32_t physicalX, in return; } UpdatePointerVisible(); - SetHardwareCursorPosition(displayId, physicalX, physicalY, lastMouseStyle_); - MMI_HILOGI("Leave, display:%{public}d, physicalX:%d, physicalY:%d", displayId, physicalX, physicalY); + SetHardwareCursorPosition(physicalX, physicalY, lastMouseStyle_); + MMI_HILOGI("Leave, rsId:%{public}d, physicalX:%{public}d, physicalY:%{public}d", + rsId, physicalX, physicalY); } void PointerDrawingManager::UpdateMouseStyle() @@ -560,10 +560,10 @@ int32_t PointerDrawingManager::SwitchPointerStyle() #ifdef OHOS_BUILD_ENABLE_MAGICCURSOR if (HasMagicCursor()) { MAGIC_CURSOR->EnableCursorInversion(); - MAGIC_CURSOR->CreatePointerWindow(displayInfo_.uniqueId, physicalX, physicalY, direction, surfaceNode_); + MAGIC_CURSOR->CreatePointerWindow(displayInfo_.rsId, physicalX, physicalY, direction, surfaceNode_); } else { MAGIC_CURSOR->DisableCursorInversion(); - CreatePointerWindow(displayInfo_.uniqueId, physicalX, physicalY, direction); + CreatePointerWindow(displayInfo_.rsId, physicalX, physicalY, direction); } #endif // OHOS_BUILD_ENABLE_MAGICCURSOR int32_t ret = InitLayer(MOUSE_ICON(lastMouseStyle_.id)); @@ -572,7 +572,7 @@ int32_t PointerDrawingManager::SwitchPointerStyle() return ret; } UpdatePointerVisible(); - SetHardwareCursorPosition(displayInfo_.uniqueId, physicalX, physicalY, lastMouseStyle_); + SetHardwareCursorPosition(physicalX, physicalY, lastMouseStyle_); return RET_OK; } @@ -726,15 +726,15 @@ sptr PointerDrawingManager::RetryGetSurfaceBuffer(sptrdisplayMode == DisplayMode::FULL && foldableDevicePolicyFull)))); } -Direction PointerDrawingManager::GetDisplayDirection(const DisplayInfo *displayInfo) +Direction PointerDrawingManager::GetDisplayDirection(const OLD::DisplayInfo *displayInfo) { Direction direction = static_cast(( ((displayInfo->direction - displayInfo->displayDirection) * ANGLE_90 + ANGLE_360) % ANGLE_360) / ANGLE_90); @@ -1613,6 +1613,7 @@ void PointerDrawingManager::AttachToDisplay() } auto surfaceNodePtr = GetSurfaceNode(); CHKPV(surfaceNodePtr); + MMI_HILOGI(">>>>>>>>>>>AttachToDisplay screenId_:%{public}" PRIu64"", screenId_); surfaceNodePtr->AttachToDisplay(screenId_); } @@ -1638,21 +1639,21 @@ void PointerDrawingManager::CreateCanvasNode() surfaceNodePtr->AddChild(canvasNode_, DEFAULT_VALUE); } -int32_t PointerDrawingManager::CreatePointerWindowForScreenPointer(int32_t displayId, +int32_t PointerDrawingManager::CreatePointerWindowForScreenPointer(int32_t rsId, int32_t physicalX, int32_t physicalY) { CALL_DEBUG_ENTER; // suface node init std::shared_ptr sp = nullptr; { - if (screenPointers_.count(static_cast(displayId))) { - sp = screenPointers_[displayId]; + if (screenPointers_.count(static_cast(rsId))) { + sp = screenPointers_[rsId]; if (!g_isRsRestart) { for (auto it : screenPointers_) { CHKPR(it.second, RET_ERR); it.second->Init(pointerRenderer_); } - if (displayId == displayInfo_.uniqueId) { + if (rsId == displayInfo_.rsId) { CHKPR(sp, RET_ERR); SetSurfaceNode(sp->GetSurfaceNode()); } @@ -1663,16 +1664,16 @@ int32_t PointerDrawingManager::CreatePointerWindowForScreenPointer(int32_t displ g_isRsRestart = true; sp = std::make_shared(hardwareCursorPointerManager_, handler_, displayInfo_); CHKPR(sp, RET_ERR); - screenPointers_[displayInfo_.uniqueId] = sp; + screenPointers_[displayInfo_.rsId] = sp; if (!sp->Init(pointerRenderer_)) { - MMI_HILOGE("ScreenPointer %{public}d init failed", displayInfo_.uniqueId); + MMI_HILOGE("ScreenPointer %{public}d init failed", displayInfo_.rsId); return RET_ERR; } - if (displayId == displayInfo_.uniqueId) { + if (rsId == displayInfo_.rsId) { SetSurfaceNode(sp->GetSurfaceNode()); } - MMI_HILOGI("ScreenPointer displayId %{public}d displayInfo_.uniqueId %{public}d", - displayId, displayInfo_.uniqueId); + MMI_HILOGI("ScreenPointer rsId %{public}d displayInfo_.rsId %{public}d", + rsId, displayInfo_.rsId); Rosen::RSTransaction::FlushImplicitTransaction(); } } @@ -1683,8 +1684,7 @@ int32_t PointerDrawingManager::CreatePointerWindowForScreenPointer(int32_t displ return RET_OK; } -int32_t PointerDrawingManager::CreatePointerWindowForNoScreenPointer(int32_t displayId, - int32_t physicalX, int32_t physicalY) +int32_t PointerDrawingManager::CreatePointerWindowForNoScreenPointer(int32_t physicalX, int32_t physicalY) { CALL_DEBUG_ENTER; Rosen::RSSurfaceNodeConfig surfaceNodeConfig; @@ -1704,27 +1704,28 @@ int32_t PointerDrawingManager::CreatePointerWindowForNoScreenPointer(int32_t dis return RET_OK; } -void PointerDrawingManager::CreatePointerWindow(int32_t displayId, int32_t physicalX, int32_t physicalY, +void PointerDrawingManager::CreatePointerWindow(int32_t rsId, int32_t physicalX, int32_t physicalY, Direction direction) { CALL_DEBUG_ENTER; CALL_INFO_TRACE; - BytraceAdapter::StartRsSurfaceNode(displayId); + BytraceAdapter::StartRsSurfaceNode(rsId); if (GetHardCursorEnabled()) { g_isHdiRemoteDied = false; - if (CreatePointerWindowForScreenPointer(displayId, physicalX, physicalY) != RET_OK) { + if (CreatePointerWindowForScreenPointer(rsId, physicalX, physicalY) != RET_OK) { return; } } else { - if (CreatePointerWindowForNoScreenPointer(displayId, physicalX, physicalY) != RET_OK) { + if (CreatePointerWindowForNoScreenPointer(rsId, physicalX, physicalY) != RET_OK) { return; } } MMI_HILOGI("CreatePointerWindow The screenId_:%{public}" PRIu64, screenId_); - screenId_ = static_cast(displayId); + screenId_ = static_cast(rsId); AttachToDisplay(); - lastDisplayId_ = displayId; + lastDisplayId_ = rsId; + MMI_HILOGI(">>>>>>>>>>>>>>>>CreatePointerWindow The screenId_:%{public}" PRIu64, screenId_); RotateDegree(direction); lastDirection_ = direction; CreateCanvasNode(); @@ -2192,7 +2193,7 @@ int32_t PointerDrawingManager::SetPointerColor(int32_t color) } } UpdatePointerVisible(); - SetHardwareCursorPosition(displayInfo_.uniqueId, lastPhysicalX_, lastPhysicalY_, lastMouseStyle_); + SetHardwareCursorPosition(lastPhysicalX_, lastPhysicalY_, lastMouseStyle_); return RET_OK; } @@ -2210,12 +2211,12 @@ int32_t PointerDrawingManager::GetPointerColor() return pointerColor; } -void PointerDrawingManager::UpdateDisplayInfo(const DisplayInfo &displayInfo) +void PointerDrawingManager::UpdateDisplayInfo(const OLD::DisplayInfo &displayInfo) { CALL_DEBUG_ENTER; if (GetHardCursorEnabled()) { - if (screenPointers_.count(static_cast(displayInfo.uniqueId))) { - auto sp = screenPointers_[displayInfo.uniqueId]; + if (screenPointers_.count(static_cast(displayInfo.rsId))) { + auto sp = screenPointers_[displayInfo.rsId]; CHKPV(sp); sp->OnDisplayInfo(displayInfo, IsWindowRotation(&displayInfo)); if (sp->IsMain()) { @@ -2280,12 +2281,12 @@ int32_t PointerDrawingManager::SetPointerSize(int32_t size) AdjustMouseFocusToSoftRenderOrigin(direction, MOUSE_ICON(lastMouseStyle_.id), physicalX, physicalY); #ifdef OHOS_BUILD_ENABLE_MAGICCURSOR if (HasMagicCursor()) { - MAGIC_CURSOR->CreatePointerWindow(displayInfo_.uniqueId, physicalX, physicalY, direction, surfaceNode_); + MAGIC_CURSOR->CreatePointerWindow(displayInfo_.rsId, physicalX, physicalY, direction, surfaceNode_); } else { - CreatePointerWindow(displayInfo_.uniqueId, physicalX, physicalY, direction); + CreatePointerWindow(displayInfo_.rsId, physicalX, physicalY, direction); } #else - CreatePointerWindow(displayInfo_.uniqueId, physicalX, physicalY, direction); + CreatePointerWindow(displayInfo_.rsId, physicalX, physicalY, direction); #endif // OHOS_BUILD_ENABLE_MAGICCURSOR if (lastMouseStyle_.id == MOUSE_ICON::CURSOR_CIRCLE) { MMI_HILOGE("Cursor circle does not need to draw size"); @@ -2295,7 +2296,7 @@ int32_t PointerDrawingManager::SetPointerSize(int32_t size) return RET_ERR; } UpdatePointerVisible(); - SetHardwareCursorPosition(displayInfo_.uniqueId, physicalX, physicalY, lastMouseStyle_); + SetHardwareCursorPosition(physicalX, physicalY, lastMouseStyle_); return RET_OK; } @@ -2323,7 +2324,7 @@ int32_t PointerDrawingManager::GetCursorSurfaceId(uint64_t &surfaceId) return RET_OK; } -void PointerDrawingManager::OnDisplayInfo(const DisplayGroupInfo &displayGroupInfo) +void PointerDrawingManager::OnDisplayInfo(const OLD::DisplayGroupInfo &displayGroupInfo) { CALL_DEBUG_ENTER; if (displayGroupInfo.groupId != DEFAULT_GROUP_ID) { @@ -2331,21 +2332,21 @@ void PointerDrawingManager::OnDisplayInfo(const DisplayGroupInfo &displayGroupIn return; } for (const auto& item : displayGroupInfo.displaysInfo) { - if (item.uniqueId == displayInfo_.uniqueId && - item.screenCombination == displayInfo_.screenCombination) { + if (item.rsId == displayInfo_.rsId && + item.displaySourceMode == displayInfo_.displaySourceMode) { UpdateDisplayInfo(item); DrawManager(); return; } } - DisplayInfo displayInfo = displayGroupInfo.displaysInfo[0]; + OLD::DisplayInfo displayInfo = displayGroupInfo.displaysInfo[0]; if (GetHardCursorEnabled()) { (void)GetMainScreenDisplayInfo(displayGroupInfo, displayInfo); } UpdateDisplayInfo(displayInfo); lastPhysicalX_ = displayInfo.validWidth / CALCULATE_MIDDLE; lastPhysicalY_ = displayInfo.validHeight / CALCULATE_MIDDLE; - MouseEventHdr->OnDisplayLost(displayInfo_.uniqueId); + MouseEventHdr->OnDisplayLost(displayInfo_.rsId); auto surfaceNodePtr = GetSurfaceNode(); if (surfaceNodePtr != nullptr) { if (!GetHardCursorEnabled()) { @@ -2356,8 +2357,8 @@ void PointerDrawingManager::OnDisplayInfo(const DisplayGroupInfo &displayGroupIn Rosen::RSTransaction::FlushImplicitTransaction(); MMI_HILOGD("Pointer window destroy success"); } - MMI_HILOGD("displayId_:%{public}d, displayWidth_:%{public}d, displayHeight_:%{public}d", - displayInfo_.uniqueId, displayInfo_.validWidth, displayInfo_.validHeight); + MMI_HILOGD("rsId:%{public}d, displayWidth_:%{public}d, displayHeight_:%{public}d", + displayInfo_.rsId, displayInfo_.validWidth, displayInfo_.validHeight); } void PointerDrawingManager::OnWindowInfo(const WinInfo &info) @@ -2383,7 +2384,7 @@ void PointerDrawingManager::UpdatePointerDevice(bool hasPointerDevice, bool isPo pointerVisible = (pointerVisible && IsPointerVisible()); } SetPointerVisible(getpid(), pointerVisible, 0, false); - } else { +} else { DeletePointerVisible(getpid()); } DrawManager(); @@ -2477,12 +2478,12 @@ void PointerDrawingManager::DrawManager() Direction direction = GetDisplayDirection(&displayInfo_); lastDrawPointerStyle_ = pointerStyle; if (lastPhysicalX_ == -1 || lastPhysicalY_ == -1) { - DrawPointer(displayInfo_.uniqueId, displayInfo_.validWidth / CALCULATE_MIDDLE, + DrawPointer(displayInfo_.rsId, displayInfo_.validWidth / CALCULATE_MIDDLE, displayInfo_.validHeight / CALCULATE_MIDDLE, pointerStyle, direction); MMI_HILOGI("Draw manager, mouseStyle:%{public}d, last physical is initial value", pointerStyle.id); return; } - DrawPointer(displayInfo_.uniqueId, lastPhysicalX_, lastPhysicalY_, pointerStyle, direction); + DrawPointer(displayInfo_.rsId, lastPhysicalX_, lastPhysicalY_, pointerStyle, direction); MMI_HILOGI("Draw manager, mouseStyle:%{public}d", pointerStyle.id); return; } @@ -2533,7 +2534,7 @@ void PointerDrawingManager::UpdatePointerVisible() return; } auto align = MouseIcon2IconType(MOUSE_ICON(lastMouseStyle_.id)); - if (!SetCursorLocation(displayId_, lastPhysicalX_, lastPhysicalY_, align)) { + if (!SetCursorLocation(lastPhysicalX_, lastPhysicalY_, align)) { MMI_HILOGE("SetCursorLocation fail"); } } @@ -2706,7 +2707,7 @@ void PointerDrawingManager::SetPointerLocation(int32_t x, int32_t y, int32_t dis CHKPV(surfaceNodePtr); displayId_ = displayId; if (GetHardCursorEnabled()) { - if (!SetCursorLocation(displayId_, x, y, MouseIcon2IconType(MOUSE_ICON(lastMouseStyle_.id)))) { + if (!SetCursorLocation(x, y, MouseIcon2IconType(MOUSE_ICON(lastMouseStyle_.id)))) { MMI_HILOGE("SetCursorLocation fail"); return; } @@ -2934,13 +2935,13 @@ void PointerDrawingManager::DrawPointerStyle(const PointerStyle& pointerStyle) } Direction direction = GetDisplayDirection(&displayInfo_); if (lastPhysicalX_ == -1 || lastPhysicalY_ == -1) { - DrawPointer(displayInfo_.uniqueId, displayInfo_.validWidth / CALCULATE_MIDDLE, + DrawPointer(displayInfo_.rsId, displayInfo_.validWidth / CALCULATE_MIDDLE, displayInfo_.validHeight / CALCULATE_MIDDLE, pointerStyle, direction); MMI_HILOGD("Draw pointer style, mouseStyle:%{public}d", pointerStyle.id); return; } - DrawPointer(displayInfo_.uniqueId, lastPhysicalX_, lastPhysicalY_, pointerStyle, direction); + DrawPointer(displayInfo_.rsId, lastPhysicalX_, lastPhysicalY_, pointerStyle, direction); MMI_HILOGD("Draw pointer style, mouseStyle:%{public}d", pointerStyle.id); } } @@ -3102,15 +3103,15 @@ int32_t PointerDrawingManager::SkipPointerLayer(bool isSkip) return RET_OK; } -std::vector> PointerDrawingManager::GetDisplayInfo(DisplayInfo &di) +std::vector> PointerDrawingManager::GetDisplayInfo(OLD::DisplayInfo &di) { std::vector> displayInfo = { {std::to_string(di.id), std::to_string(di.x), std::to_string(di.y), std::to_string(di.width), std::to_string(di.height), std::to_string(di.dpi), di.name, di.uniq, std::to_string(static_cast(di.direction)), std::to_string(static_cast(di.displayDirection)), std::to_string(static_cast(di.displayMode)), std::to_string(di.isCurrentOffScreenRendering), - std::to_string(di.screenRealWidth), std::to_string(di.screenRealHeight), std::to_string(di.screenRealPPI), - std::to_string(di.screenRealDPI), std::to_string(static_cast(di.screenCombination))}}; + std::to_string(di.screenRealWidth), std::to_string(di.screenRealHeight), + std::to_string(di.screenRealDPI), std::to_string(static_cast(di.displaySourceMode))}}; return displayInfo; } @@ -3179,13 +3180,13 @@ void PointerDrawingManager::Dump(int32_t fd, const std::vector &arg dprintf(fd, dumpInfo.c_str()); } -void PointerDrawingManager::UpdateBindDisplayId(int32_t displayId) +void PointerDrawingManager::UpdateBindDisplayId(int32_t rsId) { - if (lastDisplayId_ == displayId) { + if (lastDisplayId_ == rsId) { return; } - MMI_HILOGI("Mouse traversal occurs, lastDisplayId_:%{public}d, displayId:%{public}d", - lastDisplayId_, displayId); + MMI_HILOGI("Mouse traversal occurs, lastDisplayId_:%{public}d, rsId:%{public}d", + lastDisplayId_, rsId); if (GetHardCursorEnabled()) { // 隐藏上一个屏幕的软、硬光标 @@ -3196,8 +3197,8 @@ void PointerDrawingManager::UpdateBindDisplayId(int32_t displayId) Rosen::RSTransaction::FlushImplicitTransaction(); // 绑定新屏幕 SurfaceNode 到全局 surfaceNode_ - screenId_ = static_cast(displayId); - MMI_HILOGI("The screenId_:%{public}" PRIu64, screenId_); + screenId_ = static_cast(rsId); + MMI_HILOGI(">>>>>>>>>>>>>The screenId_:%{public}" PRIu64, screenId_); AttachToDisplay(); // 新屏幕上重新绘制软硬光标 @@ -3206,17 +3207,17 @@ void PointerDrawingManager::UpdateBindDisplayId(int32_t displayId) // 绑定新屏幕 SurfaceNode 到全局 surfaceNode_ MMI_HILOGI("UpdateBindDisplayId The screenId_:%{public}" PRIu64, screenId_); - screenId_ = static_cast(displayId); + screenId_ = static_cast(rsId); MMI_HILOGI("The screenId_:%{public}" PRIu64, screenId_); AttachToDisplay(); // 新屏幕上软硬光标位置更新 auto align = MouseIcon2IconType(MOUSE_ICON(lastMouseStyle_.id)); - if (!SetCursorLocation(displayId, lastPhysicalX_, lastPhysicalY_, align)) { + if (!SetCursorLocation(lastPhysicalX_, lastPhysicalY_, align)) { MMI_HILOGE("SetCursorLocation fail"); } - lastDisplayId_ = displayId; + lastDisplayId_ = rsId; } void PointerDrawingManager::OnScreenModeChange(const std::vector> &screens) @@ -3230,7 +3231,7 @@ void PointerDrawingManager::OnScreenModeChange(const std::vector lock(mtx_); // construct ScreenPointers for new screens for (auto si : screens) { - MMI_HILOGI("Got screen, id:%{public}llu, shape=(%{public}u,%{public}u), rotation=%{public}u, " + MMI_HILOGI("Got screen, RsId:%{public}lu, shape=(%{public}u,%{public}u), rotation=%{public}u, " "dpi=%{public}f", si->GetRsId(), GetScreenInfoWidth(si), GetScreenInfoHeight(si), si->GetRotation(), si->GetVirtualPixelRatio()); if (si->GetType() != OHOS::Rosen::ScreenType::REAL) { @@ -3424,7 +3425,7 @@ int32_t PointerDrawingManager::DrawHardCursor(std::shared_ptr sp, return RET_OK; } -void PointerDrawingManager::UpdateMirrorScreens(std::shared_ptr sp, DisplayInfo displayInfo) +void PointerDrawingManager::UpdateMirrorScreens(std::shared_ptr sp, OLD::DisplayInfo displayInfo) { uint32_t mainWidth = sp->GetScreenWidth(); uint32_t mainHeight = sp->GetScreenHeight(); @@ -3612,7 +3613,7 @@ void PointerDrawingManager::DrawScreenCenterPointer(const PointerStyle& pointerS std::swap(x, y); } MMI_HILOGD("DrawScreenCenterPointer, x=%{public}d, y=%{public}d", x, y); - DrawPointer(displayInfo_.uniqueId, x, y, pointerStyle, direction); + DrawPointer(displayInfo_.rsId, x, y, pointerStyle, direction); } else { DrawPointer(displayInfo_.id, displayInfo_.validWidth / CALCULATE_MIDDLE, displayInfo_.validHeight / CALCULATE_MIDDLE, pointerStyle, direction); @@ -3753,7 +3754,7 @@ void PointerDrawingManager::SetSurfaceNode(std::shared_ptr surfaceNode_ = ptr; } -DisplayInfo PointerDrawingManager::GetCurrentDisplayInfo() +OLD::DisplayInfo PointerDrawingManager::GetCurrentDisplayInfo() { return displayInfo_; } diff --git a/service/window_manager/src/screen_pointer.cpp b/service/window_manager/src/screen_pointer.cpp index e4fd4dbb508d7278f22b1e9297bf1e6388fed8ba..fd0ca3f7e7c5770f91c5bdc01b50699bd13c5ec4 100644 --- a/service/window_manager/src/screen_pointer.cpp +++ b/service/window_manager/src/screen_pointer.cpp @@ -67,10 +67,10 @@ uint32_t GetScreenInfoHeight(screen_info_ptr_t si) return modes[modeId]->height_; } -ScreenPointer::ScreenPointer(hwcmgr_ptr_t hwcMgr, handler_ptr_t handler, const DisplayInfo &di) +ScreenPointer::ScreenPointer(hwcmgr_ptr_t hwcMgr, handler_ptr_t handler, const OLD::DisplayInfo &di) : hwcMgr_(hwcMgr), handler_(handler) { - screenId_ = di.uniqueId; + screenId_ = di.rsId; width_ = di.width; height_ = di.height; rotation_ = static_cast(di.direction); @@ -311,9 +311,9 @@ void ScreenPointer::UpdateScreenInfo(const sptr si) "rotation=%{public}u, dpi=%{public}f", screenId_, width_, height_, mode_, rotation_, dpi_); } -void ScreenPointer::OnDisplayInfo(const DisplayInfo &di, bool isWindowRotation) +void ScreenPointer::OnDisplayInfo(const OLD::DisplayInfo &di, bool isWindowRotation) { - if (screenId_ != uint32_t(di.uniqueId)) { + if (screenId_ != uint32_t(di.rsId)) { return; } diff --git a/service/window_manager/src/touch_drawing_manager.cpp b/service/window_manager/src/touch_drawing_manager.cpp index 23c3e98cde026f4a38bb4d3e43c73d0df60e93ce..d3697db0cae5db93dc322e794498cb6ab0a4d44d 100644 --- a/service/window_manager/src/touch_drawing_manager.cpp +++ b/service/window_manager/src/touch_drawing_manager.cpp @@ -182,15 +182,15 @@ void TouchDrawingManager::TouchDrawHandler(std::shared_ptr pointer } } -void TouchDrawingManager::UpdateDisplayInfo(const DisplayInfo& displayInfo) +void TouchDrawingManager::UpdateDisplayInfo(const OLD::DisplayInfo& displayInfo) { CALL_DEBUG_ENTER; isChangedRotation_ = displayInfo.direction == displayInfo_.direction ? false : true; isChangedMode_ = displayInfo.displayMode == displayInfo_.displayMode ? false : true; scaleW_ = displayInfo.validWidth > displayInfo.validHeight ? displayInfo.validWidth : displayInfo.validHeight; scaleH_ = displayInfo.validWidth > displayInfo.validHeight ? displayInfo.validWidth : displayInfo.validHeight; - if (displayInfo.screenCombination != displayInfo_.screenCombination || - displayInfo.uniqueId != displayInfo_.uniqueId) { + if (displayInfo.displaySourceMode != displayInfo_.displaySourceMode || + displayInfo.rsId != displayInfo_.rsId) { if (surfaceNode_ != nullptr) { surfaceNode_->ClearChildren(); surfaceNode_.reset(); @@ -400,11 +400,11 @@ void TouchDrawingManager::AddCanvasNode(std::shared_ptr& ca CALL_DEBUG_ENTER; std::lock_guard lock(mutex_); CHKPV(surfaceNode_); - if (canvasNode != nullptr && screenId_ == static_cast(displayInfo_.uniqueId)) { + if (canvasNode != nullptr && screenId_ == static_cast(displayInfo_.rsId)) { return; } - MMI_HILOGI("Screen from:%{public}" PRIu64 " to :%{public}d", screenId_, displayInfo_.uniqueId); - screenId_ = static_cast(displayInfo_.uniqueId); + MMI_HILOGI("Screen from:%{public}" PRIu64 " to :%{public}d", screenId_, displayInfo_.rsId); + screenId_ = static_cast(displayInfo_.rsId); canvasNode = isTrackerNode ? Rosen::RSCanvasDrawingNode::Create() : Rosen::RSCanvasNode::Create(); canvasNode->SetBounds(0, 0, scaleW_, scaleH_); canvasNode->SetFrame(0, 0, scaleW_, scaleH_); @@ -490,11 +490,12 @@ void TouchDrawingManager::CreateTouchWindow() surfaceNode_->SetBackgroundColor(Rosen::Drawing::Color::COLOR_TRANSPARENT); #endif surfaceNode_->SetRotation(0); - screenId_ = static_cast(displayInfo_.uniqueId); + screenId_ = static_cast(displayInfo_.rsId); if (windowScreenId_ == screenId_) { screenId_ = displayNodeScreenId_; } surfaceNode_->AttachToDisplay(screenId_); + MMI_HILOGI(">>>>>>>>>>TouchDrawingManager::CreateTouchWindow:%" PRIu64, screenId_); MMI_HILOGI("Setting screen:%{public}" PRIu64 ", displayNode:%{public}" PRIu64, screenId_, surfaceNode_->GetId()); } diff --git a/service/window_manager/test/input_windows_manager_test.cpp b/service/window_manager/test/input_windows_manager_test.cpp index ae2a551b81c1a469b2ea80e8fb04a896c771845b..8dd8069f82efeeaebfaa6b23b8b23bde754f0fec 100644 --- a/service/window_manager/test/input_windows_manager_test.cpp +++ b/service/window_manager/test/input_windows_manager_test.cpp @@ -6751,7 +6751,7 @@ HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_UpdateDisplayInfo_Poin displayInfo1.name = "pp"; displayInfo1.uniq = "pp"; displayInfo1.direction = DIRECTION0; - displayInfo1.screenCombination = OHOS::MMI::ScreenCombination::SCREEN_MAIN; + displayInfo1.displaySourceMode = OHOS::MMI::DisplaySourceMode::SCREEN_MAIN; DisplayInfo displayInfo2; displayInfo2.id = 2; @@ -6763,7 +6763,7 @@ HWTEST_F(InputWindowsManagerTest, InputWindowsManagerTest_UpdateDisplayInfo_Poin displayInfo2.name = "pp"; displayInfo2.uniq = "pp"; displayInfo2.direction = DIRECTION0; - displayInfo2.screenCombination = OHOS::MMI::ScreenCombination::SCREEN_EXPAND; + displayInfo2.displaySourceMode = OHOS::MMI::DisplaySourceMode::SCREEN_EXPAND; displayGroupInfo.displaysInfo.push_back(displayInfo2); displayGroupInfo.displaysInfo.push_back(displayInfo1); diff --git a/util/common/include/struct_multimodal.h b/util/common/include/struct_multimodal.h index 03860e19e3b42ff7c4499fa0531cc8c2f2949811..47af8daef9f6d228eb05e8ac3e0a677dcb7e9eac 100644 --- a/util/common/include/struct_multimodal.h +++ b/util/common/include/struct_multimodal.h @@ -255,20 +255,21 @@ struct EventJoyStickAxis { EventJoyStickAxisAbsInfo abs_wheel; }; -struct NormalizedCoords { - double x {}; - double y {}; +struct MMICoordinate2D { + double x { 0.0f }; + double y { 0.0f }; }; -struct PhysicalCoordinate { - double x {}; - double y {}; -}; +using NormalizedCoords = MMICoordinate2D; +using PhysicalCoordinate = MMICoordinate2D; +using LogicalCoordinate = MMICoordinate2D; -struct LogicalCoordinate { - int32_t x {}; - int32_t y {}; -}; +using OriginalTPCoords = MMICoordinate2D; +using TouchPanelCoords = MMICoordinate2D; +using ScreenCoords = MMICoordinate2D; +using DefaultDisplayCoords = MMICoordinate2D; +using RotatedDisplayCoords = MMICoordinate2D; +using GlobalCoords = MMICoordinate2D; struct LogicalRectangle { LogicalCoordinate point; @@ -403,6 +404,7 @@ struct EventTouch { int32_t seatSlot {}; PhysicalCoordinate coordF {}; LogicalCoordinate point {}; + GlobalCoords globalCoord {}; // 全局坐标 LogicalRectangle toolRect {}; DEVICE_TYPE deviceType { DEVICE_TYPE::DEVICE_TYPE_UNKNOWN }; double pressure {};