diff --git a/window_scene/session/host/include/move_drag_controller.h b/window_scene/session/host/include/move_drag_controller.h index 7e06debb9b1950a96d82b2552e17d74aaa7e26ef..c7729a341f01ec2539b0659fbc18eb16c8fc0476 100644 --- a/window_scene/session/host/include/move_drag_controller.h +++ b/window_scene/session/host/include/move_drag_controller.h @@ -322,7 +322,7 @@ private: int32_t originalDisplayOffsetY_ = 0; std::mutex displayIdSetDuringMoveDragMutex_; std::set displayIdSetDuringMoveDrag_; - DMRect moveAvailableArea_; + DMRect moveAvailableArea_ = {0, 0, 0, 0}; DisplayId moveInputBarStartDisplayId_ = DISPLAY_ID_INVALID; ScreenSizeProperty screenSizeProperty_; // Above guarded by displayIdSetDuringMoveDragMutex_ diff --git a/window_scene/session/host/include/scene_session.h b/window_scene/session/host/include/scene_session.h index 4c09ea6668318db3a27db54f00626c061458317c..f6e1da54d68fafd215c1742d2e899c73d55727fb 100644 --- a/window_scene/session/host/include/scene_session.h +++ b/window_scene/session/host/include/scene_session.h @@ -595,7 +595,7 @@ public: DragResizeType GetAppDragResizeType() const { return appDragResizeType_; } void RegisterSessionEventCallback(NotifySessionEventFunc&& callback); void SetWindowMovingCallback(NotifyWindowMovingFunc&& func); - int32_t CalcAvoidAreaForStatusBar(); + DMRect CalcRectForStatusBar(); WSError SetMoveAvailableArea(DisplayId displayId); /* diff --git a/window_scene/session/host/src/scene_session.cpp b/window_scene/session/host/src/scene_session.cpp index cf4de60fb48388bc8c8b1a575a85c7e54425b280..65ff5febe0055ba3c7172de7032db8fdf0e6f34d 100644 --- a/window_scene/session/host/src/scene_session.cpp +++ b/window_scene/session/host/src/scene_session.cpp @@ -626,22 +626,30 @@ WSError SceneSession::UpdateActiveStatus(bool isActive) return WSError::WS_OK; } -int32_t SceneSession::CalcAvoidAreaForStatusBar() +DMRect SceneSession::CalcRectForStatusBar() { - int32_t height = 0; + DMRect statusBarRect = {0, 0, 0, 0}; if (specificCallback_ == nullptr || specificCallback_->onGetSceneSessionVectorByTypeAndDisplayId_ == nullptr) { TLOGE(WmsLogTag::WMS_KEYBOARD, "specificCallback is null"); - return height; + return statusBarRect; } const auto& statusBarVector = specificCallback_->onGetSceneSessionVectorByTypeAndDisplayId_( WindowType::WINDOW_TYPE_STATUS_BAR, GetSessionProperty()->GetDisplayId()); for (auto& statusBar : statusBarVector) { - if (statusBar != nullptr && statusBar->IsVisible() && statusBar->GetSessionRect().height_ > height) { - height = statusBar->GetSessionRect().height_; + if (statusBar == nullptr) { + continue; + } + if (statusBar->IsVisible() && + static_cast(statusBar->GetSessionRect().height_) > statusBarRect.height_) { + statusBarRect.height_ = static_cast(statusBar->GetSessionRect().height_); + } + if (static_cast(statusBar->GetSessionRect().width_) > statusBarRect.width_) { + statusBarRect.width_ = static_cast(statusBar->GetSessionRect().width_); } } - TLOGD(WmsLogTag::WMS_KEYBOARD, "height: %{public}d", height); - return height; + TLOGD( + WmsLogTag::WMS_KEYBOARD, "width: %{public}d, height: %{public}d", statusBarRect.width_, statusBarRect.height_); + return statusBarRect; } WSError SceneSession::SetMoveAvailableArea(DisplayId displayId) @@ -659,8 +667,9 @@ WSError SceneSession::SetMoveAvailableArea(DisplayId displayId) return WSError::WS_ERROR_INVALID_DISPLAY; } - if ((systemConfig_.IsPadWindow() || systemConfig_.IsPhoneWindow()) && !systemConfig_.IsFreeMultiWindowMode()) { - int32_t statusBarHeight = CalcAvoidAreaForStatusBar(); + DMRect statusBarRect = CalcRectForStatusBar(); + if (systemConfig_.IsPadWindow() || systemConfig_.IsPhoneWindow()) { + uint32_t statusBarHeight = statusBarRect.height_; if (statusBarHeight > availableArea.posY_) { availableArea.posY_ = statusBarHeight; } @@ -675,6 +684,10 @@ WSError SceneSession::SetMoveAvailableArea(DisplayId displayId) availableArea.height_ = currentScreenHeight - static_cast(availableArea.posY_); } + bool isFoldable = ScreenSessionManagerClient::GetInstance().IsFoldable(); + if (systemConfig_.IsPhoneWindow() && isFoldable && statusBarRect.width_) { + availableArea.width_ = statusBarRect.width_; + } TLOGD(WmsLogTag::WMS_KEYBOARD, "the available area x is: %{public}d, y is: %{public}d, width is: %{public}d, height is: %{public}d", availableArea.posX_, availableArea.posY_, availableArea.width_, availableArea.height_); diff --git a/window_scene/test/unittest/scene_session_test.cpp b/window_scene/test/unittest/scene_session_test.cpp index 9b6ae377defb36dafda300fa9e1742e65b472bfb..09de91e07b261fc490feee1c3523b365b5c5db11 100644 --- a/window_scene/test/unittest/scene_session_test.cpp +++ b/window_scene/test/unittest/scene_session_test.cpp @@ -1405,19 +1405,20 @@ HWTEST_F(SceneSessionTest, DumpSessionInfo, Function | SmallTest | Level2) } /** - * @tc.name: CalcAvoidAreaForStatusBar - * @tc.desc: CalcAvoidAreaForStatusBar + * @tc.name: CalcRectForStatusBar + * @tc.desc: CalcRectForStatusBar * @tc.type: FUNC */ -HWTEST_F(SceneSessionTest, CalcAvoidAreaForStatusBar, Function | SmallTest | Level2) +HWTEST_F(SceneSessionTest, CalcRectForStatusBar, Function | SmallTest | Level2) { SessionInfo info; - info.abilityName_ = "CalcAvoidAreaForStatusBar"; - info.bundleName_ = "CalcAvoidAreaForStatusBar"; + info.abilityName_ = "CalcRectForStatusBar"; + info.bundleName_ = "CalcRectForStatusBar"; sptr sceneSession = sptr::MakeSptr(info, nullptr); - int32_t result = sceneSession->CalcAvoidAreaForStatusBar(); - - EXPECT_EQ(result, 0); + uint32_t width = sceneSession->CalcRectForStatusBar().width_; + uint32_t height = sceneSession->CalcRectForStatusBar().height_; + EXPECT_EQ(width, 0); + EXPECT_EQ(height, 0); } /**