From 79d4ad64e6b7490b4010c5bfefe169388b01284e Mon Sep 17 00:00:00 2001 From: gaoguanghui Date: Mon, 28 Aug 2023 23:29:17 +0800 Subject: [PATCH] fix XTS bug Signed-off-by: gaoguanghui Change-Id: I2e113ace9d95d2911d8fbe0c1a79bf33e39c79c1 --- .../session/screen/include/screen_session.h | 1 + .../session/screen/src/screen_session.cpp | 30 +++++++++++++++++++ .../src/scene_session_manager.cpp | 2 -- 3 files changed, 31 insertions(+), 2 deletions(-) diff --git a/window_scene/session/screen/include/screen_session.h b/window_scene/session/screen/include/screen_session.h index bff22fbddd..29164984f2 100644 --- a/window_scene/session/screen/include/screen_session.h +++ b/window_scene/session/screen/include/screen_session.h @@ -85,6 +85,7 @@ public: void ReleaseDisplayNode(); Rotation CalcRotation(Orientation orientation) const; + DisplayOrientation CalcDisplayOrientation(Rotation rotation) const; void FillScreenInfo(sptr info) const; void InitRSDisplayNode(RSDisplayNodeConfig& config, Point& startPoint); diff --git a/window_scene/session/screen/src/screen_session.cpp b/window_scene/session/screen/src/screen_session.cpp index 195e9f0d14..283ad8e107 100644 --- a/window_scene/session/screen/src/screen_session.cpp +++ b/window_scene/session/screen/src/screen_session.cpp @@ -257,6 +257,8 @@ void ScreenSession::UpdatePropertyAfterRotation(RRect bounds, int rotation) targetRotation = Rotation::ROTATION_0; break; } + DisplayOrientation displayOrientation = CalcDisplayOrientation(targetRotation); + property_.SetDisplayOrientation(displayOrientation); property_.SetBounds(bounds); property_.SetRotation(static_cast(rotation)); property_.UpdateScreenRotation(targetRotation); @@ -350,6 +352,34 @@ Rotation ScreenSession::CalcRotation(Orientation orientation) const } } +DisplayOrientation ScreenSession::CalcDisplayOrientation(Rotation rotation) const +{ + sptr info = GetActiveScreenMode(); + if (info == nullptr) { + return DisplayOrientation::UNKNOWN; + } + // vertical: phone(Plugin screen); horizontal: pad & external screen + bool isVerticalScreen = info->width_ < info->height_; + switch (rotation) { + case Rotation::ROTATION_0: { + return isVerticalScreen ? DisplayOrientation::PORTRAIT : DisplayOrientation::LANDSCAPE; + } + case Rotation::ROTATION_90: { + return isVerticalScreen ? DisplayOrientation::LANDSCAPE : DisplayOrientation::PORTRAIT; + } + case Rotation::ROTATION_180: { + return isVerticalScreen ? DisplayOrientation::PORTRAIT_INVERTED : DisplayOrientation::LANDSCAPE_INVERTED; + } + case Rotation::ROTATION_270: { + return isVerticalScreen ? DisplayOrientation::LANDSCAPE_INVERTED : DisplayOrientation::PORTRAIT_INVERTED; + } + default: { + WLOGE("unknown rotation %{public}u", rotation); + return DisplayOrientation::UNKNOWN; + } + } +} + ScreenSourceMode ScreenSession::GetSourceMode() const { if (screenId_ == defaultScreenId_) { diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index 264c725640..52f993e838 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -1637,8 +1637,6 @@ void SceneSessionManager::HandleUpdateProperty(const sptr break; } case WSPropertyChangeAction::ACTION_UPDATE_ORIENTATION: { - ScreenSessionManager::GetInstance(). - SetOrientationFromWindow(property->GetDisplayId(), property->GetRequestedOrientation()); sceneSession->SetRequestedOrientation(property->GetRequestedOrientation()); break; } -- Gitee