From dc854353d2812979ce13bc39dfd8a53bb5573792 Mon Sep 17 00:00:00 2001 From: xingyanan Date: Fri, 25 Feb 2022 16:12:10 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=88=86=E5=B1=8F=E4=BA=8B?= =?UTF-8?q?=E4=BB=B6=E5=8F=91=E9=80=81=E6=9D=83=E9=99=90=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: xingyanan Change-Id: I11ee03bc16b1fdc11b90a7b09445112b0fcaca66 Signed-off-by: xingyanan --- wm/src/window_impl.cpp | 23 ++++++++++++----------- wmserver/src/window_controller.cpp | 5 ++++- wmserver/src/window_node_container.cpp | 18 +++++++++--------- 3 files changed, 25 insertions(+), 21 deletions(-) diff --git a/wm/src/window_impl.cpp b/wm/src/window_impl.cpp index 3305e66e..68215cd0 100644 --- a/wm/src/window_impl.cpp +++ b/wm/src/window_impl.cpp @@ -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().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().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().ProcessWindowTouchedEvent(property_->GetWindowId()); + } return WMError::WM_OK; } SetDefaultOption(); diff --git a/wmserver/src/window_controller.cpp b/wmserver/src/window_controller.cpp index 747bb62d..3ea46a4c 100644 --- a/wmserver/src/window_controller.cpp +++ b/wmserver/src/window_controller.cpp @@ -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(); diff --git a/wmserver/src/window_node_container.cpp b/wmserver/src/window_node_container.cpp index 96cefa75..a3c9cd96 100644 --- a/wmserver/src/window_node_container.cpp +++ b/wmserver/src/window_node_container.cpp @@ -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 WindowNodeContainer::FindSplitPairNode(sptr& triggerNode) const