mirror of
https://gitee.com/openharmony/window_window_manager
synced 2024-11-27 00:51:35 +00:00
commit
9b3baa7dc2
@ -566,8 +566,8 @@ private:
|
||||
/**
|
||||
* Window Layout
|
||||
*/
|
||||
std::atomic_bool windowSizeChanged_ = false;
|
||||
WSRect layoutRect_;
|
||||
std::atomic_bool windowSizeChanged_ = false;
|
||||
std::atomic_bool enableFrameLayoutFinishCb_ = false;
|
||||
WindowSizeChangeReason lastSizeChangeReason_ = WindowSizeChangeReason::END;
|
||||
bool postTaskDone_ = false;
|
||||
|
@ -683,10 +683,10 @@ WSError WindowSessionImpl::UpdateRect(const WSRect& rect, SizeChangeReason reaso
|
||||
auto wmReason = static_cast<WindowSizeChangeReason>(reason);
|
||||
Rect wmRect = { rect.posX_, rect.posY_, rect.width_, rect.height_ };
|
||||
auto preRect = GetRect();
|
||||
property_->SetWindowRect(wmRect);
|
||||
if (preRect.width_ != wmRect.width_ || preRect.height_ != wmRect.height_) {
|
||||
windowSizeChanged_ = true;
|
||||
}
|
||||
property_->SetWindowRect(wmRect);
|
||||
property_->SetRequestRect(wmRect);
|
||||
|
||||
TLOGI(WmsLogTag::WMS_LAYOUT, "%{public}s, preRect:%{public}s, reason:%{public}u, hasRSTransaction:%{public}d"
|
||||
@ -863,7 +863,10 @@ void WindowSessionImpl::FlushLayoutSize(int32_t width, int32_t height)
|
||||
return;
|
||||
}
|
||||
WSRect rect = { 0, 0, width, height };
|
||||
if (windowSizeChanged_ || layoutRect_ != rect || enableFrameLayoutFinishCb_) {
|
||||
bool windowSizeChanged = true;
|
||||
bool enableFrameLayoutFinishCb = true;
|
||||
if (windowSizeChanged_.compare_exchange_strong(windowSizeChanged, false) ||
|
||||
enableFrameLayoutFinishCb_.compare_exchange_strong(enableFrameLayoutFinishCb, false) || layoutRect_ != rect) {
|
||||
HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER,
|
||||
"NotifyFrameLayoutFinishFromApp, id: %u, rect: %s, notifyListener: %d",
|
||||
GetWindowId(), rect.ToString().c_str(), enableFrameLayoutFinishCb_.load());
|
||||
@ -873,7 +876,6 @@ void WindowSessionImpl::FlushLayoutSize(int32_t width, int32_t height)
|
||||
if (auto session = GetHostSession()) {
|
||||
session->NotifyFrameLayoutFinishFromApp(enableFrameLayoutFinishCb_, rect);
|
||||
}
|
||||
windowSizeChanged_ = false;
|
||||
layoutRect_ = rect;
|
||||
enableFrameLayoutFinishCb_ = false;
|
||||
}
|
||||
|
@ -2187,27 +2187,27 @@ HWTEST_F(WindowSessionImplTest4, FlushLayoutSize, Function | SmallTest | Level2)
|
||||
{
|
||||
#undef private
|
||||
GTEST_LOG_(INFO) << "WindowSessionImplTest4: FlushLayoutSize start";
|
||||
sptr<WindowOption> option_ = sptr<WindowOption>::MakeSptr();
|
||||
option_->SetWindowName("FlushLayoutSize");
|
||||
sptr<WindowSessionImpl> window_ = sptr<WindowSessionImpl>::MakeSptr(option_);
|
||||
window_->property_->SetWindowType(WindowType::APP_SUB_WINDOW_BASE);
|
||||
sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
|
||||
option->SetWindowName("FlushLayoutSize");
|
||||
sptr<WindowSessionImpl> window = sptr<WindowSessionImpl>::MakeSptr(option);
|
||||
window->property_->SetWindowType(WindowType::APP_SUB_WINDOW_BASE);
|
||||
int32_t width = 1320;
|
||||
int32_t height = 2710;
|
||||
WSRect rect = { 0, 0, width, height };
|
||||
window_->FlushLayoutSize(width, height);
|
||||
window->FlushLayoutSize(width, height);
|
||||
|
||||
window_->property_->SetWindowType(WindowType::APP_MAIN_WINDOW_BASE);
|
||||
window_->windowSizeChanged_ = true;
|
||||
window_->FlushLayoutSize(width, height);
|
||||
ASSERT_EQ(window_->windowSizeChanged_, false);
|
||||
window->property_->SetWindowType(WindowType::APP_MAIN_WINDOW_BASE);
|
||||
window->windowSizeChanged_ = true;
|
||||
window->FlushLayoutSize(width, height);
|
||||
ASSERT_EQ(window->windowSizeChanged_, false);
|
||||
|
||||
window_->layoutRect_ = { 0, 0, 2710, 1320 };
|
||||
window_->FlushLayoutSize(width, height);
|
||||
ASSERT_EQ(window_->layoutRect_, rect);
|
||||
window->layoutRect_ = { 0, 0, 2710, 1320 };
|
||||
window->FlushLayoutSize(width, height);
|
||||
ASSERT_EQ(window->layoutRect_, rect);
|
||||
|
||||
window_->enableFrameLayoutFinishCb_ = true;
|
||||
window_->FlushLayoutSize(width, height);
|
||||
ASSERT_EQ(window_->windowSizeChanged_, false);
|
||||
window->enableFrameLayoutFinishCb_ = true;
|
||||
window->FlushLayoutSize(width, height);
|
||||
ASSERT_EQ(window->enableFrameLayoutFinishCb_, false);
|
||||
|
||||
GTEST_LOG_(INFO) << "WindowSessionImplTest4: FlushLayoutSize end";
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user