!10964 修复pc兼容模式拖拽问题

Merge pull request !10964 from 马健/drag
This commit is contained in:
openharmony_ci 2024-11-22 13:22:02 +00:00 committed by Gitee
commit 8d54959229
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
2 changed files with 10 additions and 11 deletions

View File

@ -2600,10 +2600,11 @@ void SceneSession::HandleCompatibleModeDrag(WSRect& rect, SizeChangeReason reaso
const int32_t compatibleInPcLandscapeWidth = sessionProperty->GetCompatibleInPcLandscapeWidth();
const int32_t compatibleInPcLandscapeHeight = sessionProperty->GetCompatibleInPcLandscapeHeight();
const int32_t compatibleInPcDragLimit = compatibleInPcLandscapeWidth - compatibleInPcPortraitWidth;
WSRect windowRect = GetSessionRect();
WSRect windowRect = moveDragController_->GetTargetRect(reason == SizeChangeReason::DRAG_END ?
MoveDragController::TargetRectCoordinate::RELATED_TO_END_DISPLAY :
MoveDragController::TargetRectCoordinate::GLOBAL);
auto windowWidth = windowRect.width_;
auto windowHeight = windowRect.height_;
if (isSupportDragInPcCompatibleMode && windowWidth > windowHeight &&
(rect.width_ < compatibleInPcLandscapeWidth - compatibleInPcDragLimit ||
rect.width_ == static_cast<int32_t>(windowLimits.minWidth_))) {
@ -2620,13 +2621,8 @@ void SceneSession::HandleCompatibleModeDrag(WSRect& rect, SizeChangeReason reaso
UpdateSizeChangeReason(reason);
UpdateRect(rect, reason, "compatibleInPcLandscape");
} else if (isSupportDragInPcCompatibleMode) {
if (windowWidth < windowHeight) {
rect.width_ = compatibleInPcPortraitWidth;
rect.height_ = compatibleInPcPortraitHeight;
} else {
rect.width_ = compatibleInPcLandscapeWidth;
rect.height_ = compatibleInPcLandscapeHeight;
}
rect.width_ = (windowWidth < windowHeight) ? compatibleInPcPortraitWidth : compatibleInPcLandscapeWidth;
rect.height_ = (windowWidth < windowHeight) ? compatibleInPcPortraitHeight : compatibleInPcLandscapeHeight;
rect.posX_ = windowRect.posX_;
rect.posY_ = windowRect.posY_;
SetSurfaceBounds(rect, isGlobal, needFlush);
@ -2808,7 +2804,6 @@ void SceneSession::OnMoveDragCallback(SizeChangeReason reason)
MoveDragController::TargetRectCoordinate::GLOBAL);
bool isGlobal = (reason != SizeChangeReason::DRAG_END);
bool needFlush = (reason != SizeChangeReason::DRAG_END);
TLOGD(WmsLogTag::WMS_LAYOUT, "Rect: [%{public}d, %{public}d, %{public}u, %{public}u], reason: %{public}d, "
"isCompatibleMode: %{public}d, isSupportDragInPcCompatibleMode: %{public}d", rect.posX_, rect.posY_,
rect.width_, rect.height_, reason, isCompatibleModeInPc, isSupportDragInPcCompatibleMode);
@ -2818,7 +2813,9 @@ void SceneSession::OnMoveDragCallback(SizeChangeReason reason)
}
HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER,
"SceneSession::OnMoveDragCallback [%d, %d, %u, %u]", rect.posX_, rect.posY_, rect.width_, rect.height_);
if (isCompatibleModeInPc && !IsFreeMultiWindowMode()) {
if (isCompatibleModeInPc && !IsFreeMultiWindowMode() && reason == SizeChangeReason::DRAG_END) {
HandleCompatibleModeMoveDrag(rect, reason, isSupportDragInPcCompatibleMode, isGlobal, needFlush);
} else if (isCompatibleModeInPc && !IsFreeMultiWindowMode() && reason != SizeChangeReason::DRAG_END) {
HandleCompatibleModeMoveDrag(globalRect, reason, isSupportDragInPcCompatibleMode, isGlobal, needFlush);
} else if (reason == SizeChangeReason::DRAG && IsFreeMultiWindowMode() && isMainWindow) {
OnSessionEvent(SessionEvent::EVENT_DRAG);

View File

@ -1912,6 +1912,7 @@ HWTEST_F(SceneSessionTest, HandleCompatibleModeMoveDrag, Function | SmallTest |
info.bundleName_ = "HandleCompatibleModeMoveDrag";
sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
EXPECT_NE(sceneSession, nullptr);
sceneSession->moveDragController_ = sptr<MoveDragController>::MakeSptr(12, WindowType::WINDOW_TYPE_FLOAT);
WSRect rect = {1, 1, 1, 1};
WSRect rect2 = {1, 1, 2, 1};
@ -1967,6 +1968,7 @@ HWTEST_F(SceneSessionTest, HandleCompatibleModeDrag, Function | SmallTest | Leve
info.bundleName_ = "HandleCompatibleModeDrag";
sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
EXPECT_NE(sceneSession, nullptr);
sceneSession->moveDragController_ = sptr<MoveDragController>::MakeSptr(12, WindowType::WINDOW_TYPE_FLOAT);
WSRect rect = {1, 1, 1, 1};
WSRect rect2 = {2, 1, 1, 1};