mirror of
https://gitee.com/openharmony/window_window_manager
synced 2024-11-23 06:50:40 +00:00
commit
b026b5d459
@ -40,8 +40,6 @@ public:
|
||||
void SetSkipSelfWhenShowOnVirtualScreen(bool isSkip) override;
|
||||
void SyncScenePanelGlobalPosition(bool needSync) override;
|
||||
bool IsNeedSyncScenePanelGlobalPosition() override { return isNeedSyncGlobalPos_; }
|
||||
std::shared_ptr<RSSurfaceNode> GetSurfaceNode();
|
||||
|
||||
bool IsVisibleForeground() const override;
|
||||
|
||||
protected:
|
||||
|
@ -204,6 +204,7 @@ public:
|
||||
virtual WSError UpdateAvoidArea(const sptr<AvoidArea>& avoidArea, AvoidAreaType type) { return WSError::WS_OK; }
|
||||
|
||||
int32_t GetPersistentId() const;
|
||||
void SetSurfaceNode(const std::shared_ptr<RSSurfaceNode>& surfaceNode);
|
||||
std::shared_ptr<RSSurfaceNode> GetSurfaceNode() const;
|
||||
void SetLeashWinSurfaceNode(std::shared_ptr<RSSurfaceNode> leashWinSurfaceNode);
|
||||
std::shared_ptr<RSSurfaceNode> GetLeashWinSurfaceNode() const;
|
||||
@ -603,6 +604,7 @@ protected:
|
||||
std::atomic<SessionState> state_ = SessionState::STATE_DISCONNECT;
|
||||
SessionInfo sessionInfo_;
|
||||
std::recursive_mutex sessionInfoMutex_;
|
||||
mutable std::mutex surfaceNodeMutex_;
|
||||
std::shared_ptr<RSSurfaceNode> surfaceNode_;
|
||||
mutable std::mutex snapshotMutex_;
|
||||
std::shared_ptr<Media::PixelMap> snapshot_;
|
||||
|
@ -210,15 +210,6 @@ void SCBSystemSession::SetSkipSelfWhenShowOnVirtualScreen(bool isSkip)
|
||||
PostTask(task, "SetSkipSelf");
|
||||
}
|
||||
|
||||
std::shared_ptr<RSSurfaceNode> SCBSystemSession::GetSurfaceNode()
|
||||
{
|
||||
if (!surfaceNode_) {
|
||||
TLOGE(WmsLogTag::WMS_SCB, "surfaceNode_ is null");
|
||||
return nullptr;
|
||||
}
|
||||
return surfaceNode_;
|
||||
}
|
||||
|
||||
bool SCBSystemSession::IsVisibleForeground() const
|
||||
{
|
||||
return isVisible_;
|
||||
|
@ -2299,7 +2299,8 @@ WSError SceneSession::TransferPointerEventInner(const std::shared_ptr<MMI::Point
|
||||
if ((systemConfig_.IsPcWindow() || IsFreeMultiWindowMode() ||
|
||||
(property->GetIsPcAppInPad() && !isMainWindow)) &&
|
||||
moveDragController_->ConsumeDragEvent(pointerEvent, winRect_, property, systemConfig_)) {
|
||||
moveDragController_->UpdateGravityWhenDrag(pointerEvent, surfaceNode_);
|
||||
auto surfaceNode = GetSurfaceNode();
|
||||
moveDragController_->UpdateGravityWhenDrag(pointerEvent, surfaceNode);
|
||||
PresentFoucusIfNeed(pointerEvent->GetPointerAction());
|
||||
pointerEvent->MarkProcessed();
|
||||
return WSError::WS_OK;
|
||||
@ -2917,35 +2918,36 @@ void SceneSession::SetSurfaceBounds(const WSRect& rect, bool isGlobal, bool need
|
||||
if (rsTransaction != nullptr && needFlush) {
|
||||
rsTransaction->Begin();
|
||||
}
|
||||
auto surfaceNode = GetSurfaceNode();
|
||||
auto leashWinSurfaceNode = GetLeashWinSurfaceNode();
|
||||
auto property = GetSessionProperty();
|
||||
if (surfaceNode_ && leashWinSurfaceNode) {
|
||||
if (surfaceNode && leashWinSurfaceNode) {
|
||||
leashWinSurfaceNode->SetGlobalPositionEnabled(isGlobal);
|
||||
leashWinSurfaceNode->SetBounds(rect.posX_, rect.posY_, rect.width_, rect.height_);
|
||||
leashWinSurfaceNode->SetFrame(rect.posX_, rect.posY_, rect.width_, rect.height_);
|
||||
surfaceNode_->SetBounds(0, 0, rect.width_, rect.height_);
|
||||
surfaceNode_->SetFrame(0, 0, rect.width_, rect.height_);
|
||||
} else if (WindowHelper::IsPipWindow(GetWindowType()) && surfaceNode_) {
|
||||
surfaceNode->SetBounds(0, 0, rect.width_, rect.height_);
|
||||
surfaceNode->SetFrame(0, 0, rect.width_, rect.height_);
|
||||
} else if (WindowHelper::IsPipWindow(GetWindowType()) && surfaceNode) {
|
||||
TLOGD(WmsLogTag::WMS_PIP, "PipWindow setSurfaceBounds");
|
||||
surfaceNode_->SetGlobalPositionEnabled(isGlobal);
|
||||
surfaceNode_->SetBounds(rect.posX_, rect.posY_, rect.width_, rect.height_);
|
||||
surfaceNode_->SetFrame(rect.posX_, rect.posY_, rect.width_, rect.height_);
|
||||
} else if (WindowHelper::IsSubWindow(GetWindowType()) && surfaceNode_) {
|
||||
surfaceNode->SetGlobalPositionEnabled(isGlobal);
|
||||
surfaceNode->SetBounds(rect.posX_, rect.posY_, rect.width_, rect.height_);
|
||||
surfaceNode->SetFrame(rect.posX_, rect.posY_, rect.width_, rect.height_);
|
||||
} else if (WindowHelper::IsSubWindow(GetWindowType()) && surfaceNode) {
|
||||
WLOGFD("subwindow setSurfaceBounds");
|
||||
surfaceNode_->SetGlobalPositionEnabled(isGlobal);
|
||||
surfaceNode_->SetBounds(rect.posX_, rect.posY_, rect.width_, rect.height_);
|
||||
surfaceNode_->SetFrame(rect.posX_, rect.posY_, rect.width_, rect.height_);
|
||||
} else if (WindowHelper::IsDialogWindow(GetWindowType()) && surfaceNode_) {
|
||||
surfaceNode->SetGlobalPositionEnabled(isGlobal);
|
||||
surfaceNode->SetBounds(rect.posX_, rect.posY_, rect.width_, rect.height_);
|
||||
surfaceNode->SetFrame(rect.posX_, rect.posY_, rect.width_, rect.height_);
|
||||
} else if (WindowHelper::IsDialogWindow(GetWindowType()) && surfaceNode) {
|
||||
TLOGD(WmsLogTag::WMS_DIALOG, "dialogWindow setSurfaceBounds");
|
||||
surfaceNode_->SetGlobalPositionEnabled(isGlobal);
|
||||
surfaceNode_->SetBounds(rect.posX_, rect.posY_, rect.width_, rect.height_);
|
||||
surfaceNode_->SetFrame(rect.posX_, rect.posY_, rect.width_, rect.height_);
|
||||
surfaceNode->SetGlobalPositionEnabled(isGlobal);
|
||||
surfaceNode->SetBounds(rect.posX_, rect.posY_, rect.width_, rect.height_);
|
||||
surfaceNode->SetFrame(rect.posX_, rect.posY_, rect.width_, rect.height_);
|
||||
} else if (WindowHelper::IsSystemWindow(GetWindowType()) &&
|
||||
property && property->GetDragEnabled() && surfaceNode_) {
|
||||
property && property->GetDragEnabled() && surfaceNode) {
|
||||
TLOGD(WmsLogTag::WMS_SYSTEM, "drag enabled systemwindow setSurfaceBounds");
|
||||
surfaceNode_->SetGlobalPositionEnabled(isGlobal);
|
||||
surfaceNode_->SetBounds(rect.posX_, rect.posY_, rect.width_, rect.height_);
|
||||
surfaceNode_->SetFrame(rect.posX_, rect.posY_, rect.width_, rect.height_);
|
||||
surfaceNode->SetGlobalPositionEnabled(isGlobal);
|
||||
surfaceNode->SetBounds(rect.posX_, rect.posY_, rect.width_, rect.height_);
|
||||
surfaceNode->SetFrame(rect.posX_, rect.posY_, rect.width_, rect.height_);
|
||||
} else {
|
||||
WLOGE("SetSurfaceBounds surfaceNode is null!");
|
||||
}
|
||||
@ -3135,7 +3137,8 @@ void SceneSession::SetPrivacyMode(bool isPrivacy)
|
||||
WLOGFE("SetPrivacyMode property is null");
|
||||
return;
|
||||
}
|
||||
if (!surfaceNode_) {
|
||||
auto surfaceNode = GetSurfaceNode();
|
||||
if (!surfaceNode) {
|
||||
WLOGFE("surfaceNode_ is null");
|
||||
return;
|
||||
}
|
||||
@ -3150,7 +3153,7 @@ void SceneSession::SetPrivacyMode(bool isPrivacy)
|
||||
if (rsTransaction != nullptr) {
|
||||
rsTransaction->Begin();
|
||||
}
|
||||
surfaceNode_->SetSecurityLayer(isPrivacy);
|
||||
surfaceNode->SetSecurityLayer(isPrivacy);
|
||||
auto leashWinSurfaceNode = GetLeashWinSurfaceNode();
|
||||
if (leashWinSurfaceNode != nullptr) {
|
||||
leashWinSurfaceNode->SetSecurityLayer(isPrivacy);
|
||||
@ -3190,7 +3193,8 @@ void SceneSession::SetSnapshotSkip(bool isSkip)
|
||||
TLOGE(WmsLogTag::DEFAULT, "property is null");
|
||||
return;
|
||||
}
|
||||
if (!surfaceNode_) {
|
||||
auto surfaceNode = GetSurfaceNode();
|
||||
if (!surfaceNode) {
|
||||
TLOGE(WmsLogTag::DEFAULT, "surfaceNode_ is null");
|
||||
return;
|
||||
}
|
||||
@ -3205,7 +3209,7 @@ void SceneSession::SetSnapshotSkip(bool isSkip)
|
||||
if (rsTransaction != nullptr) {
|
||||
rsTransaction->Begin();
|
||||
}
|
||||
surfaceNode_->SetSkipLayer(isSkip);
|
||||
surfaceNode->SetSkipLayer(isSkip);
|
||||
auto leashWinSurfaceNode = GetLeashWinSurfaceNode();
|
||||
if (leashWinSurfaceNode != nullptr) {
|
||||
leashWinSurfaceNode->SetSkipLayer(isSkip);
|
||||
@ -3217,7 +3221,8 @@ void SceneSession::SetSnapshotSkip(bool isSkip)
|
||||
|
||||
void SceneSession::SetWatermarkEnabled(const std::string& watermarkName, bool isEnabled)
|
||||
{
|
||||
if (!surfaceNode_) {
|
||||
auto surfaceNode = GetSurfaceNode();
|
||||
if (!surfaceNode) {
|
||||
TLOGE(WmsLogTag::DEFAULT, "surfaceNode is null");
|
||||
return;
|
||||
}
|
||||
@ -3227,7 +3232,7 @@ void SceneSession::SetWatermarkEnabled(const std::string& watermarkName, bool is
|
||||
if (rsTransaction != nullptr) {
|
||||
rsTransaction->Begin();
|
||||
}
|
||||
surfaceNode_->SetWatermarkEnabled(watermarkName, isEnabled);
|
||||
surfaceNode->SetWatermarkEnabled(watermarkName, isEnabled);
|
||||
if (auto leashWinSurfaceNode = GetLeashWinSurfaceNode()) {
|
||||
leashWinSurfaceNode->SetWatermarkEnabled(watermarkName, isEnabled);
|
||||
}
|
||||
@ -3248,7 +3253,8 @@ void SceneSession::SetSystemSceneOcclusionAlpha(double alpha)
|
||||
WLOGFE("OnSetSystemSceneOcclusionAlpha property is null");
|
||||
return;
|
||||
}
|
||||
if (!surfaceNode_) {
|
||||
auto surfaceNode = GetSurfaceNode();
|
||||
if (!surfaceNode) {
|
||||
WLOGFE("surfaceNode_ is null");
|
||||
return;
|
||||
}
|
||||
@ -3258,7 +3264,7 @@ void SceneSession::SetSystemSceneOcclusionAlpha(double alpha)
|
||||
if (rsTransaction != nullptr) {
|
||||
rsTransaction->Begin();
|
||||
}
|
||||
surfaceNode_->SetAbilityBGAlpha(alpha8bit);
|
||||
surfaceNode->SetAbilityBGAlpha(alpha8bit);
|
||||
auto leashWinSurfaceNode = GetLeashWinSurfaceNode();
|
||||
if (leashWinSurfaceNode != nullptr) {
|
||||
leashWinSurfaceNode->SetAbilityBGAlpha(alpha8bit);
|
||||
@ -3272,7 +3278,8 @@ void SceneSession::SetSystemSceneForceUIFirst(bool forceUIFirst)
|
||||
{
|
||||
HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "SceneSession::SetForceUIFirst");
|
||||
auto leashWinSurfaceNode = GetLeashWinSurfaceNode();
|
||||
if (leashWinSurfaceNode == nullptr && surfaceNode_ == nullptr) {
|
||||
auto surfaceNode = GetSurfaceNode();
|
||||
if (leashWinSurfaceNode == nullptr && surfaceNode == nullptr) {
|
||||
TLOGE(WmsLogTag::DEFAULT, "leashWindow and surfaceNode are nullptr");
|
||||
return;
|
||||
}
|
||||
@ -3284,10 +3291,10 @@ void SceneSession::SetSystemSceneForceUIFirst(bool forceUIFirst)
|
||||
TLOGI(WmsLogTag::DEFAULT, "%{public}s %{public}" PRIu64 " forceUIFirst=%{public}d.",
|
||||
leashWinSurfaceNode->GetName().c_str(), leashWinSurfaceNode->GetId(), forceUIFirst);
|
||||
leashWinSurfaceNode->SetForceUIFirst(forceUIFirst);
|
||||
} else if (surfaceNode_ != nullptr) {
|
||||
} else if (surfaceNode != nullptr) {
|
||||
TLOGI(WmsLogTag::DEFAULT, "%{public}s %{public}" PRIu64 " forceUIFirst=%{public}d.",
|
||||
surfaceNode_->GetName().c_str(), surfaceNode_->GetId(), forceUIFirst);
|
||||
surfaceNode_->SetForceUIFirst(forceUIFirst);
|
||||
surfaceNode->GetName().c_str(), surfaceNode->GetId(), forceUIFirst);
|
||||
surfaceNode->SetForceUIFirst(forceUIFirst);
|
||||
}
|
||||
if (rsTransaction != nullptr) {
|
||||
rsTransaction->Commit();
|
||||
@ -3298,7 +3305,8 @@ void SceneSession::MarkSystemSceneUIFirst(bool isForced, bool isUIFirstEnabled)
|
||||
{
|
||||
HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "SceneSession::MarkSystemSceneUIFirst");
|
||||
auto leashWinSurfaceNode = GetLeashWinSurfaceNode();
|
||||
if (leashWinSurfaceNode == nullptr && surfaceNode_ == nullptr) {
|
||||
auto surfaceNode = GetSurfaceNode();
|
||||
if (leashWinSurfaceNode == nullptr && surfaceNode == nullptr) {
|
||||
TLOGE(WmsLogTag::DEFAULT, "leashWindow and surfaceNode are nullptr");
|
||||
return;
|
||||
}
|
||||
@ -3308,8 +3316,8 @@ void SceneSession::MarkSystemSceneUIFirst(bool isForced, bool isUIFirstEnabled)
|
||||
leashWinSurfaceNode->MarkUifirstNode(isForced, isUIFirstEnabled);
|
||||
} else {
|
||||
TLOGI(WmsLogTag::DEFAULT, "%{public}s %{public}" PRIu64 " isForced=%{public}d. isUIFirstEnabled=%{public}d",
|
||||
surfaceNode_->GetName().c_str(), surfaceNode_->GetId(), isForced, isUIFirstEnabled);
|
||||
surfaceNode_->MarkUifirstNode(isForced, isUIFirstEnabled);
|
||||
surfaceNode->GetName().c_str(), surfaceNode->GetId(), isForced, isUIFirstEnabled);
|
||||
surfaceNode->MarkUifirstNode(isForced, isUIFirstEnabled);
|
||||
}
|
||||
}
|
||||
|
||||
@ -5143,7 +5151,8 @@ bool SceneSession::IsTemporarilyShowWhenLocked() const
|
||||
|
||||
void SceneSession::SetSkipDraw(bool skip)
|
||||
{
|
||||
if (!surfaceNode_) {
|
||||
auto surfaceNode = GetSurfaceNode();
|
||||
if (!surfaceNode) {
|
||||
WLOGFE("surfaceNode_ is null");
|
||||
return;
|
||||
}
|
||||
@ -5151,9 +5160,8 @@ void SceneSession::SetSkipDraw(bool skip)
|
||||
if (rsTransaction != nullptr) {
|
||||
rsTransaction->Begin();
|
||||
}
|
||||
surfaceNode_->SetSkipDraw(skip);
|
||||
auto leashWinSurfaceNode = GetLeashWinSurfaceNode();
|
||||
if (leashWinSurfaceNode != nullptr) {
|
||||
surfaceNode->SetSkipDraw(skip);
|
||||
if (auto leashWinSurfaceNode = GetLeashWinSurfaceNode()) {
|
||||
leashWinSurfaceNode->SetSkipDraw(skip);
|
||||
}
|
||||
if (rsTransaction != nullptr) {
|
||||
@ -5765,12 +5773,13 @@ void SceneSession::SetWindowRectAutoSaveCallback(NotifySetWindowRectAutoSaveFunc
|
||||
|
||||
bool SceneSession::SetFrameGravity(Gravity gravity)
|
||||
{
|
||||
if (surfaceNode_ == nullptr) {
|
||||
auto surfaceNode = GetSurfaceNode();
|
||||
if (surfaceNode == nullptr) {
|
||||
TLOGW(WmsLogTag::WMS_LAYOUT, "fail id:%{public}d gravity:%{public}d", GetPersistentId(), gravity);
|
||||
return false;
|
||||
}
|
||||
TLOGI(WmsLogTag::WMS_LAYOUT, "id:%{public}d gravity:%{public}d", GetPersistentId(), gravity);
|
||||
surfaceNode_->SetFrameGravity(gravity);
|
||||
surfaceNode->SetFrameGravity(gravity);
|
||||
return true;
|
||||
}
|
||||
} // namespace OHOS::Rosen
|
||||
|
@ -147,8 +147,15 @@ int32_t Session::GetPersistentId() const
|
||||
return persistentId_;
|
||||
}
|
||||
|
||||
void Session::SetSurfaceNode(const std::shared_ptr<RSSurfaceNode>& surfaceNode)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(surfaceNodeMutex_);
|
||||
surfaceNode_ = surfaceNode;
|
||||
}
|
||||
|
||||
std::shared_ptr<RSSurfaceNode> Session::GetSurfaceNode() const
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(surfaceNodeMutex_);
|
||||
return surfaceNode_;
|
||||
}
|
||||
|
||||
@ -188,7 +195,7 @@ std::shared_ptr<RSSurfaceNode> Session::GetSurfaceNodeForMoveDrag() const
|
||||
{
|
||||
auto movedSurfaceNode = GetLeashWinSurfaceNode();
|
||||
if (!movedSurfaceNode) {
|
||||
movedSurfaceNode = surfaceNode_;
|
||||
movedSurfaceNode = GetSurfaceNode();
|
||||
}
|
||||
return movedSurfaceNode;
|
||||
}
|
||||
@ -1054,7 +1061,7 @@ __attribute__((no_sanitize("cfi"))) WSError Session::ConnectInner(const sptr<ISe
|
||||
}
|
||||
sessionStage_ = sessionStage;
|
||||
windowEventChannel_ = eventChannel;
|
||||
surfaceNode_ = surfaceNode;
|
||||
SetSurfaceNode(surfaceNode);
|
||||
abilityToken_ = token;
|
||||
systemConfig = systemConfig_;
|
||||
InitSessionPropertyWhenConnect(property);
|
||||
@ -1147,7 +1154,7 @@ WSError Session::Reconnect(const sptr<ISessionStage>& sessionStage, const sptr<I
|
||||
return WSError::WS_ERROR_NULLPTR;
|
||||
}
|
||||
sessionStage_ = sessionStage;
|
||||
surfaceNode_ = surfaceNode;
|
||||
SetSurfaceNode(surfaceNode);
|
||||
windowEventChannel_ = eventChannel;
|
||||
abilityToken_ = token;
|
||||
SetSessionProperty(property);
|
||||
@ -1284,7 +1291,12 @@ WSError Session::Disconnect(bool isFromClient, const std::string& identityToken)
|
||||
bufferAvailable_ = false;
|
||||
isNeedSyncSessionRect_ = true;
|
||||
if (mainHandler_) {
|
||||
mainHandler_->PostTask([surfaceNode = std::move(surfaceNode_)]() mutable {
|
||||
std::shared_ptr<RSSurfaceNode> surfaceNode;
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(surfaceNodeMutex_);
|
||||
surfaceNode_.swap(surfaceNode);
|
||||
}
|
||||
mainHandler_->PostTask([surfaceNode = std::move(surfaceNode)]() mutable {
|
||||
surfaceNode.reset();
|
||||
});
|
||||
}
|
||||
@ -2200,7 +2212,8 @@ std::shared_ptr<Media::PixelMap> Session::Snapshot(bool runInFfrt, float scalePa
|
||||
if (scenePersistence_ == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
if (!surfaceNode_ || !surfaceNode_->IsBufferAvailable()) {
|
||||
auto surfaceNode = GetSurfaceNode();
|
||||
if (!surfaceNode || !surfaceNode->IsBufferAvailable()) {
|
||||
scenePersistence_->SetHasSnapshot(false);
|
||||
return nullptr;
|
||||
}
|
||||
@ -2214,7 +2227,7 @@ std::shared_ptr<Media::PixelMap> Session::Snapshot(bool runInFfrt, float scalePa
|
||||
.useDma = true,
|
||||
.useCurWindow = useCurWindow,
|
||||
};
|
||||
bool ret = RSInterfaces::GetInstance().TakeSurfaceCapture(surfaceNode_, callback, config);
|
||||
bool ret = RSInterfaces::GetInstance().TakeSurfaceCapture(surfaceNode, callback, config);
|
||||
if (!ret) {
|
||||
TLOGE(WmsLogTag::WMS_MAIN, "TakeSurfaceCapture failed");
|
||||
return nullptr;
|
||||
@ -2708,13 +2721,14 @@ WSError Session::UpdateWindowMode(WindowMode mode)
|
||||
|
||||
void Session::UpdateGravityWhenUpdateWindowMode(WindowMode mode)
|
||||
{
|
||||
if ((systemConfig_.IsPcWindow() || systemConfig_.IsFreeMultiWindowMode()) && surfaceNode_ != nullptr) {
|
||||
auto surfaceNode = GetSurfaceNode();
|
||||
if ((systemConfig_.IsPcWindow() || systemConfig_.IsFreeMultiWindowMode()) && surfaceNode != nullptr) {
|
||||
if (mode == WindowMode::WINDOW_MODE_SPLIT_PRIMARY) {
|
||||
surfaceNode_->SetFrameGravity(Gravity::LEFT);
|
||||
surfaceNode->SetFrameGravity(Gravity::LEFT);
|
||||
} else if (mode == WindowMode::WINDOW_MODE_SPLIT_SECONDARY) {
|
||||
surfaceNode_->SetFrameGravity(Gravity::RIGHT);
|
||||
surfaceNode->SetFrameGravity(Gravity::RIGHT);
|
||||
} else if (mode == WindowMode::WINDOW_MODE_FLOATING || mode == WindowMode::WINDOW_MODE_FULLSCREEN) {
|
||||
surfaceNode_->SetFrameGravity(Gravity::RESIZE);
|
||||
surfaceNode->SetFrameGravity(Gravity::RESIZE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user