mirror of
https://github.com/openharmony/windowmanager.git
synced 2026-07-21 20:45:26 -04:00
fix display orientation
Signed-off-by: l00574490 <liuqi149@huawei.com> Change-Id: I040c73e37539a5acb65972562608c261c669a925
This commit is contained in:
@@ -41,7 +41,8 @@ private:
|
||||
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, DisplayId displayId);
|
||||
void UpdatePhysicalDisplayInfo(const sptr<DisplayInfo>& displayInfo, DisplayId displayId);
|
||||
void UpdateLogicalDisplayInfo(const sptr<DisplayInfo>& displayInfo, DisplayId displayId);
|
||||
void UpdateDisplayDirection(MMI::PhysicalDisplayInfo& physicalDisplayInfo, const sptr<DisplayInfo>& displayInfo);
|
||||
};
|
||||
}
|
||||
|
||||
@@ -96,7 +96,7 @@ public:
|
||||
void UpdateVirtualPixelRatio(DisplayId displayId, float virtualPixelRatio);
|
||||
void SetDisplaySize(DisplayId displayId, uint32_t width, uint32_t height);
|
||||
void SetDisplayVirtualPixelRatio(DisplayId displayId, float virtualPixelRatio);
|
||||
void SetDisplayOrientation(DisplayId displayId, Orientation orientation);
|
||||
void SetDisplayRotation(DisplayId displayId, Rotation rotation);
|
||||
void AddDisplay(const sptr<DisplayInfo>& displayInfo);
|
||||
void DeleteDisplay(const sptr<DisplayInfo>& displayInfo);
|
||||
sptr<DisplayInfo> GetDisplayInfo(DisplayId displayId);
|
||||
|
||||
@@ -57,7 +57,14 @@ void InputWindowMonitor::UpdateInputWindowByDisplayId(DisplayId displayId)
|
||||
WLOGFE("can not get window node container.");
|
||||
return;
|
||||
}
|
||||
UpdateDisplaysInfo(container, displayId);
|
||||
|
||||
auto displayInfo = container->GetDisplayInfo(displayId);
|
||||
if (displayInfo == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
UpdatePhysicalDisplayInfo(displayInfo, displayId);
|
||||
UpdateLogicalDisplayInfo(displayInfo, displayId);
|
||||
std::vector<sptr<WindowNode>> windowNodes;
|
||||
container->TraverseContainer(windowNodes);
|
||||
auto iter = std::find_if(logicalDisplays_.begin(), logicalDisplays_.end(),
|
||||
@@ -77,26 +84,29 @@ void InputWindowMonitor::UpdateInputWindowByDisplayId(DisplayId displayId)
|
||||
MMI::InputManager::GetInstance()->UpdateDisplayInfo(physicalDisplays_, logicalDisplays_);
|
||||
}
|
||||
|
||||
void InputWindowMonitor::UpdateDisplaysInfo(const sptr<WindowNodeContainer>& container, DisplayId displayId)
|
||||
void InputWindowMonitor::UpdatePhysicalDisplayInfo(const sptr<DisplayInfo>& displayInfo, DisplayId displayId)
|
||||
{
|
||||
sptr<DisplayInfo> displayInfo = container->GetDisplayInfo(displayId);
|
||||
if (displayInfo == nullptr) {
|
||||
return;
|
||||
uint32_t physicalWidth = displayInfo->GetWidth();
|
||||
uint32_t physicalHeight = displayInfo->GetHeight();
|
||||
if (displayInfo->GetRotation() == Rotation::ROTATION_90 || displayInfo->GetRotation() == Rotation::ROTATION_270) {
|
||||
std::swap(physicalWidth, physicalHeight);
|
||||
}
|
||||
|
||||
MMI::PhysicalDisplayInfo physicalDisplayInfo = {
|
||||
.id = static_cast<int32_t>(displayInfo->GetDisplayId()),
|
||||
.id = static_cast<int32_t>(displayId),
|
||||
.leftDisplayId = static_cast<int32_t>(DISPLAY_ID_INVALID),
|
||||
.upDisplayId = static_cast<int32_t>(DISPLAY_ID_INVALID),
|
||||
.topLeftX = 0,
|
||||
.topLeftY = 0,
|
||||
.width = static_cast<int32_t>(displayInfo->GetWidth()),
|
||||
.height = static_cast<int32_t>(displayInfo->GetHeight()),
|
||||
.width = static_cast<int32_t>(physicalWidth),
|
||||
.height = static_cast<int32_t>(physicalHeight),
|
||||
.name = "physical_display0",
|
||||
.seatId = "seat0",
|
||||
.seatName = "default0",
|
||||
.logicWidth = static_cast<int32_t>(displayInfo->GetWidth()),
|
||||
.logicHeight = static_cast<int32_t>(displayInfo->GetHeight()),
|
||||
.logicWidth = static_cast<int32_t>(physicalWidth),
|
||||
.logicHeight = static_cast<int32_t>(physicalHeight),
|
||||
};
|
||||
|
||||
UpdateDisplayDirection(physicalDisplayInfo, displayInfo);
|
||||
auto physicalDisplayIter = std::find_if(physicalDisplays_.begin(), physicalDisplays_.end(),
|
||||
[&physicalDisplayInfo](MMI::PhysicalDisplayInfo& physicalDisplay) {
|
||||
@@ -107,9 +117,12 @@ void InputWindowMonitor::UpdateDisplaysInfo(const sptr<WindowNodeContainer>& con
|
||||
} else {
|
||||
physicalDisplays_.emplace_back(physicalDisplayInfo);
|
||||
}
|
||||
}
|
||||
|
||||
void InputWindowMonitor::UpdateLogicalDisplayInfo(const sptr<DisplayInfo>& displayInfo, DisplayId displayId)
|
||||
{
|
||||
MMI::LogicalDisplayInfo logicalDisplayInfo = {
|
||||
.id = static_cast<int32_t>(container->GetScreenId(displayId)),
|
||||
.id = static_cast<int32_t>(displayId),
|
||||
.topLeftX = displayInfo->GetOffsetX(),
|
||||
.topLeftY = displayInfo->GetOffsetY(),
|
||||
.width = static_cast<int32_t>(displayInfo->GetWidth()),
|
||||
|
||||
@@ -54,6 +54,9 @@ void WindowLayoutPolicy::UpdateDisplayInfo(const std::map<DisplayId, Rect>& disp
|
||||
displayRectMap_.insert(displayRect);
|
||||
}
|
||||
Launch();
|
||||
for (auto& displayRect : displayRectMap) {
|
||||
LayoutWindowTree(displayRect.first);
|
||||
}
|
||||
}
|
||||
|
||||
void WindowLayoutPolicy::LayoutWindowNodesByRootType(const std::vector<sptr<WindowNode>>& nodeVec)
|
||||
|
||||
@@ -1690,18 +1690,18 @@ void WindowNodeContainer::SetDisplaySize(DisplayId displayId, uint32_t width, ui
|
||||
return;
|
||||
}
|
||||
displayInfosMap_[displayId]->SetWidth(width);
|
||||
displayInfosMap_[displayId]->SetHeight(width);
|
||||
displayInfosMap_[displayId]->SetHeight(height);
|
||||
displayRectMap_[displayId].width_ = width;
|
||||
displayRectMap_[displayId].height_ = height;
|
||||
layoutPolicy_->UpdateDisplayInfo(displayRectMap_);
|
||||
}
|
||||
|
||||
void WindowNodeContainer::SetDisplayOrientation(DisplayId displayId, Orientation orientation)
|
||||
void WindowNodeContainer::SetDisplayRotation(DisplayId displayId, Rotation rotation)
|
||||
{
|
||||
if (displayInfosMap_.find(displayId) == std::end(displayInfosMap_)) {
|
||||
return;
|
||||
}
|
||||
displayInfosMap_[displayId]->SetOrientation(orientation);
|
||||
displayInfosMap_[displayId]->SetRotation(rotation);
|
||||
}
|
||||
|
||||
void WindowNodeContainer::SetDisplayVirtualPixelRatio(DisplayId displayId, float virtualPixelRatio)
|
||||
|
||||
@@ -946,8 +946,8 @@ void WindowRoot::ProcessDisplayChange(const sptr<DisplayInfo>& displayInfo, Disp
|
||||
switch (type) {
|
||||
case DisplayStateChangeType::SIZE_CHANGE:
|
||||
case DisplayStateChangeType::UPDATE_ROTATION: {
|
||||
WLOGFI("update display: %{public}" PRIu64" rotation", displayId);
|
||||
container->SetDisplayOrientation(displayId, displayInfo->GetOrientation());
|
||||
WLOGFI("update display: %{public}" PRIu64", rotation: %{public}u", displayId, displayInfo->GetRotation());
|
||||
container->SetDisplayRotation(displayId, displayInfo->GetRotation());
|
||||
container->SetDisplaySize(displayId, displayInfo->GetWidth(), displayInfo->GetHeight());
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user