From 9a87cb5f8573e5492903a4a4ad1b39af9f67812d Mon Sep 17 00:00:00 2001 From: 18 Date: Tue, 20 May 2025 11:13:57 +0800 Subject: [PATCH 1/8] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=82=AC=E6=B5=AE?= =?UTF-8?q?=E7=AA=97=E5=9C=BA=E6=99=AF=E4=B8=8B=E4=B8=BB=E7=AA=97=E5=A4=B1?= =?UTF-8?q?=E7=84=A6=E7=9A=84bug=20Signed-off-by:=2018=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../include/scene_session_manager.h | 2 + .../src/scene_session_manager.cpp | 113 ++++++++++++++++-- .../src/window_focus_controller.cpp | 5 - .../unittest/scene_session_manager_test5.cpp | 83 +++++++++++++ 4 files changed, 187 insertions(+), 16 deletions(-) diff --git a/window_scene/session_manager/include/scene_session_manager.h b/window_scene/session_manager/include/scene_session_manager.h index 13bd19ce1d..e0930be256 100644 --- a/window_scene/session_manager/include/scene_session_manager.h +++ b/window_scene/session_manager/include/scene_session_manager.h @@ -844,6 +844,8 @@ private: const sptr& sceneSession, FocusChangeReason reason); bool IsParentSessionVisible(const sptr& session); sptr GetNextFocusableSession(DisplayId displayId, int32_t persistentId); + sptr GetTopFloatingSession(DisplayId displayGroupId, int32_t persistentId); + sptr GetNextFocusableSessionWhenFloatWindowExist(DisplayId displayGroupId, int32_t persistentId); sptr GetTopNearestBlockingFocusSession(DisplayId displayId, uint32_t zOrder, bool includingAppSession); sptr GetTopFocusableNonAppSession(); diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index bdc16037bd..7f54c08dab 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -6785,9 +6785,13 @@ bool SceneSessionManager::CheckFocusIsDownThroughBlockingType(const sptrGetZOrder(); - TLOGD(WmsLogTag::WMS_FOCUS, "requestSessionZOrder: %{public}d, focusedSessionZOrder: %{public}d\ - topNearestBlockingZOrder: %{public}d", requestSessionZOrder, focusedSessionZOrder, - topNearestBlockingZOrder); + TLOGI(WmsLogTag::WMS_FOCUS, + "requestSessionZOrder: %{public}d, focusedSessionZOrder: %{public}d\ + topNearestBlockingZOrder: %{public}d, topNearestBlockingId: %{public}d", + requestSessionZOrder, + focusedSessionZOrder, + topNearestBlockingZOrder, + topNearestBlockingFocusSession->GetPersistentId()); } if (focusedSessionZOrder >= topNearestBlockingZOrder && requestSessionZOrder < topNearestBlockingZOrder) { TLOGD(WmsLogTag::WMS_FOCUS, "focus pass through, needs to be intercepted"); @@ -6930,6 +6934,7 @@ sptr SceneSessionManager::GetNextFocusableSession(DisplayId displa bool previousFocusedSessionFound = false; sptr ret = nullptr; DisplayId displayGroupId = windowFocusController_->GetDisplayGroupId(displayId); + sptr topFloatingSession = GetNextFocusableSessionWhenFloatWindowExist(displayGroupId, persistentId); auto func = [this, persistentId, &previousFocusedSessionFound, &ret, displayGroupId](sptr session) { if (session == nullptr) { return false; @@ -6953,6 +6958,66 @@ sptr SceneSessionManager::GetNextFocusableSession(DisplayId displa return false; }; TraverseSessionTree(func, true); + if (topFloatingSession != nullptr && ret != nullptr && ret->GetWindowType() == == WindowType::WINDOW_TYPE_DESKTOP) { + TLOGI(WmsLogTag::WMS_FOCUS, "topFloatingSession: %{public}d", topFloatingSession->GetPersistentId()); + return topFloatingSession; + } + return ret; +} + +sptr SceneSessionManager::GetNextFocusableSessionWhenFloatWindowExist(DisplayId displayGroupId, + int32_t persistentId) +{ + bool isPhoneOrPad = + systemConfig_.IsPhoneWindow() || (systemConfig_.IsPadWindow() && !systemConfig_.IsFreeMultiWindowMode()); + if (!isPhoneOrPad) { + return nullptr; + } + auto topFloatingSession = GetTopFloatingSession(displayGroupId, persistentId); + auto sceneSession = GetSceneSession(persistentId); + if (topFloatingSession != nullptr && SessionHelper::IsMainWindow(sceneSession->GetWindowType()) && + sceneSession->GetWindowMode() == WindowMode::WINDOW_MODE_FULLSCREEN) { + return topFloatingSession; + } else { + return nullptr; + } +} + +sptr SceneSessionManager::GetTopFloatingSession(DisplayId displayGroupId, int32_t persistentId) +{ + bool previousFocusedSessionFound = false; + sptr ret = nullptr; + auto func = [this, persistentId, &previousFocusedSessionFound, &ret, displayGroupId](sptr session) { + if (session == nullptr || ret != nullptr || previousFocusedSessionFound) { + return false; + } + if (windowFocusController_->GetDisplayGroupId(session->GetSessionProperty()->GetDisplayId()) != + displayGroupId) { + return false; + } + if (session->GetForceHideState() != ForceHideState::NOT_HIDDEN) { + TLOGND(WmsLogTag::WMS_FOCUS, "the window hide id: %{public}d", persistentId); + return false; + } + // need to be floating window + if (session->GetWindowMode() != WindowMode::WINDOW_MODE_FLOATING) { + return false; + } + // need todo main window + if (!SessionHelper::IsMainWindow(session->GetWindowType())) { + return false; + } + + if (session->CheckFocusable() && session->IsVisible()) { + ret = session; + return true; + } + if (session->GetPersistentId() == persistentId) { + previousFocusedSessionFound = true; + } + return false; + }; + TraverseSessionTree(func, true); return ret; } @@ -6988,14 +7053,8 @@ sptr SceneSessionManager::GetTopNearestBlockingFocusSession(Displa TLOGND(WmsLogTag::WMS_FOCUS, "sub window of topmost do not block"); return false; } - bool isPhoneOrPad = systemConfig_.IsPhoneWindow() || systemConfig_.IsPadWindow(); - bool isPcOrPcMode = systemConfig_.IsPcWindow() || - (systemConfig_.IsPadWindow() && systemConfig_.IsFreeMultiWindowMode()); - bool isBlockingType = (includingAppSession && session->IsAppSession() && - !(isPcOrPcMode && session->GetWindowType() == WindowType::WINDOW_TYPE_FLOAT)) || - (session->GetSessionInfo().isSystem_ && session->GetBlockingFocus()) || - (isPhoneOrPad && session->GetWindowType() == WindowType::WINDOW_TYPE_VOICE_INTERACTION); - if (IsSessionVisibleForeground(session) && isBlockingType) { + + if (IsSessionVisibleForeground(session) && CheckBlockingFocus(session,includingAppSession)){ ret = session; return true; } @@ -7005,6 +7064,38 @@ sptr SceneSessionManager::GetTopNearestBlockingFocusSession(Displa return ret; } +sptr SceneSessionManager::CheckBlockingFocus(const sptr& session, bool includingAppSession) +{ + if (session->GetSessionInfo().isSystem_ && session->GetBlockingFocus()) { + return true; + } + + bool isPhoneOrPad = systemConfig_.IsPhoneWindow() || systemConfig_.IsPadWindow(); + if (isPhoneOrPad && session->GetWindowType() == WindowType::WINDOW_TYPE_VOICE_INTERACTION) { + return true; + } + if (includingAppSession && session->IsAppSession()) { + TLOGD(WmsLogTag::WMS_FOCUS, + "id: %{public}d, isFloatType: %{public}d, isFloatMode: %{public}d", + session->GetPersistentId(), + session->GetWindowType() == WindowType::WINDOW_TYPE_FLOAT, + session->GetWindowType == WindowMode::WINDOW_MODE_FLOATIN); + bool isPcOrPcMode = + systemConfig_.IsPcWindow() || (systemConfig_.IsPadWindow() && systemConfig_.IsFreeMultiWindowMode()); + + if (isPcOrPcMode && session->GetWindowType() == WindowType::WINDOW_TYPE_FLOAT) { + return false; + } + bool isPhoneAndPadWithoutPcMode = + systemConfig_.IsPhoneWindow() || (systemConfig_.IsPadWindow() && !systemConfig_.IsFreeMultiWindowMode()); + if (isPhoneAndPadWithoutPcMode && session->GetWindowType == WindowMode::WINDOW_MODE_FLOATING) { + return false; + } + return true; + } + return false; +} + sptr SceneSessionManager::GetTopFocusableNonAppSession() { TLOGD(WmsLogTag::WMS_FOCUS, "in."); diff --git a/window_scene/session_manager/src/window_focus_controller.cpp b/window_scene/session_manager/src/window_focus_controller.cpp index 4c4c4217c4..b2390728ef 100644 --- a/window_scene/session_manager/src/window_focus_controller.cpp +++ b/window_scene/session_manager/src/window_focus_controller.cpp @@ -44,7 +44,6 @@ WindowFocusController::WindowFocusController() noexcept DisplayId WindowFocusController::GetDisplayGroupId(DisplayId displayId) { - TLOGD(WmsLogTag::WMS_FOCUS, "displayId: %{public}" PRIu64, displayId); if (displayId == DEFAULT_DISPLAY_ID || virtualScreenDisplayIdSet_.size() == 0) { return DEFAULT_DISPLAY_ID; } @@ -86,8 +85,6 @@ WSError WindowFocusController::RemoveFocusGroup(DisplayId displayId) sptr WindowFocusController::GetFocusGroupInner(DisplayId displayId) { DisplayId displayGroupId = GetDisplayGroupId(displayId); - TLOGD(WmsLogTag::WMS_FOCUS, "displayId: %{public}" PRIu64 ", displayGroupId: %{public}" PRIu64, - displayId, displayGroupId); if (displayGroupId == DEFAULT_DISPLAY_ID) { return focusGroupMap_[DEFAULT_DISPLAY_ID]; } @@ -101,7 +98,6 @@ sptr WindowFocusController::GetFocusGroupInner(DisplayId displayId) int32_t WindowFocusController::GetFocusedSessionId(DisplayId displayId) { - TLOGD(WmsLogTag::WMS_FOCUS, "displayId: %{public}" PRIu64, displayId); if (displayId == DISPLAY_ID_INVALID) { TLOGE(WmsLogTag::WMS_FOCUS, "displayId invalid"); return INVALID_SESSION_ID; @@ -116,7 +112,6 @@ int32_t WindowFocusController::GetFocusedSessionId(DisplayId displayId) sptr WindowFocusController::GetFocusGroup(DisplayId displayId) { - TLOGD(WmsLogTag::WMS_FOCUS, "displayId: %{public}" PRIu64, displayId); if (displayId == DISPLAY_ID_INVALID) { TLOGE(WmsLogTag::WMS_FOCUS, "displayId invalid"); return nullptr; diff --git a/window_scene/test/unittest/scene_session_manager_test5.cpp b/window_scene/test/unittest/scene_session_manager_test5.cpp index 56bd440228..edee95e31e 100644 --- a/window_scene/test/unittest/scene_session_manager_test5.cpp +++ b/window_scene/test/unittest/scene_session_manager_test5.cpp @@ -1794,6 +1794,89 @@ HWTEST_F(SceneSessionManagerTest5, SetDelayRemoveSnapshot, TestSize.Level1) auto res = ssm_->GetDelayRemoveSnapshot(); ASSERT_EQ(true, res); } + +/** + * @tc.name: GetTopFloatingSession + * @tc.desc: GetTopFloatingSession Test + * @tc.type: FUNC + */ +HWTEST_F(SceneSessionManagerTest5, GetTopFloatingSession, TestSize.Level1) +{ + ssm_->sceneSessionMap_.clear(); + ASSERT_NE(ssm_, nullptr); + SessionInfo info; + info.abilityName_ = "RequestSessionUnfocus02"; + info.bundleName_ = "RequestSessionUnfocus02"; + sptr sceneSession = sptr::MakeSptr(info, nullptr); + sceneSession->persistentId_ = 1; + sceneSession->zOrder_ = 1; + sceneSession->property_->SetDisplayId(DEFAULT_DISPLAY_ID); + ssm_->SetFocusedSessionId(1, DEFAULT_DISPLAY_ID); + + sptr sceneSession1 = sptr::MakeSptr(info, nullptr); + sceneSession1->persistentId_ = 1; + sceneSession1->zOrder_ = 1; + sceneSession1->property_->SetDisplayId(DEFAULT_DISPLAY_ID); + sceneSession1->SetFocusable(true); + sceneSession1->isVisible_ = true; + sptr result = ssm->GetTopFloatingSession(DEFAULT_DISPLAY_ID, 1); + ASSERT_EQ(result, nullptr); + sceneSession1->property_->windowMode_ = WindowMode::WINDOW_MODE_FLOATING; + ssm_->sceneSessionMap_.insert(std::make_pair(sceneSession->GetPersistentId(), sceneSession)); + ssm_->sceneSessionMap_.insert(std::make_pair(sceneSession1->GetPersistentId(), sceneSession1)); + result = ssm->GetTopFloatingSession(DEFAULT_DISPLAY_ID, 1); + ASSERT_NE(result, nullptr); + ASSERT_EQ(result->GetPersistentId(), sceneSession1->GetPersistentId()); +} + +/** + * @tc.name: GetNextFocusableSessionWhenFloatWindowExist + * @tc.desc: GetNextFocusableSessionWhenFloatWindowExist Test + * @tc.type: FUNC + */ +HWTEST_F(SceneSessionManagerTest5, GetNextFocusableSessionWhenFloatWindowExist TestSize.Level1) +{ + ssm_->sceneSessionMap_.clear(); + ASSERT_NE(ssm_, nullptr); + SessionInfo info; + info.abilityName_ = "GetNextFocusableSessionWhenFloatWindowExist"; + info.bundleName_ = "GetNextFocusableSessionWhenFloatWindowExist"; + sptr sceneSession = sptr::MakeSptr(info, nullptr); + sceneSession->persistentId_ = 1; + sceneSession->zOrder_ = 1; + sceneSession->property_->SetDisplayId(DEFAULT_DISPLAY_ID); + + ssm_->systemConfig_.windowUIType_ = WindowUIType::PC_WINDOW; + ssm_->sceneSessionMap_.insert(std::make_pair(sceneSession->GetPersistentId(), sceneSession)); + sptr result = + ssm->GetNextFocusableSessionWhenFloatWindowExist(DEFAULT_DISPLAY_ID, sceneSession->GetPersistentId()); + ASSERT_EQ(result, nullptr); + ssm_->systemConfig_.windowUIType_ = WindowUIType::PAD_WINDOW; + ssm_->systemConfig_.freeMultiWindowEnable_ = true; + result = ssm->GetNextFocusableSessionWhenFloatWindowExist(DEFAULT_DISPLAY_ID, sceneSession->GetPersistentId()); + ASSERT_EQ(result, nullptr); + ssm_->systemConfig_.windowUIType_ = WindowUIType::PHONE_WINDOW; + ASSERT_EQ(result, nullptr); + + sptr sceneSession1 = sptr::MakeSptr(info, nullptr); + sceneSession1->persistentId_ = 2; + sceneSession1->zOrder_ = 2; + sceneSession1->property_->SetDisplayId(DEFAULT_DISPLAY_ID); + sceneSession1->SetFocusable(true); + sceneSession1->isVisible_ = true; + sceneSession1->property_->windowMode_ = WindowMode::WINDOW_MODE_FLOATING; + + sceneSession->property->SetWindowType(WindowType::WINDOW_TYPE_NEGATIVE_SCREEN); + ssm_->sceneSessionMap_.insert(std::make_pair(sceneSession1->GetPersistentId(), sceneSession1)); + result = ssm->GetNextFocusableSessionWhenFloatWindowExist(DEFAULT_DISPLAY_ID, sceneSession->GetPersistentId()); + ASSERT_EQ(result, nullptr); + sceneSession->property->SetWindowType(WindowType::APP_MAIN_WINDOW_BASE); + sceneSession1->property_->windowMode_ = WindowMode::WINDOW_MODE_PIP; + result = ssm->GetNextFocusableSessionWhenFloatWindowExist(DEFAULT_DISPLAY_ID, sceneSession->GetPersistentId()); + ASSERT_NE(result, nullptr); + ASSERT_EQ(result->GetPersistentId(), sceneSession1->GetPersistentId()); +} + } // namespace } // namespace Rosen } // namespace OHOS -- Gitee From 5f27d8ed4bef5f422c132a5f4c6414708785a6d3 Mon Sep 17 00:00:00 2001 From: 18 Date: Tue, 20 May 2025 11:38:06 +0800 Subject: [PATCH 2/8] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=82=AC=E6=B5=AE?= =?UTF-8?q?=E7=AA=97=E5=9C=BA=E6=99=AF=E4=B8=8B=E4=B8=BB=E7=AA=97=E5=A4=B1?= =?UTF-8?q?=E7=84=A6=E7=9A=84bug=20Signed-off-by:=2018=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../include/scene_session_manager.h | 1 + .../src/scene_session_manager.cpp | 13 +++++---- .../unittest/scene_session_manager_test5.cpp | 28 +++++++++---------- 3 files changed, 22 insertions(+), 20 deletions(-) diff --git a/window_scene/session_manager/include/scene_session_manager.h b/window_scene/session_manager/include/scene_session_manager.h index e0930be256..72cd8fd3ff 100644 --- a/window_scene/session_manager/include/scene_session_manager.h +++ b/window_scene/session_manager/include/scene_session_manager.h @@ -849,6 +849,7 @@ private: sptr GetTopNearestBlockingFocusSession(DisplayId displayId, uint32_t zOrder, bool includingAppSession); sptr GetTopFocusableNonAppSession(); + bool CheckBlockingFocus(const sptr& session, bool includingAppSession) WSError ShiftFocus(DisplayId displayId, const sptr& nextSession, bool isProactiveUnfocus, FocusChangeReason reason = FocusChangeReason::DEFAULT); void UpdateFocusStatus(DisplayId displayId, const sptr& sceneSession, bool isFocused); diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index 7f54c08dab..fb6a150cab 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -6958,8 +6958,8 @@ sptr SceneSessionManager::GetNextFocusableSession(DisplayId displa return false; }; TraverseSessionTree(func, true); - if (topFloatingSession != nullptr && ret != nullptr && ret->GetWindowType() == == WindowType::WINDOW_TYPE_DESKTOP) { - TLOGI(WmsLogTag::WMS_FOCUS, "topFloatingSession: %{public}d", topFloatingSession->GetPersistentId()); + if (topFloatingSession != nullptr && ret != nullptr && ret->GetWindowType() == WindowType::WINDOW_TYPE_DESKTOP) { + TLOGI(WmsLogTag::WMS_FOCUS, "topFloatingSessionId: %{public}d", topFloatingSession->GetPersistentId()); return topFloatingSession; } return ret; @@ -7003,7 +7003,7 @@ sptr SceneSessionManager::GetTopFloatingSession(DisplayId displayG if (session->GetWindowMode() != WindowMode::WINDOW_MODE_FLOATING) { return false; } - // need todo main window + // need to be main window if (!SessionHelper::IsMainWindow(session->GetWindowType())) { return false; } @@ -7064,9 +7064,10 @@ sptr SceneSessionManager::GetTopNearestBlockingFocusSession(Displa return ret; } -sptr SceneSessionManager::CheckBlockingFocus(const sptr& session, bool includingAppSession) +bool SceneSessionManager::CheckBlockingFocus(const sptr& session, bool includingAppSession) { if (session->GetSessionInfo().isSystem_ && session->GetBlockingFocus()) { + TLOGD(WmsLogTag::WMS_FOCUS, "system window blocked"); return true; } @@ -7079,7 +7080,7 @@ sptr SceneSessionManager::CheckBlockingFocus(const sptrGetPersistentId(), session->GetWindowType() == WindowType::WINDOW_TYPE_FLOAT, - session->GetWindowType == WindowMode::WINDOW_MODE_FLOATIN); + session->GetWindowMode() == WindowMode::WINDOW_MODE_FLOATING); bool isPcOrPcMode = systemConfig_.IsPcWindow() || (systemConfig_.IsPadWindow() && systemConfig_.IsFreeMultiWindowMode()); @@ -7088,7 +7089,7 @@ sptr SceneSessionManager::CheckBlockingFocus(const sptrGetWindowType == WindowMode::WINDOW_MODE_FLOATING) { + if (isPhoneAndPadWithoutPcMode && session->GetWindowMode() == WindowMode::WINDOW_MODE_FLOATING) { return false; } return true; diff --git a/window_scene/test/unittest/scene_session_manager_test5.cpp b/window_scene/test/unittest/scene_session_manager_test5.cpp index edee95e31e..e8109a5896 100644 --- a/window_scene/test/unittest/scene_session_manager_test5.cpp +++ b/window_scene/test/unittest/scene_session_manager_test5.cpp @@ -1800,13 +1800,13 @@ HWTEST_F(SceneSessionManagerTest5, SetDelayRemoveSnapshot, TestSize.Level1) * @tc.desc: GetTopFloatingSession Test * @tc.type: FUNC */ -HWTEST_F(SceneSessionManagerTest5, GetTopFloatingSession, TestSize.Level1) +HWTEST_F(SceneSessionManagerTest5, GetTopFloatingSession, TestSize.Level3) { ssm_->sceneSessionMap_.clear(); ASSERT_NE(ssm_, nullptr); SessionInfo info; - info.abilityName_ = "RequestSessionUnfocus02"; - info.bundleName_ = "RequestSessionUnfocus02"; + info.abilityName_ = "GetTopFloatingSession"; + info.bundleName_ = "GetTopFloatingSession"; sptr sceneSession = sptr::MakeSptr(info, nullptr); sceneSession->persistentId_ = 1; sceneSession->zOrder_ = 1; @@ -1814,17 +1814,17 @@ HWTEST_F(SceneSessionManagerTest5, GetTopFloatingSession, TestSize.Level1) ssm_->SetFocusedSessionId(1, DEFAULT_DISPLAY_ID); sptr sceneSession1 = sptr::MakeSptr(info, nullptr); - sceneSession1->persistentId_ = 1; - sceneSession1->zOrder_ = 1; + sceneSession1->persistentId_ = 2; + sceneSession1->zOrder_ = 2; sceneSession1->property_->SetDisplayId(DEFAULT_DISPLAY_ID); sceneSession1->SetFocusable(true); sceneSession1->isVisible_ = true; - sptr result = ssm->GetTopFloatingSession(DEFAULT_DISPLAY_ID, 1); + sptr result = ssm_->GetTopFloatingSession(DEFAULT_DISPLAY_ID, 1); ASSERT_EQ(result, nullptr); sceneSession1->property_->windowMode_ = WindowMode::WINDOW_MODE_FLOATING; ssm_->sceneSessionMap_.insert(std::make_pair(sceneSession->GetPersistentId(), sceneSession)); ssm_->sceneSessionMap_.insert(std::make_pair(sceneSession1->GetPersistentId(), sceneSession1)); - result = ssm->GetTopFloatingSession(DEFAULT_DISPLAY_ID, 1); + result = ssm_->GetTopFloatingSession(DEFAULT_DISPLAY_ID, 1); ASSERT_NE(result, nullptr); ASSERT_EQ(result->GetPersistentId(), sceneSession1->GetPersistentId()); } @@ -1849,11 +1849,11 @@ HWTEST_F(SceneSessionManagerTest5, GetNextFocusableSessionWhenFloatWindowExist T ssm_->systemConfig_.windowUIType_ = WindowUIType::PC_WINDOW; ssm_->sceneSessionMap_.insert(std::make_pair(sceneSession->GetPersistentId(), sceneSession)); sptr result = - ssm->GetNextFocusableSessionWhenFloatWindowExist(DEFAULT_DISPLAY_ID, sceneSession->GetPersistentId()); + ssm_->GetNextFocusableSessionWhenFloatWindowExist(DEFAULT_DISPLAY_ID, sceneSession->GetPersistentId()); ASSERT_EQ(result, nullptr); ssm_->systemConfig_.windowUIType_ = WindowUIType::PAD_WINDOW; ssm_->systemConfig_.freeMultiWindowEnable_ = true; - result = ssm->GetNextFocusableSessionWhenFloatWindowExist(DEFAULT_DISPLAY_ID, sceneSession->GetPersistentId()); + result = ssm_->GetNextFocusableSessionWhenFloatWindowExist(DEFAULT_DISPLAY_ID, sceneSession->GetPersistentId()); ASSERT_EQ(result, nullptr); ssm_->systemConfig_.windowUIType_ = WindowUIType::PHONE_WINDOW; ASSERT_EQ(result, nullptr); @@ -1866,13 +1866,13 @@ HWTEST_F(SceneSessionManagerTest5, GetNextFocusableSessionWhenFloatWindowExist T sceneSession1->isVisible_ = true; sceneSession1->property_->windowMode_ = WindowMode::WINDOW_MODE_FLOATING; - sceneSession->property->SetWindowType(WindowType::WINDOW_TYPE_NEGATIVE_SCREEN); + sceneSession->property_->SetWindowType(WindowType::WINDOW_TYPE_NEGATIVE_SCREEN); ssm_->sceneSessionMap_.insert(std::make_pair(sceneSession1->GetPersistentId(), sceneSession1)); - result = ssm->GetNextFocusableSessionWhenFloatWindowExist(DEFAULT_DISPLAY_ID, sceneSession->GetPersistentId()); + result = ssm_->GetNextFocusableSessionWhenFloatWindowExist(DEFAULT_DISPLAY_ID, sceneSession->GetPersistentId()); ASSERT_EQ(result, nullptr); - sceneSession->property->SetWindowType(WindowType::APP_MAIN_WINDOW_BASE); - sceneSession1->property_->windowMode_ = WindowMode::WINDOW_MODE_PIP; - result = ssm->GetNextFocusableSessionWhenFloatWindowExist(DEFAULT_DISPLAY_ID, sceneSession->GetPersistentId()); + sceneSession->property_->SetWindowType(WindowType::APP_MAIN_WINDOW_BASE); + sceneSession->property_->windowMode_ = WindowMode::WINDOW_MODE_PIP; + result = ssm_->GetNextFocusableSessionWhenFloatWindowExist(DEFAULT_DISPLAY_ID, sceneSession->GetPersistentId()); ASSERT_NE(result, nullptr); ASSERT_EQ(result->GetPersistentId(), sceneSession1->GetPersistentId()); } -- Gitee From 709517f4c5916edd30a6af1ac57b857745403e04 Mon Sep 17 00:00:00 2001 From: 18 Date: Tue, 20 May 2025 14:23:54 +0800 Subject: [PATCH 3/8] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=82=AC=E6=B5=AE?= =?UTF-8?q?=E7=AA=97=E5=9C=BA=E6=99=AF=E4=B8=8B=E4=B8=BB=E7=AA=97=E5=A4=B1?= =?UTF-8?q?=E7=84=A6=E7=9A=84bug=20Signed-off-by:=2018=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- window_scene/session_manager/include/scene_session_manager.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/window_scene/session_manager/include/scene_session_manager.h b/window_scene/session_manager/include/scene_session_manager.h index 72cd8fd3ff..134cfbe8c1 100644 --- a/window_scene/session_manager/include/scene_session_manager.h +++ b/window_scene/session_manager/include/scene_session_manager.h @@ -849,7 +849,7 @@ private: sptr GetTopNearestBlockingFocusSession(DisplayId displayId, uint32_t zOrder, bool includingAppSession); sptr GetTopFocusableNonAppSession(); - bool CheckBlockingFocus(const sptr& session, bool includingAppSession) + bool CheckBlockingFocus(const sptr& session, bool includingAppSession); WSError ShiftFocus(DisplayId displayId, const sptr& nextSession, bool isProactiveUnfocus, FocusChangeReason reason = FocusChangeReason::DEFAULT); void UpdateFocusStatus(DisplayId displayId, const sptr& sceneSession, bool isFocused); -- Gitee From 5ef1952e76d6b925e573b9910b84b96bc9005506 Mon Sep 17 00:00:00 2001 From: 18 Date: Tue, 20 May 2025 14:59:00 +0800 Subject: [PATCH 4/8] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=82=AC=E6=B5=AE?= =?UTF-8?q?=E7=AA=97=E5=9C=BA=E6=99=AF=E4=B8=8B=E4=B8=BB=E7=AA=97=E5=A4=B1?= =?UTF-8?q?=E7=84=A6=E7=9A=84bug=20Signed-off-by:=2018=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- window_scene/test/unittest/scene_session_manager_test5.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/window_scene/test/unittest/scene_session_manager_test5.cpp b/window_scene/test/unittest/scene_session_manager_test5.cpp index e8109a5896..8781a3b005 100644 --- a/window_scene/test/unittest/scene_session_manager_test5.cpp +++ b/window_scene/test/unittest/scene_session_manager_test5.cpp @@ -1871,7 +1871,7 @@ HWTEST_F(SceneSessionManagerTest5, GetNextFocusableSessionWhenFloatWindowExist T result = ssm_->GetNextFocusableSessionWhenFloatWindowExist(DEFAULT_DISPLAY_ID, sceneSession->GetPersistentId()); ASSERT_EQ(result, nullptr); sceneSession->property_->SetWindowType(WindowType::APP_MAIN_WINDOW_BASE); - sceneSession->property_->windowMode_ = WindowMode::WINDOW_MODE_PIP; + sceneSession->property_->windowMode_ = WindowMode::WINDOW_MODE_FULLSCREEN; result = ssm_->GetNextFocusableSessionWhenFloatWindowExist(DEFAULT_DISPLAY_ID, sceneSession->GetPersistentId()); ASSERT_NE(result, nullptr); ASSERT_EQ(result->GetPersistentId(), sceneSession1->GetPersistentId()); -- Gitee From 107ff1ccabcfbbf7983ae27afb9b572347dea5ec Mon Sep 17 00:00:00 2001 From: 18 Date: Tue, 20 May 2025 15:47:44 +0800 Subject: [PATCH 5/8] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=82=AC=E6=B5=AE?= =?UTF-8?q?=E7=AA=97=E5=9C=BA=E6=99=AF=E4=B8=8B=E4=B8=BB=E7=AA=97=E5=A4=B1?= =?UTF-8?q?=E7=84=A6=E7=9A=84bug=20Signed-off-by:=2018=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- window_scene/test/unittest/scene_session_manager_test5.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/window_scene/test/unittest/scene_session_manager_test5.cpp b/window_scene/test/unittest/scene_session_manager_test5.cpp index 8781a3b005..cf02ed1612 100644 --- a/window_scene/test/unittest/scene_session_manager_test5.cpp +++ b/window_scene/test/unittest/scene_session_manager_test5.cpp @@ -1834,7 +1834,7 @@ HWTEST_F(SceneSessionManagerTest5, GetTopFloatingSession, TestSize.Level3) * @tc.desc: GetNextFocusableSessionWhenFloatWindowExist Test * @tc.type: FUNC */ -HWTEST_F(SceneSessionManagerTest5, GetNextFocusableSessionWhenFloatWindowExist TestSize.Level1) +HWTEST_F(SceneSessionManagerTest5, GetNextFocusableSessionWhenFloatWindowExist, TestSize.Level3) { ssm_->sceneSessionMap_.clear(); ASSERT_NE(ssm_, nullptr); -- Gitee From 851006521eada8912acd8cafd8c7cedee2eb71fa Mon Sep 17 00:00:00 2001 From: 18 Date: Wed, 21 May 2025 15:45:36 +0800 Subject: [PATCH 6/8] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=82=AC=E6=B5=AE?= =?UTF-8?q?=E7=AA=97=E5=9C=BA=E6=99=AF=E4=B8=8B=E4=B8=BB=E7=AA=97=E5=A4=B1?= =?UTF-8?q?=E7=84=A6=E7=9A=84bug=20Signed-off-by:=2018=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/scene_session_manager.cpp | 20 +++++++++---------- .../unittest/scene_session_manager_test5.cpp | 14 ++++++------- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index fb6a150cab..fd78e49723 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -6932,10 +6932,10 @@ sptr SceneSessionManager::GetNextFocusableSession(DisplayId displa { TLOGD(WmsLogTag::WMS_FOCUS, "id: %{public}d", persistentId); bool previousFocusedSessionFound = false; - sptr ret = nullptr; DisplayId displayGroupId = windowFocusController_->GetDisplayGroupId(displayId); sptr topFloatingSession = GetNextFocusableSessionWhenFloatWindowExist(displayGroupId, persistentId); - auto func = [this, persistentId, &previousFocusedSessionFound, &ret, displayGroupId](sptr session) { + sptr nextFocusableSession = nullptr; + auto func = [this, persistentId, &previousFocusedSessionFound, &nextFocusableSession, displayGroupId](sptr session) { if (session == nullptr) { return false; } @@ -6949,7 +6949,7 @@ sptr SceneSessionManager::GetNextFocusableSession(DisplayId displa } if (previousFocusedSessionFound && session->CheckFocusable() && session->IsVisible() && IsParentSessionVisible(session)) { - ret = session; + nextFocusableSession = session; return true; } if (session->GetPersistentId() == persistentId) { @@ -6958,11 +6958,11 @@ sptr SceneSessionManager::GetNextFocusableSession(DisplayId displa return false; }; TraverseSessionTree(func, true); - if (topFloatingSession != nullptr && ret != nullptr && ret->GetWindowType() == WindowType::WINDOW_TYPE_DESKTOP) { + if (topFloatingSession != nullptr && nextFocusableSession != nullptr && nextFocusableSession->GetWindowType() == WindowType::WINDOW_TYPE_DESKTOP) { TLOGI(WmsLogTag::WMS_FOCUS, "topFloatingSessionId: %{public}d", topFloatingSession->GetPersistentId()); return topFloatingSession; } - return ret; + return nextFocusableSession; } sptr SceneSessionManager::GetNextFocusableSessionWhenFloatWindowExist(DisplayId displayGroupId, @@ -6986,9 +6986,9 @@ sptr SceneSessionManager::GetNextFocusableSessionWhenFloatWindowEx sptr SceneSessionManager::GetTopFloatingSession(DisplayId displayGroupId, int32_t persistentId) { bool previousFocusedSessionFound = false; - sptr ret = nullptr; - auto func = [this, persistentId, &previousFocusedSessionFound, &ret, displayGroupId](sptr session) { - if (session == nullptr || ret != nullptr || previousFocusedSessionFound) { + sptr topFloatingSession = nullptr; + auto func = [this, persistentId, &previousFocusedSessionFound, &topFloatingSession, displayGroupId](sptr session) { + if (session == nullptr || topFloatingSession != nullptr || previousFocusedSessionFound) { return false; } if (windowFocusController_->GetDisplayGroupId(session->GetSessionProperty()->GetDisplayId()) != @@ -7009,7 +7009,7 @@ sptr SceneSessionManager::GetTopFloatingSession(DisplayId displayG } if (session->CheckFocusable() && session->IsVisible()) { - ret = session; + topFloatingSession = session; return true; } if (session->GetPersistentId() == persistentId) { @@ -7018,7 +7018,7 @@ sptr SceneSessionManager::GetTopFloatingSession(DisplayId displayG return false; }; TraverseSessionTree(func, true); - return ret; + return topFloatingSession; } /** diff --git a/window_scene/test/unittest/scene_session_manager_test5.cpp b/window_scene/test/unittest/scene_session_manager_test5.cpp index cf02ed1612..8348e90b85 100644 --- a/window_scene/test/unittest/scene_session_manager_test5.cpp +++ b/window_scene/test/unittest/scene_session_manager_test5.cpp @@ -1820,13 +1820,13 @@ HWTEST_F(SceneSessionManagerTest5, GetTopFloatingSession, TestSize.Level3) sceneSession1->SetFocusable(true); sceneSession1->isVisible_ = true; sptr result = ssm_->GetTopFloatingSession(DEFAULT_DISPLAY_ID, 1); - ASSERT_EQ(result, nullptr); + EXPECT_EQ(result, nullptr); sceneSession1->property_->windowMode_ = WindowMode::WINDOW_MODE_FLOATING; ssm_->sceneSessionMap_.insert(std::make_pair(sceneSession->GetPersistentId(), sceneSession)); ssm_->sceneSessionMap_.insert(std::make_pair(sceneSession1->GetPersistentId(), sceneSession1)); result = ssm_->GetTopFloatingSession(DEFAULT_DISPLAY_ID, 1); ASSERT_NE(result, nullptr); - ASSERT_EQ(result->GetPersistentId(), sceneSession1->GetPersistentId()); + EXPECT_EQ(result->GetPersistentId(), sceneSession1->GetPersistentId()); } /** @@ -1850,13 +1850,13 @@ HWTEST_F(SceneSessionManagerTest5, GetNextFocusableSessionWhenFloatWindowExist, ssm_->sceneSessionMap_.insert(std::make_pair(sceneSession->GetPersistentId(), sceneSession)); sptr result = ssm_->GetNextFocusableSessionWhenFloatWindowExist(DEFAULT_DISPLAY_ID, sceneSession->GetPersistentId()); - ASSERT_EQ(result, nullptr); + EXPECT_EQ(result, nullptr); ssm_->systemConfig_.windowUIType_ = WindowUIType::PAD_WINDOW; ssm_->systemConfig_.freeMultiWindowEnable_ = true; result = ssm_->GetNextFocusableSessionWhenFloatWindowExist(DEFAULT_DISPLAY_ID, sceneSession->GetPersistentId()); - ASSERT_EQ(result, nullptr); + EXPECT_EQ(result, nullptr); ssm_->systemConfig_.windowUIType_ = WindowUIType::PHONE_WINDOW; - ASSERT_EQ(result, nullptr); + EXPECT_EQ(result, nullptr); sptr sceneSession1 = sptr::MakeSptr(info, nullptr); sceneSession1->persistentId_ = 2; @@ -1869,12 +1869,12 @@ HWTEST_F(SceneSessionManagerTest5, GetNextFocusableSessionWhenFloatWindowExist, sceneSession->property_->SetWindowType(WindowType::WINDOW_TYPE_NEGATIVE_SCREEN); ssm_->sceneSessionMap_.insert(std::make_pair(sceneSession1->GetPersistentId(), sceneSession1)); result = ssm_->GetNextFocusableSessionWhenFloatWindowExist(DEFAULT_DISPLAY_ID, sceneSession->GetPersistentId()); - ASSERT_EQ(result, nullptr); + EXPECT_EQ(result, nullptr); sceneSession->property_->SetWindowType(WindowType::APP_MAIN_WINDOW_BASE); sceneSession->property_->windowMode_ = WindowMode::WINDOW_MODE_FULLSCREEN; result = ssm_->GetNextFocusableSessionWhenFloatWindowExist(DEFAULT_DISPLAY_ID, sceneSession->GetPersistentId()); ASSERT_NE(result, nullptr); - ASSERT_EQ(result->GetPersistentId(), sceneSession1->GetPersistentId()); + EXPECT_EQ(result->GetPersistentId(), sceneSession1->GetPersistentId()); } } // namespace -- Gitee From 87a2ad816fde248efcd707ed4f6374946c23baa8 Mon Sep 17 00:00:00 2001 From: 18 Date: Thu, 22 May 2025 09:36:08 +0800 Subject: [PATCH 7/8] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=82=AC=E6=B5=AE?= =?UTF-8?q?=E7=AA=97=E5=9C=BA=E6=99=AF=E4=B8=8B=E4=B8=BB=E7=AA=97=E5=A4=B1?= =?UTF-8?q?=E7=84=A6=E7=9A=84bug=20Signed-off-by:=2018=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../session_manager/src/scene_session_manager.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index fd78e49723..6e85c74a2f 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -6786,12 +6786,10 @@ bool SceneSessionManager::CheckFocusIsDownThroughBlockingType(const sptrGetZOrder(); TLOGI(WmsLogTag::WMS_FOCUS, - "requestSessionZOrder: %{public}d, focusedSessionZOrder: %{public}d\ + "requestSessionZOrder: %{public}d, focusedSessionZOrder: %{public}d\ topNearestBlockingZOrder: %{public}d, topNearestBlockingId: %{public}d", - requestSessionZOrder, - focusedSessionZOrder, - topNearestBlockingZOrder, - topNearestBlockingFocusSession->GetPersistentId()); + requestSessionZOrder, focusedSessionZOrder, + topNearestBlockingZOrder, topNearestBlockingFocusSession->GetPersistentId()); } if (focusedSessionZOrder >= topNearestBlockingZOrder && requestSessionZOrder < topNearestBlockingZOrder) { TLOGD(WmsLogTag::WMS_FOCUS, "focus pass through, needs to be intercepted"); @@ -6933,7 +6931,6 @@ sptr SceneSessionManager::GetNextFocusableSession(DisplayId displa TLOGD(WmsLogTag::WMS_FOCUS, "id: %{public}d", persistentId); bool previousFocusedSessionFound = false; DisplayId displayGroupId = windowFocusController_->GetDisplayGroupId(displayId); - sptr topFloatingSession = GetNextFocusableSessionWhenFloatWindowExist(displayGroupId, persistentId); sptr nextFocusableSession = nullptr; auto func = [this, persistentId, &previousFocusedSessionFound, &nextFocusableSession, displayGroupId](sptr session) { if (session == nullptr) { @@ -6958,6 +6955,7 @@ sptr SceneSessionManager::GetNextFocusableSession(DisplayId displa return false; }; TraverseSessionTree(func, true); + sptr topFloatingSession = GetNextFocusableSessionWhenFloatWindowExist(displayGroupId, persistentId); if (topFloatingSession != nullptr && nextFocusableSession != nullptr && nextFocusableSession->GetWindowType() == WindowType::WINDOW_TYPE_DESKTOP) { TLOGI(WmsLogTag::WMS_FOCUS, "topFloatingSessionId: %{public}d", topFloatingSession->GetPersistentId()); return topFloatingSession; -- Gitee From 954722b756d0ff255d37b5659d16e9cd2e7c1352 Mon Sep 17 00:00:00 2001 From: 18 Date: Thu, 22 May 2025 10:41:32 +0800 Subject: [PATCH 8/8] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=82=AC=E6=B5=AE?= =?UTF-8?q?=E7=AA=97=E5=9C=BA=E6=99=AF=E4=B8=8B=E4=B8=BB=E7=AA=97=E5=A4=B1?= =?UTF-8?q?=E7=84=A6=E7=9A=84bug=20Signed-off-by:=2018=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../session_manager/src/scene_session_manager.cpp | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index 6e85c74a2f..0ae8b73322 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -6976,9 +6976,8 @@ sptr SceneSessionManager::GetNextFocusableSessionWhenFloatWindowEx if (topFloatingSession != nullptr && SessionHelper::IsMainWindow(sceneSession->GetWindowType()) && sceneSession->GetWindowMode() == WindowMode::WINDOW_MODE_FULLSCREEN) { return topFloatingSession; - } else { - return nullptr; } + return nullptr; } sptr SceneSessionManager::GetTopFloatingSession(DisplayId displayGroupId, int32_t persistentId) @@ -7046,13 +7045,12 @@ sptr SceneSessionManager::GetTopNearestBlockingFocusSession(Displa } auto parentSession = GetSceneSession(session->GetParentPersistentId()); if (SessionHelper::IsSubWindow(session->GetWindowType()) && parentSession != nullptr && - parentSession->GetWindowType() == WindowType::WINDOW_TYPE_APP_MAIN_WINDOW && - parentSession->IsTopmost()) { + parentSession->GetWindowType() == WindowType::WINDOW_TYPE_APP_MAIN_WINDOW && parentSession->IsTopmost()) { TLOGND(WmsLogTag::WMS_FOCUS, "sub window of topmost do not block"); return false; } - - if (IsSessionVisibleForeground(session) && CheckBlockingFocus(session,includingAppSession)){ + + if (IsSessionVisibleForeground(session) && CheckBlockingFocus(session, includingAppSession)) { ret = session; return true; } @@ -7075,8 +7073,7 @@ bool SceneSessionManager::CheckBlockingFocus(const sptr& session, } if (includingAppSession && session->IsAppSession()) { TLOGD(WmsLogTag::WMS_FOCUS, - "id: %{public}d, isFloatType: %{public}d, isFloatMode: %{public}d", - session->GetPersistentId(), + "id: %{public}d, isFloatType: %{public}d, isFloatMode: %{public}d", session->GetPersistentId(), session->GetWindowType() == WindowType::WINDOW_TYPE_FLOAT, session->GetWindowMode() == WindowMode::WINDOW_MODE_FLOATING); bool isPcOrPcMode = -- Gitee