修复分屏事件发送权限问题

Signed-off-by: xingyanan <xingyanan2@huawei.com>
Change-Id: I11ee03bc16b1fdc11b90a7b09445112b0fcaca66
Signed-off-by: xingyanan <xingyanan2@huawei.com>
This commit is contained in:
xingyanan
2022-02-25 16:12:10 +08:00
parent 210ca0abcf
commit dc854353d2
3 changed files with 25 additions and 21 deletions
+12 -11
View File
@@ -594,18 +594,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();
+4 -1
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();
+9 -9
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)
@@ -822,19 +823,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