mirror of
https://github.com/openharmony/windowmanager.git
synced 2026-07-21 04:25:28 -04:00
fix updating display resolution to IMS
Signed-off-by: wangxinpeng <wangxinpeng4@huawei.com> Change-Id: Ib4db3a24ec00ca302519758deef41e9628a42eb7
This commit is contained in:
@@ -16,6 +16,7 @@
|
||||
#ifndef OHOS_INPUT_WINDOW_MONITOR_H
|
||||
#define OHOS_INPUT_WINDOW_MONITOR_H
|
||||
|
||||
#include <unordered_set>
|
||||
#include <input_manager.h>
|
||||
#include <refbase.h>
|
||||
|
||||
@@ -25,38 +26,7 @@ namespace OHOS {
|
||||
namespace Rosen {
|
||||
class InputWindowMonitor : public RefBase {
|
||||
public:
|
||||
InputWindowMonitor(sptr<WindowRoot>& root) : windowRoot_(root)
|
||||
{
|
||||
MMI::PhysicalDisplayInfo physicalDisplayInfo = {
|
||||
.id = 0, //todo: update when DMS is ready
|
||||
.leftDisplayId = -1, // todo: invalid displayId for testing
|
||||
.upDisplayId = -1, // todo: invalid displayId for testing
|
||||
.topLeftX = 0, // todo: use wgn info for testing
|
||||
.topLeftY = 0, // todo: use wgn info for testing
|
||||
.width = 2560, // todo: use wgn info for testing
|
||||
.height = 1600, // todo: use wgn info for testing
|
||||
.name = "physical_display0", // todo: wait for DMS
|
||||
.seatId = "seat0", // todo: update seatId
|
||||
.seatName = "default0", // todo: update seatId
|
||||
.logicWidth = 2560, // todo: use wgn info for testing
|
||||
.logicHeight = 1600, // todo: use wgn info for testing
|
||||
.direction = MMI::Direction0 // todo: use direction 0 for testing
|
||||
};
|
||||
physicalDisplays_.emplace_back(physicalDisplayInfo);
|
||||
MMI::LogicalDisplayInfo logicalDisplayInfo = {
|
||||
.id = 0, //todo: update when DMS is ready
|
||||
.topLeftX = 0, // todo: use wgn info for testing
|
||||
.topLeftY = 0, // todo: use wgn info for testing
|
||||
.width = 2560, // todo: use wgn info for testing
|
||||
.height = 1600, // todo: use wgn info for testing
|
||||
.name = "logical_display0", // todo: wait for DMS
|
||||
.seatId = "seat0", // todo: update seatId
|
||||
.seatName = "default0", // todo: update seatName
|
||||
.focusWindowId = -1,
|
||||
.windowsInfo_ = {},
|
||||
};
|
||||
logicalDisplays_.emplace_back(logicalDisplayInfo);
|
||||
}
|
||||
InputWindowMonitor(sptr<WindowRoot>& root) : windowRoot_(root) {}
|
||||
~InputWindowMonitor() = default;
|
||||
void UpdateInputWindow(uint32_t windowId);
|
||||
|
||||
@@ -64,8 +34,12 @@ private:
|
||||
sptr<WindowRoot> windowRoot_;
|
||||
std::vector<MMI::PhysicalDisplayInfo> physicalDisplays_;
|
||||
std::vector<MMI::LogicalDisplayInfo> logicalDisplays_;
|
||||
std::unordered_set<WindowType> windowTypeSkipped_ { WindowType::WINDOW_TYPE_POINTER};
|
||||
const int INVALID_DISPLAY_ID = -1;
|
||||
const int INVALID_WINDOW_ID = -1;
|
||||
void TraverseWindowNodes(const std::vector<sptr<WindowNode>>& windowNodes,
|
||||
std::vector<MMI::LogicalDisplayInfo>::iterator& iter);
|
||||
void UpdateDisplaysInfo(const sptr<WindowNodeContainer>& container);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ namespace OHOS {
|
||||
namespace Rosen {
|
||||
class WindowNodeContainer : public RefBase {
|
||||
public:
|
||||
WindowNodeContainer(uint64_t screenId, uint32_t width, uint32_t height)
|
||||
WindowNodeContainer(uint64_t screenId, uint32_t width, uint32_t height) : screenId_(screenId)
|
||||
{
|
||||
struct RSDisplayNodeConfig config = {screenId};
|
||||
displayNode_ = RSDisplayNode::Create(config);
|
||||
@@ -49,6 +49,8 @@ public:
|
||||
WMError MinimizeOtherFullScreenAbility(); // adapt to api7
|
||||
void TraverseContainer(std::vector<sptr<WindowNode>>& windowNodes);
|
||||
WMError LayoutWindowNodes();
|
||||
uint64_t GetScreenId() const;
|
||||
Rect GetDisplayRect() const;
|
||||
|
||||
private:
|
||||
void AssignZOrder(sptr<WindowNode>& node);
|
||||
@@ -67,6 +69,7 @@ private:
|
||||
std::shared_ptr<RSDisplayNode> displayNode_;
|
||||
std::vector<uint32_t> removedIds_;
|
||||
uint32_t zOrder_ { 0 };
|
||||
uint64_t screenId_ = 0;
|
||||
uint32_t focusedWindow_ { 0 };
|
||||
Rect displayRect_;
|
||||
WMError LayoutWindowNode(sptr<WindowNode>& node);
|
||||
|
||||
@@ -44,6 +44,7 @@ void InputWindowMonitor::UpdateInputWindow(uint32_t windowId)
|
||||
WLOGFE("can not get window node container.");
|
||||
return;
|
||||
}
|
||||
UpdateDisplaysInfo(container);
|
||||
std::vector<sptr<WindowNode>> windowNodes;
|
||||
container->TraverseContainer(windowNodes);
|
||||
|
||||
@@ -64,11 +65,66 @@ void InputWindowMonitor::UpdateInputWindow(uint32_t windowId)
|
||||
MMI::InputManager::GetInstance()->UpdateDisplayInfo(physicalDisplays_, logicalDisplays_);
|
||||
}
|
||||
|
||||
void InputWindowMonitor::UpdateDisplaysInfo(const sptr<WindowNodeContainer>& container)
|
||||
{
|
||||
MMI::PhysicalDisplayInfo physicalDisplayInfo = {
|
||||
.id = static_cast<int32_t>(container->GetScreenId()),
|
||||
.leftDisplayId = INVALID_DISPLAY_ID,
|
||||
.upDisplayId = INVALID_DISPLAY_ID,
|
||||
.topLeftX = container->GetDisplayRect().posX_,
|
||||
.topLeftY = container->GetDisplayRect().posY_,
|
||||
.width = static_cast<int32_t>(container->GetDisplayRect().width_),
|
||||
.height = static_cast<int32_t>(container->GetDisplayRect().height_),
|
||||
.name = "physical_display0",
|
||||
.seatId = "seat0",
|
||||
.seatName = "default0",
|
||||
.logicWidth = static_cast<int32_t>(container->GetDisplayRect().width_),
|
||||
.logicHeight = static_cast<int32_t>(container->GetDisplayRect().height_),
|
||||
.direction = MMI::Direction0
|
||||
};
|
||||
auto physicalDisplayIter = std::find_if(physicalDisplays_.begin(), physicalDisplays_.end(),
|
||||
[&physicalDisplayInfo](MMI::PhysicalDisplayInfo& physicalDisplay) {
|
||||
return physicalDisplay.id = physicalDisplayInfo.id;
|
||||
});
|
||||
if (physicalDisplayIter != physicalDisplays_.end()) {
|
||||
*physicalDisplayIter = physicalDisplayInfo;
|
||||
} else {
|
||||
physicalDisplays_.emplace_back(physicalDisplayInfo);
|
||||
}
|
||||
|
||||
MMI::LogicalDisplayInfo logicalDisplayInfo = {
|
||||
.id = static_cast<int32_t>(container->GetScreenId()),
|
||||
.topLeftX = container->GetDisplayRect().posX_,
|
||||
.topLeftY = container->GetDisplayRect().posY_,
|
||||
.width = static_cast<int32_t>(container->GetDisplayRect().width_),
|
||||
.height = static_cast<int32_t>(container->GetDisplayRect().height_),
|
||||
.name = "logical_display0",
|
||||
.seatId = "seat0",
|
||||
.seatName = "default0",
|
||||
.focusWindowId = INVALID_WINDOW_ID,
|
||||
.windowsInfo_ = {},
|
||||
};
|
||||
auto logicalDisplayIter = std::find_if(logicalDisplays_.begin(), logicalDisplays_.end(),
|
||||
[&logicalDisplayInfo](MMI::LogicalDisplayInfo& logicalDisplay) {
|
||||
return logicalDisplay.id = logicalDisplayInfo.id;
|
||||
});
|
||||
if (logicalDisplayIter != logicalDisplays_.end()) {
|
||||
*logicalDisplayIter = logicalDisplayInfo;
|
||||
} else {
|
||||
logicalDisplays_.emplace_back(logicalDisplayInfo);
|
||||
}
|
||||
}
|
||||
|
||||
void InputWindowMonitor::TraverseWindowNodes(const std::vector<sptr<WindowNode>> &windowNodes,
|
||||
std::vector<MMI::LogicalDisplayInfo>::iterator& iter)
|
||||
{
|
||||
iter->windowsInfo_.clear();
|
||||
for (auto& windowNode: windowNodes) {
|
||||
if (windowTypeSkipped_.find(windowNode->GetWindowProperty()->GetWindowType()) != windowTypeSkipped_.end()) {
|
||||
WLOGFI("window has been skipped. [id: %{public}d, type: %{public}d]", windowNode->GetWindowId(),
|
||||
windowNode->GetWindowProperty()->GetWindowType());
|
||||
continue;
|
||||
}
|
||||
MMI::WindowInfo windowInfo = {
|
||||
.id = static_cast<int32_t>(windowNode->GetWindowId()),
|
||||
.pid = windowNode->GetCallingPid(),
|
||||
|
||||
@@ -362,5 +362,15 @@ void WindowNodeContainer::TraverseWindowNode(sptr<WindowNode>& node, std::vector
|
||||
windowNodes.emplace_back(*iter);
|
||||
}
|
||||
}
|
||||
|
||||
uint64_t WindowNodeContainer::GetScreenId() const
|
||||
{
|
||||
return screenId_;
|
||||
}
|
||||
|
||||
Rect WindowNodeContainer::GetDisplayRect() const
|
||||
{
|
||||
return displayRect_;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user