diff --git a/multimodalinput_mini.gni b/multimodalinput_mini.gni index b480d73b26b8c9c796e00349a882bef68bf9610e..6d62a3c78781d405446279e60e10a87a0c9e6c66 100644 --- a/multimodalinput_mini.gni +++ b/multimodalinput_mini.gni @@ -435,6 +435,7 @@ if (input_feature_product == "pc") { input_default_defines += [ "OHOS_BUILD_PC_PRIORITY" ] input_default_defines += [ "OHOS_BUILD_PC_UNIT_TEST" ] input_default_defines += [ "OHOS_BUILD_MOUSE_REPORTING_RATE" ] + input_default_defines += [ "OHOS_BUILD_EXTERNAL_SCREEN" ] } if (input_feature_product == "watch") { diff --git a/service/mouse_event_normalize/src/mouse_transform_processor.cpp b/service/mouse_event_normalize/src/mouse_transform_processor.cpp index 133e6d1cf8cc5a2722b3bac536aa8a59bc02a392..28e64b152518194f06a706671a84c0c3d3bdce20 100644 --- a/service/mouse_event_normalize/src/mouse_transform_processor.cpp +++ b/service/mouse_event_normalize/src/mouse_transform_processor.cpp @@ -223,8 +223,8 @@ int32_t MouseTransformProcessor::UpdateMouseMoveLocation(const OLD::DisplayInfo* #ifdef OHOS_BUILD_MOUSE_REPORTING_RATE dalta_time = filterInsertionPoint_.filterDeltaTime; HandleFilterMouseEvent(&offset); - CalculateOffset(displayInfo, offset); #endif // OHOS_BUILD_MOUSE_REPORTING_RATE + CalculateOffset(displayInfo, offset); if (!enableMouseAleaccelerateBool_) { abs_x += offset.dx; abs_y += offset.dy; diff --git a/service/touch_event_normalize/include/touch_transform_processor.h b/service/touch_event_normalize/include/touch_transform_processor.h index 341c9263b828d66e6e3a13e4ccd88fdf9d61cca0..ab8fea8b614816c7440316c7e673d12f3997da7c 100644 --- a/service/touch_event_normalize/include/touch_transform_processor.h +++ b/service/touch_event_normalize/include/touch_transform_processor.h @@ -44,6 +44,11 @@ private: void UpdatePointerItemByTouchInfo(PointerEvent::PointerItem &item, EventTouch &touchInfo); void InitToolTypes(); bool DumpInner(); +#ifdef OHOS_BUILD_EXTERNAL_SCREEN + void AddInvalidAreaDownedEvent(int32_t seatSlot); + void RemoveInvalidAreaDownedEvent(int32_t seatSlot); + bool isInvalidAreaDownedEvent(int32_t seatSlot); +#endif // OHOS_BUILD_EXTERNAL_SCREEN private: const int32_t deviceId_ { -1 }; int32_t processedCount_ { 0 }; @@ -67,6 +72,9 @@ private: #ifdef OHOS_BUILD_ENABLE_FINGERSENSE_WRAPPER TouchType rawTouch_; #endif // OHOS_BUILD_ENABLE_FINGERSENSE_WRAPPER +#ifdef OHOS_BUILD_EXTERNAL_SCREEN + std::list InvalidAreaDownedEvents_; +#endif // OHOS_BUILD_EXTERNAL_SCREEN }; } // namespace MMI } // namespace OHOS diff --git a/service/touch_event_normalize/src/touch_transform_processor.cpp b/service/touch_event_normalize/src/touch_transform_processor.cpp index db9387aa8e027e610f5a8d36298ca01e1108412e..ed25aed587cf88285973e09505058ebb75213e36 100644 --- a/service/touch_event_normalize/src/touch_transform_processor.cpp +++ b/service/touch_event_normalize/src/touch_transform_processor.cpp @@ -38,6 +38,9 @@ constexpr int32_t DRIVER_NUMBER { 8 }; constexpr int32_t MT_TOOL_THP_FEATURE {11}; constexpr uint32_t TOUCH_CANCEL_MASK { 1U << 29U }; constexpr int32_t PRINT_INTERVAL_COUNT { 50 }; +#ifdef OHOS_BUILD_EXTERNAL_SCREEN +constexpr int32_t MAX_N_POINTER_ITEMS { 10 }; +#endif // OHOS_BUILD_EXTERNAL_SCREEN } // namespace TouchTransformProcessor::TouchTransformProcessor(int32_t deviceId) @@ -60,6 +63,9 @@ bool TouchTransformProcessor::OnEventTouchCancel(struct libinput_event *event) PointerEvent::PointerItem item; int32_t seatSlot = libinput_event_touch_get_seat_slot(touch); +#ifdef OHOS_BUILD_EXTERNAL_SCREEN + RemoveInvalidAreaDownedEvent(seatSlot); +#endif // OHOS_BUILD_EXTERNAL_SCREEN if (!(pointerEvent_->GetPointerItem(seatSlot, item))) { MMI_HILOGE("Get pointer parameter failed"); return false; @@ -86,10 +92,17 @@ bool TouchTransformProcessor::OnEventTouchDown(struct libinput_event *event) CHKPF(device); EventTouch touchInfo; int32_t logicalDisplayId = -1; + int32_t seatSlot = libinput_event_touch_get_seat_slot(touch); if (!WIN_MGR->TouchPointToDisplayPoint(deviceId_, touch, touchInfo, logicalDisplayId)) { MMI_HILOGE("TouchDownPointToDisplayPoint failed"); +#ifdef OHOS_BUILD_EXTERNAL_SCREEN + AddInvalidAreaDownedEvent(seatSlot); +#endif // OHOS_BUILD_EXTERNAL_SCREEN return false; } +#ifdef OHOS_BUILD_EXTERNAL_SCREEN + RemoveInvalidAreaDownedEvent(seatSlot); +#endif // OHOS_BUILD_EXTERNAL_SCREEN auto pointIds = pointerEvent_->GetPointerIds(); uint64_t time = libinput_event_touch_get_time_usec(touch); if (pointIds.empty()) { @@ -102,7 +115,6 @@ bool TouchTransformProcessor::OnEventTouchDown(struct libinput_event *event) int32_t blobId = libinput_event_touch_get_blob_id(touch); item.SetBlobId(blobId); double pressure = libinput_event_touch_get_pressure(touch); - int32_t seatSlot = libinput_event_touch_get_seat_slot(touch); // we clean up pointerItem's cancel mark at down stage to ensure newer event // always starts with a clean and inital state if (pointerItemCancelMarks_.find(seatSlot) != pointerItemCancelMarks_.end()) { @@ -199,7 +211,16 @@ bool TouchTransformProcessor::OnEventTouchMotion(struct libinput_event *event) pointerEvent_->SetPointerAction(PointerEvent::POINTER_ACTION_MOVE); EventTouch touchInfo; int32_t logicalDisplayId = pointerEvent_->GetTargetDisplayId(); - if (!WIN_MGR->TouchPointToDisplayPoint(deviceId_, touch, touchInfo, logicalDisplayId, true)) { + int32_t seatSlot = libinput_event_touch_get_seat_slot(touch); +#ifdef OHOS_BUILD_EXTERNAL_SCREEN + if (isInvalidAreaDownedEvent(seatSlot) && + WIN_MGR->TouchPointToDisplayPoint(deviceId_, touch, touchInfo, logicalDisplayId, true, false)) { + CHKFR(OnEventTouchDown(event), false, "Get OnEventTouchDown failed"); + RemoveInvalidAreaDownedEvent(seatSlot); + return true; + } +#endif // OHOS_BUILD_EXTERNAL_SCREEN + if (!WIN_MGR->TouchPointToDisplayPoint(deviceId_, touch, touchInfo, logicalDisplayId, true, true)) { processedCount_++; if (processedCount_ == PRINT_INTERVAL_COUNT) { MMI_HILOGE("Get TouchMotionPointToDisplayPoint failed"); @@ -208,7 +229,6 @@ bool TouchTransformProcessor::OnEventTouchMotion(struct libinput_event *event) return false; } PointerEvent::PointerItem item; - int32_t seatSlot = libinput_event_touch_get_seat_slot(touch); if (!(pointerEvent_->GetPointerItem(seatSlot, item))) { MMI_HILOGE("Get pointer parameter failed"); return false; @@ -242,6 +262,9 @@ bool TouchTransformProcessor::OnEventTouchUp(struct libinput_event *event) uint64_t time = libinput_event_touch_get_time_usec(touch); pointerEvent_->SetActionTime(time); int32_t seatSlot = libinput_event_touch_get_seat_slot(touch); +#ifdef OHOS_BUILD_EXTERNAL_SCREEN + RemoveInvalidAreaDownedEvent(seatSlot); +#endif // OHOS_BUILD_EXTERNAL_SCREEN if (pointerItemCancelMarks_.find(seatSlot) != pointerItemCancelMarks_.end()) { pointerEvent_->SetPointerAction(PointerEvent::POINTER_ACTION_CANCEL); pointerItemCancelMarks_.erase(seatSlot); @@ -406,5 +429,41 @@ void TouchTransformProcessor::InitToolTypes() vecToolType_.emplace_back(std::make_pair(BTN_TOOL_MOUSE, PointerEvent::TOOL_TYPE_MOUSE)); vecToolType_.emplace_back(std::make_pair(BTN_TOOL_LENS, PointerEvent::TOOL_TYPE_LENS)); } + +#ifdef OHOS_BUILD_EXTERNAL_SCREEN +bool TouchTransformProcessor::isInvalidAreaDownedEvent(int32_t seatSlot) +{ + for (auto& item : InvalidAreaDownedEvents_) { + if (item == seatSlot) { + return true; + } + } + return false; +} + +void TouchTransformProcessor::AddInvalidAreaDownedEvent(int32_t seatSlot) +{ + if (InvalidAreaDownedEvents_.size() >= MAX_N_POINTER_ITEMS) { + InvalidAreaDownedEvents_.erase(InvalidAreaDownedEvents_.begin()); + return; + } + for (auto& item : InvalidAreaDownedEvents_) { + if (item == seatSlot) { + return; + } + } + InvalidAreaDownedEvents_.push_back(seatSlot); +} + +void TouchTransformProcessor::RemoveInvalidAreaDownedEvent(int32_t seatSlot) +{ + for (auto it = InvalidAreaDownedEvents_.begin(); it != InvalidAreaDownedEvents_.end(); ++it) { + if (*it == seatSlot) { + InvalidAreaDownedEvents_.erase(it); + break; + } + } +} +#endif // OHOS_BUILD_EXTERNAL_SCREEN } // namespace MMI } // namespace OHOS diff --git a/service/window_manager/include/i_input_windows_manager.h b/service/window_manager/include/i_input_windows_manager.h index 84d9f7bad7fe9683fb0b48dc5df2596d5faccb70..dea9bde882418060e52700c9e074a381ca4d896c 100644 --- a/service/window_manager/include/i_input_windows_manager.h +++ b/service/window_manager/include/i_input_windows_manager.h @@ -141,7 +141,7 @@ public: #ifdef OHOS_BUILD_ENABLE_TOUCH virtual bool TouchPointToDisplayPoint(int32_t deviceId, struct libinput_event_touch* touch, - EventTouch& touchInfo, int32_t& targetDisplayId, bool isNeedClear = false) = 0; + EventTouch& touchInfo, int32_t& targetDisplayId, bool isNeedClear = false, bool isPointerDowned = false) = 0; virtual bool CalculateTipPoint(struct libinput_event_tablet_tool* tip, int32_t& targetDisplayId, PhysicalCoordinate& coord, PointerEvent::PointerItem& pointerItem) = 0; virtual const OLD::DisplayInfo *GetDefaultDisplayInfo() const = 0; diff --git a/service/window_manager/include/input_windows_manager.h b/service/window_manager/include/input_windows_manager.h index bbd8e7d86c24f6918caa8596fc2260402f2a2ab6..cd4c56acb6b881d2e438ff2bc26f176a8c4a3932 100644 --- a/service/window_manager/include/input_windows_manager.h +++ b/service/window_manager/include/input_windows_manager.h @@ -141,7 +141,7 @@ public: #ifdef OHOS_BUILD_ENABLE_TOUCH 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); + EventTouch& touchInfo, int32_t& targetDisplayId, bool isNeedClear = false, bool hasValidAreaDowned = false); #endif // OHOS_BUILD_ENABLE_TOUCH #if defined(OHOS_BUILD_ENABLE_POINTER) || defined(OHOS_BUILD_ENABLE_TOUCH) void ReverseRotateScreen(const OLD::DisplayInfo& info, const double x, const double y, @@ -393,7 +393,8 @@ void HandleOneHandMode(const OLD::DisplayInfo &displayInfo, std::shared_ptr keyEvent, int32_t focusWindowId, int32_t groupId = DEFAULT_GROUP_ID); diff --git a/service/window_manager/include/screen_pointer.h b/service/window_manager/include/screen_pointer.h index 63593fa4763909045a4b257f5c4137bb6680d7da..1cb2a9406227515fc0b249895dce855516e658a5 100644 --- a/service/window_manager/include/screen_pointer.h +++ b/service/window_manager/include/screen_pointer.h @@ -205,6 +205,9 @@ private: void Rotate(rotation_t rotation, int32_t& x, int32_t& y); void CalculateHwcPositionForMirror(int32_t& x, int32_t& y); void CalculateHwcPositionForExtend(int32_t& x, int32_t& y); +#ifdef OHOS_BUILD_EXTERNAL_SCREEN + void CalculateHwcPositionForMain(int32_t& x, int32_t& y); +#endif // OHOS_BUILD_EXTERNAL_SCREEN bool InitDefaultBuffer(const OHOS::BufferRequestConfig &bufferCfg, PointerRenderer &render); bool InitTransparentBuffer(const OHOS::BufferRequestConfig &bufferCfg); bool InitCommonBuffer(const OHOS::BufferRequestConfig &bufferCfg); diff --git a/service/window_manager/src/input_windows_manager.cpp b/service/window_manager/src/input_windows_manager.cpp index eac59d538cef0e7eda503a46c72361f702b4146b..fd7ecb0251a4f2859a8d387d3df34e9e2d692522 100644 --- a/service/window_manager/src/input_windows_manager.cpp +++ b/service/window_manager/src/input_windows_manager.cpp @@ -1453,7 +1453,7 @@ void InputWindowsManager::ResetPointerPositionIfOutValidDisplay(const OLD::Displ } bool InputWindowsManager::IsPositionOutValidDisplay( - Coordinate2D &position, const OLD::DisplayInfo ¤tDisplay, bool isPhysicalPos) + Coordinate2D &position, const OLD::DisplayInfo ¤tDisplay, bool isPhysicalPos, bool hasValidAreaDowned) { double posX = position.x; double posY = position.y; @@ -1501,6 +1501,15 @@ bool InputWindowsManager::IsPositionOutValidDisplay( } bool isOut = (rotateX < offsetX) || (rotateX > offsetX + validW) || (rotateY < offsetY) || (rotateY > offsetY + validH); +#ifdef OHOS_BUILD_EXTERNAL_SCREEN + if (isOut && hasValidAreaDowned) { + rotateX = std::max(rotateX, offsetX); + rotateX = std::min(rotateX, offsetX + validW); + rotateY = std::max(rotateY, offsetY); + rotateY = std::min(rotateY, offsetY + validH); + isOut = false; + } +#endif // OHOS_BUILD_EXTERNAL_SCREEN PrintDisplayInfo(currentDisplay); MMI_HILOGD("isOut=%{public}d,isPhysicalPos=%{public}d Position={%{private}f %{private}f}" "->{%{private}f %{private}f} RealValidWH={w:%{private}f h:%{private}f}", @@ -3018,7 +3027,7 @@ void InputWindowsManager::RotateDisplayScreen(const OLD::DisplayInfo& info, Phys #ifdef OHOS_BUILD_ENABLE_TOUCH bool InputWindowsManager::GetPhysicalDisplayCoord(int32_t deviceId, struct libinput_event_touch* touch, - const OLD::DisplayInfo& info, EventTouch& touchInfo, bool isNeedClear) + const OLD::DisplayInfo& info, EventTouch& touchInfo, bool isNeedClear, bool hasValidAreaDowned) { PrintDisplayInfo(info); auto width = info.width; @@ -3037,7 +3046,7 @@ bool InputWindowsManager::GetPhysicalDisplayCoord(int32_t deviceId, struct libin MMI_HILOGD("width:%{private}d, height:%{private}d, physicalX:%{private}f, physicalY:%{private}f", width, height, coord.x, coord.y); Coordinate2D pos = { .x = coord.x, .y = coord.y }; - if (IsPositionOutValidDisplay(pos, info, true)) { + if (IsPositionOutValidDisplay(pos, info, true, hasValidAreaDowned)) { if (INPUT_DEV_MGR->GetVendorConfig(deviceId).enableOutScreen != ENABLE_OUT_SCREEN_TOUCH) { MMI_HILOGW("Position out valid display width:%{private}d, height:%{private}d, " "physicalX:%{private}f, physicalY:%{private}f", width, height, pos.x, pos.y); @@ -3125,7 +3134,7 @@ void InputWindowsManager::SetAntiMisTakeStatus(bool state) } bool InputWindowsManager::TouchPointToDisplayPoint(int32_t deviceId, struct libinput_event_touch* touch, - EventTouch& touchInfo, int32_t& physicalDisplayId, bool isNeedClear) + EventTouch& touchInfo, int32_t& physicalDisplayId, bool isNeedClear, bool hasValidAreaDowned) { CHKPF(touch); std::string screenId = bindInfo_.GetBindDisplayNameByInputDevice(deviceId); @@ -3139,7 +3148,7 @@ bool InputWindowsManager::TouchPointToDisplayPoint(int32_t deviceId, struct libi MMI_HILOGE("Get OLD::DisplayInfo is error"); return false; } - return GetPhysicalDisplayCoord(deviceId, touch, *info, touchInfo, isNeedClear); + return GetPhysicalDisplayCoord(deviceId, touch, *info, touchInfo, isNeedClear, hasValidAreaDowned); } bool InputWindowsManager::TransformTipPoint(struct libinput_event_tablet_tool* tip, diff --git a/service/window_manager/src/pointer_drawing_manager.cpp b/service/window_manager/src/pointer_drawing_manager.cpp index a123671b8f3d5c61b15e0787362b60890cbba569..502406466fb49a5cc369ff851f42af3bc5f61c4f 100644 --- a/service/window_manager/src/pointer_drawing_manager.cpp +++ b/service/window_manager/src/pointer_drawing_manager.cpp @@ -3315,8 +3315,8 @@ void PointerDrawingManager::OnScreenModeChange(const std::vectorGetSourceMode() == OHOS::Rosen::ScreenSourceMode::SCREEN_MAIN) { - mainWidth = (si->GetMirrorWidth() == 0) ? GetScreenInfoWidth(si) : si->GetMirrorWidth(); - mainHeight = (si->GetMirrorHeight() == 0) ? GetScreenInfoHeight(si) : si->GetMirrorHeight(); + mainWidth = GetScreenInfoWidth(si); + mainHeight = GetScreenInfoHeight(si); mainRotation = static_cast(si->GetRotation()); } @@ -3325,8 +3325,6 @@ void PointerDrawingManager::OnScreenModeChange(const std::vectorsecond->UpdateScreenInfo(si); - it->second->SetMirrorWidth(mainWidth); - it->second->SetMirrorHeight(mainHeight); } else { // Create & Init ScreenPointer MMI_HILOGI("OnScreenModeChange got new screen %{public}" PRIu64, sid); @@ -3359,6 +3357,13 @@ void PointerDrawingManager::OnScreenModeChange(const std::vectorSetRotation(mainRotation); sp.second->UpdatePadding(mainWidth, mainHeight); } +#ifdef OHOS_BUILD_EXTERNAL_SCREEN + if (sp.second->IsMirror() || sp.second->IsMain()) { + mainWidth = sp.second->GetMirrorWidth() == 0 ? mainWidth : sp.second->GetMirrorWidth(); + mainHeight = sp.second->GetMirrorHeight() == 0 ? mainHeight : sp.second->GetMirrorHeight(); + sp.second->UpdatePadding(mainWidth, mainHeight); + } +#endif // OHOS_BUILD_EXTERNAL_SCREEN } } UpdateDisplayInfo(displayInfo_); @@ -3522,8 +3527,8 @@ int32_t PointerDrawingManager::DrawHardCursor(std::shared_ptr sp, void PointerDrawingManager::UpdateMirrorScreens(std::shared_ptr sp, OLD::DisplayInfo displayInfo) { CHKPV(sp); - uint32_t mainWidth = (sp->GetMirrorWidth() == 0) ? sp->GetScreenWidth() : sp->GetMirrorWidth(); - uint32_t mainHeight = (sp->GetMirrorHeight() == 0) ? sp->GetScreenHeight(): sp->GetMirrorHeight(); + uint32_t mainWidth = sp->GetScreenWidth(); + uint32_t mainHeight = sp->GetScreenHeight(); std::lock_guard lock(mtx_); for (auto it : screenPointers_) { if (it.second == nullptr) { @@ -3546,7 +3551,13 @@ void PointerDrawingManager::UpdateMirrorScreens(std::shared_ptr s isDirectionChanged = true; } if (isDirectionChanged) { +#ifdef OHOS_BUILD_EXTERNAL_SCREEN + mainWidth = mirrorScreen->GetMirrorWidth() == 0 ? mainWidth : mirrorScreen->GetMirrorWidth(); + mainHeight = mirrorScreen->GetMirrorHeight() == 0 ? mainHeight : mirrorScreen->GetMirrorHeight(); + mirrorScreen->UpdatePadding(mainWidth, mainHeight); +#else mirrorScreen->UpdatePadding(mainWidth, mainHeight); +#endif // OHOS_BUILD_EXTERNAL_SCREEN } MMI_HILOGD("update mirror screen dpi, mainScreen dpi: %{public}f, original mirrorScreen dpi: %{public}f", sp->GetDPI(), mirrorScreen->GetDPI()); diff --git a/service/window_manager/src/screen_pointer.cpp b/service/window_manager/src/screen_pointer.cpp index d6da11bde48a8b627ed15bdbfc7331e21bee98ca..bf8b3f006eee36ea626f39e6faa3af2cb27d89d2 100644 --- a/service/window_manager/src/screen_pointer.cpp +++ b/service/window_manager/src/screen_pointer.cpp @@ -81,6 +81,10 @@ ScreenPointer::ScreenPointer(hwcmgr_ptr_t hwcMgr, handler_ptr_t handler, const O std::swap(width_, height_); } dpi_ = float(di.dpi) / BASELINE_DENSITY; +#ifdef OHOS_BUILD_EXTERNAL_SCREEN + mirrorWidth_ = di.validWidth; + mirrorHeight_ = di.validHeight; +#endif // OHOS_BUILD_EXTERNAL_SCREEN MMI_HILOGI("Construct with DisplayInfo, id=%{public}" PRIu64 ", shape=(%{public}u, %{public}u), mode=%{public}u, " "rotation=%{public}u, dpi=%{public}f", screenId_, width_, height_, mode_, rotation_, dpi_); } @@ -94,6 +98,10 @@ ScreenPointer::ScreenPointer(hwcmgr_ptr_t hwcMgr, handler_ptr_t handler, screen_ mode_ = si->GetSourceMode(); rotation_ = si->GetRotation(); dpi_ = si->GetVirtualPixelRatio(); +#ifdef OHOS_BUILD_EXTERNAL_SCREEN + mirrorWidth_ = si->GetMirrorWidth() == 0 ? GetScreenInfoWidth(si) : si->GetMirrorWidth(); + mirrorHeight_ = si->GetMirrorHeight() == 0 ? GetScreenInfoHeight(si) : si->GetMirrorHeight(); +#endif // OHOS_BUILD_EXTERNAL_SCREEN MMI_HILOGI("Construct with ScreenInfo, id=%{public}" PRIu64 ", shape=(%{public}u, %{public}u), mode=%{public}u, " "rotation=%{public}u, dpi=%{public}f", screenId_, width_, height_, mode_, rotation_, dpi_); } @@ -309,6 +317,10 @@ void ScreenPointer::UpdateScreenInfo(const sptr si) mode_ = si->GetSourceMode(); rotation_ = si->GetRotation(); dpi_ = si->GetVirtualPixelRatio(); +#ifdef OHOS_BUILD_EXTERNAL_SCREEN + mirrorWidth_ = si->GetMirrorWidth() == 0 ? GetScreenInfoWidth(si) : si->GetMirrorWidth(); + mirrorHeight_ = si->GetMirrorHeight() == 0 ? GetScreenInfoHeight(si) : si->GetMirrorHeight(); +#endif // OHOS_BUILD_EXTERNAL_SCREEN surfaceNode_->AttachToDisplay(screenId_); Rosen::RSTransaction::FlushImplicitTransaction(); MMI_HILOGI("Update with ScreenInfo, id=%{public}" PRIu64 ", shape=(%{public}u, %{public}u), mode=%{public}u, " @@ -344,6 +356,7 @@ void ScreenPointer::OnDisplayInfo(const OLD::DisplayInfo &di, bool isWindowRotat bool ScreenPointer::UpdatePadding(uint32_t mainWidth, uint32_t mainHeight) { +#ifndef OHOS_BUILD_EXTERNAL_SCREEN if (!IsMirror()) { MMI_HILOGI("UpdatePadidng, reset padding, screenId=%{public}" PRIu64 ", scale=%{public}f, " "paddingTop_=%{public}u, paddingLeft_=%{public}u", screenId_, scale_, paddingTop_, paddingLeft_); @@ -352,11 +365,12 @@ bool ScreenPointer::UpdatePadding(uint32_t mainWidth, uint32_t mainHeight) paddingLeft_ = 0; return false; } +#endif // OHOS_BUILD_EXTERNAL_SCREEN if (mainWidth == 0 || mainHeight == 0) { MMI_HILOGE("Invalid parameters, mainWidth=%{public}u, mainHeight=%{public}u", mainWidth, mainHeight); return false; } - if (rotation_ == rotation_t::ROTATION_90 || rotation_ == rotation_t::ROTATION_270) { + if ((rotation_ == rotation_t::ROTATION_90 || rotation_ == rotation_t::ROTATION_270) && IsMirror()) { std::swap(mainWidth, mainHeight); } @@ -364,6 +378,11 @@ bool ScreenPointer::UpdatePadding(uint32_t mainWidth, uint32_t mainHeight) scale_ = fmin(float(width_) / mainWidth, float(height_) / mainHeight); paddingTop_ = (height_ - mainHeight * scale_) / NUM_TWO; paddingLeft_ = (width_ - mainWidth * scale_) / NUM_TWO; +#ifdef OHOS_BUILD_EXTERNAL_SCREEN + if (IsMain()) { + scale_ = 1.0; + } +#endif // OHOS_BUILD_EXTERNAL_SCREEN MMI_HILOGI("UpdatePadding, screenId=%{public}" PRIu64 ", scale=%{public}f, paddingTop_=%{public}u," " paddingLeft_=%{public}u", screenId_, scale_, paddingTop_, paddingLeft_); return true; @@ -418,6 +437,14 @@ void ScreenPointer::CalculateHwcPositionForMirror(int32_t& x, int32_t& y) y += paddingTop_; } +#ifdef OHOS_BUILD_EXTERNAL_SCREEN +void ScreenPointer::CalculateHwcPositionForMain(int32_t& x, int32_t& y) +{ + x += paddingLeft_; + y += paddingTop_; +} +#endif // OHOS_BUILD_EXTERNAL_SCREEN + void ScreenPointer::CalculateHwcPositionForExtend(int32_t& x, int32_t& y) { x = x * offRenderScale_; @@ -433,6 +460,11 @@ bool ScreenPointer::Move(int32_t x, int32_t y, ICON_TYPE align) CHKPF(hwcMgr_); int32_t px = 0; int32_t py = 0; +#ifdef OHOS_BUILD_EXTERNAL_SCREEN + if (IsMain()) { + CalculateHwcPositionForMain(x, y); + } +#endif // OHOS_BUILD_EXTERNAL_SCREEN if (IsMirror()) { CalculateHwcPositionForMirror(x, y); } else if (GetIsCurrentOffScreenRendering() && !IsMirror()) { diff --git a/test/facility/mock/include/input_windows_manager_mock.h b/test/facility/mock/include/input_windows_manager_mock.h index c5cc3e01d351a2ecb72a5afa20e50d6995f842dd..929b3ad358a9e45baf421c27f029b6b84ae0231d 100644 --- a/test/facility/mock/include/input_windows_manager_mock.h +++ b/test/facility/mock/include/input_windows_manager_mock.h @@ -103,7 +103,8 @@ public: #endif //OHOS_BUILD_ENABLE_POINTER #ifdef OHOS_BUILD_ENABLE_TOUCH - MOCK_METHOD(bool, TouchPointToDisplayPoint, (int32_t, struct libinput_event_touch*, EventTouch&, int32_t&, bool)); + MOCK_METHOD(bool, TouchPointToDisplayPoint, (int32_t, struct libinput_event_touch*, EventTouch&, int32_t&, bool, + bool)); MOCK_METHOD(bool, CalculateTipPoint, (struct libinput_event_tablet_tool*, int32_t&, PhysicalCoordinate&, PointerEvent::PointerItem&)); MOCK_METHOD(const OLD::DisplayInfo *, GetDefaultDisplayInfo, (), (const));