!12297 小艺输入法跨屏拖拽优化遗留问题闭环

Merge pull request !12297 from liangwei/master
This commit is contained in:
openharmony_ci 2025-01-23 07:25:21 +00:00 committed by Gitee
commit 9088d65d84
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
5 changed files with 121 additions and 115 deletions

View File

@ -42,7 +42,7 @@ using NotifyWindowPidChangeCallback = std::function<void(int32_t windowId, bool
const uint32_t WINDOW_HOT_AREA_TYPE_UNDEFINED = 0;
enum class MouseMoveDirection: uint32_t {
enum class MoveDirection : uint32_t {
UNKNOWN,
LEFT_TO_RIGHT,
RIGHT_TO_LEFT,
@ -77,9 +77,9 @@ public:
void SetTargetRect(const WSRect& rect);
WSRect GetOriginalRect() const;
void InitMoveDragProperty();
void SetOriginalWindowPos(int32_t pointerId, int32_t pointerType, int32_t pointerPosX,
int32_t pointerPosY, int32_t pointerWindowX, int32_t pointerWindowY,
const WSRect& winRect);
void SetOriginalMoveDragPos(int32_t pointerId, int32_t pointerType, int32_t pointerPosX,
int32_t pointerPosY, int32_t pointerWindowX, int32_t pointerWindowY,
const WSRect& winRect);
void SetAspectRatio(float ratio);
bool ConsumeMoveEvent(const std::shared_ptr<MMI::PointerEvent>& pointerEvent, const WSRect& originalRect);
bool ConsumeDragEvent(const std::shared_ptr<MMI::PointerEvent>& pointerEvent, const WSRect& originalRect,
@ -109,9 +109,8 @@ public:
void SetMoveAvailableArea(const DMRect& area);
void UpdateMoveAvailableArea(DisplayId targetDisplayId);
void SetCurrentScreenProperty(DisplayId targetDisplayId);
void ResetCurrentScreenProperty();
void SetMoveInputBarStartDisplayId(DisplayId displayId);
void SetInputBarCrossAttr(MouseMoveDirection mouseMoveDirection, DisplayId targetDisplayId);
void SetInputBarCrossAttr(MoveDirection moveDirection, DisplayId targetDisplayId);
void SetOriginalDisplayOffset(int32_t offsetX, int32_t offsetY);
/*
@ -134,7 +133,9 @@ private:
int32_t pointerType_ = -1;
int32_t originalPointerPosX_ = -1;
int32_t originalPointerPosY_ = -1;
// the x coordinate of the pointer related to the active window
int32_t originalPointerWindowX_ = -1;
// the y coordinate of the pointer related to the active window
int32_t originalPointerWindowY_ = -1;
WSRect originalRect_ = { 0, 0, 0, 0 };
WSRect targetRect_ = { 0, 0, 0, 0 };
@ -162,17 +163,27 @@ private:
};
struct ScreenSizeProperty {
uint32_t currentDisplayStartX_ = 0;
uint32_t currentDisplayStartY_ = 0;
int32_t currentDisplayX_ = 0;
int32_t currentDisplayY_ = 0;
int32_t width_ = 0;
int32_t height_ = 0;
uint32_t currentDisplayStartX = 0;
uint32_t currentDisplayStartY = 0;
int32_t currentDisplayLeft = 0;
int32_t currentDisplayTop = 0;
int32_t width = 0;
int32_t height = 0;
bool IsEmpty() const
{
return (currentDisplayStartX_ == 0 && currentDisplayStartY_ == 0 && currentDisplayX_ == 0 &&
currentDisplayY_ == 0 && width_ == 0 && height_ == 0);
return (currentDisplayStartX == 0 && currentDisplayStartY == 0 && currentDisplayLeft == 0 &&
currentDisplayTop == 0 && width == 0 && height == 0);
}
void Reset()
{
currentDisplayStartX = 0;
currentDisplayStartY = 0;
currentDisplayLeft = 0;
currentDisplayTop = 0;
width = 0;
height = 0;
}
std::string ToString() const
@ -181,12 +192,12 @@ private:
return "empty";
}
std::stringstream ss;
ss << "currentDisplayStartX_: " << currentDisplayStartX_ << ","
<< "currentDisplayStartY_: " << currentDisplayStartY_ << ","
<< "currentDisplayX_: " << currentDisplayX_ << ","
<< "currentDisplayY_: " << currentDisplayY_ << ","
<< "width_: " << width_ << "," << "height_: " << height_;
std::ostringstream ss;
ss << "currentDisplayStartX: " << currentDisplayStartX << ","
<< "currentDisplayStartY: " << currentDisplayStartY << ","
<< "currentDisplayLeft: " << currentDisplayLeft << ","
<< "currentDisplayTop: " << currentDisplayTop << ","
<< "width: " << width << "," << "height: " << height;
return ss.str();
}
};
@ -198,8 +209,8 @@ private:
bool EventDownInit(const std::shared_ptr<MMI::PointerEvent>& pointerEvent, const WSRect& originalRect,
const sptr<WindowSessionProperty> property, const SystemSessionConfig& sysConfig);
bool CalcMoveInputBarRect(const std::shared_ptr<MMI::PointerEvent>& pointerEvent, const WSRect& originalRect);
void AdjustXYByAvailableArea(int32_t& x, int32_t& y);
MouseMoveDirection CalcMouseMoveDirection(DisplayId lastDisplayId, DisplayId currentDisplayId);
void AdjustTargetPositionByAvailableArea(int32_t& moveDragFinalX, int32_t& moveDragFinalY);
MoveDirection CalcMoveDirection(DisplayId lastDisplayId, DisplayId currentDisplayId);
void InitializeMoveDragPropertyNotValid(const std::shared_ptr<MMI::PointerEvent>& pointerEvent,
const WSRect& originalRect);

View File

@ -244,7 +244,7 @@ void MoveDragController::ResetCrossMoveDragProperty()
moveDragIsInterrupted_ = false;
}
void MoveDragController::SetOriginalWindowPos(int32_t pointerId, int32_t pointerType, int32_t pointerPosX,
void MoveDragController::SetOriginalMoveDragPos(int32_t pointerId, int32_t pointerType, int32_t pointerPosX,
int32_t pointerPosY, int32_t pointerWindowX, int32_t pointerWindowY, const WSRect& winRect)
{
moveDragProperty_.pointerId_ = pointerId;
@ -594,22 +594,12 @@ void MoveDragController::SetCurrentScreenProperty(DisplayId targetDisplayId)
return;
}
ScreenProperty currentScreenProperty = currentScreenSession->GetScreenProperty();
screenSizeProperty_.currentDisplayStartX_ = currentScreenProperty.GetStartX();
screenSizeProperty_.currentDisplayStartY_ = currentScreenProperty.GetStartY();
screenSizeProperty_.currentDisplayX_ = currentScreenProperty.GetBounds().rect_.left_;
screenSizeProperty_.currentDisplayY_ = currentScreenProperty.GetBounds().rect_.top_;
screenSizeProperty_.width_ = currentScreenProperty.GetBounds().rect_.width_;
screenSizeProperty_.height_ = currentScreenProperty.GetBounds().rect_.height_;
}
void MoveDragController::ResetCurrentScreenProperty()
{
screenSizeProperty_.currentDisplayStartX_ = 0;
screenSizeProperty_.currentDisplayStartY_ = 0;
screenSizeProperty_.currentDisplayX_ = 0;
screenSizeProperty_.currentDisplayY_ = 0;
screenSizeProperty_.width_ = 0;
screenSizeProperty_.height_ = 0;
screenSizeProperty_.currentDisplayStartX = currentScreenProperty.GetStartX();
screenSizeProperty_.currentDisplayStartY = currentScreenProperty.GetStartY();
screenSizeProperty_.currentDisplayLeft = currentScreenProperty.GetBounds().rect_.left_;
screenSizeProperty_.currentDisplayTop = currentScreenProperty.GetBounds().rect_.top_;
screenSizeProperty_.width = currentScreenProperty.GetBounds().rect_.width_;
screenSizeProperty_.height = currentScreenProperty.GetBounds().rect_.height_;
}
std::pair<int32_t, int32_t> MoveDragController::CalcUnifiedTranslate(
@ -634,24 +624,25 @@ std::pair<int32_t, int32_t> MoveDragController::CalcUnifiedTranslate(
return std::make_pair(tranX, tranY);
}
void MoveDragController::AdjustXYByAvailableArea(int32_t& x, int32_t& y)
void MoveDragController::AdjustTargetPositionByAvailableArea(int32_t& moveDragFinalX, int32_t& moveDragFinalY)
{
x = std::max(moveAvailableArea_.posX_, x);
y = std::max(moveAvailableArea_.posY_, y);
moveDragFinalX = std::max(moveAvailableArea_.posX_, moveDragFinalX);
moveDragFinalY = std::max(moveAvailableArea_.posY_, moveDragFinalY);
int32_t rightBoundsLimit =
moveAvailableArea_.posX_ + moveAvailableArea_.width_ - moveDragProperty_.originalRect_.width_;
int32_t bottomBoundsLimit =
moveAvailableArea_.posY_ + moveAvailableArea_.height_ - moveDragProperty_.originalRect_.height_;
if (x >= rightBoundsLimit) {
x = rightBoundsLimit;
if (moveDragFinalX >= rightBoundsLimit) {
moveDragFinalX = rightBoundsLimit;
}
if (y >= bottomBoundsLimit) {
y = bottomBoundsLimit;
if (moveDragFinalY >= bottomBoundsLimit) {
moveDragFinalY = bottomBoundsLimit;
}
}
MouseMoveDirection MoveDragController::CalcMouseMoveDirection(DisplayId lastDisplayId, DisplayId currentDisplayId)
MoveDirection MoveDragController::CalcMoveDirection(DisplayId lastDisplayId, DisplayId currentDisplayId)
{
sptr<ScreenSession> lastScreenSession =
ScreenSessionManagerClient::GetInstance().GetScreenSessionById(lastDisplayId);
@ -659,7 +650,7 @@ MouseMoveDirection MoveDragController::CalcMouseMoveDirection(DisplayId lastDisp
ScreenSessionManagerClient::GetInstance().GetScreenSessionById(currentDisplayId);
if (!lastScreenSession || !currentScreenSession) {
TLOGW(WmsLogTag::WMS_KEYBOARD, "Screen session is null, return default mouse move direction.");
return MouseMoveDirection::UNKNOWN;
return MoveDirection::UNKNOWN;
}
ScreenProperty lastScreenProperty = lastScreenSession->GetScreenProperty();
@ -676,16 +667,16 @@ MouseMoveDirection MoveDragController::CalcMouseMoveDirection(DisplayId lastDisp
uint32_t currentScreenHeight = currentScreenProperty.GetBounds().rect_.height_;
if (currentOriginStartX == lastOriginStartX + lastScreenWidth) {
return MouseMoveDirection::LEFT_TO_RIGHT;
return MoveDirection::LEFT_TO_RIGHT;
} else if (currentOriginStartX == lastOriginStartX - currentScreenWidth) {
return MouseMoveDirection::RIGHT_TO_LEFT;
return MoveDirection::RIGHT_TO_LEFT;
} else if (currentOriginStartY == lastOriginStartY + lastScreenHeight) {
return MouseMoveDirection::UP_TO_BOTTOM;
return MoveDirection::UP_TO_BOTTOM;
} else if (currentOriginStartY == lastOriginStartY - currentScreenHeight) {
return MouseMoveDirection::BOTTOM_TO_UP;
return MoveDirection::BOTTOM_TO_UP;
}
return MouseMoveDirection::UNKNOWN;
return MoveDirection::UNKNOWN;
}
void MoveDragController::SetOriginalDisplayOffset(int32_t offsetX, int32_t offsetY)
@ -694,15 +685,15 @@ void MoveDragController::SetOriginalDisplayOffset(int32_t offsetX, int32_t offse
originalDisplayOffsetY_ = offsetY;
}
void MoveDragController::SetInputBarCrossAttr(MouseMoveDirection mouseMoveDirection, DisplayId targetDisplayId)
void MoveDragController::SetInputBarCrossAttr(MoveDirection moveDirection, DisplayId targetDisplayId)
{
if (mouseMoveDirection == MouseMoveDirection::LEFT_TO_RIGHT ||
mouseMoveDirection == MouseMoveDirection::RIGHT_TO_LEFT) {
if (moveDirection == MoveDirection::LEFT_TO_RIGHT ||
moveDirection == MoveDirection::RIGHT_TO_LEFT) {
UpdateMoveAvailableArea(targetDisplayId);
}
moveInputBarStartDisplayId_ = targetDisplayId;
SetOriginalDisplayOffset(screenSizeProperty_.currentDisplayStartX_, screenSizeProperty_.currentDisplayStartY_);
ResetCurrentScreenProperty();
SetOriginalDisplayOffset(screenSizeProperty_.currentDisplayStartX, screenSizeProperty_.currentDisplayStartY);
screenSizeProperty_.Reset();
}
void MoveDragController::InitializeMoveDragPropertyNotValid(const std::shared_ptr<MMI::PointerEvent>& pointerEvent,
@ -747,7 +738,7 @@ void MoveDragController::HandleLeftToRightCross(DisplayId targetDisplayId,
moveDragFinalX = 0;
}
moveDragFinalY = pointerDisplayY - moveDragProperty_.originalPointerWindowY_;
SetInputBarCrossAttr(MouseMoveDirection::LEFT_TO_RIGHT, targetDisplayId);
SetInputBarCrossAttr(MoveDirection::LEFT_TO_RIGHT, targetDisplayId);
}
void MoveDragController::HandleRightToLeftCross(DisplayId targetDisplayId,
@ -756,15 +747,15 @@ void MoveDragController::HandleRightToLeftCross(DisplayId targetDisplayId,
int32_t& moveDragFinalX,
int32_t& moveDragFinalY)
{
int32_t actualCrossScreenPos = screenSizeProperty_.width_ -
int32_t boundaryPos = screenSizeProperty_.width -
moveDragProperty_.originalRect_.width_ + moveDragProperty_.originalPointerWindowX_;
if (pointerDisplayX <= actualCrossScreenPos) {
if (pointerDisplayX <= boundaryPos) {
moveDragFinalX = pointerDisplayX - moveDragProperty_.originalPointerWindowX_;
} else {
moveDragFinalX = screenSizeProperty_.width_ - moveDragProperty_.originalRect_.width_;
moveDragFinalX = screenSizeProperty_.width - moveDragProperty_.originalRect_.width_;
}
moveDragFinalY = pointerDisplayY - moveDragProperty_.originalPointerWindowY_;
SetInputBarCrossAttr(MouseMoveDirection::RIGHT_TO_LEFT, targetDisplayId);
SetInputBarCrossAttr(MoveDirection::RIGHT_TO_LEFT, targetDisplayId);
}
void MoveDragController::HandleUpToBottomCross(DisplayId targetDisplayId,
@ -774,14 +765,14 @@ void MoveDragController::HandleUpToBottomCross(DisplayId targetDisplayId,
int32_t& moveDragFinalY)
{
UpdateMoveAvailableArea(targetDisplayId);
int32_t statusBarHeight = moveAvailableArea_.posY_ - screenSizeProperty_.currentDisplayY_;
int32_t statusBarHeight = moveAvailableArea_.posY_ - screenSizeProperty_.currentDisplayTop;
if (pointerDisplayY >= statusBarHeight + moveDragProperty_.originalPointerWindowY_) {
moveDragFinalY = pointerDisplayY - moveDragProperty_.originalPointerWindowY_;
} else {
moveDragFinalY = statusBarHeight;
}
moveDragFinalX = pointerDisplayX - moveDragProperty_.originalPointerWindowX_;
SetInputBarCrossAttr(MouseMoveDirection::UP_TO_BOTTOM, targetDisplayId);
SetInputBarCrossAttr(MoveDirection::UP_TO_BOTTOM, targetDisplayId);
}
void MoveDragController::HandleBottomToUpCross(DisplayId targetDisplayId,
@ -792,16 +783,16 @@ void MoveDragController::HandleBottomToUpCross(DisplayId targetDisplayId,
{
UpdateMoveAvailableArea(targetDisplayId);
int32_t dockBarHeight =
screenSizeProperty_.currentDisplayY_ - moveAvailableArea_.posY_ - moveAvailableArea_.height_;
int32_t currentCrossScreenPos =
screenSizeProperty_.height_ - dockBarHeight - moveDragProperty_.originalPointerWindowY_;
if (pointerDisplayY <= currentCrossScreenPos) {
screenSizeProperty_.currentDisplayTop - moveAvailableArea_.posY_ - moveAvailableArea_.height_;
int32_t boundaryPos =
screenSizeProperty_.height - dockBarHeight - moveDragProperty_.originalPointerWindowY_;
if (pointerDisplayY <= boundaryPos) {
moveDragFinalY = pointerDisplayY - moveDragProperty_.originalPointerWindowY_;
} else {
moveDragFinalY = screenSizeProperty_.height_ - dockBarHeight - moveDragProperty_.originalPointerWindowY_;
moveDragFinalY = screenSizeProperty_.height - dockBarHeight - moveDragProperty_.originalPointerWindowY_;
}
moveDragFinalX = pointerDisplayX - moveDragProperty_.originalPointerWindowX_;
SetInputBarCrossAttr(MouseMoveDirection::BOTTOM_TO_UP, targetDisplayId);
SetInputBarCrossAttr(MoveDirection::BOTTOM_TO_UP, targetDisplayId);
}
void MoveDragController::CalcMoveForSameDisplay(const std::shared_ptr<MMI::PointerEvent>& pointerEvent,
@ -814,7 +805,7 @@ void MoveDragController::CalcMoveForSameDisplay(const std::shared_ptr<MMI::Point
int32_t pointerDisplayY = pointerItem.GetDisplayY();
moveDragFinalX = pointerDisplayX - moveDragProperty_.originalPointerWindowX_;
moveDragFinalY = pointerDisplayY - moveDragProperty_.originalPointerWindowY_;
AdjustXYByAvailableArea(moveDragFinalX, moveDragFinalY);
AdjustTargetPositionByAvailableArea(moveDragFinalX, moveDragFinalY);
}
bool MoveDragController::CalcMoveInputBarRect(const std::shared_ptr<MMI::PointerEvent>& pointerEvent,
@ -836,26 +827,26 @@ bool MoveDragController::CalcMoveInputBarRect(const std::shared_ptr<MMI::Pointer
if (targetDisplayId == moveInputBarStartDisplayId_) {
CalcMoveForSameDisplay(pointerEvent, moveDragFinalX, moveDragFinalY);
} else {
MouseMoveDirection mouseMoveDirection =
CalcMouseMoveDirection(moveInputBarStartDisplayId_, pointerEvent->GetTargetDisplayId());
MoveDirection moveDirection =
CalcMoveDirection(moveInputBarStartDisplayId_, pointerEvent->GetTargetDisplayId());
if (screenSizeProperty_.IsEmpty()) {
SetCurrentScreenProperty(targetDisplayId);
}
switch (mouseMoveDirection) {
case MouseMoveDirection::LEFT_TO_RIGHT:
switch (moveDirection) {
case MoveDirection::LEFT_TO_RIGHT:
HandleLeftToRightCross(
targetDisplayId, pointerDisplayX, pointerDisplayY, moveDragFinalX, moveDragFinalY);
break;
case MouseMoveDirection::RIGHT_TO_LEFT:
case MoveDirection::RIGHT_TO_LEFT:
HandleRightToLeftCross(
targetDisplayId, pointerDisplayX, pointerDisplayY, moveDragFinalX, moveDragFinalY);
break;
case MouseMoveDirection::UP_TO_BOTTOM:
case MoveDirection::UP_TO_BOTTOM:
HandleUpToBottomCross(
targetDisplayId, pointerDisplayX, pointerDisplayY, moveDragFinalX, moveDragFinalY);
break;
case MouseMoveDirection::BOTTOM_TO_UP:
case MoveDirection::BOTTOM_TO_UP:
HandleBottomToUpCross(
targetDisplayId, pointerDisplayX, pointerDisplayY, moveDragFinalX, moveDragFinalY);
break;
@ -1315,13 +1306,13 @@ void MoveDragController::CalcFirstMoveTargetRect(const WSRect& windowRect, bool
originalRect.posX_ = windowRect.posX_;
originalRect.posY_ = windowRect.posY_;
}
SetOriginalWindowPos(moveTempProperty_.pointerId_,
moveTempProperty_.pointerType_,
moveTempProperty_.lastDownPointerPosX_,
moveTempProperty_.lastDownPointerPosY_,
moveTempProperty_.lastDownPointerWindowX_,
moveTempProperty_.lastDownPointerWindowY_,
originalRect);
SetOriginalMoveDragPos(moveTempProperty_.pointerId_,
moveTempProperty_.pointerType_,
moveTempProperty_.lastDownPointerPosX_,
moveTempProperty_.lastDownPointerPosY_,
moveTempProperty_.lastDownPointerWindowX_,
moveTempProperty_.lastDownPointerWindowY_,
originalRect);
int32_t offsetX = moveTempProperty_.lastMovePointerPosX_ - moveTempProperty_.lastDownPointerPosX_;
int32_t offsetY = moveTempProperty_.lastMovePointerPosY_ - moveTempProperty_.lastDownPointerPosY_;

View File

@ -650,8 +650,7 @@ WSError SceneSession::InitializeMoveInputBar()
{
auto property = GetSessionProperty();
WindowType windowType = property->GetWindowType();
if (windowType == WindowType::WINDOW_TYPE_INPUT_METHOD_STATUS_BAR ||
windowType == WindowType::WINDOW_TYPE_INPUT_METHOD_FLOAT) {
if (WindowHelper::IsInputWindow(windowType)) {
TLOGD(WmsLogTag::WMS_KEYBOARD, "Start init move input bar param");
DisplayId displayId = property->GetDisplayId();

View File

@ -214,11 +214,11 @@ HWTEST_F(MoveDragControllerTest, InitCrossDisplayProperty, Function | SmallTest
}
/**
* @tc.name: SetOriginalWindowPos
* @tc.desc: test function : SetOriginalWindowPos
* @tc.name: SetOriginalMoveDragPos
* @tc.desc: test function : SetOriginalMoveDragPos
* @tc.type: FUNC
*/
HWTEST_F(MoveDragControllerTest, SetOriginalWindowPos, Function | SmallTest | Level1)
HWTEST_F(MoveDragControllerTest, SetOriginalMoveDragPos, Function | SmallTest | Level1)
{
std::shared_ptr<MMI::PointerEvent> pointerEvent = MMI::PointerEvent::Create();
int32_t pointerId = pointerEvent->GetPointerId();
@ -228,7 +228,7 @@ HWTEST_F(MoveDragControllerTest, SetOriginalWindowPos, Function | SmallTest | Le
int32_t pointerWindowX = 10;
int32_t pointerWindowY = 10;
WSRect winRect = { 100, 100, 1000, 1000 };
moveDragController->SetOriginalWindowPos(
moveDragController->SetOriginalMoveDragPos(
pointerId, pointerType, pointerPosX, pointerPosY, pointerWindowX, pointerWindowY, winRect);
ASSERT_EQ(moveDragController->moveDragProperty_.pointerId_, pointerId);
ASSERT_EQ(moveDragController->moveDragProperty_.pointerType_, pointerType);
@ -315,7 +315,7 @@ HWTEST_F(MoveDragControllerTest, CalcMoveTargetRect, Function | SmallTest | Leve
int32_t pointerPosY = 30;
int32_t pointerWindowX = 10;
int32_t pointerWindowY = 10;
moveDragController->SetOriginalWindowPos(
moveDragController->SetOriginalMoveDragPos(
pointerId, pointerType, pointerPosX, pointerPosY, pointerWindowX, pointerWindowY, originalRect);
moveDragController->CalcMoveTargetRect(pointerEvent, originalRect);
ASSERT_EQ(0, res);
@ -328,33 +328,39 @@ HWTEST_F(MoveDragControllerTest, CalcMoveTargetRect, Function | SmallTest | Leve
*/
HWTEST_F(MoveDragControllerTest, CalcMoveInputBarRect, Function | SmallTest | Level1)
{
int32_t res = 0;
moveDragController->InitMoveDragProperty();
moveDragController->SetMoveAvailableArea({0, 75, 3120, 1980});
moveDragController->SetMoveInputBarStartDisplayId(1);
WSRect originalRect = {10, 20, 336, 146};
std::shared_ptr<MMI::PointerEvent> pointerEvent = MMI::PointerEvent::Create();
WSRect originalRect = { 100, 100, 1000, 1000 };
moveDragController->CalcMoveInputBarRect(pointerEvent, originalRect);
ASSERT_EQ(0, res);
pointerEvent = MMI::PointerEvent::Create();
int32_t pointerId = pointerEvent->GetPointerId();
int32_t pointerType = pointerEvent->GetSourceType();
pointerEvent->SetTargetDisplayId(1);
pointerEvent->SetPointerId(1);
pointerEvent->SetSourceType(MMI::PointerEvent::SOURCE_TYPE_MOUSE);
MMI::PointerEvent::PointerItem pointerItem;
pointerItem.SetPointerId(1);
pointerItem.SetDisplayX(100);
pointerItem.SetDisplayY(200);
pointerEvent->AddPointerItem(pointerItem);
int32_t pointerPosX = 10;
int32_t pointerPosY = 30;
int32_t pointerWindowX = 10;
int32_t pointerWindowY = 10;
moveDragController->SetOriginalWindowPos(
pointerId, pointerType, pointerPosX, pointerPosY, pointerWindowX, pointerWindowY, originalRect);
moveDragController->SetOriginalMoveDragPos(pointerEvent->GetPointerId(),
pointerEvent->GetSourceType(), pointerPosX, pointerPosY, pointerWindowX,
pointerWindowY, originalRect);
moveDragController->CalcMoveInputBarRect(pointerEvent, originalRect);
ASSERT_EQ(0, res);
ASSERT_EQ(90, moveDragController->moveDragProperty_.targetRect_.posX_);
ASSERT_EQ(190, moveDragController->moveDragProperty_.targetRect_.posY_);
}
/**
* @tc.name: AdjustXYByAvailableArea
* @tc.desc: test function : AdjustXYByAvailableArea
* @tc.name: AdjustTargetPositionByAvailableArea
* @tc.desc: test function : AdjustTargetPositionByAvailableArea
* @tc.type: FUNC
*/
HWTEST_F(MoveDragControllerTest, AdjustXYByAvailableArea, Function | SmallTest | Level1)
HWTEST_F(MoveDragControllerTest, AdjustTargetPositionByAvailableArea, Function | SmallTest | Level1)
{
DMRect moveAvailableArea = {0, 75, 3120, 1980};
WSRect originalRect = {10, 20, 336, 146};
@ -365,27 +371,27 @@ HWTEST_F(MoveDragControllerTest, AdjustXYByAvailableArea, Function | SmallTest |
int32_t y;
x = 50, y = 100;
moveDragController->AdjustXYByAvailableArea(x, y);
moveDragController->AdjustTargetPositionByAvailableArea(x, y);
EXPECT_EQ(x, 50);
EXPECT_EQ(y, 100);
x = -10, y = 100;
moveDragController->AdjustXYByAvailableArea(x, y);
moveDragController->AdjustTargetPositionByAvailableArea(x, y);
EXPECT_EQ(x, 0);
EXPECT_EQ(y, 100);
x = 3200, y = 200;
moveDragController->AdjustXYByAvailableArea(x, y);
moveDragController->AdjustTargetPositionByAvailableArea(x, y);
EXPECT_EQ(x, 2784);
EXPECT_EQ(y, 200);
x = 100, y = 60;
moveDragController->AdjustXYByAvailableArea(x, y);
moveDragController->AdjustTargetPositionByAvailableArea(x, y);
EXPECT_EQ(x, 100);
EXPECT_EQ(y, 75);
x = 100, y = 1980;
moveDragController->AdjustXYByAvailableArea(x, y);
moveDragController->AdjustTargetPositionByAvailableArea(x, y);
EXPECT_EQ(x, 100);
EXPECT_EQ(y, 1909);
}

View File

@ -2682,8 +2682,7 @@ bool WindowSceneSessionImpl::IsStartMoving()
bool WindowSceneSessionImpl::CalcWindowShouldMove()
{
WindowType windowType = GetType();
if (windowType == WindowType::WINDOW_TYPE_INPUT_METHOD_FLOAT ||
windowType == WindowType::WINDOW_TYPE_INPUT_METHOD_STATUS_BAR) {
if (WindowHelper::IsInputWindow(windowType)) {
if (windowSystemConfig_.IsPcWindow() || windowSystemConfig_.IsPadWindow() ||
windowSystemConfig_.IsPhoneWindow()) {
return true;