mirror of
https://github.com/openharmony/windowmanager.git
synced 2026-08-26 21:31:14 -04:00
add st for window mode support
Signed-off-by: zhirong <215782872@qq.com> Change-Id: I57724f0b6dadd4e5469643db74812380634338b5 Signed-off-by: zhirong <215782872@qq.com>
This commit is contained in:
@@ -217,6 +217,7 @@ public:
|
||||
virtual void SetRequestedOrientation(Orientation) = 0;
|
||||
virtual Orientation GetRequestedOrientation() = 0;
|
||||
virtual void SetModeSupportInfo(uint32_t modeSupportInfo) = 0;
|
||||
virtual uint32_t GetModeSupportInfo() const = 0;
|
||||
|
||||
virtual bool IsDecorEnable() const = 0;
|
||||
virtual WMError Maximize() = 0;
|
||||
|
||||
@@ -546,6 +546,7 @@ bool WindowProperty::WriteMemberVariable(Parcel& parcel, const MemberVariable& m
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void WindowProperty::ReadMemberVariable(Parcel& parcel, const MemberVariable& mv)
|
||||
{
|
||||
void* mvData = reinterpret_cast<uint8_t*>(this) + mv.offset_;
|
||||
|
||||
@@ -94,7 +94,7 @@ public:
|
||||
virtual const std::string& GetWindowName() const override;
|
||||
virtual uint32_t GetWindowId() const override;
|
||||
virtual uint32_t GetWindowFlags() const override;
|
||||
uint32_t GetModeSupportInfo() const;
|
||||
uint32_t GetModeSupportInfo() const override;
|
||||
inline NotifyNativeWinDestroyFunc GetNativeDestroyCallback()
|
||||
{
|
||||
return notifyNativefunc_;
|
||||
|
||||
@@ -1479,10 +1479,9 @@ void WindowImpl::UpdateRect(const struct Rect& rect, bool decoStatus, WindowSize
|
||||
Rect rectToAce = rect;
|
||||
// update rectToAce for stretchable window
|
||||
if (windowSystemConfig_.isStretchable_ && WindowHelper::IsMainFloatingWindow(GetType(), GetMode())) {
|
||||
if (reason == WindowSizeChangeReason::DRAG ||
|
||||
reason == WindowSizeChangeReason::DRAG_END ||
|
||||
reason == WindowSizeChangeReason::DRAG_START ||
|
||||
reason == WindowSizeChangeReason::RECOVER) {
|
||||
if (reason == WindowSizeChangeReason::DRAG || reason == WindowSizeChangeReason::DRAG_END ||
|
||||
reason == WindowSizeChangeReason::DRAG_START || reason == WindowSizeChangeReason::RECOVER ||
|
||||
reason == WindowSizeChangeReason::MOVE) {
|
||||
rectToAce = originRect;
|
||||
} else {
|
||||
property_->SetOriginRect(rect);
|
||||
|
||||
@@ -27,6 +27,7 @@ group("systemtest") {
|
||||
":wm_window_immersive_test",
|
||||
":wm_window_input_method_test",
|
||||
":wm_window_layout_test",
|
||||
":wm_window_mode_support_info_test",
|
||||
":wm_window_move_drag_test",
|
||||
":wm_window_multi_ability_test",
|
||||
":wm_window_occupied_area_change_test",
|
||||
@@ -219,6 +220,17 @@ ohos_systemtest("wm_window_outside_pressed_test") {
|
||||
|
||||
## SystemTest wm_window_outside_pressed_test }}}
|
||||
|
||||
## SystemTest wm_window_mode_support_info_test {{{
|
||||
ohos_systemtest("wm_window_mode_support_info_test") {
|
||||
module_out_path = module_out_path
|
||||
|
||||
sources = [ "window_mode_support_info_test.cpp" ]
|
||||
|
||||
deps = [ ":wm_systemtest_common" ]
|
||||
}
|
||||
|
||||
## SystemTest wm_window_mode_support_info_test }}}
|
||||
|
||||
## Build wm_systemtest_common.a {{{
|
||||
config("wm_systemtest_common_public_config") {
|
||||
include_dirs = [
|
||||
|
||||
@@ -0,0 +1,237 @@
|
||||
/*
|
||||
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
// gtest
|
||||
#include <gtest/gtest.h>
|
||||
#include "window_manager.h"
|
||||
#include "window_test_utils.h"
|
||||
using namespace testing;
|
||||
using namespace testing::ext;
|
||||
|
||||
namespace OHOS {
|
||||
namespace Rosen {
|
||||
using utils = WindowTestUtils;
|
||||
class WindowModeSupportInfoTest : public testing::Test {
|
||||
public:
|
||||
static void SetUpTestCase();
|
||||
static void TearDownTestCase();
|
||||
virtual void SetUp() override;
|
||||
virtual void TearDown() override;
|
||||
utils::TestWindowInfo fullScreenAppInfo_;
|
||||
utils::TestWindowInfo floatingScreenAppInfo_;
|
||||
private:
|
||||
static constexpr uint32_t WAIT_SYANC_US = 100000;
|
||||
};
|
||||
|
||||
void WindowModeSupportInfoTest::SetUpTestCase()
|
||||
{
|
||||
auto display = DisplayManager::GetInstance().GetDisplayById(0);
|
||||
ASSERT_TRUE((display != nullptr));
|
||||
Rect displayRect = {0, 0, display->GetWidth(), display->GetHeight()};
|
||||
utils::InitByDisplayRect(displayRect);
|
||||
}
|
||||
|
||||
void WindowModeSupportInfoTest::TearDownTestCase()
|
||||
{
|
||||
}
|
||||
|
||||
void WindowModeSupportInfoTest::SetUp()
|
||||
{
|
||||
fullScreenAppInfo_ = {
|
||||
.name = "FullWindow",
|
||||
.rect = utils::customAppRect_,
|
||||
.type = WindowType::WINDOW_TYPE_APP_MAIN_WINDOW,
|
||||
.mode = WindowMode::WINDOW_MODE_FULLSCREEN,
|
||||
.needAvoid = false,
|
||||
.parentLimit = false,
|
||||
.parentName = "",
|
||||
};
|
||||
floatingScreenAppInfo_ = {
|
||||
.name = "FloatingWindow",
|
||||
.rect = utils::customAppRect_,
|
||||
.type = WindowType::WINDOW_TYPE_APP_MAIN_WINDOW,
|
||||
.mode = WindowMode::WINDOW_MODE_FULLSCREEN,
|
||||
.needAvoid = false,
|
||||
.parentLimit = false,
|
||||
.parentName = "",
|
||||
};
|
||||
}
|
||||
|
||||
void WindowModeSupportInfoTest::TearDown()
|
||||
{
|
||||
}
|
||||
|
||||
namespace {
|
||||
/**
|
||||
* @tc.name: WindowModeSupportInfo01
|
||||
* @tc.desc: SetModeSupportInfo | GetModeSupportInfo
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(WindowModeSupportInfoTest, WindowModeSupportInfo01, Function | MediumTest | Level3)
|
||||
{
|
||||
const sptr<Window>& window = utils::CreateTestWindow(fullScreenAppInfo_);
|
||||
|
||||
window->SetModeSupportInfo(WindowModeSupport::WINDOW_MODE_SUPPORT_FULLSCREEN);
|
||||
ASSERT_EQ(WindowModeSupport::WINDOW_MODE_SUPPORT_FULLSCREEN, window->GetModeSupportInfo());
|
||||
window->Destroy();
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: WindowModeSupportInfo02
|
||||
* @tc.desc: modeSupportInfo test for single window
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(WindowModeSupportInfoTest, WindowModeSupportInfo02, Function | MediumTest | Level3)
|
||||
{
|
||||
const sptr<Window>& window = utils::CreateTestWindow(fullScreenAppInfo_);
|
||||
|
||||
window->SetModeSupportInfo(WindowModeSupport::WINDOW_MODE_SUPPORT_FULLSCREEN |
|
||||
WindowModeSupport::WINDOW_MODE_SUPPORT_FLOATING);
|
||||
ASSERT_EQ(WMError::WM_OK, window->Show());
|
||||
ASSERT_EQ(WindowMode::WINDOW_MODE_FULLSCREEN, window->GetMode());
|
||||
ASSERT_EQ(WMError::WM_OK, window->Hide());
|
||||
|
||||
window->SetWindowMode(WindowMode::WINDOW_MODE_FLOATING);
|
||||
ASSERT_EQ(WMError::WM_OK, window->Show());
|
||||
ASSERT_EQ(WindowMode::WINDOW_MODE_FLOATING, window->GetMode());
|
||||
ASSERT_EQ(WMError::WM_OK, window->Hide());
|
||||
|
||||
window->SetWindowMode(WindowMode::WINDOW_MODE_FULLSCREEN);
|
||||
ASSERT_EQ(WMError::WM_OK, window->Show());
|
||||
ASSERT_EQ(WindowMode::WINDOW_MODE_FULLSCREEN, window->GetMode());
|
||||
ASSERT_EQ(WMError::WM_OK, window->Hide());
|
||||
|
||||
window->SetWindowMode(WindowMode::WINDOW_MODE_SPLIT_PRIMARY);
|
||||
ASSERT_EQ(WMError::WM_OK, window->Show());
|
||||
ASSERT_EQ(WindowMode::WINDOW_MODE_FULLSCREEN, window->GetMode());
|
||||
ASSERT_EQ(WMError::WM_OK, window->Hide());
|
||||
|
||||
window->SetWindowMode(WindowMode::WINDOW_MODE_SPLIT_SECONDARY);
|
||||
ASSERT_EQ(WMError::WM_OK, window->Show());
|
||||
ASSERT_EQ(WindowMode::WINDOW_MODE_FULLSCREEN, window->GetMode());
|
||||
ASSERT_EQ(WMError::WM_OK, window->Hide());
|
||||
|
||||
window->Destroy();
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: WindowModeSupportInfo03
|
||||
* @tc.desc: modeSupportInfo test for single window in case current window mode is not supported.
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(WindowModeSupportInfoTest, WindowModeSupportInfo03, Function | MediumTest | Level3)
|
||||
{
|
||||
const sptr<Window>& window = utils::CreateTestWindow(fullScreenAppInfo_);
|
||||
window->SetModeSupportInfo(WindowModeSupport::WINDOW_MODE_SUPPORT_FLOATING |
|
||||
WindowModeSupport::WINDOW_MODE_SUPPORT_SPLIT_PRIMARY |
|
||||
WindowModeSupport::WINDOW_MODE_SUPPORT_SPLIT_SECONDARY);
|
||||
ASSERT_EQ(WMError::WM_OK, window->Show());
|
||||
ASSERT_EQ(WindowMode::WINDOW_MODE_FLOATING, window->GetMode());
|
||||
ASSERT_EQ(WMError::WM_OK, window->Hide());
|
||||
|
||||
window->SetModeSupportInfo(WindowModeSupport::WINDOW_MODE_SUPPORT_SPLIT_PRIMARY |
|
||||
WindowModeSupport::WINDOW_MODE_SUPPORT_SPLIT_SECONDARY);
|
||||
ASSERT_EQ(WMError::WM_OK, window->Show());
|
||||
ASSERT_EQ(WindowMode::WINDOW_MODE_SPLIT_PRIMARY, window->GetMode());
|
||||
ASSERT_EQ(WMError::WM_OK, window->Hide());
|
||||
|
||||
window->Destroy();
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: WindowModeSupportInfo04
|
||||
* @tc.desc: modeSupportInfo test for layout cascade
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(WindowModeSupportInfoTest, WindowModeSupportInfo04, Function | MediumTest | Level3)
|
||||
{
|
||||
const sptr<Window>& window1 = utils::CreateTestWindow(fullScreenAppInfo_);
|
||||
window1->SetModeSupportInfo(WindowModeSupport::WINDOW_MODE_SUPPORT_FULLSCREEN);
|
||||
const sptr<Window>& window2 = utils::CreateTestWindow(utils::TestWindowInfo {
|
||||
.name = "FullWindow2",
|
||||
.rect = utils::customAppRect_,
|
||||
.type = WindowType::WINDOW_TYPE_APP_MAIN_WINDOW,
|
||||
.mode = WindowMode::WINDOW_MODE_FULLSCREEN,
|
||||
.needAvoid = false,
|
||||
.parentLimit = false,
|
||||
.parentName = "",
|
||||
});
|
||||
window2->SetModeSupportInfo(WindowModeSupport::WINDOW_MODE_SUPPORT_ALL);
|
||||
ASSERT_EQ(WMError::WM_OK, window1->Show());
|
||||
ASSERT_EQ(WMError::WM_OK, window2->Show());
|
||||
WindowManager::GetInstance().SetWindowLayoutMode(WindowLayoutMode::CASCADE);
|
||||
usleep(WAIT_SYANC_US);
|
||||
|
||||
ASSERT_EQ(WindowMode::WINDOW_MODE_FULLSCREEN, window1->GetMode());
|
||||
ASSERT_EQ(WindowMode::WINDOW_MODE_FLOATING, window2->GetMode());
|
||||
|
||||
window1->Destroy();
|
||||
window2->Destroy();
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: WindowModeSupportInfo05
|
||||
* @tc.desc: modeSupportInfo test for layout tile
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(WindowModeSupportInfoTest, WindowModeSupportInfo05, Function | MediumTest | Level3)
|
||||
{
|
||||
const sptr<Window>& window = utils::CreateTestWindow(fullScreenAppInfo_);
|
||||
window->SetModeSupportInfo(WindowModeSupport::WINDOW_MODE_SUPPORT_FULLSCREEN);
|
||||
ASSERT_EQ(WMError::WM_OK, window->Show());
|
||||
WindowManager::GetInstance().SetWindowLayoutMode(WindowLayoutMode::TILE);
|
||||
usleep(WAIT_SYANC_US);
|
||||
|
||||
ASSERT_EQ(WindowMode::WINDOW_MODE_FULLSCREEN, window->GetMode());
|
||||
|
||||
window->Destroy();
|
||||
WindowManager::GetInstance().SetWindowLayoutMode(WindowLayoutMode::CASCADE);
|
||||
usleep(WAIT_SYANC_US);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: WindowModeSupportInfo06
|
||||
* @tc.desc: modeSupportInfo test for split
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(WindowModeSupportInfoTest, WindowModeSupportInfo06, Function | MediumTest | Level3)
|
||||
{
|
||||
const sptr<Window>& window1 = utils::CreateTestWindow(fullScreenAppInfo_);
|
||||
window1->SetModeSupportInfo(WindowModeSupport::WINDOW_MODE_SUPPORT_ALL);
|
||||
const sptr<Window>& window2 = utils::CreateTestWindow(utils::TestWindowInfo {
|
||||
.name = "FullWindow2",
|
||||
.rect = utils::customAppRect_,
|
||||
.type = WindowType::WINDOW_TYPE_APP_MAIN_WINDOW,
|
||||
.mode = WindowMode::WINDOW_MODE_FULLSCREEN,
|
||||
.needAvoid = false,
|
||||
.parentLimit = false,
|
||||
.parentName = "",
|
||||
});
|
||||
window2->SetModeSupportInfo(WindowModeSupport::WINDOW_MODE_SUPPORT_FULLSCREEN);
|
||||
ASSERT_EQ(WMError::WM_OK, window1->Show());
|
||||
ASSERT_EQ(WMError::WM_OK, window2->Show());
|
||||
usleep(WAIT_SYANC_US);
|
||||
|
||||
window1->SetWindowMode(WindowMode::WINDOW_MODE_SPLIT_PRIMARY);
|
||||
|
||||
ASSERT_EQ(WindowMode::WINDOW_MODE_SPLIT_PRIMARY, window1->GetMode());
|
||||
ASSERT_EQ(WindowMode::WINDOW_MODE_FULLSCREEN, window2->GetMode());
|
||||
|
||||
window1->Destroy();
|
||||
window2->Destroy();
|
||||
}
|
||||
} // namespace
|
||||
} // namespace Rosen
|
||||
} // namespace OHOS
|
||||
@@ -63,7 +63,7 @@ public:
|
||||
Rect GetDisplayRect(DisplayId displayId) const;
|
||||
std::unordered_map<WindowType, SystemBarProperty> GetExpectImmersiveProperty() const;
|
||||
void NotifyAccessibilityWindowInfo(const sptr<WindowNode>& windowId, WindowUpdateType type) const;
|
||||
int GetWindowCountByType(WindowType windowType);
|
||||
uint32_t GetWindowCountByType(WindowType windowType);
|
||||
bool IsForbidDockSliceMove(DisplayId displayId) const;
|
||||
bool IsDockSliceInExitSplitModeArea(DisplayId displayId) const;
|
||||
void ExitSplitMode(DisplayId displayId);
|
||||
|
||||
@@ -126,7 +126,7 @@ private:
|
||||
sptr<AgentDeathRecipient> windowDeath_ = new AgentDeathRecipient(std::bind(&WindowRoot::OnRemoteDied,
|
||||
this, std::placeholders::_1));
|
||||
Callback callback_;
|
||||
int maxAppWindowNumber_ = 100;
|
||||
uint32_t maxAppWindowNumber_ = 100;
|
||||
FloatingWindowLimitsConfig floatingWindowLimitsConfig_;
|
||||
SplitRatioConfig splitRatioConfig_ = {0.1, 0.9, {}};
|
||||
};
|
||||
|
||||
@@ -240,7 +240,9 @@ void WindowManagerService::ConfigureWindowManagerService()
|
||||
if (intNumbersConfig.count("maxAppWindowNumber") != 0) {
|
||||
auto numbers = intNumbersConfig.at("maxAppWindowNumber");
|
||||
if (numbers.size() == 1) {
|
||||
windowRoot_->SetMaxAppWindowNumber(numbers[0]);
|
||||
if (numbers[0] > 0) {
|
||||
windowRoot_->SetMaxAppWindowNumber(static_cast<uint32_t>(numbers[0]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -75,9 +75,9 @@ WindowNodeContainer::~WindowNodeContainer()
|
||||
Destroy();
|
||||
}
|
||||
|
||||
int WindowNodeContainer::GetWindowCountByType(WindowType windowType)
|
||||
uint32_t WindowNodeContainer::GetWindowCountByType(WindowType windowType)
|
||||
{
|
||||
int windowNumber = 0;
|
||||
uint32_t windowNumber = 0;
|
||||
auto counter = [&windowNumber, &windowType](sptr<WindowNode>& windowNode) {
|
||||
if (windowNode->GetWindowType() == windowType && !windowNode->startingWindowShown_) ++windowNumber;
|
||||
};
|
||||
|
||||
@@ -431,7 +431,7 @@ WMError WindowRoot::AddWindowNode(uint32_t parentId, sptr<WindowNode>& node, boo
|
||||
}
|
||||
// limit number of main window
|
||||
int mainWindowNumber = container->GetWindowCountByType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW);
|
||||
if (mainWindowNumber >= maxAppWindowNumber_) {
|
||||
if (mainWindowNumber >= maxAppWindowNumber_ && node->GetWindowType() == WindowType::WINDOW_TYPE_APP_MAIN_WINDOW) {
|
||||
container->MinimizeOldestAppWindow();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user