mirror of
https://gitee.com/openharmony/window_window_manager
synced 2024-11-23 06:50:40 +00:00
fix comments
Signed-off-by: 白钰胜 <baiyusheng@h-partners.com>
This commit is contained in:
parent
a3d93c7822
commit
a58a1767fd
@ -727,15 +727,15 @@ HWTEST_F(WindowLayoutTest, ResizeDataRoute, Function | MediumTest | Level3)
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: FixRectByAspectRatio
|
||||
* @tc.desc: test FixRectByAspectRatio
|
||||
* @tc.name: AdjustRectByAspectRatio
|
||||
* @tc.desc: test AdjustRectByAspectRatio
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(WindowLayoutTest, FixRectByAspectRatio, Function | MediumTest | Level0)
|
||||
HWTEST_F(WindowLayoutTest, AdjustRectByAspectRatio, Function | MediumTest | Level0)
|
||||
{
|
||||
TLOGI(WmsLogTag::WMS_LAYOUT, "### WindowLayoutTest::FixRectByAspectRatio begin ###");
|
||||
TLOGI(WmsLogTag::WMS_LAYOUT, "### WindowLayoutTest::AdjustRectByAspectRatio begin ###");
|
||||
sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
|
||||
option->SetWindowName("FixRectByAspectRatio");
|
||||
option->SetWindowName("AdjustRectByAspectRatio");
|
||||
option->SetWindowType(WindowType::APP_WINDOW_BASE);
|
||||
option->SetWindowMode(WindowMode::WINDOW_MODE_FLOATING);
|
||||
sptr<WindowSceneSessionImpl> windowSceneSessionImpl = sptr<WindowSceneSessionImpl>::MakeSptr(option);
|
||||
@ -775,12 +775,12 @@ HWTEST_F(WindowLayoutTest, FixRectByAspectRatio, Function | MediumTest | Level0)
|
||||
WSError wsRet2 = session->UpdateSessionRect(wsRect, SizeChangeReason::RESIZE, false);
|
||||
EXPECT_EQ(WSError::WS_OK, wsRet2);
|
||||
usleep(WAIT_SERVERAL_FRAMES);
|
||||
WSError wsRet3 = session->UpdateRect(wsRect, SizeChangeReason::RESIZE, "FixRectByAspectRatio", nullptr);
|
||||
WSError wsRet3 = session->UpdateRect(wsRect, SizeChangeReason::RESIZE, "AdjustRectByAspectRatio", nullptr);
|
||||
EXPECT_EQ(WSError::WS_OK, wsRet3);
|
||||
usleep(WAIT_SERVERAL_FRAMES);
|
||||
WSError wsRet4 = session->SetAspectRatio(ratio);
|
||||
EXPECT_EQ(WSError::WS_OK, wsRet4);
|
||||
TLOGI(WmsLogTag::WMS_LAYOUT, "### WindowLayoutTest::FixRectByAspectRatio end ###");
|
||||
TLOGI(WmsLogTag::WMS_LAYOUT, "### WindowLayoutTest::AdjustRectByAspectRatio end ###");
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -532,7 +532,7 @@ public:
|
||||
bool IsDirtyWindow();
|
||||
bool IsDirtyDragWindow();
|
||||
void ResetSizeChangeReasonIfDirty();
|
||||
void SetRequestNextVsyncFunc(const RequestVsyncFunc&& func);
|
||||
void SetRequestNextVsyncFunc(RequestVsyncFunc&& func);
|
||||
void OnNextVsyncReceivedWhenDrag();
|
||||
void RegisterLayoutFullScreenChangeCallback(NotifyLayoutFullScreenChangeFunc&& callback);
|
||||
bool SetFrameGravity(Gravity gravity);
|
||||
@ -792,8 +792,8 @@ private:
|
||||
/**
|
||||
* Window Layout
|
||||
*/
|
||||
void FixRectByLimits(WindowLimits limits, WSRect& rect, float ratio, bool isDecor, float vpr);
|
||||
bool FixRectByAspectRatio(WSRect& rect);
|
||||
void AdjustRectByLimits(WindowLimits limits, float ratio, bool isDecor, float vpr, WSRect& rect);
|
||||
bool AdjustRectByAspectRatio(WSRect& rect);
|
||||
bool SaveAspectRatio(float ratio);
|
||||
void UpdateSessionRectInner(const WSRect& rect, SizeChangeReason reason);
|
||||
WSError UpdateRectForDrag(const WSRect& rect);
|
||||
|
@ -671,10 +671,10 @@ protected:
|
||||
*/
|
||||
RequestVsyncFunc requestNextVsyncFunc_;
|
||||
WSRect winRect_;
|
||||
WSRect clientRect_; // rect saved when prelayout or notify client to update rect
|
||||
WSRect clientRect_; // rect saved when prelayout or notify client to update rect
|
||||
WSRect lastLayoutRect_; // rect saved when go background
|
||||
WSRect layoutRect_; // rect of root view
|
||||
WSRect globalRect_; // globalRect include translate
|
||||
WSRect layoutRect_; // rect of root view
|
||||
WSRect globalRect_; // globalRect include translate
|
||||
SizeChangeReason reason_ = SizeChangeReason::UNDEFINED;
|
||||
NotifySessionRectChangeFunc sessionRectChangeFunc_;
|
||||
float clientScaleX_ = 1.0f;
|
||||
|
@ -338,7 +338,7 @@ WSError SceneSession::Foreground(
|
||||
return ForegroundTask(property);
|
||||
}
|
||||
|
||||
void SceneSession::SetRequestNextVsyncFunc(const RequestVsyncFunc&& func)
|
||||
void SceneSession::SetRequestNextVsyncFunc(RequestVsyncFunc&& func)
|
||||
{
|
||||
if (func == nullptr) {
|
||||
TLOGI(WmsLogTag::DEFAULT, "func is nullptr");
|
||||
@ -964,7 +964,7 @@ static WSError CheckAspectRatioValid(const sptr<SceneSession>& session, float ra
|
||||
/** @note @window.layout */
|
||||
WSError SceneSession::SetAspectRatio(float ratio)
|
||||
{
|
||||
auto task = [weakThis = wptr(this), ratio]() {
|
||||
auto task = [weakThis = wptr(this), ratio] {
|
||||
auto session = weakThis.promote();
|
||||
if (!session) {
|
||||
TLOGE(WmsLogTag::WMS_LAYOUT, "session is null");
|
||||
@ -989,13 +989,13 @@ WSError SceneSession::SetAspectRatio(float ratio)
|
||||
session->moveDragController_->SetAspectRatio(ratio);
|
||||
}
|
||||
session->SaveAspectRatio(session->aspectRatio_);
|
||||
WSRect fixedRect = session->winRect_;
|
||||
TLOGI(WmsLogTag::WMS_LAYOUT, "Before fixing, the id:%{public}d, the current rect: %{public}s, "
|
||||
"ratio: %{public}f", session->GetPersistentId(), fixedRect.ToString().c_str(), ratio);
|
||||
if (session->FixRectByAspectRatio(fixedRect)) {
|
||||
TLOGI(WmsLogTag::WMS_LAYOUT, "After fixing, the id:%{public}d, the fixed rect: %{public}s",
|
||||
session->GetPersistentId(), fixedRect.ToString().c_str());
|
||||
session->NotifySessionRectChange(fixedRect, SizeChangeReason::RESIZE);
|
||||
WSRect adjustedRect = session->winRect_;
|
||||
TLOGI(WmsLogTag::WMS_LAYOUT, "Before adjusting, the id:%{public}d, the current rect: %{public}s, "
|
||||
"ratio: %{public}f", session->GetPersistentId(), adjustedRect.ToString().c_str(), ratio);
|
||||
if (session->AdjustRectByAspectRatio(adjustedRect)) {
|
||||
TLOGI(WmsLogTag::WMS_LAYOUT, "After adjusting, the id:%{public}d, the adjusted rect: %{public}s",
|
||||
session->GetPersistentId(), adjustedRect.ToString().c_str());
|
||||
session->NotifySessionRectChange(adjustedRect, SizeChangeReason::RESIZE);
|
||||
}
|
||||
return WSError::WS_OK;
|
||||
};
|
||||
@ -1007,7 +1007,7 @@ WSError SceneSession::UpdateRect(const WSRect& rect, SizeChangeReason reason,
|
||||
const std::string& updateReason, const std::shared_ptr<RSTransaction>& rsTransaction)
|
||||
{
|
||||
const char* const funcName = __func__;
|
||||
auto task = [weakThis = wptr(this), rect, reason, rsTransaction, updateReason, funcName]() {
|
||||
auto task = [weakThis = wptr(this), rect, reason, rsTransaction, updateReason, funcName] {
|
||||
auto session = weakThis.promote();
|
||||
if (!session) {
|
||||
TLOGNE(WmsLogTag::WMS_LAYOUT, "%{public}s: session is null", funcName);
|
||||
@ -2466,7 +2466,7 @@ bool SceneSession::SaveAspectRatio(float ratio)
|
||||
return false;
|
||||
}
|
||||
|
||||
void SceneSession::FixRectByLimits(WindowLimits limits, WSRect& rect, float ratio, bool isDecor, float vpr)
|
||||
void SceneSession::AdjustRectByLimits(WindowLimits limits, float ratio, bool isDecor, float vpr, WSRect& rect)
|
||||
{
|
||||
if (isDecor) {
|
||||
rect.width_ = SessionUtils::ToLayoutWidth(rect.width_, vpr);
|
||||
@ -2494,7 +2494,7 @@ void SceneSession::FixRectByLimits(WindowLimits limits, WSRect& rect, float rati
|
||||
rect.width_ = SessionUtils::ToWinWidth(rect.width_, vpr);
|
||||
}
|
||||
}
|
||||
bool SceneSession::FixRectByAspectRatio(WSRect& rect)
|
||||
bool SceneSession::AdjustRectByAspectRatio(WSRect& rect)
|
||||
{
|
||||
const int tolerancePx = 2; // 2: tolerance delta pixel value, unit: px
|
||||
WSRect originalRect = rect;
|
||||
@ -2536,7 +2536,7 @@ bool SceneSession::FixRectByAspectRatio(WSRect& rect)
|
||||
rect.height_ = rect.width_ / aspectRatio_;
|
||||
}
|
||||
}
|
||||
FixRectByLimits(property->GetWindowLimits(), rect, aspectRatio_, IsDecorEnable(), vpr);
|
||||
AdjustRectByLimits(property->GetWindowLimits(), aspectRatio_, IsDecorEnable(), vpr, rect);
|
||||
if (std::abs(static_cast<int32_t>(originalRect.width_) - static_cast<int32_t>(rect.width_)) <= tolerancePx &&
|
||||
std::abs(static_cast<int32_t>(originalRect.height_) - static_cast<int32_t>(rect.height_)) <= tolerancePx) {
|
||||
rect = originalRect;
|
||||
|
@ -886,11 +886,11 @@ HWTEST_F(SceneSessionTest, NotifySessionRectChange, Function | SmallTest | Level
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: FixRectByAspectRatio
|
||||
* @tc.desc: FixRectByAspectRatio
|
||||
* @tc.name: AdjustRectByAspectRatio
|
||||
* @tc.desc: AdjustRectByAspectRatio
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(SceneSessionTest, FixRectByAspectRatio, Function | SmallTest | Level2)
|
||||
HWTEST_F(SceneSessionTest, AdjustRectByAspectRatio, Function | SmallTest | Level2)
|
||||
{
|
||||
SessionInfo info;
|
||||
info.abilityName_ = "Background01";
|
||||
@ -904,7 +904,7 @@ HWTEST_F(SceneSessionTest, FixRectByAspectRatio, Function | SmallTest | Level2)
|
||||
sceneSession = new (std::nothrow) SceneSession(info, nullptr);
|
||||
EXPECT_NE(sceneSession, nullptr);
|
||||
WSRect originalRect_ = { 0, 0, 0, 0 };
|
||||
ASSERT_EQ(false, sceneSession->FixRectByAspectRatio(originalRect_));
|
||||
ASSERT_EQ(false, sceneSession->AdjustRectByAspectRatio(originalRect_));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1648,7 +1648,7 @@ HWTEST_F(SceneSessionTest2, TransferPointerEvent03, Function | SmallTest | Level
|
||||
float ratio = 0.0;
|
||||
bool isDecor = true;
|
||||
float vpr = 0.0;
|
||||
sceneSession->FixRectByLimits(limits, rect, ratio, isDecor, vpr);
|
||||
sceneSession->AdjustRectByLimits(limits, ratio, isDecor, vpr, rect);
|
||||
sceneSession->SetPipActionEvent("pointerEvent", 0);
|
||||
|
||||
auto property = sptr<WindowSessionProperty>::MakeSptr();
|
||||
@ -1660,7 +1660,7 @@ HWTEST_F(SceneSessionTest2, TransferPointerEvent03, Function | SmallTest | Level
|
||||
sceneSession->sessionStage_ = sptr<SessionStageMocker>::MakeSptr();
|
||||
property->SetWindowType(WindowType::WINDOW_TYPE_PIP);
|
||||
property->SetWindowMode(WindowMode::WINDOW_MODE_PIP);
|
||||
sceneSession->FixRectByLimits(limits, rect, ratio, false, vpr);
|
||||
sceneSession->AdjustRectByLimits(limits, ratio, false, vpr, rect);
|
||||
ASSERT_EQ(WSError::WS_OK, sceneSession->SetPipActionEvent("pointerEvent", 0));
|
||||
}
|
||||
|
||||
|
@ -742,42 +742,42 @@ HWTEST_F(SceneSessionTest5, GetSystemAvoidArea02, Function | SmallTest | Level2)
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: FixRectByAspectRatio
|
||||
* @tc.desc: FixRectByAspectRatio function01
|
||||
* @tc.name: AdjustRectByAspectRatio
|
||||
* @tc.desc: AdjustRectByAspectRatio function01
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(SceneSessionTest5, FixRectByAspectRatio, Function | SmallTest | Level2)
|
||||
HWTEST_F(SceneSessionTest5, AdjustRectByAspectRatio, Function | SmallTest | Level2)
|
||||
{
|
||||
SessionInfo info;
|
||||
info.abilityName_ = "FixRectByAspectRatio";
|
||||
info.bundleName_ = "FixRectByAspectRatio";
|
||||
info.abilityName_ = "AdjustRectByAspectRatio";
|
||||
info.bundleName_ = "AdjustRectByAspectRatio";
|
||||
info.isSystem_ = false;
|
||||
sptr<SceneSession> session = sptr<SceneSession>::MakeSptr(info, nullptr);
|
||||
EXPECT_NE(session, nullptr);
|
||||
sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
|
||||
session->SetSessionProperty(nullptr);
|
||||
WSRect rect;
|
||||
EXPECT_EQ(false, session->FixRectByAspectRatio(rect));
|
||||
EXPECT_EQ(false, session->AdjustRectByAspectRatio(rect));
|
||||
session->SetSessionProperty(property);
|
||||
property->SetWindowMode(WindowMode::WINDOW_MODE_UNDEFINED);
|
||||
EXPECT_EQ(false, session->FixRectByAspectRatio(rect));
|
||||
EXPECT_EQ(false, session->AdjustRectByAspectRatio(rect));
|
||||
property->SetWindowMode(WindowMode::WINDOW_MODE_FLOATING);
|
||||
property->SetWindowType(WindowType::APP_MAIN_WINDOW_END);
|
||||
EXPECT_EQ(false, session->FixRectByAspectRatio(rect));
|
||||
EXPECT_EQ(false, session->AdjustRectByAspectRatio(rect));
|
||||
property->SetWindowType(WindowType::APP_MAIN_WINDOW_BASE);
|
||||
EXPECT_EQ(true, session->FixRectByAspectRatio(rect));
|
||||
EXPECT_EQ(true, session->AdjustRectByAspectRatio(rect));
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: FixRectByAspectRatio01
|
||||
* @tc.desc: FixRectByAspectRatio function01
|
||||
* @tc.name: AdjustRectByAspectRatio01
|
||||
* @tc.desc: AdjustRectByAspectRatio function01
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(SceneSessionTest5, FixRectByAspectRatio01, Function | SmallTest | Level2)
|
||||
HWTEST_F(SceneSessionTest5, AdjustRectByAspectRatio01, Function | SmallTest | Level2)
|
||||
{
|
||||
SessionInfo info;
|
||||
info.abilityName_ = "FixRectByAspectRatio01";
|
||||
info.bundleName_ = "FixRectByAspectRatio01";
|
||||
info.abilityName_ = "AdjustRectByAspectRatio01";
|
||||
info.bundleName_ = "AdjustRectByAspectRatio01";
|
||||
info.isSystem_ = false;
|
||||
sptr<SceneSession> session = sptr<SceneSession>::MakeSptr(info, nullptr);
|
||||
EXPECT_NE(session, nullptr);
|
||||
@ -791,14 +791,14 @@ HWTEST_F(SceneSessionTest5, FixRectByAspectRatio01, Function | SmallTest | Level
|
||||
systemConfig.isSystemDecorEnable_ = true;
|
||||
systemConfig.decorWindowModeSupportType_ = 2;
|
||||
session->SetSystemConfig(systemConfig);
|
||||
EXPECT_EQ(true, session->FixRectByAspectRatio(rect));
|
||||
EXPECT_EQ(true, session->AdjustRectByAspectRatio(rect));
|
||||
|
||||
systemConfig.isSystemDecorEnable_ = false;
|
||||
EXPECT_EQ(false, session->FixRectByAspectRatio(rect));
|
||||
EXPECT_EQ(false, session->AdjustRectByAspectRatio(rect));
|
||||
|
||||
systemConfig.isSystemDecorEnable_ = true;
|
||||
session->SetSessionProperty(nullptr);
|
||||
EXPECT_EQ(false, session->FixRectByAspectRatio(rect));
|
||||
EXPECT_EQ(false, session->AdjustRectByAspectRatio(rect));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -813,7 +813,7 @@ HWTEST_F(SceneSessionTest5, OnMoveDragCallback, Function | SmallTest | Level2)
|
||||
info.bundleName_ = "OnMoveDragCallback";
|
||||
info.isSystem_ = false;
|
||||
sptr<SceneSession> session = sptr<SceneSession>::MakeSptr(info, nullptr);
|
||||
session->SetRequestNextVsyncFunc([](const std::shared_ptr<VsyncCallback>& callback){});
|
||||
session->SetRequestNextVsyncFunc([](const std::shared_ptr<VsyncCallback>& callback) {});
|
||||
EXPECT_NE(nullptr, session->requestNextVsyncFunc_);
|
||||
session->moveDragController_ = nullptr;
|
||||
SizeChangeReason reason = { SizeChangeReason::DRAG };
|
||||
|
@ -420,7 +420,7 @@ protected:
|
||||
/**
|
||||
* Window Layout
|
||||
*/
|
||||
std::atomic_bool isDragTaskUpdateDone_ = true;
|
||||
std::atomic_bool isDragTaskPostDone_ = true;
|
||||
void FlushLayoutSize(int32_t width, int32_t height) override;
|
||||
sptr<FutureCallback> layoutCallback_ = nullptr;
|
||||
void UpdateVirtualPixelRatio(const sptr<Display>& display);
|
||||
|
@ -811,7 +811,7 @@ void WindowSessionImpl::UpdateRectForOtherReason(const Rect& wmRect, const Rect&
|
||||
}
|
||||
if (wmReason == WindowSizeChangeReason::DRAG) {
|
||||
window->UpdateRectForOtherReasonTask(window->GetRect(), preRect, wmReason, rsTransaction);
|
||||
window->isDragTaskUpdateDone_.store(true);
|
||||
window->isDragTaskPostDone_.store(true);
|
||||
} else {
|
||||
window->UpdateRectForOtherReasonTask(wmRect, preRect, wmReason, rsTransaction);
|
||||
}
|
||||
@ -820,9 +820,9 @@ void WindowSessionImpl::UpdateRectForOtherReason(const Rect& wmRect, const Rect&
|
||||
}
|
||||
};
|
||||
if (wmReason == WindowSizeChangeReason::DRAG) {
|
||||
if (isDragTaskUpdateDone_.load()) {
|
||||
bool isDragTaskPostDone = true;
|
||||
if (isDragTaskPostDone_.compare_exchange_strong(isDragTaskPostDone, false)) {
|
||||
handler_->PostTask(task, "WMS_WindowSessionImpl_UpdateRectForOtherReason");
|
||||
isDragTaskUpdateDone_.store(false);
|
||||
}
|
||||
} else {
|
||||
handler_->PostTask(task, "WMS_WindowSessionImpl_UpdateRectForOtherReason");
|
||||
|
Loading…
Reference in New Issue
Block a user