fix virtual

Signed-off-by: langsongping <langsongping1@huawei-partners.com>
This commit is contained in:
langsongping 2024-11-04 22:09:04 +08:00
parent e849c3b85d
commit 048a76fb7e
3 changed files with 12 additions and 2 deletions

View File

@ -3532,6 +3532,9 @@ DMError ScreenSessionManager::MakeUniqueScreen(const std::vector<ScreenId>& scre
TLOGE(WmsLogTag::DMS, "screen session is nullptr");
continue;
}
Rosen::RSDisplayNodeConfig rsConfig;
rsConfig.screenId = rsScreenId;
screenSession->CreateDisplayNode(rsConfig);
screenSession->SetDisplayNodeScreenId(rsScreenId);
// notify scb to build Screen widget
OnVirtualScreenChange(screenId, ScreenEvent::CONNECTED);
@ -3738,7 +3741,7 @@ sptr<ScreenSession> ScreenSessionManager::InitVirtualScreen(ScreenId smsScreenId
.name = option.name_,
};
sptr<ScreenSession> screenSession =
new(std::nothrow) ScreenSession(config, ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL);
new(std::nothrow) ScreenSession(config, ScreenSessionReason::CREATE_SESSION_WITHOUT_DISPLAY_NODE);
sptr<SupportedScreenModes> info = new(std::nothrow) SupportedScreenModes();
if (screenSession == nullptr || info == nullptr) {
TLOGI(WmsLogTag::DMS, "new screenSession or info failed");

View File

@ -1391,6 +1391,10 @@ void ScreenSession::Resize(uint32_t width, uint32_t height)
UpdatePropertyByActiveMode();
{
std::shared_lock<std::shared_mutex> displayNodeLock(displayNodeMutex_);
if (displayNode_ == nullptr) {
WLOGFE("displayNode_ is null, resize failed");
return;
}
displayNode_->SetFrame(0, 0, static_cast<float>(width), static_cast<float>(height));
displayNode_->SetBounds(0, 0, static_cast<float>(width), static_cast<float>(height));
}

View File

@ -2340,7 +2340,10 @@ HWTEST_F(ScreenSessionManagerTest, ResizeVirtualScreen, Function | SmallTest | L
uint32_t width {100};
uint32_t height {100};
EXPECT_EQ(DMError::DM_OK, ssm_->ResizeVirtualScreen(screenId, width, height));
sptr<ScreenSession> screenSession = ssm_->GetScreenSession(screenId);
if (screenSession->GetDisplayNode() != nullptr) {
EXPECT_EQ(DMError::DM_OK, ssm_->ResizeVirtualScreen(screenId, width, height));
}
ssm_->DestroyVirtualScreen(screenId);
}