diff --git a/interfaces/innerkits/dm/dm_common.h b/interfaces/innerkits/dm/dm_common.h new file mode 100644 index 0000000000000000000000000000000000000000..fdc5202745a0b88159d25040b369794d8988733c --- /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 15fa9d61c996c5258c8dc49249225173973c6324..2f6ca7ed2a7760d74eb9adf73325b14d61de384d 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 6a960cba4afa5a6a38164eb9f17cf5e8c6f4f163..c84454342f328cf64bbe56a35f451d8e21292464 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 36e61710a8fe28175b259c408355db0b87eb1d25..56a0fa8665507abe0629bef8e10b1d4fcea37a05 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)