!388 修复分屏事件foudation同进程下发送问题

Merge pull request !388 from 邢亚楠/develop
This commit is contained in:
openharmony_ci 2022-02-26 12:45:40 +00:00 committed by Gitee
commit dc4ceda59f
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
3 changed files with 25 additions and 21 deletions

View File

@ -628,18 +628,19 @@ WMError WindowImpl::Show()
if (!IsWindowValid()) {
return WMError::WM_ERROR_INVALID_WINDOW;
}
if (state_ == WindowState::STATE_SHOWN && property_->GetWindowType() == WindowType::WINDOW_TYPE_DESKTOP) {
WLOGFI("Minimize all app windows");
SingletonContainer::Get<WindowAdapter>().MinimizeAllAppWindows(property_->GetDisplayId());
for (auto& listener : lifecycleListeners_) {
if (listener != nullptr) {
listener->AfterForeground();
}
}
return WMError::WM_OK;
}
if (state_ == WindowState::STATE_SHOWN) {
WLOGFI("window is already shown id: %{public}d", property_->GetWindowId());
if (property_->GetWindowType() == WindowType::WINDOW_TYPE_DESKTOP) {
WLOGFI("desktop window [id:%{public}d] is shown, minimize all app windows", property_->GetWindowId());
SingletonContainer::Get<WindowAdapter>().MinimizeAllAppWindows(property_->GetDisplayId());
for (auto& listener : lifecycleListeners_) {
if (listener != nullptr) {
listener->AfterForeground();
}
}
} else {
WLOGFI("window is already shown id: %{public}d, raise to top", property_->GetWindowId());
SingletonContainer::Get<WindowAdapter>().ProcessWindowTouchedEvent(property_->GetWindowId());
}
return WMError::WM_OK;
}
SetDefaultOption();

View File

@ -179,7 +179,6 @@ WMError WindowController::SetWindowMode(uint32_t windowId, WindowMode dstMode)
return WMError::WM_OK;
}
WMError res = WMError::WM_OK;
node->SetWindowMode(dstMode);
if ((srcMode == WindowMode::WINDOW_MODE_FULLSCREEN) && (dstMode == WindowMode::WINDOW_MODE_FLOATING)) {
node->SetWindowSizeChangeReason(WindowSizeChangeReason::RECOVER);
} else if (dstMode == WindowMode::WINDOW_MODE_FULLSCREEN) {
@ -190,9 +189,13 @@ WMError WindowController::SetWindowMode(uint32_t windowId, WindowMode dstMode)
if (WindowHelper::IsSplitWindowMode(srcMode)) {
// change split mode to other
res = windowRoot_->ExitSplitWindowMode(node);
node->SetWindowMode(dstMode);
} else if (!WindowHelper::IsSplitWindowMode(srcMode) && WindowHelper::IsSplitWindowMode(dstMode)) {
// change other mode to split
node->SetWindowMode(dstMode);
res = windowRoot_->EnterSplitWindowMode(node);
} else {
node->SetWindowMode(dstMode);
}
if (res != WMError::WM_OK) {
node->GetWindowProperty()->ResumeLastWindowMode();

View File

@ -38,6 +38,7 @@ namespace Rosen {
namespace {
constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_WINDOW, "WindowNodeContainer"};
constexpr int WINDOW_NAME_MAX_LENGTH = 10;
const std::string SPLIT_SCREEN_EVENT_NAME = "common.event.SPLIT_SCREEN";
}
WindowNodeContainer::WindowNodeContainer(DisplayId displayId, uint32_t width, uint32_t height) : displayId_(displayId)
@ -821,19 +822,18 @@ void WindowNodeContainer::MinimizeAllAppWindows()
void WindowNodeContainer::SendSplitScreenEvent(WindowMode mode)
{
// should define in common_event_support.h and @ohos.commonEvent.d.ts
WLOGFI("send split sceen event , trigger mode is %{public}d", mode);
const std::string eventName = "common.event.SPLIT_SCREEN";
// reset ipc identity
std::string identity = IPCSkeleton::ResetCallingIdentity();
AAFwk::Want want;
want.SetAction(eventName);
want.SetAction(SPLIT_SCREEN_EVENT_NAME);
EventFwk::CommonEventData commonEventData;
commonEventData.SetWant(want);
if (mode == WindowMode::WINDOW_MODE_SPLIT_PRIMARY) {
commonEventData.SetData("Secondary");
} else {
commonEventData.SetData("Primary");
}
std::string eventData = (mode == WindowMode::WINDOW_MODE_SPLIT_PRIMARY) ? "Secondary" : "Primary";
commonEventData.SetData(eventData);
EventFwk::CommonEventManager::PublishCommonEvent(commonEventData);
// set ipc identity to raw
IPCSkeleton::SetCallingIdentity(identity);
WLOGFI("send split sceen event finish.");
}
sptr<WindowNode> WindowNodeContainer::FindSplitPairNode(sptr<WindowNode>& triggerNode) const