fix updating display info to IMS when app died

Signed-off-by: wangxinpeng <wangxinpeng4@huawei.com>
Change-Id: I911b7ac80f4e5be4a14adee2a4d8c308171290b2
This commit is contained in:
wangxinpeng
2022-01-08 19:42:47 +08:00
parent 27a7808485
commit 9be97edc04
4 changed files with 56 additions and 3 deletions
+26
View File
@@ -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 <cstdint>
namespace OHOS {
namespace Rosen {
constexpr int32_t INVALID_DISPLAY_ID = -1;
}
}
#endif // OHOS_ROSEN_DM_COMMON_H
+1
View File
@@ -29,6 +29,7 @@ public:
InputWindowMonitor(sptr<WindowRoot>& root) : windowRoot_(root) {}
~InputWindowMonitor() = default;
void UpdateInputWindow(uint32_t windowId);
void UpdateInputWindowByDisplayId(int32_t displayId);
private:
sptr<WindowRoot> windowRoot_;
+12
View File
@@ -19,6 +19,7 @@
#include <ipc_skeleton.h>
#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.");
+17 -3
View File
@@ -20,6 +20,7 @@
#include <ipc_skeleton.h>
#include <system_ability_definition.h>
#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<std::recursive_mutex> 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<std::recursive_mutex> 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<std::recursive_mutex> 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)