From 37c51708fe18787e8b34c5072053b44170a137b8 Mon Sep 17 00:00:00 2001 From: LHHHYYY Date: Wed, 3 Sep 2025 15:28:41 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E6=8B=89=E8=B5=B7=E5=85=A8=E5=B1=8F?= =?UTF-8?q?=E7=AA=97=E5=8F=A3=E6=97=B6=E5=B1=8F=E8=94=BD=E4=B8=8B=E6=96=B9?= =?UTF-8?q?=E7=82=B9=E5=87=BB=E8=8E=B7=E7=84=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: LHHHYYY --- .../session/host/include/scene_session.h | 2 + .../session/host/src/scene_session.cpp | 43 ++++++++ .../src/scene_session_manager.cpp | 5 +- window_scene/test/mock/mock_scene_session.h | 2 + .../unittest/scene_session_manager_test9.cpp | 101 +++++++++++++++--- .../window_focus_scene_session_test.cpp | 76 +++++++++++++ 6 files changed, 209 insertions(+), 20 deletions(-) diff --git a/window_scene/session/host/include/scene_session.h b/window_scene/session/host/include/scene_session.h index f0f5d2c7e8..5d3d4a142b 100644 --- a/window_scene/session/host/include/scene_session.h +++ b/window_scene/session/host/include/scene_session.h @@ -523,6 +523,8 @@ public: bool IsDecorEnable() const; bool IsAppSession() const; bool IsAppOrLowerSystemSession() const; + virtual bool IsBlockingFocusFullScreenSystemPanel() const; + virtual bool IsAppMainWindowFullScreen(); bool IsSystemSessionAboveApp() const; bool IsTurnScreenOn() const; bool IsKeepScreenOn() const; diff --git a/window_scene/session/host/src/scene_session.cpp b/window_scene/session/host/src/scene_session.cpp index 2a037c2232..774d4cdbb5 100644 --- a/window_scene/session/host/src/scene_session.cpp +++ b/window_scene/session/host/src/scene_session.cpp @@ -4970,6 +4970,49 @@ bool SceneSession::IsAppOrLowerSystemSession() const return IsAppSession(); } +/** @note @window.focus */ +bool SceneSession::IsBlockingFocusFullScreenSystemPanel() const +{ + bool blockingFocus = GetBlockingFocus(); + if (!blockingFocus) { + TLOGD(WmsLogTag::WMS_FOCUS, "not blocking focus window"); + return false; + } + if (!(systemConfig_.IsPhoneWindow() || systemConfig_.IsPadWindow())) { + TLOGD(WmsLogTag::WMS_FOCUS, "device type unmatched"); + return false; + } + WindowType windowType = GetWindowType(); + //Get height and width of current screen + uint64_t displayId = GetSessionProperty()->GetDisplayId(); + auto display = DisplayManager::GetInstance().GetDisplayById(displayId); + if (display == nullptr) { + TLOGE(WmsLogTag::WMS_FOCUS, "get display object failed of display: %{public}" PRIu64, displayId); + return false; + } + auto displayInfo = display->GetDisplayInfo(); + if (displayInfo == nullptr) { + TLOGE(WmsLogTag::WMS_FOCUS, "get display info failed of display: %{public}" PRIu64, displayId); + return false; + } + if ((windowType == WindowType::WINDOW_TYPE_PANEL || windowType == WindowType::WINDOW_TYPE_GLOBAL_SEARCH || + windowType == WindowType::WINDOW_TYPE_NEGATIVE_SCREEN) && + (GetSessionRect().height_ == displayInfo->GetHeight() && GetSessionRect().width_ == displayInfo->GetWidth())) { + return true; + } + TLOGD(WmsLogTag::WMS_FOCUS, "current session is not full-screen, " + "screen w: %{public}d, h: %{public}d, window w: %{public}d, h: %{public}d", + displayInfo->GetWidth(), displayInfo->GetHeight(), GetSessionRect().width_, GetSessionRect().height_); + return false; +} + +/** @note @window.focus */ +bool SceneSession::IsAppMainWindowFullScreen() +{ + auto mainSession = GetMainSession(); + return mainSession == nullptr ? false : (mainSession->GetWindowMode() == WindowMode::WINDOW_MODE_FULLSCREEN); +} + /** @note @window.focus */ bool SceneSession::IsSystemSessionAboveApp() const { diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index 5a2f962d74..f101b8f8c5 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -7635,11 +7635,10 @@ bool SceneSessionManager::CheckRequestFocusSubWindowImmediately(const sptr& focusedSession, const sptr& sceneSession, FocusChangeReason reason) { - if (focusedSession->GetWindowType() != WindowType::WINDOW_TYPE_GLOBAL_SEARCH && - focusedSession->GetWindowType() != WindowType::WINDOW_TYPE_NEGATIVE_SCREEN) { + if (reason != FocusChangeReason::CLICK) { return false; } - if (reason != FocusChangeReason::CLICK || !focusedSession->GetBlockingFocus()) { + if (!focusedSession->IsBlockingFocusFullScreenSystemPanel() && !focusedSession->IsAppMainWindowFullScreen()) { return false; } return sceneSession->GetZOrder() < focusedSession->GetZOrder(); diff --git a/window_scene/test/mock/mock_scene_session.h b/window_scene/test/mock/mock_scene_session.h index b9654b6282..7e99455cfb 100644 --- a/window_scene/test/mock/mock_scene_session.h +++ b/window_scene/test/mock/mock_scene_session.h @@ -30,6 +30,8 @@ public: MOCK_METHOD(void, UpdateCrossAxisOfLayout, (const WSRect& rect), (override)); MOCK_METHOD(void, UpdateCrossAxis, (), (override)); MOCK_METHOD(WSError, UpdateGlobalDisplayRect, (const WSRect& rect, SizeChangeReason reason), (override)); + MOCK_CONST_METHOD0(IsBlockingFocusFullScreenSystemPanel, bool()); + MOCK_METHOD(bool, IsAppMainWindowFullScreen, (), (override)); }; } } diff --git a/window_scene/test/unittest/scene_session_manager_test9.cpp b/window_scene/test/unittest/scene_session_manager_test9.cpp index d2cc830d8f..943eb9c8ab 100644 --- a/window_scene/test/unittest/scene_session_manager_test9.cpp +++ b/window_scene/test/unittest/scene_session_manager_test9.cpp @@ -21,6 +21,7 @@ #include "session_manager/include/scene_session_manager.h" #include "session_info.h" #include "session/host/include/scene_session.h" +#include "mock/mock_scene_session.h" #include "session_manager.h" using namespace testing; @@ -1270,32 +1271,98 @@ HWTEST_F(SceneSessionManagerTest9, GetSessionRSVisible, TestSize.Level1) } /** - * @tc.name: CheckClickFocusIsDownThroughFullScreen - * @tc.desc: CheckClickFocusIsDownThroughFullScreen + * @tc.name: CheckClickFocusIsDownThroughFullScreen_FocusChangeReason + * @tc.desc: Test return value with click-reason and other reasons * @tc.type: FUNC */ -HWTEST_F(SceneSessionManagerTest9, CheckClickFocusIsDownThroughFullScreen, TestSize.Level1) +HWTEST_F(SceneSessionManagerTest9, CheckClickFocusIsDownThroughFullScreen_FocusChangeReason, TestSize.Level1) { ASSERT_NE(ssm_, nullptr); SessionInfo info; - info.abilityName_ = "test1"; - info.bundleName_ = "test2"; + info.abilityName_ = "CheckClickFocusIsDownThroughFullScreen_FocusChangeReason"; + info.bundleName_ = "CheckClickFocusIsDownThroughFullScreen_FocusChangeReason"; + + sptr sceneSession = sptr::MakeSptr(info, nullptr); + sceneSession->zOrder_ = 1; + + sptr focusedSession = sptr::MakeSptr(info, nullptr); + focusedSession->zOrder_ = 2; + EXPECT_CAll(*focusedSession, IsBlockingFocusFullScreenSystemPanel()).WillRepeatedly(Return(true)); - sptr focusedSession = sptr::MakeSptr(info, nullptr); - ASSERT_NE(focusedSession, nullptr); - sptr sceneSession = sptr::MakeSptr(info, nullptr); - ASSERT_NE(sceneSession, nullptr); bool ret = ssm_->CheckClickFocusIsDownThroughFullScreen(focusedSession, sceneSession, FocusChangeReason::DEFAULT); - ASSERT_EQ(ret, false); + EXPECT_EQ(ret, false); - focusedSession->property_->SetWindowType(WindowType::WINDOW_TYPE_GLOBAL_SEARCH); - ret = ssm_->CheckClickFocusIsDownThroughFullScreen(focusedSession, sceneSession, FocusChangeReason::DEFAULT); - ASSERT_EQ(ret, false); - sceneSession->SetZOrder(50); - focusedSession->SetZOrder(100); - focusedSession->blockingFocus_ = true; ret = ssm_->CheckClickFocusIsDownThroughFullScreen(focusedSession, sceneSession, FocusChangeReason::CLICK); - ASSERT_EQ(ret, true); + EXPECT_EQ(ret, true); +} + +/** + * @tc.name: CheckClickFocusIsDownThroughFullScreen_FullScreenCheck + * @tc.desc: Test return value with full-screen window and non-full-screen window + * @tc.type: FUNC + */ +HWTEST_F(SceneSessionManagerTest9, CheckClickFocusIsDownThroughFullScreen_FullScreenCheck, TestSize.Level1) +{ + ASSERT_NE(ssm_, nullptr); + SessionInfo info; + info.abilityName_ = "CheckClickFocusIsDownThroughFullScreen_FullScreenCheck"; + info.bundleName_ = "CheckClickFocusIsDownThroughFullScreen_FullScreenCheck"; + + sptr sceneSession = sptr::MakeSptr(info, nullptr); + sceneSession->zOrder_ = 1; + + sptr focusedSession = sptr::MakeSptr(info, nullptr); + focusedSession->zOrder_ = 2; + + FocusChangeReason focusChangeReason = FocusChangeReason::CLICK; + + EXPECT_CALL(*focusedSession, IsBlockingFocusFullScreenSystemPanel()).WillRepeatedly(Return(false)); + EXPECT_CALL(*focusedSession, IsAppMainWindowFullScreen()).WillRepeatedly(Return(false)); + bool ret = ssm_->CheckClickFocusIsDownThroughFullScreen(focusedSession, sceneSession, reason); + EXPECT_EQ(ret, false); + + EXPECT_CALL(*focusedSession, IsBlockingFocusFullScreenSystemPanel()).WillRepeatedly(Return(true)); + ret = ssm_->CheckClickFocusIsDownThroughFullScreen(focusedSession, sceneSession, reason); + EXPECT_EQ(ret, true); + + EXPECT_CALL(*focusedSession, IsBlockingFocusFullScreenSystemPanel()).WillRepeatedly(Return(false)); + EXPECT_CALL(*focusedSession, IsAppMainWindowFullScreen()).WillRepeatedly(Return(true)); + ret = ssm_->CheckClickFocusIsDownThroughFullScreen(focusedSession, sceneSession, reason); + EXPECT_EQ(ret, true); +} + +/** + * @tc.name: CheckClickFocusIsDownThroughFullScreen_ZOrderCheck + * @tc.desc: Test return value with window-pairs of different zorder-relationships + * @tc.type: FUNC + */ +HWTEST_F(SceneSessionManagerTest9, CheckClickFocusIsDownThroughFullScreen_ZOrderCheck, TestSize.Level1) +{ + ASSERT_NE(ssm_, nullptr); + SessionInfo info; + info.abilityName_ = "CheckClickFocusIsDownThroughFullScreen_ZOrderCheck"; + info.bundleName_ = "CheckClickFocusIsDownThroughFullScreen_ZOrderCheck"; + + sptr sceneSession = sptr::MakeSptr(info, nullptr); + sptr focusedSession = sptr::MakeSptr(info, nullptr); + EXPECT_CALL(*focusedSession, IsBlockingFocusFullScreenSystemPanel()).WillRepeatedly(Return(false)); + EXPECT_CALL(*focusedSession, IsAppMainWindowFullScreen()).WillRepeatedly(Return(false)); + + FocusChangeReason reason = FocusChangeReason::CLICK; + + focusedSession->zOrder_ = 0; + sceneSession->zOrder_ = 1; + + bool ret = ssm_->CheckClickFocusIsDownThroughFullScreen(focusedSession, sceneSession, reason); + EXPECT_EQ(ret, false); + + focusedSession->zOrder_ = 1; + ret = ssm_->CheckClickFocusIsDownThroughFullScreen(focusedSession, sceneSession, reason); + EXPECT_EQ(ret, false); + + focusedSession->zOrder_ = 2; + ret = ssm_->CheckClickFocusIsDownThroughFullScreen(focusedSession, sceneSession, reason); + EXPECT_EQ(ret, true); } /** diff --git a/window_scene/test/unittest/window_focus/window_focus_scene_session_test.cpp b/window_scene/test/unittest/window_focus/window_focus_scene_session_test.cpp index 22ef170514..d83ab2ab03 100644 --- a/window_scene/test/unittest/window_focus/window_focus_scene_session_test.cpp +++ b/window_scene/test/unittest/window_focus/window_focus_scene_session_test.cpp @@ -143,6 +143,82 @@ HWTEST_F(WindowFocusSceneSessionTest, IsAppOrLowerSystemSession02, TestSize.Leve ASSERT_EQ(true, sceneSession->IsAppOrLowerSystemSession()); } +/** + * @tc.name: IsBlockingFocusFullScreenSystemPanel_SessionConfig + * @tc.desc: Check if the session blockingFocus and device type is qualified + * @tc.type: FUNC + */ +HWTEST_F(WindowFocusSceneSessionTest, IsBlockingFocusFullScreenSystemPanel_SessionConfig, TestSize.Level1) +{ + SessionInfo info; + info.abilityName_ = "IsBlockingFocusFullScreenSystemPanel_SessionConfig"; + info.bundleName_ = "IsBlockingFocusFullScreenSystemPanel_SessionConfig"; + sptr sceneSession = sptr::MakeSptr(info, nullptr); + + sceneSession->blockingFocus_ = false; + EXPECT_EQ(false, sceneSession->IsBlockingFocusFullScreenSystemPanel()); + + sceneSession->blockingFocus_ = true; + sceneSession->systemConfig_.windowUIType_ = WindowUIType::PC_WINDOW; + EXPECT_EQ(false, sceneSession->IsBlockingFocusFullScreenSystemPanel()); +} + +/** + * @tc.name: IsBlockingFocusFullScreenSystemPanel_RectCheck + * @tc.desc: Check if the height and width of the current session is full-screen + * @tc.type: FUNC + */ +HWTEST_F(WindowFocusSceneSessionTest, IsBlockingFocusFullScreenSystemPanel_RectCheck, TestSize.Level1) +{ + SessionInfo info; + info.abilityName_ = "IsBlockingFocusFullScreenSystemPanel_RectCheck"; + info.bundleName_ = "IsBlockingFocusFullScreenSystemPanel_RectCheck"; + sptr sceneSession = sptr::MakeSptr(info, nullptr); + + sceneSession->blockingFocus_ = true; + sceneSession->systemConfig_.windowUIType_ = WindowUIType::PHONE_WINDOW; + constexpr DisplayId DISPLAY_ID = 0; + sceneSession->GetSessionProperty()->SetDisplayId(DISPLAY_ID); + + const WSRect rect = {0, 0, 0, 0}; + sceneSession->SetSessionRect(rect); + sceneSession->property_->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW); + EXPECT_EQ(false, sceneSession->IsBlockingFocusFullScreenSystemPanel()); + + sceneSession->property_->SetWindowType(WindowType::WINDOW_TYPE_PANEL); + EXPECT_EQ(false, sceneSession->IsBlockingFocusFullScreenSystemPanel()); +} + +/** + * @tc.name: IsAppMainWindowFullScreen + * @tc.desc: Check if main session of the current session is full-screen + * @tc.type: FUNC + */ +HWTEST_F(WindowFocusSceneSessionTest, IsAppMainWindowFullScreen, TestSize.Level1) +{ + SessionInfo subSessionInfo; + subSessionInfo.abilityName_ = "IsAppMainWindowFullScreen_SubSession"; + subSessionInfo.bundleName_ = "IsAppMainWindowFullScreen_SubSession"; + sptr subSession = sptr::MakeSptr(subSessionInfo, nullptr); + + subSession->property_->SetWindowType(WindowType::WINDOW_TYPE_APP_SUB_WINDOW); + subSession->SetParentSession(nullptr); + EXPECT_EQ(false, subSession->IsAppMainWindowFullScreen()); + + SessionInfo mainSessionInfo; + mainSessionInfo.abilityName_ = "IsAppMainWindowFullScreen_MainSession"; + mainSessionInfo.bundleName_ = "IsAppMainWindowFullScreen_MainSession"; + sptr mainSession = sptr::MakeSptr(mainSessionInfo, nullptr); + + mainSession->property_->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW); + mainSession->property_->SetWindowMode(WindowMode::WINDOW_MODE_FLOATING); + subSession->SetParentSession(mainSession); + EXPECT_EQ(false, subSession->IsAppMainWindowFullScreen()); + + mainSession->property_->SetWindowMode(WindowMode::WINDOW_MODE_FULLSCREEN); + EXPECT_EQ(false, subSession->IsAppMainWindowFullScreen()); +} + /** * @tc.name: IsSystemSessionAboveApp * @tc.desc: IsSystemSessionAboveApp true -- Gitee From 51e7fa8350cc03f7f3637b765b3e776e9e970297 Mon Sep 17 00:00:00 2001 From: LHHHYYY Date: Thu, 4 Sep 2025 16:00:28 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E3=80=90=E6=A3=80=E8=A7=86=E6=84=8F?= =?UTF-8?q?=E8=A7=81=E4=BF=AE=E6=94=B91=E3=80=91=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E5=A4=B4=E6=96=87=E4=BB=B6=E9=A1=BA=E5=BA=8F=EF=BC=8C=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D=E5=BA=94=E7=94=A8=E7=AA=97=E5=8F=A3=E6=9C=AA=E4=BD=BF?= =?UTF-8?q?=E7=94=A8=E4=B8=BB=E7=AA=97=E6=AF=94=E8=BE=83=E5=B1=82=E7=BA=A7?= =?UTF-8?q?=E5=85=B3=E7=B3=BB=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: LHHHYYY --- .../session_manager/src/scene_session_manager.cpp | 9 ++++++--- .../test/unittest/scene_session_manager_test9.cpp | 8 +++++--- 2 files changed, 11 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 f101b8f8c5..a987e693b3 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -7638,10 +7638,13 @@ bool SceneSessionManager::CheckClickFocusIsDownThroughFullScreen(const sptrIsBlockingFocusFullScreenSystemPanel() && !focusedSession->IsAppMainWindowFullScreen()) { - return false; + if (focusedSession->IsBlockingFocusFullScreenSystemPanel()) { + return sceneSession->GetZOrder() < focusedSession->GetZOrder(); + } + if (focusedSession->IsAppMainWindowFullScreen()) { + return sceneSession->GetZOrder() < focusedSession->GetMainSession()->GetZOrder(); } - return sceneSession->GetZOrder() < focusedSession->GetZOrder(); + return false; } WSError SceneSessionManager::RequestFocusSpecificCheck(DisplayId displayId, const sptr& sceneSession, diff --git a/window_scene/test/unittest/scene_session_manager_test9.cpp b/window_scene/test/unittest/scene_session_manager_test9.cpp index 943eb9c8ab..6a391dff96 100644 --- a/window_scene/test/unittest/scene_session_manager_test9.cpp +++ b/window_scene/test/unittest/scene_session_manager_test9.cpp @@ -18,11 +18,11 @@ #include "common/include/session_permission.h" #include "interfaces/include/ws_common.h" #include "iremote_object_mocker.h" -#include "session_manager/include/scene_session_manager.h" -#include "session_info.h" -#include "session/host/include/scene_session.h" #include "mock/mock_scene_session.h" +#include "session/host/include/scene_session.h" +#include "session_info.h" #include "session_manager.h" +#include "session_manager/include/scene_session_manager.h" using namespace testing; using namespace testing::ext; @@ -1312,6 +1312,7 @@ HWTEST_F(SceneSessionManagerTest9, CheckClickFocusIsDownThroughFullScreen_FullSc sceneSession->zOrder_ = 1; sptr focusedSession = sptr::MakeSptr(info, nullptr); + focusedSession->property_->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW); focusedSession->zOrder_ = 2; FocusChangeReason focusChangeReason = FocusChangeReason::CLICK; @@ -1345,6 +1346,7 @@ HWTEST_F(SceneSessionManagerTest9, CheckClickFocusIsDownThroughFullScreen_ZOrder sptr sceneSession = sptr::MakeSptr(info, nullptr); sptr focusedSession = sptr::MakeSptr(info, nullptr); + focusedSession->property_->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW); EXPECT_CALL(*focusedSession, IsBlockingFocusFullScreenSystemPanel()).WillRepeatedly(Return(false)); EXPECT_CALL(*focusedSession, IsAppMainWindowFullScreen()).WillRepeatedly(Return(false)); -- Gitee From 736912bd01e6659616575ddf3cc2f3a7b27da44c Mon Sep 17 00:00:00 2001 From: LHHHYYY Date: Thu, 4 Sep 2025 16:06:37 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E3=80=90=E6=A3=80=E8=A7=86=E6=84=8F?= =?UTF-8?q?=E8=A7=81=E4=BF=AE=E6=94=B92=E3=80=91=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E5=BD=92=E7=B1=BB=E5=88=B0=E7=84=A6=E7=82=B9?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E4=B8=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: LHHHYYY --- window_scene/session/host/include/scene_session.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/window_scene/session/host/include/scene_session.h b/window_scene/session/host/include/scene_session.h index 5d3d4a142b..fb60840d3b 100644 --- a/window_scene/session/host/include/scene_session.h +++ b/window_scene/session/host/include/scene_session.h @@ -523,8 +523,6 @@ public: bool IsDecorEnable() const; bool IsAppSession() const; bool IsAppOrLowerSystemSession() const; - virtual bool IsBlockingFocusFullScreenSystemPanel() const; - virtual bool IsAppMainWindowFullScreen(); bool IsSystemSessionAboveApp() const; bool IsTurnScreenOn() const; bool IsKeepScreenOn() const; @@ -840,6 +838,8 @@ public: void SetFollowParentRectFunc(NotifyFollowParentRectFunc&& func); WSError SetFollowParentWindowLayoutEnabled(bool isFollow) override; bool IsDelayFocusChange(); + virtual bool IsBlockingFocusFullScreenSystemPanel() const; + virtual bool IsAppMainWindowFullScreen(); /* * Window Property -- Gitee