modify orientation 180, window size should not change

Signed-off-by: leafly2021 <figo.yefei@huawei.com>
Change-Id: I1c87bcd81df66cbb5ec018ec98913591cb920f84
This commit is contained in:
leafly2021 2023-03-01 16:11:13 +08:00
parent 21ebf5ad72
commit 3062ae5e00
6 changed files with 26 additions and 24 deletions

View File

@ -296,10 +296,9 @@ public:
bool Marshalling(Parcel& parcel) const
{
return parcel.WriteFloat(pivotX_) && parcel.WriteFloat(pivotY_) &&
parcel.WriteFloat(scaleX_) && parcel.WriteFloat(scaleY_) && parcel.WriteFloat(scaleZ_) &&
parcel.WriteFloat(rotationX_) && parcel.WriteFloat(rotationY_) &&
parcel.WriteFloat(rotationZ_) && parcel.WriteFloat(translateX_) &&
parcel.WriteFloat(translateY_) && parcel.WriteFloat(translateZ_);
parcel.WriteFloat(scaleX_) && parcel.WriteFloat(scaleY_) && parcel.WriteFloat(scaleZ_) &&
parcel.WriteFloat(rotationX_) && parcel.WriteFloat(rotationY_) && parcel.WriteFloat(rotationZ_) &&
parcel.WriteFloat(translateX_) && parcel.WriteFloat(translateY_) && parcel.WriteFloat(translateZ_);
}
void Unmarshalling(Parcel& parcel)

View File

@ -87,17 +87,17 @@ HWTEST_F(WindowDisplayZoomTest, DisplayZoom01, Function | MediumTest | Level3)
Rect rect = window->GetRect();
expect.pivotX_ = (0 - rect.posX_) * 1.0 / rect.width_;
expect.pivotY_ = (0 - rect.posY_) * 1.0 / rect.height_;
expect.scaleX_ = expect.scaleY_ = 2;
expect.scaleX_ = expect.scaleY_ = 2; // scale value
ASSERT_TRUE(expect == implPtr->GetWindowProperty()->GetZoomTransform());
WindowAccessibilityController::GetInstance().SetAnchorAndScale(0, 0, 2);
sleep(1);
expect.scaleX_ = expect.scaleY_ = 4;
expect.scaleX_ = expect.scaleY_ = 4; // scale value
ASSERT_TRUE(expect == implPtr->GetWindowProperty()->GetZoomTransform());
WindowAccessibilityController::GetInstance().SetAnchorAndScale(0, 0, 0.5);
sleep(1);
expect.scaleX_ = expect.scaleY_ = 2;
expect.scaleX_ = expect.scaleY_ = 2; // scale value
ASSERT_TRUE(expect == implPtr->GetWindowProperty()->GetZoomTransform());
WindowAccessibilityController::GetInstance().SetAnchorAndScale(0, 0, 0.1);
@ -134,8 +134,8 @@ HWTEST_F(WindowDisplayZoomTest, DisplayZoom02, Function | MediumTest | Level3)
Rect rect = window->GetRect();
expect.pivotX_ = (0 - rect.posX_) * 1.0 / rect.width_;
expect.pivotY_ = (0 - rect.posY_) * 1.0 / rect.height_;
expect.scaleX_ = expect.scaleY_ = 2;
expect.translateX_ = expect.translateY_ = -100;
expect.scaleX_ = expect.scaleY_ = 2; // scale value
expect.translateX_ = expect.translateY_ = -100; // translate value
WindowAccessibilityController::GetInstance().SetAnchorOffset(200, 200);
sleep(1);
@ -192,7 +192,7 @@ HWTEST_F(WindowDisplayZoomTest, DisplayZoom04, Function | MediumTest | Level3)
Rect rect = window->GetRect();
expect.pivotX_ = (0 - rect.posX_) * 1.0 / rect.width_;
expect.pivotY_ = (0 - rect.posY_) * 1.0 / rect.height_;
expect.scaleX_ = expect.scaleY_ = 2;
expect.scaleX_ = expect.scaleY_ = 2; // scale value
ASSERT_TRUE(expect == implPtr->GetWindowProperty()->GetZoomTransform());
ASSERT_EQ(WMError::WM_OK, window->Hide());;
@ -226,8 +226,8 @@ HWTEST_F(WindowDisplayZoomTest, DisplayZoom05, Function | MediumTest | Level3)
ASSERT_EQ(WMError::WM_OK, window->Show());
Transform animate;
animate.translateX_ = -100;
animate.translateZ_ = 100;
animate.translateX_ = -100; // translate x value
animate.translateZ_ = 100; // translate z value
window->SetTransform(animate);
sleep(1);
@ -235,7 +235,7 @@ HWTEST_F(WindowDisplayZoomTest, DisplayZoom05, Function | MediumTest | Level3)
Rect rect = window->GetRect();
expect.pivotX_ = (0 - rect.posX_) * 1.0 / rect.width_;
expect.pivotY_ = (0 - rect.posY_) * 1.0 / rect.height_;
expect.scaleX_ = expect.scaleY_ = 1.7;
expect.scaleX_ = expect.scaleY_ = 1.7; // scale value
Transform actual = implPtr->GetWindowProperty()->GetZoomTransform();
auto isExpec = [](float a, float b) -> bool {

View File

@ -44,9 +44,9 @@ public:
static bool IsExpectedRotateLandscapeWindow(Orientation requestOrientation,
DisplayOrientation currentOrientation, uint32_t flags);
static bool IsExpectedRotatableWindow(Orientation requestOrientation,
DisplayOrientation currentOrientation, WindowMode mode, uint32_t flags);
DisplayOrientation currentOrientation, WindowMode mode, uint32_t flags, bool restricted = true);
static bool IsExpectedRotatableWindow(Orientation requestOrientation,
DisplayOrientation currentOrientation, uint32_t flags);
DisplayOrientation currentOrientation, uint32_t flags, bool restricted = true);
};
}
}

