3 个文件变更+47-34
@@ -210,8 +210,8 @@ int32_t MouseTransformProcessor::UpdateMouseMoveLocation(const OLD::DisplayInfo*
210#ifdef OHOS_BUILD_MOUSE_REPORTING_RATE210#ifdef OHOS_BUILD_MOUSE_REPORTING_RATE
211 dalta_time = filterInsertionPoint_.filterDeltaTime;211 dalta_time = filterInsertionPoint_.filterDeltaTime;
212 HandleFilterMouseEvent(&offset);212 HandleFilterMouseEvent(&offset);
213- CalculateOffset(displayInfo, offset);
214#endif // OHOS_BUILD_MOUSE_REPORTING_RATE213#endif // OHOS_BUILD_MOUSE_REPORTING_RATE
214+ CalculateOffset(displayInfo, offset);
215 if (!enableMouseAleaccelerateBool_) {215 if (!enableMouseAleaccelerateBool_) {
216 abs_x += offset.dx;216 abs_x += offset.dx;
217 abs_y += offset.dy;217 abs_y += offset.dy;
@@ -424,8 +424,8 @@ bool MouseTransformProcessor::IsWindowRotation(const OLD::DisplayInfo* displayIn
424 424 
425Direction MouseTransformProcessor::GetDisplayDirection(const OLD::DisplayInfo *displayInfo)425Direction MouseTransformProcessor::GetDisplayDirection(const OLD::DisplayInfo *displayInfo)
426{426{
427- Direction displayDirection = DIRECTION0;
428 CHKPR(displayInfo, DIRECTION0);427 CHKPR(displayInfo, DIRECTION0);
428+ Direction displayDirection = displayInfo->direction;
429 if (Rosen::SceneBoardJudgement::IsSceneBoardEnabled()) {429 if (Rosen::SceneBoardJudgement::IsSceneBoardEnabled()) {
430 displayDirection = static_cast<Direction>((430 displayDirection = static_cast<Direction>((
431 ((displayInfo->direction - displayInfo->displayDirection) * ANGLE_90 + ANGLE_360) % ANGLE_360) / ANGLE_90);431 ((displayInfo->direction - displayInfo->displayDirection) * ANGLE_90 + ANGLE_360) % ANGLE_360) / ANGLE_90);
@@ -444,21 +444,19 @@ Direction MouseTransformProcessor::GetDisplayDirection(const OLD::DisplayInfo *d
444void MouseTransformProcessor::CalculateOffset(const OLD::DisplayInfo* displayInfo, Offset &offset)444void MouseTransformProcessor::CalculateOffset(const OLD::DisplayInfo* displayInfo, Offset &offset)
445{445{
446#ifndef OHOS_BUILD_EMULATOR446#ifndef OHOS_BUILD_EMULATOR
447- if (Rosen::SceneBoardJudgement::IsSceneBoardEnabled()) {447+ Direction direction = GetDisplayDirection(displayInfo);
448- Direction direction = GetDisplayDirection(displayInfo);448+ std::negate<double> neg;
449- std::negate<double> neg;449+ if (direction == DIRECTION90) {
450- if (direction == DIRECTION90) {450+ double tmp = offset.dx;
451- double tmp = offset.dx;451+ offset.dx = offset.dy;
452- offset.dx = offset.dy;452+ offset.dy = neg(tmp);
453- offset.dy = neg(tmp);453+ } else if (direction == DIRECTION180) {
454- } else if (direction == DIRECTION180) {454+ offset.dx = neg(offset.dx);
455- offset.dx = neg(offset.dx);455+ offset.dy = neg(offset.dy);
456- offset.dy = neg(offset.dy);456+ } else if (direction == DIRECTION270) {
457- } else if (direction == DIRECTION270) {457+ double tmp = offset.dx;
458- double tmp = offset.dx;458+ offset.dx = neg(offset.dy);
459- offset.dx = neg(offset.dy);459+ offset.dy = tmp;
460- offset.dy = tmp;
461- }
462 }460 }
463#endif // OHOS_BUILD_EMULATOR461#endif // OHOS_BUILD_EMULATOR
464}462}
@@ -146,7 +146,7 @@ public:
146 Coordinate2D& cursorPos) const;146 Coordinate2D& cursorPos) const;
147 void ReverseRotateDisplayScreen(const OLD::DisplayInfo& info, const double x, const double y,147 void ReverseRotateDisplayScreen(const OLD::DisplayInfo& info, const double x, const double y,
148 Coordinate2D& cursorPos) const;148 Coordinate2D& cursorPos) const;
149- void ScreenRotateAdjustDisplayXY(const OLD::DisplayInfo& info, PhysicalCoordinate& coord) const;149+ void ScreenRotateAdjustDisplayXY(const OLD::DisplayInfo& info, PhysicalCoordinate& coord);
150 void RotateScreen(const OLD::DisplayInfo& info, PhysicalCoordinate& coord) const;150 void RotateScreen(const OLD::DisplayInfo& info, PhysicalCoordinate& coord) const;
151 void RotateDisplayScreen(const OLD::DisplayInfo& info, PhysicalCoordinate& coord);151 void RotateDisplayScreen(const OLD::DisplayInfo& info, PhysicalCoordinate& coord);
152#endif // OHOS_BUILD_ENABLE_POINTER || OHOS_BUILD_ENABLE_TOUCH152#endif // OHOS_BUILD_ENABLE_POINTER || OHOS_BUILD_ENABLE_TOUCH
@@ -1459,7 +1459,8 @@ bool InputWindowsManager::IsPositionOutValidDisplay(
1459 if (isPhysicalPos) {1459 if (isPhysicalPos) {
1460 Direction displayDirection = static_cast<Direction>((1460 Direction displayDirection = static_cast<Direction>((
1461 ((currentDisplay.direction - currentDisplay.fixedDirection) * ANGLE_90 + ANGLE_360) % ANGLE_360) / ANGLE_90);1461 ((currentDisplay.direction - currentDisplay.fixedDirection) * ANGLE_90 + ANGLE_360) % ANGLE_360) / ANGLE_90);
1462- if (displayDirection == DIRECTION90 || displayDirection == DIRECTION270) {1462+ if (Rosen::SceneBoardJudgement::IsSceneBoardEnabled() &&
1463+ (displayDirection == DIRECTION90 || displayDirection == DIRECTION270)) {
1463 std::swap(validW, validH);1464 std::swap(validW, validH);
1464 std::swap(posWidth, posHeight);1465 std::swap(posWidth, posHeight);
1465 }1466 }
@@ -1954,8 +1955,8 @@ void InputWindowsManager::AdjustDisplayRotation(int32_t groupId)
1954 CursorPosition cursorPosCur;1955 CursorPosition cursorPosCur;
1955 1956 
1956 const auto iter = cursorPosMap_.find(groupId);1957 const auto iter = cursorPosMap_.find(groupId);
1957- if (iter == cursorPosMap_.end()) {1958+ if (iter != cursorPosMap_.end()) {
1958- cursorPosMap_[groupId] = cursorPosCur;1959+ cursorPosCur = cursorPosMap_[groupId];
1959 }1960 }
1960 PhysicalCoordinate coord {1961 PhysicalCoordinate coord {
1961 .x = cursorPosCur.cursorPos.x,1962 .x = cursorPosCur.cursorPos.x,
@@ -1973,7 +1974,7 @@ void InputWindowsManager::AdjustDisplayRotation(int32_t groupId)
1973 displayInfo->id, displayInfo->x, displayInfo->y, displayInfo->width, displayInfo->height,1974 displayInfo->id, displayInfo->x, displayInfo->y, displayInfo->width, displayInfo->height,
1974 displayInfo->dpi, displayInfo->name.c_str(), displayInfo->uniq.c_str(), displayInfo->direction,1975 displayInfo->dpi, displayInfo->name.c_str(), displayInfo->uniq.c_str(), displayInfo->direction,
1975 displayInfo->displayDirection);1976 displayInfo->displayDirection);
1976- if (cursorPosCur.direction == displayInfo->direction) {1977+ if (cursorPosCur.direction != displayInfo->direction) {
1977 ScreenRotateAdjustDisplayXY(*displayInfo, coord);1978 ScreenRotateAdjustDisplayXY(*displayInfo, coord);
1978 }1979 }
1979 1980 
@@ -1982,7 +1983,11 @@ void InputWindowsManager::AdjustDisplayRotation(int32_t groupId)
1982 cursorPosMap_[groupId].direction = displayInfo->direction;1983 cursorPosMap_[groupId].direction = displayInfo->direction;
1983 cursorPosMap_[groupId].displayDirection = displayInfo->displayDirection;1984 cursorPosMap_[groupId].displayDirection = displayInfo->displayDirection;
1984 }1985 }
1985- UpdateAndAdjustMouseLocation(cursorPosCur.displayId, coord.x, coord.y);1986+ if (!Rosen::SceneBoardJudgement::IsSceneBoardEnabled()) {
1987+ UpdateAndAdjustMouseLocation(cursorPosCur.displayId, cursorPosCur.cursorPos.x, cursorPosCur.cursorPos.y);
1988+ } else {
1989+ UpdateAndAdjustMouseLocation(cursorPosCur.displayId, coord.x, coord.y);
1990+ }
1986 if (GetHardCursorEnabled() && extraData_.appended &&1991 if (GetHardCursorEnabled() && extraData_.appended &&
1987 (extraData_.sourceType == PointerEvent::SOURCE_TYPE_MOUSE)) {1992 (extraData_.sourceType == PointerEvent::SOURCE_TYPE_MOUSE)) {
1988 AdjustDragPosition(groupId);1993 AdjustDragPosition(groupId);
@@ -2873,19 +2878,18 @@ const OLD::DisplayInfo *InputWindowsManager::GetDefaultDisplayInfo() const
2873#endif // OHOS_BUILD_ENABLE_TOUCH2878#endif // OHOS_BUILD_ENABLE_TOUCH
2874 2879 
2875#if defined(OHOS_BUILD_ENABLE_POINTER) || defined(OHOS_BUILD_ENABLE_TOUCH)2880#if defined(OHOS_BUILD_ENABLE_POINTER) || defined(OHOS_BUILD_ENABLE_TOUCH)
2876-void InputWindowsManager::ScreenRotateAdjustDisplayXY(const OLD::DisplayInfo& info, PhysicalCoordinate& coord) const2881+void InputWindowsManager::ScreenRotateAdjustDisplayXY(const OLD::DisplayInfo& info, PhysicalCoordinate& coord)
2877{2882{
2883+ if (!Rosen::SceneBoardJudgement::IsSceneBoardEnabled()) {
2884+ RotateDisplayScreen(info, coord);
2885+ return;
2886+ }
2878 int32_t groupId = FindDisplayGroupId(info.id);2887 int32_t groupId = FindDisplayGroupId(info.id);
2879 Direction rotation = info.direction;2888 Direction rotation = info.direction;
2880 auto it = cursorPosMap_.find(groupId);2889 auto it = cursorPosMap_.find(groupId);
2881 Direction lastRotation = (it != cursorPosMap_.end()) ? it->second.direction : cursorPos_.direction;2890 Direction lastRotation = (it != cursorPosMap_.end()) ? it->second.direction : cursorPos_.direction;
2882 int32_t width = info.validWidth;2891 int32_t width = info.validWidth;
2883 int32_t height = info.validHeight;2892 int32_t height = info.validHeight;
2884- if (!Rosen::SceneBoardJudgement::IsSceneBoardEnabled() &&
2885- (rotation == DIRECTION90 || rotation == DIRECTION270)) {
2886- height = info.validWidth;
2887- width = info.validHeight;
2888- }
2889 if ((static_cast<int32_t>(lastRotation) + 1) % 4 == static_cast<int32_t>(rotation)) {2893 if ((static_cast<int32_t>(lastRotation) + 1) % 4 == static_cast<int32_t>(rotation)) {
2890 double temp = coord.x;2894 double temp = coord.x;
2891 coord.x = width - coord.y;2895 coord.x = width - coord.y;
@@ -6078,12 +6082,16 @@ Direction InputWindowsManager::GetDisplayDirection(const OLD::DisplayInfo *displ
6078void InputWindowsManager::GetWidthAndHeight(const OLD::DisplayInfo* displayInfo, int32_t &width, int32_t &height,6082void InputWindowsManager::GetWidthAndHeight(const OLD::DisplayInfo* displayInfo, int32_t &width, int32_t &height,
6079 bool isRealData)6083 bool isRealData)
6080{6084{
6085+ if (displayInfo == nullptr) {
6086+ MMI_HILOGE("DisplayInfo is null");
6087+ return;
6088+ }
6081 auto displayDirection = GetDisplayDirection(displayInfo);6089 auto displayDirection = GetDisplayDirection(displayInfo);
6082 if (displayDirection == DIRECTION0 || displayDirection == DIRECTION180) {6090 if (displayDirection == DIRECTION0 || displayDirection == DIRECTION180) {
6083 width = displayInfo->validWidth;6091 width = displayInfo->validWidth;
6084 height = displayInfo->validHeight;6092 height = displayInfo->validHeight;
6085 } else {6093 } else {
6086- if (!isRealData) {6094+ if (!Rosen::SceneBoardJudgement::IsSceneBoardEnabled() || !isRealData) {
6087 width = displayInfo->validWidth;6095 width = displayInfo->validWidth;
6088 height = displayInfo->validHeight;6096 height = displayInfo->validHeight;
6089 return;6097 return;
@@ -6153,6 +6161,13 @@ void InputWindowsManager::ReverseRotateDisplayScreen(const OLD::DisplayInfo& inf
6153 info.height,6161 info.height,
6154 info.validWidth,6162 info.validWidth,
6155 info.validHeight);6163 info.validHeight);
6164+ int32_t width = info.validWidth;
6165+ int32_t height = info.validHeight;
6166+ if (!Rosen::SceneBoardJudgement::IsSceneBoardEnabled() &&
6167+ (displayDirection == DIRECTION90 || displayDirection == DIRECTION270)) {
6168+ height = info.validWidth;
6169+ width = info.validHeight;
6170+ }
6156 switch (displayDirection) {6171 switch (displayDirection) {
6157 case DIRECTION0: {6172 case DIRECTION0: {
6158 cursorPos.x = x;6173 cursorPos.x = x;
@@ -6161,19 +6176,19 @@ void InputWindowsManager::ReverseRotateDisplayScreen(const OLD::DisplayInfo& inf
6161 break;6176 break;
6162 }6177 }
6163 case DIRECTION90: {6178 case DIRECTION90: {
6164- cursorPos.y = static_cast<double>(info.validWidth) - 1 - x;6179+ cursorPos.y = static_cast<double>(width) - 1 - x;
6165 cursorPos.x = y;6180 cursorPos.x = y;
6166 MMI_HILOGD("DIRECTION90, physicalX:%{private}.2f, physicalY:%{private}.2f", cursorPos.x, cursorPos.y);6181 MMI_HILOGD("DIRECTION90, physicalX:%{private}.2f, physicalY:%{private}.2f", cursorPos.x, cursorPos.y);
6167 break;6182 break;
6168 }6183 }
6169 case DIRECTION180: {6184 case DIRECTION180: {
6170- cursorPos.x = static_cast<double>(info.validWidth) - 1 - x;6185+ cursorPos.x = static_cast<double>(width) - 1 - x;
6171- cursorPos.y = static_cast<double>(info.validHeight) - 1 - y;6186+ cursorPos.y = static_cast<double>(height) - 1 - y;
6172 MMI_HILOGD("DIRECTION180, physicalX:%{private}.2f, physicalY:%{private}.2f", cursorPos.x, cursorPos.y);6187 MMI_HILOGD("DIRECTION180, physicalX:%{private}.2f, physicalY:%{private}.2f", cursorPos.x, cursorPos.y);
6173 break;6188 break;
6174 }6189 }
6175 case DIRECTION270: {6190 case DIRECTION270: {
6176- cursorPos.x = static_cast<double>(info.validHeight) - 1 - y;6191+ cursorPos.x = static_cast<double>(height) - 1 - y;
6177 cursorPos.y = x;6192 cursorPos.y = x;
6178 MMI_HILOGD("DIRECTION270, physicalX:%{private}.2f, physicalY:%{private}.2f", cursorPos.x, cursorPos.y);6193 MMI_HILOGD("DIRECTION270, physicalX:%{private}.2f, physicalY:%{private}.2f", cursorPos.x, cursorPos.y);
6179 break;6194 break;