From 2e90c72dc68cc0931b23b0a8f9dc4352528f9e70 Mon Sep 17 00:00:00 2001 From: wangxinpeng Date: Sat, 8 Jan 2022 19:42:47 +0800 Subject: [PATCH] fix updating display info to IMS when app died Signed-off-by: wangxinpeng Change-Id: I911b7ac80f4e5be4a14adee2a4d8c308171290b2 --- interfaces/innerkits/dm/dm_common.h | 26 +++++++++++++++++++++++++ wmserver/include/input_window_monitor.h | 1 + wmserver/src/input_window_monitor.cpp | 12 ++++++++++++ wmserver/src/window_manager_service.cpp | 20 ++++++++++++++++--- 4 files changed, 56 insertions(+), 3 deletions(-) create mode 100644 interfaces/innerkits/dm/dm_common.h diff --git a/interfaces/innerkits/dm/dm_common.h b/interfaces/innerkits/dm/dm_common.h new file mode 100644 index 0000000000..fdc5202745 --- /dev/null +++ b/interfaces/innerkits/dm/dm_common.h @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef OHOS_ROSEN_DM_COMMON_H +#define OHOS_ROSEN_DM_COMMON_H + +#include + +namespace OHOS { +namespace Rosen { +constexpr int32_t INVALID_DISPLAY_ID = -1; +} +} +#endif // OHOS_ROSEN_DM_COMMON_H diff --git a/wmserver/include/input_window_monitor.h b/wmserver/include/input_window_monitor.h index 15fa9d61c9..2f6ca7ed2a 100644 --- a/wmserver/include/input_window_monitor.h +++ b/wmserver/include/input_window_monitor.h @@ -29,6 +29,7 @@ public: InputWindowMonitor(sptr& root) : windowRoot_(root) {} ~InputWindowMonitor() = default; void UpdateInputWindow(uint32_t windowId); + void UpdateInputWindowByDisplayId(int32_t displayId); private: sptr windowRoot_; diff --git a/wmserver/src/input_window_monitor.cpp b/wmserver/src/input_window_monitor.cpp index 6a960cba4a..c84454342f 100644 --- a/wmserver/src/input_window_monitor.cpp +++ b/wmserver/src/input_window_monitor.cpp @@ -19,6 +19,7 @@ #include +#include "dm_common.h" #include "window_manager_hilog.h" namespace OHOS { @@ -38,7 +39,18 @@ void InputWindowMonitor::UpdateInputWindow(uint32_t windowId) WLOGFE("window node could not be found."); return; } + if (windowTypeSkipped_.find(windowNode->GetWindowProperty()->GetWindowType()) != windowTypeSkipped_.end()) { + return; + } int32_t displayId = windowNode->GetDisplayId(); + UpdateInputWindowByDisplayId(displayId); +} + +void InputWindowMonitor::UpdateInputWindowByDisplayId(int32_t displayId) +{ + if (displayId == INVALID_DISPLAY_ID) { + return; + } auto container = windowRoot_->GetOrCreateWindowNodeContainer(displayId); if (container == nullptr) { WLOGFE("can not get window node container."); diff --git a/wmserver/src/window_manager_service.cpp b/wmserver/src/window_manager_service.cpp index 36e61710a8..56a0fa8665 100644 --- a/wmserver/src/window_manager_service.cpp +++ b/wmserver/src/window_manager_service.cpp @@ -20,6 +20,7 @@ #include #include +#include "dm_common.h" #include "window_manager_hilog.h" #include "wm_trace.h" @@ -114,9 +115,14 @@ WMError WindowManagerService::DestroyWindow(uint32_t windowId) WLOGFI("[WMS] Destroy: %{public}d", windowId); WM_SCOPED_TRACE("wms:DestroyWindow(%d)", windowId); std::lock_guard lock(mutex_); + int32_t displayId = INVALID_DISPLAY_ID; + auto node = windowRoot_->GetWindowNode(windowId); + if (node != nullptr) { + displayId = node->GetDisplayId(); + } WMError res = windowController_->DestroyWindow(windowId); if (res == WMError::WM_OK) { - inputWindowMonitor_->UpdateInputWindow(windowId); + inputWindowMonitor_->UpdateInputWindowByDisplayId(displayId); } return res; } @@ -126,7 +132,11 @@ WMError WindowManagerService::MoveTo(uint32_t windowId, int32_t x, int32_t y) WLOGFI("[WMS] MoveTo: %{public}d [%{public}d, %{public}d]", windowId, x, y); WM_SCOPED_TRACE("wms:MoveTo"); std::lock_guard lock(mutex_); - return windowController_->MoveTo(windowId, x, y); + WMError res = windowController_->MoveTo(windowId, x, y); + if (res == WMError::WM_OK) { + inputWindowMonitor_->UpdateInputWindow(windowId); + } + return res; } WMError WindowManagerService::Resize(uint32_t windowId, uint32_t width, uint32_t height) @@ -134,7 +144,11 @@ WMError WindowManagerService::Resize(uint32_t windowId, uint32_t width, uint32_t WLOGFI("[WMS] Resize: %{public}d [%{public}d, %{public}d]", windowId, width, height); WM_SCOPED_TRACE("wms:Resize"); std::lock_guard lock(mutex_); - return windowController_->Resize(windowId, width, height); + WMError res = windowController_->Resize(windowId, width, height); + if (res == WMError::WM_OK) { + inputWindowMonitor_->UpdateInputWindow(windowId); + } + return res; } WMError WindowManagerService::RequestFocus(uint32_t windowId) -- Gitee