View File

@ -89,7 +89,7 @@ sptr<WindowNode> StartingWindow::CreateWindowNode(const sptr<WindowTransitionInf
property->SetWindowType(info->GetWindowType());
auto displayInfo = DisplayGroupInfo::GetInstance().GetDisplayInfo(info->GetDisplayId());
if (!(displayInfo && WmsUtils::IsExpectedRotatableWindow(orientation,
displayInfo->GetDisplayOrientation(), property->GetWindowMode(), property->GetWindowFlags()))) {
displayInfo->GetDisplayOrientation(), property->GetWindowMode(), property->GetWindowFlags(), false))) {
property->AddWindowFlag(WindowFlag::WINDOW_FLAG_NEED_AVOID);
}
if (info->GetShowFlagWhenLocked()) {

View File

@ -48,16 +48,16 @@ bool WmsUtils::IsExpectedRotateLandscapeWindow(Orientation requestOrientation,
}
bool WmsUtils::IsExpectedRotatableWindow(Orientation requestOrientation,
DisplayOrientation currentOrientation, WindowMode mode, uint32_t flags)
DisplayOrientation currentOrientation, WindowMode mode, uint32_t flags, bool restricted)
{
if (mode != WindowMode::WINDOW_MODE_FULLSCREEN) {
return false;
}
return IsExpectedRotatableWindow(requestOrientation, currentOrientation, flags);
return IsExpectedRotatableWindow(requestOrientation, currentOrientation, flags, restricted);
}
bool WmsUtils::IsExpectedRotatableWindow(Orientation requestOrientation,
DisplayOrientation currentOrientation, uint32_t flags)
DisplayOrientation currentOrientation, uint32_t flags, bool restricted)
{
if (!FIX_ORIENTATION_ENABLE) {
return false;
@ -69,10 +69,13 @@ bool WmsUtils::IsExpectedRotatableWindow(Orientation requestOrientation,
return false;
}
DisplayOrientation disOrientation = WINDOW_TO_DISPLAY_ORIENTATION_MAP.at(requestOrientation);
if (disOrientation != currentOrientation) {
return true;
if (disOrientation == currentOrientation) {
return false;
}
return false;
if (restricted && (static_cast<int32_t>(disOrientation) - static_cast<int32_t>(currentOrientation)) % 2 == 0) {
return false;
}
return true;
}
}
}

View File

@ -767,12 +767,12 @@ void WindowRoot::UpdateDisplayOrientationWhenHideWindow(sptr<WindowNode>& node)
WLOGFD("[FixOrientation] begin");
auto container = GetOrCreateWindowNodeContainer(node->GetDisplayId());
if (container == nullptr) {
WLOGFE("[FixOrientation]failed, window container could not be found");
WLOGFE("[FixOrientation] failed, window container could not be found");
return;
}
auto nextRotatableWindow = container->GetNextRotatableWindow(node->GetWindowId());
if (nextRotatableWindow != nullptr) {
WLOGFD("[FixOrientation] nexi rotatable window: %{public}u", nextRotatableWindow->GetWindowId());
WLOGFD("[FixOrientation] next rotatable window: %{public}u", nextRotatableWindow->GetWindowId());
SetDisplayOrientationFromWindow(nextRotatableWindow, false);
}
}