!2446 解决同时设置elevation和radius冲突,导致窗口阴影消失问题

Merge pull request !2446 from xukunkun/master
This commit is contained in:
openharmony_ci 2023-04-07 07:49:01 +00:00 committed by Gitee
commit 66216748a3
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F

View File

@ -125,17 +125,22 @@ WMError WindowSystemEffect::SetWindowShadow(const sptr<WindowNode>& node)
WLOGFE("window surfaceNode is null"); WLOGFE("window surfaceNode is null");
return WMError::WM_ERROR_NULLPTR; return WMError::WM_ERROR_NULLPTR;
} }
auto& shadow = node->isFocused_ ? windowSystemEffectConfig_.focusedShadow_ :
windowSystemEffectConfig_.unfocusedShadow_;
// when float mode change to fullscreen/split mode // when float mode change to fullscreen/split mode
if (!WindowHelper::IsFloatingWindow(node->GetWindowMode())) { if (!WindowHelper::IsFloatingWindow(node->GetWindowMode())) {
surfaceNode->SetShadowElevation(0.f); if (MathHelper::GreatNotEqual(shadow.elevation_, 0.f)) {
surfaceNode->SetShadowElevation(0.f);
} else {
surfaceNode->SetShadowRadius(0.f);
}
surfaceNode->SetShadowAlpha(0.f); surfaceNode->SetShadowAlpha(0.f);
surfaceNode->SetShadowRadius(0.f);
WLOGFD("[WEffect]close shadow id: %{public}u", node->GetWindowId()); WLOGFD("[WEffect]close shadow id: %{public}u", node->GetWindowId());
return WMError::WM_OK; return WMError::WM_OK;
} }
auto& shadow = node->isFocused_ ? windowSystemEffectConfig_.focusedShadow_ :
windowSystemEffectConfig_.unfocusedShadow_;
uint32_t colorValue; uint32_t colorValue;
if (!ColorParser::Parse(shadow.color_, colorValue)) { if (!ColorParser::Parse(shadow.color_, colorValue)) {
WLOGFE("[WEffect]invalid color string: %{public}s", shadow.color_.c_str()); WLOGFE("[WEffect]invalid color string: %{public}s", shadow.color_.c_str());
@ -147,12 +152,15 @@ WMError WindowSystemEffect::SetWindowShadow(const sptr<WindowNode>& node)
WLOGFI("[WEffect]color: %{public}s offsetX: %{public}f offsetY: %{public}f alpha: %{public}f radius: %{public}f", WLOGFI("[WEffect]color: %{public}s offsetX: %{public}f offsetY: %{public}f alpha: %{public}f radius: %{public}f",
shadow.color_.c_str(), shadow.offsetX_, shadow.offsetY_, shadow.alpha_, shadow.radius_); shadow.color_.c_str(), shadow.offsetX_, shadow.offsetY_, shadow.alpha_, shadow.radius_);
auto vpr = DisplayGroupInfo::GetInstance().GetDisplayVirtualPixelRatio(node->GetDisplayId()); auto vpr = DisplayGroupInfo::GetInstance().GetDisplayVirtualPixelRatio(node->GetDisplayId());
surfaceNode->SetShadowElevation(shadow.elevation_ * vpr); if (MathHelper::GreatNotEqual(shadow.elevation_, 0.f)) {
surfaceNode->SetShadowElevation(shadow.elevation_ * vpr);
} else {
surfaceNode->SetShadowRadius(shadow.radius_);
}
surfaceNode->SetShadowColor(colorValue); surfaceNode->SetShadowColor(colorValue);
surfaceNode->SetShadowOffsetX(shadow.offsetX_); surfaceNode->SetShadowOffsetX(shadow.offsetX_);
surfaceNode->SetShadowOffsetY(shadow.offsetY_); surfaceNode->SetShadowOffsetY(shadow.offsetY_);
surfaceNode->SetShadowAlpha(shadow.alpha_); surfaceNode->SetShadowAlpha(shadow.alpha_);
surfaceNode->SetShadowRadius(shadow.radius_);
return WMError::WM_OK; return WMError::WM_OK;
} }