fix rotate virtual display

Signed-off-by: l00574490 <liuqi149@huawei.com>
Change-Id: I9edc3bf3da8e989cfb0a00c654d081e64a06dabe
This commit is contained in:
l00574490
2022-05-30 09:53:55 +08:00
parent 22c6dc7142
commit fedb3553d5
3 changed files with 20 additions and 8 deletions
+7 -2
View File
@@ -626,8 +626,13 @@ bool AbstractScreenController::SetOrientation(ScreenId screenId, Orientation new
Rotation rotationAfter = screen->CalcRotation(newOrientation);
if (rotationAfter != screen->rotation_) {
WLOGI("set orientation. roatiton %{public}u", rotationAfter);
if (!rsInterface_.RequestRotation(screenId, static_cast<ScreenRotation>(rotationAfter))) {
WLOGE("rotate screen fail. %{public}" PRIu64"", screenId);
ScreenId rsScreenId;
if (!screenIdManager_.ConvertToRsScreenId(screenId, rsScreenId)) {
WLOGE("Convert to RsScreenId fail. screenId: %{public}" PRIu64"", screenId);
return false;
}
if (!rsInterface_.RequestRotation(rsScreenId, static_cast<ScreenRotation>(rotationAfter))) {
WLOGE("rotate screen fail. rsScreenId: %{public}" PRIu64"", rsScreenId);
return false;
}
} else {
+2 -2
View File
@@ -72,7 +72,7 @@ private:
WMError SetSystemBarProperty(uint32_t windowId, WindowType type, const SystemBarProperty& property);
WMError ResizeRect(uint32_t windowId, const Rect& rect, WindowSizeChangeReason reason);
WMError SetWindowMode(uint32_t windowId, WindowMode dstMode);
void ReSizeSystemBarPropertySizeIfNeed(sptr<WindowNode> node);
void ResizeSystemBarPropertySizeIfNeed(const sptr<WindowNode>& node);
void HandleTurnScreenOn(const sptr<WindowNode>& node);
void ProcessSystemBarChange(const sptr<DisplayInfo>& displayInfo);
void NotifyOutsidePressed(const sptr<WindowNode>& node);
@@ -80,7 +80,7 @@ private:
sptr<WindowRoot> windowRoot_;
sptr<InputWindowMonitor> inputWindowMonitor_;
std::atomic<uint32_t> windowId_ { INVALID_WINDOW_ID };
// Remove 'sysBarWinId_' after SystemUI resize 'systembar'
// Remove 'sysBarWinId_' after SystemUI resize 'systembar', systemBar only exist on default display currently
std::unordered_map<WindowType, uint32_t> sysBarWinId_ {
{ WindowType::WINDOW_TYPE_STATUS_BAR, INVALID_WINDOW_ID },
{ WindowType::WINDOW_TYPE_NAVIGATION_BAR, INVALID_WINDOW_ID },
+11 -4
View File
@@ -200,14 +200,14 @@ WMError WindowController::AddWindowNode(sptr<WindowProperty>& property)
if (node->GetWindowType() == WindowType::WINDOW_TYPE_STATUS_BAR ||
node->GetWindowType() == WindowType::WINDOW_TYPE_NAVIGATION_BAR) {
sysBarWinId_[node->GetWindowType()] = node->GetWindowId();
ReSizeSystemBarPropertySizeIfNeed(node);
ResizeSystemBarPropertySizeIfNeed(node);
}
StopBootAnimationIfNeed(node->GetWindowType());
MinimizeApp::ExecuteMinimizeAll();
return WMError::WM_OK;
}
void WindowController::ReSizeSystemBarPropertySizeIfNeed(sptr<WindowNode> node)
void WindowController::ResizeSystemBarPropertySizeIfNeed(const sptr<WindowNode>& node)
{
auto displayInfo = DisplayManagerServiceInner::GetInstance().GetDisplayById(node->GetDisplayId());
if (displayInfo == nullptr) {
@@ -441,14 +441,21 @@ void WindowController::ProcessSystemBarChange(const sptr<DisplayInfo>& displayIn
if (statusBarRectIter != systemBarRect_[WindowType::WINDOW_TYPE_STATUS_BAR][displayWidth].end()) {
newRect = statusBarRectIter->second;
}
ResizeRect(sysBarWinId_[WindowType::WINDOW_TYPE_STATUS_BAR], newRect, WindowSizeChangeReason::DRAG);
const auto& statusBarNode = windowRoot_->GetWindowNode(sysBarWinId_[WindowType::WINDOW_TYPE_STATUS_BAR]);
if (statusBarNode->GetDisplayId() == displayId) {
ResizeRect(sysBarWinId_[WindowType::WINDOW_TYPE_STATUS_BAR], newRect, WindowSizeChangeReason::DRAG);
}
newRect = { 0, displayInfo->GetHeight() - static_cast<int32_t>(height), width, height };
auto navigationBarRectIter =
systemBarRect_[WindowType::WINDOW_TYPE_NAVIGATION_BAR][displayWidth].find(displayHeight);
if (navigationBarRectIter != systemBarRect_[WindowType::WINDOW_TYPE_NAVIGATION_BAR][displayWidth].end()) {
newRect = navigationBarRectIter->second;
}
ResizeRect(sysBarWinId_[WindowType::WINDOW_TYPE_NAVIGATION_BAR], newRect, WindowSizeChangeReason::DRAG);
const auto& naviBarNode = windowRoot_->GetWindowNode(sysBarWinId_[WindowType::WINDOW_TYPE_NAVIGATION_BAR]);
if (naviBarNode->GetDisplayId() == displayId) {
ResizeRect(sysBarWinId_[WindowType::WINDOW_TYPE_NAVIGATION_BAR], newRect, WindowSizeChangeReason::DRAG);
}
}
void WindowController::ProcessDisplayChange(DisplayId displayId, DisplayStateChangeType type)