mirror of
https://github.com/openharmony/ace_ace_engine.git
synced 2026-07-18 12:45:07 -04:00
!2255 增加FA模型下窗口设置背景色handler
Merge pull request !2255 from xiexiyun/master
This commit is contained in:
@@ -200,6 +200,10 @@ void AceAbility::OnStart(const Want& want)
|
||||
OHOS::sptr<OHOS::Rosen::IOccupiedAreaChangeListener> occupiedAreaChangeListener(this);
|
||||
window->RegisterOccupiedAreaChangeListener(occupiedAreaChangeListener);
|
||||
|
||||
// register ace ability handler callback
|
||||
OHOS::sptr<OHOS::Rosen::IAceAbilityHandler> aceAbilityHandler(this);
|
||||
window->SetAceAbilityHandler(aceAbilityHandler);
|
||||
|
||||
int32_t deviceWidth = 0;
|
||||
int32_t deviceHeight = 0;
|
||||
auto defaultDisplay = Rosen::DisplayManager::GetInstance().GetDefaultDisplay();
|
||||
@@ -745,5 +749,61 @@ void AceAbility::OnKeyEvent(std::shared_ptr<MMI::KeyEvent>& keyEvent)
|
||||
}
|
||||
flutterAceView->DispatchKeyEvent(flutterAceView, keyEvent);
|
||||
}
|
||||
|
||||
void AceAbility::SetBackgroundColor(uint32_t color)
|
||||
{
|
||||
LOGI("AceAbilityHandler::SetBackgroundColor color is %{public}u", color);
|
||||
auto container = Platform::AceContainer::GetContainer(abilityId_);
|
||||
if (!container) {
|
||||
LOGE("SetBackgroundColor failed: container is null.");
|
||||
return;
|
||||
}
|
||||
ContainerScope scope(abilityId_);
|
||||
auto taskExecutor = container->GetTaskExecutor();
|
||||
if (!taskExecutor) {
|
||||
LOGE("SetBackgroundColor failed: taskExecutor is null.");
|
||||
return;
|
||||
}
|
||||
taskExecutor->PostSyncTask([container, bgColor = color]() {
|
||||
auto pipelineContext = container->GetPipelineContext();
|
||||
if (!pipelineContext) {
|
||||
LOGE("SetBackgroundColor failed, pipeline context is null.");
|
||||
return;
|
||||
}
|
||||
pipelineContext->SetAppBgColor(Color(bgColor));
|
||||
}, TaskExecutor::TaskType::UI);
|
||||
}
|
||||
|
||||
uint32_t AceAbility::GetBackgroundColor()
|
||||
{
|
||||
auto container = Platform::AceContainer::GetContainer(abilityId_);
|
||||
if (!container) {
|
||||
LOGE("AceAbilityHandler GetBackgroundColor failed: container is null. return 0x000000");
|
||||
return 0x000000;
|
||||
}
|
||||
auto taskExecutor = container->GetTaskExecutor();
|
||||
if (!taskExecutor) {
|
||||
LOGE("AceAbilityHandler GetBackgroundColor failed: taskExecutor is null.");
|
||||
return 0x000000;
|
||||
}
|
||||
ContainerScope scope(abilityId_);
|
||||
uint32_t bgColor = 0x000000;
|
||||
taskExecutor->PostSyncTask([&bgColor, container]() {
|
||||
if (!container) {
|
||||
LOGE("Post sync task GetBackgroundColor failed: container is null. return 0x000000");
|
||||
return;
|
||||
}
|
||||
auto pipelineContext = container->GetPipelineContext();
|
||||
if (!pipelineContext) {
|
||||
LOGE("Post sync task GetBackgroundColor failed: pipeline is null. return 0x000000");
|
||||
return;
|
||||
}
|
||||
bgColor = pipelineContext->GetAppBgColor().GetValue();
|
||||
}, TaskExecutor::TaskType::UI);
|
||||
|
||||
LOGI("AceAbilityHandler::GetBackgroundColor, value is %{public}u", bgColor);
|
||||
return bgColor;
|
||||
}
|
||||
|
||||
} // namespace Ace
|
||||
} // namespace OHOS
|
||||
|
||||
@@ -32,7 +32,8 @@ class AceAbility final : public OHOS::AppExecFwk::Ability,
|
||||
public OHOS::Rosen::IWindowChangeListener,
|
||||
public OHOS::Rosen::IWindowDragListener,
|
||||
public OHOS::Rosen::IOccupiedAreaChangeListener,
|
||||
public OHOS::Rosen::IInputEventListener {
|
||||
public OHOS::Rosen::IInputEventListener,
|
||||
public OHOS::Rosen::IAceAbilityHandler {
|
||||
public:
|
||||
AceAbility()
|
||||
{
|
||||
@@ -76,6 +77,10 @@ public:
|
||||
void OnPointerInputEvent(std::shared_ptr<MMI::PointerEvent>& pointerEvent) override;
|
||||
void OnKeyEvent(std::shared_ptr<MMI::KeyEvent>& keyEvent) override;
|
||||
|
||||
// override Rosen::IAceAbilityHandler virtual callback function
|
||||
void SetBackgroundColor(uint32_t color) override;
|
||||
uint32_t GetBackgroundColor() override;
|
||||
|
||||
void Dump(const std::vector<std::string>& params, std::vector<std::string>& info) override;
|
||||
|
||||
private:
|
||||
|
||||
Reference in New Issue
Block a user