mirror of
https://github.com/openharmony/windowmanager.git
synced 2026-07-18 16:24:27 -04:00
Merge branch 'master' of https://gitee.com/openharmony/windowmanager into split_start_dev
Change-Id: Iae830e427028ce62c4c74ca41ea0ec921d22e22d Signed-off-by: xingyanan <xingyanan2@huawei.com>
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -32,7 +32,7 @@ namespace {
|
||||
constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_DISPLAY, "ScreenshotCmdTest"};
|
||||
}
|
||||
|
||||
using utils = DisplayTestUtils;
|
||||
using Utils = DisplayTestUtils;
|
||||
class ScreenshotCmdTest : public testing::Test {
|
||||
public:
|
||||
static void SetUpTestCase();
|
||||
|
||||
@@ -28,7 +28,7 @@ namespace Rosen {
|
||||
namespace {
|
||||
constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_DISPLAY, "ScreenshotTest"};
|
||||
}
|
||||
using utils = DisplayTestUtils;
|
||||
using Utils = DisplayTestUtils;
|
||||
class ScreenshotTest : public testing::Test {
|
||||
public:
|
||||
static void SetUpTestCase();
|
||||
@@ -109,7 +109,7 @@ HWTEST_F(ScreenshotTest, ScreenShotValid03, Function | MediumTest | Level2)
|
||||
ASSERT_NE(nullptr, screenshot);
|
||||
|
||||
Media::Size screenSize = {screenshot->GetWidth(), screenshot->GetHeight()};
|
||||
ASSERT_TRUE(utils::SizeEqualToDisplay(dm.GetDefaultDisplay(), screenSize));
|
||||
ASSERT_TRUE(Utils::SizeEqualToDisplay(dm.GetDefaultDisplay(), screenSize));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -137,20 +137,20 @@ HWTEST_F(ScreenshotTest, ScreenShotValid05, Function | MediumTest | Level2)
|
||||
defaultImage_, defaultRot_);
|
||||
ASSERT_NE(nullptr, screenshot);
|
||||
Media::Size screenSize = {screenshot->GetWidth(), screenshot->GetHeight()};
|
||||
ASSERT_TRUE(utils::SizeEqual(defaultImage_, screenSize));
|
||||
ASSERT_TRUE(Utils::SizeEqual(defaultImage_, screenSize));
|
||||
|
||||
Media::Size halfDefault_ = {defaultImage_.width / 2, defaultImage_.height / 2};
|
||||
Media::Rect halfRect = {defaultScreen_.left, defaultScreen_.top, halfDefault_.width, halfDefault_.height};
|
||||
screenshot = dm.GetScreenshot(defaultId_, halfRect, defaultImage_, defaultRot_);
|
||||
ASSERT_NE(nullptr, screenshot);
|
||||
screenSize = {screenshot->GetWidth(), screenshot->GetHeight()};
|
||||
ASSERT_TRUE(utils::SizeEqual(defaultImage_, screenSize));
|
||||
ASSERT_TRUE(Utils::SizeEqual(defaultImage_, screenSize));
|
||||
|
||||
Media::Size halfSize = {halfDefault_.width, halfDefault_.height};
|
||||
screenshot = dm.GetScreenshot(defaultId_, defaultScreen_, halfSize, defaultRot_);
|
||||
ASSERT_NE(nullptr, screenshot);
|
||||
screenSize = {screenshot->GetWidth(), screenshot->GetHeight()};
|
||||
ASSERT_TRUE(utils::SizeEqual(halfSize, screenSize));
|
||||
ASSERT_TRUE(Utils::SizeEqual(halfSize, screenSize));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -165,7 +165,7 @@ HWTEST_F(ScreenshotTest, ScreenShotValid06, Function | MediumTest | Level2)
|
||||
defaultImage_, defaultRot_);
|
||||
ASSERT_NE(nullptr, screenshot);
|
||||
Media::Size screenSize = {screenshot->GetWidth(), screenshot->GetHeight()};
|
||||
ASSERT_TRUE(utils::SizeEqualToDisplay(dm.GetDefaultDisplay(), screenSize));
|
||||
ASSERT_TRUE(Utils::SizeEqualToDisplay(dm.GetDefaultDisplay(), screenSize));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -26,7 +26,7 @@ using namespace testing::ext;
|
||||
|
||||
namespace OHOS {
|
||||
namespace Rosen {
|
||||
using utils = TestUtils;
|
||||
using Utils = TestUtils;
|
||||
constexpr int32_t TEST_IMAGE_HEIGHT = 1080;
|
||||
constexpr int32_t TEST_IMAGE_WIDTH = 1920;
|
||||
using Mocker = SingletonMocker<DisplayManagerAdapter, MockDisplayManagerAdapter>;
|
||||
|
||||
@@ -98,7 +98,7 @@ public:
|
||||
bool SetVirtualPixelRatio(ScreenId screenId, float virtualPixelRatio) override;
|
||||
static float GetCustomVirtualPixelRatio();
|
||||
void RegisterDisplayChangeListener(sptr<IDisplayChangeListener> listener);
|
||||
void GetFullScreenWindowRequestedOrientation(DisplayId displayId, Orientation &orientation);
|
||||
void GetWindowPreferredOrientation(DisplayId displayId, Orientation &orientation);
|
||||
private:
|
||||
DisplayManagerService();
|
||||
~DisplayManagerService() = default;
|
||||
|
||||
@@ -46,7 +46,7 @@ public:
|
||||
bool SetOrientationFromWindow(DisplayId displayId, Orientation orientation);
|
||||
bool SetRotationFromWindow(DisplayId displayId, Rotation targetRotation);
|
||||
void SetGravitySensorSubscriptionEnabled();
|
||||
void GetFullScreenWindowRequestedOrientation(DisplayId displayId, Orientation &orientation);
|
||||
void GetWindowPreferredOrientation(DisplayId displayId, Orientation &orientation);
|
||||
};
|
||||
} // namespace OHOS::Rosen
|
||||
|
||||
|
||||
@@ -133,10 +133,10 @@ void DisplayManagerService::NotifyDisplayStateChange(DisplayId defaultDisplayId,
|
||||
}
|
||||
}
|
||||
|
||||
void DisplayManagerService::GetFullScreenWindowRequestedOrientation(DisplayId displayId, Orientation &orientation)
|
||||
void DisplayManagerService::GetWindowPreferredOrientation(DisplayId displayId, Orientation &orientation)
|
||||
{
|
||||
if (displayChangeListener_ != nullptr) {
|
||||
displayChangeListener_->OnGetFullScreenWindowRequestedOrientation(displayId, orientation);
|
||||
displayChangeListener_->OnGetWindowPreferredOrientation(displayId, orientation);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -148,9 +148,9 @@ bool DisplayManagerServiceInner::SetRotationFromWindow(DisplayId displayId, Rota
|
||||
SetRotationFromWindow(displayInfo->GetScreenId(), targetRotation);
|
||||
}
|
||||
|
||||
void DisplayManagerServiceInner::GetFullScreenWindowRequestedOrientation(DisplayId displayId, Orientation &orientation)
|
||||
void DisplayManagerServiceInner::GetWindowPreferredOrientation(DisplayId displayId, Orientation &orientation)
|
||||
{
|
||||
DisplayManagerService::GetInstance().GetFullScreenWindowRequestedOrientation(displayId, orientation);
|
||||
DisplayManagerService::GetInstance().GetWindowPreferredOrientation(displayId, orientation);
|
||||
}
|
||||
|
||||
void DisplayManagerServiceInner::SetGravitySensorSubscriptionEnabled()
|
||||
|
||||
@@ -36,7 +36,7 @@ DisplayId ScreenRotationController::defaultDisplayId_ = 0;
|
||||
bool ScreenRotationController::isGravitySensorSubscribed_ = false;
|
||||
SensorUser ScreenRotationController::user_;
|
||||
Rotation ScreenRotationController::currentDisplayRotation_;
|
||||
bool ScreenRotationController::isScreenRotationLocked_ = false;
|
||||
bool ScreenRotationController::isScreenRotationLocked_ = true;
|
||||
long ScreenRotationController::lastCallbackTime_ = 0;
|
||||
uint32_t ScreenRotationController::defaultDeviceRotationOffset_ = 0;
|
||||
Orientation ScreenRotationController::lastOrientationType_ = Orientation::UNSPECIFIED;
|
||||
@@ -55,10 +55,16 @@ void ScreenRotationController::SubscribeGravitySensor()
|
||||
}
|
||||
user_.userData = nullptr;
|
||||
user_.callback = &HandleGravitySensorEventCallback;
|
||||
SubscribeSensor(SENSOR_TYPE_ID_GRAVITY, &user_);
|
||||
if (SubscribeSensor(SENSOR_TYPE_ID_GRAVITY, &user_) != 0) {
|
||||
WLOGFE("Subscribe gravity sensor failed");
|
||||
return;
|
||||
}
|
||||
SetBatch(SENSOR_TYPE_ID_GRAVITY, &user_, ORIENTATION_SENSOR_SAMPLING_RATE, ORIENTATION_SENSOR_REPORTING_RATE);
|
||||
SetMode(SENSOR_TYPE_ID_GRAVITY, &user_, SENSOR_ON_CHANGE);
|
||||
ActivateSensor(SENSOR_TYPE_ID_GRAVITY, &user_);
|
||||
if (ActivateSensor(SENSOR_TYPE_ID_GRAVITY, &user_) != 0) {
|
||||
WLOGFE("Activate gravity sensor failed");
|
||||
return;
|
||||
}
|
||||
isGravitySensorSubscribed_ = true;
|
||||
}
|
||||
|
||||
@@ -109,6 +115,7 @@ void ScreenRotationController::HandleGravitySensorEventCallback(SensorEvent *eve
|
||||
currentDisplayRotation_ = GetCurrentDisplayRotation();
|
||||
HandleUnspecifiedOrientation(orientation);
|
||||
if (!IsSensorRelatedOrientation(orientation)) {
|
||||
lastOrientationType_ = orientation;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -128,6 +135,7 @@ void ScreenRotationController::HandleGravitySensorEventCallback(SensorEvent *eve
|
||||
ProcessRotationWhenSensorDataNotValid(orientation);
|
||||
return;
|
||||
}
|
||||
lastOrientationType_ = orientation;
|
||||
if ((ConvertToDeviceRotation(currentSensorRotation) == currentDisplayRotation_) &&
|
||||
(orientation == Orientation::SENSOR || orientation == Orientation::AUTO_ROTATION_RESTRICTED)) {
|
||||
return;
|
||||
@@ -164,7 +172,7 @@ Rotation ScreenRotationController::GetCurrentDisplayRotation()
|
||||
Orientation ScreenRotationController::GetRequestedOrientation()
|
||||
{
|
||||
Orientation orientation = Orientation::UNSPECIFIED;
|
||||
DisplayManagerServiceInner::GetInstance().GetFullScreenWindowRequestedOrientation(defaultDisplayId_, orientation);
|
||||
DisplayManagerServiceInner::GetInstance().GetWindowPreferredOrientation(defaultDisplayId_, orientation);
|
||||
return orientation;
|
||||
}
|
||||
|
||||
@@ -181,6 +189,7 @@ Rotation ScreenRotationController::CalcTargetDisplayRotation(
|
||||
case Orientation::SENSOR_HORIZONTAL: {
|
||||
return ProcessAutoRotationLandscapeOrientation(sensorRotation);
|
||||
}
|
||||
case Orientation::UNSPECIFIED:
|
||||
case Orientation::AUTO_ROTATION_RESTRICTED: {
|
||||
if (isScreenRotationLocked_) {
|
||||
return currentDisplayRotation_;
|
||||
@@ -260,7 +269,7 @@ Rotation ScreenRotationController::ConvertToDeviceRotation(Rotation sensorRotati
|
||||
|
||||
bool ScreenRotationController::IsSensorRelatedOrientation(Orientation orientation)
|
||||
{
|
||||
if ((orientation >= Orientation::BEGIN && orientation <= Orientation::REVERSE_HORIZONTAL) ||
|
||||
if ((orientation >= Orientation::VERTICAL && orientation <= Orientation::REVERSE_HORIZONTAL) ||
|
||||
orientation == Orientation::LOCKED) {
|
||||
return false;
|
||||
}
|
||||
@@ -272,7 +281,7 @@ void ScreenRotationController::HandleUnspecifiedOrientation(Orientation orientat
|
||||
if (lastOrientationType_ == orientation) {
|
||||
return;
|
||||
}
|
||||
if (orientation == Orientation::UNSPECIFIED) {
|
||||
if (orientation == Orientation::UNSPECIFIED && isScreenRotationLocked_) {
|
||||
SetScreenRotation(Rotation::ROTATION_0);
|
||||
lastOrientationType_ = orientation;
|
||||
}
|
||||
|
||||
@@ -169,7 +169,9 @@ public:
|
||||
virtual WMError SetWindowType(WindowType type) = 0;
|
||||
virtual WMError SetWindowMode(WindowMode mode) = 0;
|
||||
virtual WMError SetWindowBackgroundBlur(WindowBlurLevel level) = 0;
|
||||
virtual WMError SetAlpha(float alpha) = 0;
|
||||
virtual void SetAlpha(float alpha) = 0;
|
||||
virtual void SetTransform(const Transform& trans) = 0;
|
||||
virtual Transform GetTransform() const = 0;
|
||||
virtual WMError AddWindowFlag(WindowFlag flag) = 0;
|
||||
virtual WMError RemoveWindowFlag(WindowFlag flag) = 0;
|
||||
virtual WMError SetWindowFlags(uint32_t flags) = 0;
|
||||
@@ -178,8 +180,8 @@ public:
|
||||
virtual WMError SetLayoutFullScreen(bool status) = 0;
|
||||
virtual WMError SetFullScreen(bool status) = 0;
|
||||
virtual WMError Destroy() = 0;
|
||||
virtual WMError Show(uint32_t reason = 0) = 0;
|
||||
virtual WMError Hide(uint32_t reason = 0) = 0;
|
||||
virtual WMError Show(uint32_t reason = 0, bool isCustomAnimation = false) = 0;
|
||||
virtual WMError Hide(uint32_t reason = 0, bool isCustomAnimation = false) = 0;
|
||||
|
||||
virtual WMError MoveTo(int32_t x, int32_t y) = 0;
|
||||
virtual WMError Resize(uint32_t width, uint32_t height) = 0;
|
||||
@@ -230,8 +232,8 @@ public:
|
||||
virtual void OnNewWant(const AAFwk::Want& want) = 0;
|
||||
virtual void SetRequestedOrientation(Orientation) = 0;
|
||||
virtual Orientation GetRequestedOrientation() = 0;
|
||||
virtual void SetModeSupportInfo(uint32_t modeSupportInfo) = 0;
|
||||
virtual uint32_t GetModeSupportInfo() const = 0;
|
||||
virtual void SetRequestModeSupportInfo(uint32_t modeSupportInfo) = 0;
|
||||
virtual uint32_t GetRequestModeSupportInfo() const = 0;
|
||||
virtual WMError SetTouchHotAreas(const std::vector<Rect>& rects) = 0;
|
||||
virtual void GetRequestedTouchHotAreas(std::vector<Rect>& rects) const = 0;
|
||||
|
||||
|
||||
@@ -33,7 +33,6 @@ public:
|
||||
void SetWindowType(WindowType type);
|
||||
void SetWindowMode(WindowMode mode);
|
||||
void SetWindowBackgroundBlur(WindowBlurLevel level);
|
||||
void SetAlpha(float alpha);
|
||||
void SetFocusable(bool isFocusable);
|
||||
void SetTouchable(bool isTouchable);
|
||||
void SetDisplayId(DisplayId displayId);
|
||||
@@ -58,7 +57,6 @@ public:
|
||||
WindowType GetWindowType() const;
|
||||
WindowMode GetWindowMode() const;
|
||||
WindowBlurLevel GetWindowBackgroundBlur() const;
|
||||
float GetAlpha() const;
|
||||
bool GetFocusable() const;
|
||||
bool GetTouchable() const;
|
||||
DisplayId GetDisplayId() const;
|
||||
@@ -75,7 +73,6 @@ private:
|
||||
WindowType type_ { WindowType::WINDOW_TYPE_APP_MAIN_WINDOW };
|
||||
WindowMode mode_ { WindowMode::WINDOW_MODE_FULLSCREEN };
|
||||
WindowBlurLevel level_ { WindowBlurLevel::WINDOW_BLUR_OFF };
|
||||
float alpha_ { 1.0f };
|
||||
bool focusable_ { true };
|
||||
bool touchable_ { true };
|
||||
DisplayId displayId_ { 0 };
|
||||
|
||||
@@ -43,7 +43,7 @@ enum class WindowType : uint32_t {
|
||||
ABOVE_APP_SYSTEM_WINDOW_BASE = 2100,
|
||||
WINDOW_TYPE_APP_LAUNCHING = ABOVE_APP_SYSTEM_WINDOW_BASE,
|
||||
WINDOW_TYPE_DOCK_SLICE,
|
||||
WINDOW_TYPE_PLACE_HOLDER,
|
||||
WINDOW_TYPE_PLACEHOLDER,
|
||||
WINDOW_TYPE_INCOMING_CALL,
|
||||
WINDOW_TYPE_SEARCHING_BAR,
|
||||
WINDOW_TYPE_SYSTEM_ALARM_WINDOW,
|
||||
@@ -173,6 +173,25 @@ namespace {
|
||||
constexpr int32_t INVALID_UID = -1;
|
||||
}
|
||||
|
||||
class Transform {
|
||||
public:
|
||||
Transform()
|
||||
: pivotX_(0.5f), pivotY_(0.5f), scaleX_(1.f), scaleY_(1.f), rotationX_(0.f), rotationY_(0.f), rotationZ_(0.f),
|
||||
translateX_(0.f), translateY_(0.f), translateZ_(0.f)
|
||||
{}
|
||||
~Transform() {}
|
||||
float pivotX_;
|
||||
float pivotY_;
|
||||
float scaleX_;
|
||||
float scaleY_;
|
||||
float rotationX_;
|
||||
float rotationY_;
|
||||
float rotationZ_;
|
||||
float translateX_;
|
||||
float translateY_;
|
||||
float translateZ_;
|
||||
};
|
||||
|
||||
struct SystemBarProperty {
|
||||
bool enable_;
|
||||
uint32_t backgroundColor_;
|
||||
@@ -298,6 +317,7 @@ enum class WindowUpdateType : int32_t {
|
||||
WINDOW_UPDATE_FOCUSED,
|
||||
WINDOW_UPDATE_BOUNDS,
|
||||
WINDOW_UPDATE_ACTIVE,
|
||||
WINDOW_UPDATE_PROPERTY,
|
||||
};
|
||||
|
||||
struct SystemConfig {
|
||||
|
||||
@@ -50,6 +50,7 @@ ohos_shared_library("window_native_kit") {
|
||||
|
||||
configs = [ ":window_native_kit_config" ]
|
||||
deps = [
|
||||
"//foundation/graphic/graphic_2d/rosen/modules/render_service_client:librender_service_client",
|
||||
"//foundation/windowmanager/utils:libwmutil",
|
||||
"//foundation/windowmanager/wm:libwm",
|
||||
"//foundation/windowmanager/wmserver:libwms",
|
||||
|
||||
+107
-3
@@ -91,6 +91,82 @@ declare namespace window {
|
||||
*/
|
||||
TYPE_KEYBOARD
|
||||
}
|
||||
|
||||
/**
|
||||
* Describes the scale Transition Options of window
|
||||
* @syscap SystemCapability.WindowManager.WindowManager.Core
|
||||
* @since 9
|
||||
* @systemapi
|
||||
*/
|
||||
declare interface ScaleOptions {
|
||||
/**
|
||||
* The scale param of x direction. Default is 1.f
|
||||
*/
|
||||
x?: number;
|
||||
/**
|
||||
* The scale param of y direction. Default is 1.f
|
||||
*/
|
||||
y?: number;
|
||||
/**
|
||||
* The scale param of pivot point of x. Default is 0.5f, Interval is 0.f - 1.f
|
||||
*/
|
||||
pivotX?: number;
|
||||
/**
|
||||
* The scale param of pivot point of y. Default is 0.5f, Interval is 0.f - 1.f
|
||||
*/
|
||||
pivotY?: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* Describes the rotate Transition Options of window
|
||||
* @syscap SystemCapability.WindowManager.WindowManager.Core
|
||||
* @since 9
|
||||
* @systemapi
|
||||
*/
|
||||
declare interface RotateOptions {
|
||||
/**
|
||||
* The rotate degree of x direction. Default value is 0.f
|
||||
*/
|
||||
x?: number;
|
||||
/**
|
||||
* The rotate degree of y direction. Default value is 0.f
|
||||
*/
|
||||
y?: number;
|
||||
/**
|
||||
* The rotate degree of z direction. Default value is 0.f
|
||||
*/
|
||||
z?: number;
|
||||
/**
|
||||
* The param of pivot point of x. Default is 0.5f, Interval is 0.f - 1.f
|
||||
*/
|
||||
pivotX?: number;
|
||||
/**
|
||||
* The param of pivot point of y. Default is 0.5f, Interval is 0.f - 1.f
|
||||
*/
|
||||
pivotY?: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* Describes the translate Transition Options of window
|
||||
* @syscap SystemCapability.WindowManager.WindowManager.Core
|
||||
* @since 9
|
||||
* @systemapi
|
||||
*/
|
||||
declare interface TranslateOptions {
|
||||
/**
|
||||
* The translate pixel param of x direction. Default is 0.f
|
||||
*/
|
||||
x?: number;
|
||||
/**
|
||||
* The translate pixel param of y direction. Default is 0.f
|
||||
*/
|
||||
y?: number;
|
||||
/**
|
||||
* The translate pixel param of z direction. Default is 0.f
|
||||
*/
|
||||
z?: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* Describes the window mode of an application
|
||||
* @systemapi Hide this for inner system use.
|
||||
@@ -961,7 +1037,7 @@ declare namespace window {
|
||||
* @since 9
|
||||
*/
|
||||
setPreferredOrientation(orientation: Orientation, callback: AsyncCallback<void>): void;
|
||||
|
||||
|
||||
/**
|
||||
* disable window decoration. It must be called before loadContent.
|
||||
* @systemapi
|
||||
@@ -985,7 +1061,7 @@ declare namespace window {
|
||||
* @systemapi
|
||||
* @since 9
|
||||
*/
|
||||
setForbidSplitMove(isForbidSplitMove: boolean, callback: AsyncCallback<void>): void;
|
||||
setForbidSplitMove(isForbidSplitMove: boolean, callback: AsyncCallback<void>): void;
|
||||
|
||||
/**
|
||||
* set the flag of the window is forbidden to move in split screen mode
|
||||
@@ -994,7 +1070,35 @@ declare namespace window {
|
||||
* @systemapi
|
||||
* @since 9
|
||||
*/
|
||||
setForbidSplitMove(isForbidSplitMove: boolean): Promise<void>;
|
||||
setForbidSplitMove(isForbidSplitMove: boolean): Promise<void>;
|
||||
/**
|
||||
* Sets opacity of window
|
||||
* @param opacity Interval is 0.f-1.f.
|
||||
* @systemapi
|
||||
* @since 9
|
||||
*/
|
||||
setOpacitySync(opacity: number): void;
|
||||
/**
|
||||
* Sets scale options of window.
|
||||
* @param scaleOptions scale param of window.
|
||||
* @systemapi
|
||||
* @since 9
|
||||
*/
|
||||
setScaleSync(scaleOptions: ScaleOptions): void;
|
||||
/**
|
||||
* Sets rotate options of window.
|
||||
* @param rotateOptions rotate param of window.
|
||||
* @systemapi
|
||||
* @since 9
|
||||
*/
|
||||
setRotateSync(rotateOptions: RotateOptions): void;
|
||||
/**
|
||||
* Sets whether is transparent or not.
|
||||
* @param translateOptions translate param of window.
|
||||
* @systemapi
|
||||
* @since 9
|
||||
*/
|
||||
setTranslateSync(translateOptions: TranslateOptions): void;
|
||||
}
|
||||
|
||||
enum WindowStageEventType {
|
||||
|
||||
@@ -15,8 +15,10 @@
|
||||
|
||||
#include "js_window.h"
|
||||
#include <new>
|
||||
#include <ui/rs_surface_node.h>
|
||||
#include "js_window_utils.h"
|
||||
#include "window.h"
|
||||
#include "window_helper.h"
|
||||
#include "window_manager_hilog.h"
|
||||
#include "window_option.h"
|
||||
namespace OHOS {
|
||||
@@ -29,24 +31,28 @@ namespace {
|
||||
|
||||
static thread_local std::map<std::string, std::shared_ptr<NativeReference>> g_jsWindowMap;
|
||||
std::recursive_mutex g_mutex;
|
||||
static int ctorCnt = 0;
|
||||
static int dtorCnt = 0;
|
||||
static int finalizerCnt = 0;
|
||||
JsWindow::JsWindow(const sptr<Window>& window)
|
||||
: windowToken_(window), registerManager_(std::make_unique<JsWindowRegisterManager>())
|
||||
{
|
||||
NotifyNativeWinDestroyFunc func = [](std::string windowName) {
|
||||
std::lock_guard<std::recursive_mutex> lock(g_mutex);
|
||||
if (windowName.empty() || g_jsWindowMap.count(windowName) == 0) {
|
||||
WLOGE("[NAPI]Can not find window %{public}s ", windowName.c_str());
|
||||
WLOGFE("[NAPI]Can not find window %{public}s ", windowName.c_str());
|
||||
return;
|
||||
}
|
||||
g_jsWindowMap.erase(windowName);
|
||||
WLOGE("[NAPI]Destroy window %{public}s in js window", windowName.c_str());
|
||||
WLOGFI("[NAPI]Destroy window %{public}s in js window", windowName.c_str());
|
||||
};
|
||||
windowToken_->RegisterWindowDestroyedListener(func);
|
||||
WLOGFI("[NAPI] JsWindow constructor Count: %{public}d", ++ctorCnt);
|
||||
}
|
||||
|
||||
JsWindow::~JsWindow()
|
||||
{
|
||||
WLOGFI("[NAPI]~JsWindow");
|
||||
WLOGFI("[NAPI]~JsWindow deconstructor Count:%{public}d", ++dtorCnt);
|
||||
windowToken_ = nullptr;
|
||||
}
|
||||
|
||||
@@ -60,7 +66,7 @@ std::string JsWindow::GetWindowName()
|
||||
|
||||
void JsWindow::Finalizer(NativeEngine* engine, void* data, void* hint)
|
||||
{
|
||||
WLOGFI("[NAPI]Finalizer");
|
||||
WLOGFI("[NAPI]Finalizer Count:%{public}d", ++finalizerCnt);
|
||||
auto jsWin = std::unique_ptr<JsWindow>(static_cast<JsWindow*>(data));
|
||||
if (jsWin == nullptr) {
|
||||
WLOGFE("[NAPI]jsWin is nullptr");
|
||||
@@ -313,6 +319,34 @@ NativeValue* JsWindow::SetForbidSplitMove(NativeEngine* engine, NativeCallbackIn
|
||||
return (me != nullptr) ? me->OnSetForbidSplitMove(*engine, *info) : nullptr;
|
||||
}
|
||||
|
||||
NativeValue* JsWindow::SetOpacitySync(NativeEngine* engine, NativeCallbackInfo* info)
|
||||
{
|
||||
WLOGFI("[NAPI]SetOpacitySync");
|
||||
JsWindow* me = CheckParamsAndGetThis<JsWindow>(engine, info);
|
||||
return (me != nullptr) ? me->OnSetOpacitySync(*engine, *info) : nullptr;
|
||||
}
|
||||
|
||||
NativeValue* JsWindow::SetScaleSync(NativeEngine* engine, NativeCallbackInfo* info)
|
||||
{
|
||||
WLOGFI("[NAPI]SetScaleSync");
|
||||
JsWindow* me = CheckParamsAndGetThis<JsWindow>(engine, info);
|
||||
return (me != nullptr) ? me->OnSetScaleSync(*engine, *info) : nullptr;
|
||||
}
|
||||
|
||||
NativeValue* JsWindow::SetRotateSync(NativeEngine* engine, NativeCallbackInfo* info)
|
||||
{
|
||||
WLOGFI("[NAPI]SetRotateSync");
|
||||
JsWindow* me = CheckParamsAndGetThis<JsWindow>(engine, info);
|
||||
return (me != nullptr) ? me->OnSetRotateSync(*engine, *info) : nullptr;
|
||||
}
|
||||
|
||||
NativeValue* JsWindow::SetTranslateSync(NativeEngine* engine, NativeCallbackInfo* info)
|
||||
{
|
||||
WLOGFI("[NAPI]SetTranslateSync");
|
||||
JsWindow* me = CheckParamsAndGetThis<JsWindow>(engine, info);
|
||||
return (me != nullptr) ? me->OnSetTranslateSync(*engine, *info) : nullptr;
|
||||
}
|
||||
|
||||
NativeValue* JsWindow::OnShow(NativeEngine& engine, NativeCallbackInfo& info)
|
||||
{
|
||||
WMError errCode = WMError::WM_OK;
|
||||
@@ -1643,6 +1677,199 @@ NativeValue* JsWindow::OnSetForbidSplitMove(NativeEngine& engine, NativeCallback
|
||||
return result;
|
||||
}
|
||||
|
||||
NativeValue* JsWindow::OnSetOpacitySync(NativeEngine& engine, NativeCallbackInfo& info)
|
||||
{
|
||||
if (info.argc != 1 || windowToken_ == nullptr) {
|
||||
WLOGFE("[NAPI]Argc is invalid: %{public}zu or windowToken_ is nullptr", info.argc);
|
||||
return engine.CreateUndefined();
|
||||
}
|
||||
if (!WindowHelper::IsSystemWindow(windowToken_->GetType())) {
|
||||
WLOGFE("[NAPI]SetOpacitySync is not allowed since window is not system window");
|
||||
return engine.CreateUndefined();
|
||||
}
|
||||
NativeNumber* nativeVal = ConvertNativeValueTo<NativeNumber>(info.argv[0]);
|
||||
if (nativeVal == nullptr) {
|
||||
WLOGFE("[NAPI]Failed to convert parameter to alpha");
|
||||
return engine.CreateUndefined();
|
||||
}
|
||||
float alpha = static_cast<double>(*nativeVal);
|
||||
windowToken_->SetAlpha(alpha);
|
||||
WLOGFI("[NAPI]Window [%{public}u, %{public}s] SetOpacitySync end, alpha = %{public}f",
|
||||
windowToken_->GetWindowId(), windowToken_->GetWindowName().c_str(), alpha);
|
||||
return engine.CreateUndefined();
|
||||
}
|
||||
|
||||
bool JsWindow::ParseScaleOption(NativeEngine& engine, NativeObject* jsObject, Transform& trans)
|
||||
{
|
||||
auto surfaceNode = windowToken_->GetSurfaceNode();
|
||||
if (surfaceNode == nullptr) {
|
||||
WLOGFE("[NAPI] surfaceNode is nullptr");
|
||||
return false;
|
||||
}
|
||||
double data = 0.0f;
|
||||
if (ParseJsDoubleValue(jsObject, engine, "pivotX", data)) {
|
||||
surfaceNode->SetPivotX(data);
|
||||
trans.pivotX_ = data;
|
||||
}
|
||||
if (ParseJsDoubleValue(jsObject, engine, "pivotY", data)) {
|
||||
surfaceNode->SetPivotY(data);
|
||||
trans.pivotY_ = data;
|
||||
}
|
||||
if (ParseJsDoubleValue(jsObject, engine, "x", data)) {
|
||||
surfaceNode->SetScaleX(data);
|
||||
trans.scaleX_ = data;
|
||||
}
|
||||
if (ParseJsDoubleValue(jsObject, engine, "y", data)) {
|
||||
surfaceNode->SetScaleY(data);
|
||||
trans.scaleY_ = data;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
NativeValue* JsWindow::OnSetScaleSync(NativeEngine& engine, NativeCallbackInfo& info)
|
||||
{
|
||||
if (info.argc != 1 || windowToken_ == nullptr) {
|
||||
WLOGFE("[NAPI]Argc is invalid: %{public}zu or windowToken_ is nullptr", info.argc);
|
||||
return engine.CreateUndefined();
|
||||
}
|
||||
if (!WindowHelper::IsSystemWindow(windowToken_->GetType())) {
|
||||
WLOGFE("[NAPI]SetScaleSync is not allowed since window is not system window");
|
||||
return engine.CreateUndefined();
|
||||
}
|
||||
NativeObject* nativeObj = ConvertNativeValueTo<NativeObject>(info.argv[0]);
|
||||
if (nativeObj == nullptr) {
|
||||
WLOGFE("[NAPI]Failed to convert object to ScaleOptions");
|
||||
return engine.CreateUndefined();
|
||||
}
|
||||
auto trans = windowToken_->GetTransform();
|
||||
if (!ParseScaleOption(engine, nativeObj, trans)) {
|
||||
return engine.CreateUndefined();
|
||||
}
|
||||
windowToken_->SetTransform(trans);
|
||||
WLOGFI("[NAPI]Window [%{public}u, %{public}s] SetScaleSync end",
|
||||
windowToken_->GetWindowId(), windowToken_->GetWindowName().c_str());
|
||||
WLOGFI("[NAPI]scaleX = %{public}f, scaleY = %{public}f, pivotX = %{public}f pivotY = %{public}f",
|
||||
trans.scaleX_, trans.scaleY_, trans.pivotX_, trans.pivotY_);
|
||||
return engine.CreateUndefined();
|
||||
}
|
||||
|
||||
bool JsWindow::ParseRotateOption(NativeEngine& engine, NativeObject* jsObject, Transform& trans)
|
||||
{
|
||||
auto surfaceNode = windowToken_->GetSurfaceNode();
|
||||
if (surfaceNode == nullptr) {
|
||||
WLOGFE("[NAPI] surfaceNode is nullptr");
|
||||
return false;
|
||||
}
|
||||
double data = 0.0f;
|
||||
if (ParseJsDoubleValue(jsObject, engine, "pivotX", data)) {
|
||||
surfaceNode->SetPivotX(data);
|
||||
trans.pivotX_ = data;
|
||||
}
|
||||
if (ParseJsDoubleValue(jsObject, engine, "pivotY", data)) {
|
||||
surfaceNode->SetPivotY(data);
|
||||
trans.pivotY_ = data;
|
||||
}
|
||||
double coeff = 0.5 * 3.14 / 180; // 0.5 means half; 3.14 means pi; 180 means degree
|
||||
if (ParseJsDoubleValue(jsObject, engine, "x", data)) {
|
||||
float w = std::cos(data * coeff);
|
||||
float x = std::sin(data * coeff);
|
||||
surfaceNode->SetRotation(Quaternion(x, 0, 0, w));
|
||||
trans.rotationX_ = data;
|
||||
}
|
||||
if (ParseJsDoubleValue(jsObject, engine, "y", data)) {
|
||||
float w = std::cos(data * coeff);
|
||||
float y = std::sin(data * coeff);
|
||||
surfaceNode->SetRotation(Quaternion(0, y, 0, w));
|
||||
trans.rotationY_ = data;
|
||||
}
|
||||
if (ParseJsDoubleValue(jsObject, engine, "z", data)) {
|
||||
float w = std::cos(data * coeff);
|
||||
float z = std::sin(data * coeff);
|
||||
surfaceNode->SetRotation(Quaternion(0, 0, z, w));
|
||||
trans.rotationZ_ = data;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
NativeValue* JsWindow::OnSetRotateSync(NativeEngine& engine, NativeCallbackInfo& info)
|
||||
{
|
||||
if (info.argc != 1 || windowToken_ == nullptr) {
|
||||
WLOGFE("[NAPI]Argc is invalid: %{public}zu or windowToken_ is nullptr", info.argc);
|
||||
return engine.CreateUndefined();
|
||||
}
|
||||
if (!WindowHelper::IsSystemWindow(windowToken_->GetType())) {
|
||||
WLOGFE("[NAPI]SetRotateSync is not allowed since window is not system window");
|
||||
return engine.CreateUndefined();
|
||||
}
|
||||
NativeObject* nativeObj = ConvertNativeValueTo<NativeObject>(info.argv[0]);
|
||||
if (nativeObj == nullptr) {
|
||||
WLOGFE("[NAPI]Failed to convert object to RotateOptions");
|
||||
return engine.CreateUndefined();
|
||||
}
|
||||
// cannot use sync task since next transform base on current transform
|
||||
auto trans = windowToken_->GetTransform();
|
||||
if (!ParseRotateOption(engine, nativeObj, trans)) {
|
||||
return engine.CreateUndefined();
|
||||
}
|
||||
windowToken_->SetTransform(trans);
|
||||
WLOGFI("[NAPI]Window [%{public}u, %{public}s] SetRotateSync end",
|
||||
windowToken_->GetWindowId(), windowToken_->GetWindowName().c_str());
|
||||
WLOGFI("[NAPI]rotateX = %{public}f, rotateY = %{public}f," \
|
||||
"rotateZ = %{public}f pivotX = %{public}f pivotY = %{public}f",
|
||||
trans.rotationX_, trans.rotationY_, trans.rotationZ_, trans.pivotX_, trans.pivotY_);
|
||||
return engine.CreateUndefined();
|
||||
}
|
||||
|
||||
bool JsWindow::ParseTranslateOption(NativeEngine& engine, NativeObject* jsObject, Transform& trans)
|
||||
{
|
||||
auto surfaceNode = windowToken_->GetSurfaceNode();
|
||||
if (surfaceNode == nullptr) {
|
||||
WLOGFE("[NAPI] surfaceNode is nullptr");
|
||||
return false;
|
||||
}
|
||||
double data = 0.0f;
|
||||
if (ParseJsDoubleValue(jsObject, engine, "x", data)) {
|
||||
surfaceNode->SetTranslateX(data);
|
||||
trans.translateX_ = data;
|
||||
}
|
||||
if (ParseJsDoubleValue(jsObject, engine, "y", data)) {
|
||||
surfaceNode->SetTranslateY(data);
|
||||
trans.translateY_ = data;
|
||||
}
|
||||
if (ParseJsDoubleValue(jsObject, engine, "z", data)) {
|
||||
surfaceNode->SetTranslateZ(data);
|
||||
trans.translateZ_ = data;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
NativeValue* JsWindow::OnSetTranslateSync(NativeEngine& engine, NativeCallbackInfo& info)
|
||||
{
|
||||
if (info.argc != 1 || windowToken_ == nullptr) {
|
||||
WLOGFE("[NAPI]Argc is invalid: %{public}zu or windowToken_ is nullptr", info.argc);
|
||||
return engine.CreateUndefined();
|
||||
}
|
||||
if (!WindowHelper::IsSystemWindow(windowToken_->GetType())) {
|
||||
WLOGFE("[NAPI]SetTranslateSync is not allowed since window is not system window");
|
||||
return engine.CreateUndefined();
|
||||
}
|
||||
NativeObject* nativeObj = ConvertNativeValueTo<NativeObject>(info.argv[0]);
|
||||
if (nativeObj == nullptr) {
|
||||
WLOGFE("[NAPI]Failed to convert object to TranslateOptions");
|
||||
return engine.CreateUndefined();
|
||||
}
|
||||
auto trans = windowToken_->GetTransform();
|
||||
if (!ParseTranslateOption(engine, nativeObj, trans)) {
|
||||
return engine.CreateUndefined();
|
||||
}
|
||||
windowToken_->SetTransform(trans);
|
||||
WLOGFI("[NAPI]Window [%{public}u, %{public}s] SetRotateSync end," \
|
||||
"translateX = %{public}f, translateY = %{public}f, translateZ = %{public}f",
|
||||
windowToken_->GetWindowId(), windowToken_->GetWindowName().c_str(),
|
||||
trans.translateX_, trans.translateY_, trans.translateZ_);
|
||||
return engine.CreateUndefined();
|
||||
}
|
||||
|
||||
std::shared_ptr<NativeReference> FindJsWindowObject(std::string windowName)
|
||||
{
|
||||
WLOGFI("[NAPI]Try to find window %{public}s in g_jsWindowMap", windowName.c_str());
|
||||
@@ -1716,6 +1943,10 @@ void BindFunctions(NativeEngine& engine, NativeObject* object)
|
||||
BindNativeFunction(engine, *object, "dump", JsWindow::Dump);
|
||||
BindNativeFunction(engine, *object, "setForbidSplitMove", JsWindow::SetForbidSplitMove);
|
||||
BindNativeFunction(engine, *object, "setPreferredOrientation", JsWindow::SetPreferredOrientation);
|
||||
BindNativeFunction(engine, *object, "setOpacitySync", JsWindow::SetOpacitySync);
|
||||
BindNativeFunction(engine, *object, "setScaleSync", JsWindow::SetScaleSync);
|
||||
BindNativeFunction(engine, *object, "setRotateSync", JsWindow::SetRotateSync);
|
||||
BindNativeFunction(engine, *object, "setTranslateSync", JsWindow::SetTranslateSync);
|
||||
}
|
||||
} // namespace Rosen
|
||||
} // namespace OHOS
|
||||
|
||||
@@ -69,8 +69,16 @@ public:
|
||||
static NativeValue* Dump(NativeEngine* engine, NativeCallbackInfo* info);
|
||||
static NativeValue* SetForbidSplitMove(NativeEngine* engine, NativeCallbackInfo* info);
|
||||
|
||||
// animation config
|
||||
static NativeValue* SetOpacitySync(NativeEngine* engine, NativeCallbackInfo* info);
|
||||
static NativeValue* SetScaleSync(NativeEngine* engine, NativeCallbackInfo* info);
|
||||
static NativeValue* SetRotateSync(NativeEngine* engine, NativeCallbackInfo* info);
|
||||
static NativeValue* SetTranslateSync(NativeEngine* engine, NativeCallbackInfo* info);
|
||||
private:
|
||||
std::string GetWindowName();
|
||||
bool ParseScaleOption(NativeEngine& engine, NativeObject* jsObject, Transform& trans);
|
||||
bool ParseRotateOption(NativeEngine& engine, NativeObject* jsObject, Transform& trans);
|
||||
bool ParseTranslateOption(NativeEngine& engine, NativeObject* jsObject, Transform& trans);
|
||||
NativeValue* OnShow(NativeEngine& engine, NativeCallbackInfo& info);
|
||||
NativeValue* OnDestroy(NativeEngine& engine, NativeCallbackInfo& info);
|
||||
NativeValue* OnHide(NativeEngine& engine, NativeCallbackInfo& info);
|
||||
@@ -108,6 +116,11 @@ private:
|
||||
NativeValue* OnDump(NativeEngine& engine, NativeCallbackInfo& info);
|
||||
NativeValue* OnSetForbidSplitMove(NativeEngine& engine, NativeCallbackInfo& info);
|
||||
|
||||
// animation Config
|
||||
NativeValue* OnSetOpacitySync(NativeEngine& engine, NativeCallbackInfo& info);
|
||||
NativeValue* OnSetScaleSync(NativeEngine& engine, NativeCallbackInfo& info);
|
||||
NativeValue* OnSetRotateSync(NativeEngine& engine, NativeCallbackInfo& info);
|
||||
NativeValue* OnSetTranslateSync(NativeEngine& engine, NativeCallbackInfo& info);
|
||||
sptr<Window> windowToken_ = nullptr;
|
||||
std::unique_ptr<JsWindowRegisterManager> registerManager_ = nullptr;
|
||||
};
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
#include "js_window_listener.h"
|
||||
#include "js_runtime_utils.h"
|
||||
#include "window_manager_hilog.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Rosen {
|
||||
using namespace AbilityRuntime;
|
||||
@@ -47,7 +48,7 @@ void JsWindowListener::OnSizeChange(Rect rect, WindowSizeChangeReason reason)
|
||||
WLOGFI("[NAPI]OnSizeChange, wh[%{public}u, %{public}u], reason = %{public}u", rect.width_, rect.height_, reason);
|
||||
// js callback should run in js thread
|
||||
std::unique_ptr<AsyncTask::CompleteCallback> complete = std::make_unique<AsyncTask::CompleteCallback> (
|
||||
[self = wptr<JsWindowListener>(this), rect, eng = engine_] (NativeEngine &engine,
|
||||
[self = weakRef_, rect, eng = engine_] (NativeEngine &engine,
|
||||
AsyncTask &task, int32_t status) {
|
||||
auto thisListener = self.promote();
|
||||
if (thisListener == nullptr || eng == nullptr) {
|
||||
@@ -83,7 +84,7 @@ void JsWindowListener::OnSystemBarPropertyChange(DisplayId displayId, const Syst
|
||||
WLOGFI("[NAPI]OnSystemBarPropertyChange");
|
||||
// js callback should run in js thread
|
||||
std::unique_ptr<AsyncTask::CompleteCallback> complete = std::make_unique<AsyncTask::CompleteCallback> (
|
||||
[self = wptr<JsWindowListener>(this), displayId, tints, eng = engine_] (NativeEngine &engine,
|
||||
[self = weakRef_, displayId, tints, eng = engine_] (NativeEngine &engine,
|
||||
AsyncTask &task, int32_t status) {
|
||||
auto thisListener = self.promote();
|
||||
if (thisListener == nullptr || eng == nullptr) {
|
||||
@@ -114,7 +115,7 @@ void JsWindowListener::OnAvoidAreaChanged(const AvoidArea avoidArea, AvoidAreaTy
|
||||
WLOGFI("[NAPI]OnAvoidAreaChanged");
|
||||
// js callback should run in js thread
|
||||
std::unique_ptr<AsyncTask::CompleteCallback> complete = std::make_unique<AsyncTask::CompleteCallback> (
|
||||
[self = wptr<JsWindowListener>(this), avoidArea, type, eng = engine_] (NativeEngine &engine,
|
||||
[self = weakRef_, avoidArea, type, eng = engine_] (NativeEngine &engine,
|
||||
AsyncTask &task, int32_t status) {
|
||||
auto thisListener = self.promote();
|
||||
if (thisListener == nullptr || eng == nullptr) {
|
||||
@@ -145,7 +146,7 @@ void JsWindowListener::LifeCycleCallBack(LifeCycleEventType eventType)
|
||||
{
|
||||
WLOGFI("[NAPI]LifeCycleCallBack, envent type: %{public}u", eventType);
|
||||
std::unique_ptr<AsyncTask::CompleteCallback> complete = std::make_unique<AsyncTask::CompleteCallback>(
|
||||
[self = wptr<JsWindowListener>(this), eventType, eng = engine_] (NativeEngine &engine,
|
||||
[self = weakRef_, eventType, eng = engine_] (NativeEngine &engine,
|
||||
AsyncTask &task, int32_t status) {
|
||||
auto thisListener = self.promote();
|
||||
if (thisListener == nullptr || eng == nullptr) {
|
||||
@@ -189,7 +190,7 @@ void JsWindowListener::OnSizeChange(const sptr<OccupiedAreaChangeInfo>& info)
|
||||
info->rect_.posX_, info->rect_.posY_, info->rect_.width_, info->rect_.height_);
|
||||
// js callback should run in js thread
|
||||
std::unique_ptr<AsyncTask::CompleteCallback> complete = std::make_unique<AsyncTask::CompleteCallback> (
|
||||
[self = wptr<JsWindowListener>(this), info, eng = engine_] (NativeEngine &engine,
|
||||
[self = weakRef_, info, eng = engine_] (NativeEngine &engine,
|
||||
AsyncTask &task, int32_t status) {
|
||||
auto thisListener = self.promote();
|
||||
if (thisListener == nullptr || eng == nullptr) {
|
||||
@@ -210,7 +211,7 @@ void JsWindowListener::OnSizeChange(const sptr<OccupiedAreaChangeInfo>& info)
|
||||
void JsWindowListener::OnTouchOutside()
|
||||
{
|
||||
std::unique_ptr<AsyncTask::CompleteCallback> complete = std::make_unique<AsyncTask::CompleteCallback> (
|
||||
[self = wptr<JsWindowListener>(this)] (NativeEngine &engine, AsyncTask &task, int32_t status) {
|
||||
[self = weakRef_] (NativeEngine &engine, AsyncTask &task, int32_t status) {
|
||||
auto thisListener = self.promote();
|
||||
if (thisListener == nullptr) {
|
||||
WLOGFE("[NAPI]this listener is nullptr");
|
||||
|
||||
@@ -47,7 +47,7 @@ class JsWindowListener : public IWindowChangeListener,
|
||||
public ITouchOutsideListener {
|
||||
public:
|
||||
JsWindowListener(NativeEngine* engine, std::shared_ptr<NativeReference> callback)
|
||||
: engine_(engine), jsCallBack_(callback) {}
|
||||
: engine_(engine), jsCallBack_(callback), weakRef_(wptr<JsWindowListener> (this)) {}
|
||||
~JsWindowListener();
|
||||
void OnSystemBarPropertyChange(DisplayId displayId, const SystemBarRegionTints& tints) override;
|
||||
void OnSizeChange(Rect rect, WindowSizeChangeReason reason) override;
|
||||
@@ -64,6 +64,7 @@ private:
|
||||
void LifeCycleCallBack(LifeCycleEventType eventType);
|
||||
NativeEngine* engine_ = nullptr;
|
||||
std::shared_ptr<NativeReference> jsCallBack_ = nullptr;
|
||||
wptr<JsWindowListener> weakRef_ = nullptr;
|
||||
DEFINE_VAR_DEFAULT_FUNC_SET(bool, IsDeprecatedInterface, isDeprecatedInterface, false)
|
||||
};
|
||||
} // namespace Rosen
|
||||
|
||||
@@ -484,5 +484,20 @@ bool GetAPI7Ability(NativeEngine& engine, AppExecFwk::Ability* &ability)
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ParseJsDoubleValue(NativeObject* jsObject, NativeEngine& engine, const std::string& name, double data)
|
||||
{
|
||||
NativeValue* value = jsObject->GetProperty(name.c_str());
|
||||
if (value->TypeOf() != NATIVE_UNDEFINED) {
|
||||
if (!ConvertFromJsValue(engine, value, data)) {
|
||||
WLOGFE("[NAPI]Failed to convert parameter to scale %{public}s", name.c_str());
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
WLOGFI("[NAPI]no property with: %{public}s", name.c_str());
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
} // namespace Rosen
|
||||
} // namespace OHOS
|
||||
|
||||
@@ -165,6 +165,7 @@ const std::map<ApiOrientation, Orientation> JS_TO_NATIVE_ORIENTATION_MAP {
|
||||
NativeValue* WindowStageEventTypeInit(NativeEngine* engine);
|
||||
NativeValue* WindowLayoutModeInit(NativeEngine* engine);
|
||||
bool GetAPI7Ability(NativeEngine& engine, AppExecFwk::Ability* &ability);
|
||||
bool ParseJsDoubleValue(NativeObject* jsObject, NativeEngine& engine, const std::string& name, double data);
|
||||
template<class T>
|
||||
inline bool ConvertNativeValueToVector(NativeEngine& engine, NativeValue* nativeValue, std::vector<T>& out)
|
||||
{
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
<!--stretchable enable is true means all window be stretchable-->
|
||||
<stretchable enable="false"></stretchable>
|
||||
<!--exit split screen mode ratio config-->
|
||||
<exitSplitRatios>0.1 0.9</exitSplitRatios>
|
||||
<exitSplitRatios>0.1 0.9</exitSplitRatios>
|
||||
<!--split screen ratios config-->
|
||||
<splitRatios>0.5 0.33 0.67</splitRatios>
|
||||
</Configs>
|
||||
@@ -15,9 +15,8 @@
|
||||
*/
|
||||
-->
|
||||
|
||||
<div class="container" style="background-color: {{ backgroundColor }}"
|
||||
ontouchend="onTouchEnd" ontouchstart="onTouching">
|
||||
<button class="divider-button" onclick="onExchange" ondoubleclick="onExchangeDoubleClick"
|
||||
<div class="container" style="background-color: {{ backgroundColor }}">
|
||||
<button class="divider-button" ondoubleclick="onExchangeDoubleClick"
|
||||
click-effect="spring-small">
|
||||
</button>
|
||||
</div>
|
||||
|
||||
@@ -13,37 +13,11 @@
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
import router from '@ohos.router'
|
||||
import window from '@ohos.window';
|
||||
|
||||
export default {
|
||||
data: {
|
||||
backgroundColor:"black"
|
||||
},
|
||||
onInit() {
|
||||
callNativeHandler("EVENT_INIT", "");
|
||||
},
|
||||
onCancel() {
|
||||
callNativeHandler("EVENT_CANCEL", "");
|
||||
},
|
||||
onExit() {
|
||||
callNativeHandler("EVENT_CANCEL", "");
|
||||
},
|
||||
onExchange() {
|
||||
},
|
||||
onExchangeDoubleClick() {
|
||||
console.info('double click exchange');
|
||||
},
|
||||
onFocus(){
|
||||
this.backgroundColor = "black"
|
||||
},
|
||||
recoveryColor(){
|
||||
this.backgroundColor = "gray"
|
||||
},
|
||||
onTouching(){
|
||||
this.backgroundColor = "gray"
|
||||
},
|
||||
onTouchEnd(){
|
||||
this.backgroundColor = "black"
|
||||
}
|
||||
}
|
||||
@@ -26,9 +26,9 @@ ohos_prebuilt_etc("window_place_holder_image") {
|
||||
relative_install_dir = "window/resources"
|
||||
}
|
||||
|
||||
|
||||
group("window_resources_media") {
|
||||
deps = [ ":window_divider_image",
|
||||
":window_place_holder_image"
|
||||
]
|
||||
deps = [
|
||||
":window_divider_image",
|
||||
":window_place_holder_image",
|
||||
]
|
||||
}
|
||||
|
||||
+1
-2
@@ -45,7 +45,6 @@ ohos_shared_library("libwmutil") {
|
||||
"src/window_property.cpp",
|
||||
"src/window_transition_info.cpp",
|
||||
"src/wm_trace.cpp",
|
||||
"src/draw_surface.cpp"
|
||||
]
|
||||
|
||||
configs = [ ":libwmutil_private_config" ]
|
||||
@@ -53,9 +52,9 @@ ohos_shared_library("libwmutil") {
|
||||
public_configs = [ ":libwmutil_public_config" ]
|
||||
|
||||
deps = [
|
||||
"//foundation/graphic/graphic_2d/rosen/modules/2d_graphics:2d_graphics",
|
||||
"//foundation/graphic/graphic_2d/rosen/modules/render_service_base:librender_service_base",
|
||||
"//foundation/graphic/graphic_2d/rosen/modules/render_service_client:librender_service_client",
|
||||
"//foundation/graphic/graphic_2d/rosen/modules/2d_graphics:2d_graphics",
|
||||
"//third_party/flutter/build/skia:ace_skia_ohos",
|
||||
]
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ class IDisplayChangeListener : public RefBase {
|
||||
public:
|
||||
virtual void OnDisplayStateChange(DisplayId defaultDisplayId, sptr<DisplayInfo> info,
|
||||
const std::map<DisplayId, sptr<DisplayInfo>>& displayInfoMap, DisplayStateChangeType type) = 0;
|
||||
virtual void OnGetFullScreenWindowRequestedOrientation(DisplayId displayId, Orientation &orientation) = 0;
|
||||
virtual void OnGetWindowPreferredOrientation(DisplayId displayId, Orientation &orientation) = 0;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,48 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2022-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.
|
||||
*/
|
||||
|
||||
#ifndef DRAW_SURFACE_H
|
||||
#define DRAW_SURFACE_H
|
||||
|
||||
#include "draw/canvas.h"
|
||||
#include "nocopyable.h"
|
||||
#include "pixel_map.h"
|
||||
#include "refbase.h"
|
||||
#include "ui/rs_surface_node.h"
|
||||
#include "wm_common.h"
|
||||
#include "window.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Rosen {
|
||||
class DrawSurface {
|
||||
public:
|
||||
~DrawSurface() = default;
|
||||
static bool DrawColor(std::shared_ptr<OHOS::Rosen::RSSurfaceNode> surfaceNode, int32_t bufferWidth,
|
||||
int32_t bufferHeight, uint32_t color);
|
||||
static bool DrawImage(std::shared_ptr<OHOS::Rosen::RSSurfaceNode> surfaceNode, int32_t bufferWidth,
|
||||
int32_t bufferHeight,const std::string& imagePath);
|
||||
private:
|
||||
DrawSurface() {};
|
||||
static bool DoDraw(uint8_t *addr, uint32_t width, uint32_t height, const std::string& imagePath);
|
||||
static bool DoDraw(uint8_t *addr, uint32_t width, uint32_t height, uint32_t color);
|
||||
static sptr<OHOS::Surface> GetLayer(std::shared_ptr<OHOS::Rosen::RSSurfaceNode> surfaceNode);
|
||||
static sptr<OHOS::SurfaceBuffer> GetSurfaceBuffer(sptr<OHOS::Surface> layer,
|
||||
int32_t bufferWidth, int32_t bufferHeight);
|
||||
static void DrawPixelmap(OHOS::Rosen::Drawing::Canvas &canvas, const std::string& imagePath);
|
||||
static std::unique_ptr<OHOS::Media::PixelMap> DecodeImageToPixelMap(const std::string &imagePath);
|
||||
};
|
||||
} // Rosen
|
||||
} // OHOS
|
||||
#endif // DRAW_SURFACE_H
|
||||
@@ -18,9 +18,7 @@
|
||||
|
||||
#include <ui/rs_surface_node.h>
|
||||
#include "pixel_map.h"
|
||||
#ifdef ACE_ENABLE_GL
|
||||
#include "render_context/render_context.h"
|
||||
#endif
|
||||
|
||||
#include "refbase.h"
|
||||
#include "wm_common.h"
|
||||
#include "draw/canvas.h"
|
||||
@@ -33,21 +31,14 @@ class SurfaceDraw {
|
||||
public:
|
||||
SurfaceDraw() = default;
|
||||
~SurfaceDraw() = default;
|
||||
void Init();
|
||||
void DrawBackgroundColor(std::shared_ptr<RSSurfaceNode> surfaceNode, Rect winRect, uint32_t bkgColor);
|
||||
void DrawBitmap(std::shared_ptr<RSSurfaceNode> surfaceNode, Rect winRect,
|
||||
SkBitmap& bitmap, uint32_t bkgColor);
|
||||
bool DecodeImageFile(const char* filename, SkBitmap& bitmap);
|
||||
void DrawSkImage(std::shared_ptr<RSSurfaceNode> surfaceNode, Rect winRect,
|
||||
sptr<Media::PixelMap> pixelMap, uint32_t bkgColor);
|
||||
static bool DrawColor(std::shared_ptr<OHOS::Rosen::RSSurfaceNode> surfaceNode, int32_t bufferWidth,
|
||||
int32_t bufferHeight, uint32_t color);
|
||||
static bool DrawImage(std::shared_ptr<OHOS::Rosen::RSSurfaceNode> surfaceNode, int32_t bufferWidth,
|
||||
int32_t bufferHeight,const std::string& imagePath);
|
||||
private:
|
||||
int32_t bufferHeight, const std::string& imagePath);
|
||||
static bool DrawImageRect(std::shared_ptr<RSSurfaceNode> surfaceNode, Rect winRect,
|
||||
sptr<Media::PixelMap> pixelMap, uint32_t bkgColor);
|
||||
|
||||
std::shared_ptr<RSSurface> PrepareDraw(std::shared_ptr<RSSurfaceNode> surfaceNode,
|
||||
std::unique_ptr<RSSurfaceFrame>& frame, SkCanvas*& canvas, uint32_t width, uint32_t height);
|
||||
private:
|
||||
static bool DoDraw(uint8_t *addr, uint32_t width, uint32_t height, const std::string& imagePath);
|
||||
static bool DoDraw(uint8_t *addr, uint32_t width, uint32_t height, uint32_t color);
|
||||
static sptr<OHOS::Surface> GetLayer(std::shared_ptr<OHOS::Rosen::RSSurfaceNode> surfaceNode);
|
||||
@@ -55,10 +46,8 @@ private:
|
||||
int32_t bufferWidth, int32_t bufferHeight);
|
||||
static void DrawPixelmap(OHOS::Rosen::Drawing::Canvas &canvas, const std::string& imagePath);
|
||||
static std::unique_ptr<OHOS::Media::PixelMap> DecodeImageToPixelMap(const std::string &imagePath);
|
||||
|
||||
#ifdef ACE_ENABLE_GL
|
||||
std::unique_ptr<RenderContext> rc_ = nullptr;
|
||||
#endif
|
||||
static bool DoDrawImageRect(uint8_t *addr, int32_t winWidth, int32_t winHeight, sptr<Media::PixelMap> pixelMap,
|
||||
uint32_t color);
|
||||
};
|
||||
} // Rosen
|
||||
} // OHOS
|
||||
|
||||
@@ -332,6 +332,30 @@ public:
|
||||
return isOk;
|
||||
}
|
||||
|
||||
static bool IsRectSatisfiedWithSizeLimits(const Rect& rect, const WindowSizeLimits& sizeLimits)
|
||||
{
|
||||
if (rect.height_ == 0) {
|
||||
return false;
|
||||
}
|
||||
auto curRatio = static_cast<float>(rect.width_) / static_cast<float>(rect.height_);
|
||||
if (sizeLimits.minWidth_ <= rect.width_ && rect.width_ <= sizeLimits.maxWidth_ &&
|
||||
sizeLimits.minHeight_ <= rect.height_ && rect.height_ <= sizeLimits.maxHeight_ &&
|
||||
sizeLimits.minRatio_ <= curRatio && curRatio <= sizeLimits.maxRatio_) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool IsOnlySupportSplitAndShowWhenLocked(bool isShowWhenLocked, uint32_t modeSupportInfo)
|
||||
{
|
||||
uint32_t splitModeInfo = (WindowModeSupport::WINDOW_MODE_SUPPORT_SPLIT_PRIMARY |
|
||||
WindowModeSupport::WINDOW_MODE_SUPPORT_SPLIT_SECONDARY);
|
||||
if (isShowWhenLocked && (splitModeInfo == modeSupportInfo)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private:
|
||||
WindowHelper() = default;
|
||||
~WindowHelper() = default;
|
||||
|
||||
@@ -19,8 +19,7 @@
|
||||
#include <refbase.h>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
#include "parcel.h"
|
||||
|
||||
#include <parcel.h>
|
||||
#include "class_var_definition.h"
|
||||
#include "dm_common.h"
|
||||
#include "wm_common.h"
|
||||
@@ -68,12 +67,15 @@ public:
|
||||
void SetWindowSizeChangeReason(WindowSizeChangeReason reason);
|
||||
void SetTokenState(bool hasToken);
|
||||
void SetModeSupportInfo(uint32_t modeSupportInfo);
|
||||
void SetRequestModeSupportInfo(uint32_t requestModeSupportInfo);
|
||||
void SetDragType(DragType dragType);
|
||||
void SetStretchable(bool stretchable);
|
||||
void SetOriginRect(const Rect& rect);
|
||||
void SetTouchHotAreas(const std::vector<Rect>& rects);
|
||||
void SetAccessTokenId(uint32_t accessTokenId);
|
||||
void SetSizeLimits(const WindowSizeLimits& sizeLimits);
|
||||
WindowSizeChangeReason GetWindowSizeChangeReason() const;
|
||||
void SetTransform(const Transform& trans);
|
||||
|
||||
const std::string& GetWindowName() const;
|
||||
Rect GetRequestRect() const;
|
||||
@@ -104,11 +106,14 @@ public:
|
||||
const PointInfo& GetHitOffset() const;
|
||||
uint32_t GetAnimationFlag() const;
|
||||
uint32_t GetModeSupportInfo() const;
|
||||
uint32_t GetRequestModeSupportInfo() const;
|
||||
DragType GetDragType() const;
|
||||
bool GetStretchable() const;
|
||||
const Rect& GetOriginRect() const;
|
||||
void GetTouchHotAreas(std::vector<Rect>& rects) const;
|
||||
uint32_t GetAccessTokenId() const;
|
||||
Transform GetTransform() const;
|
||||
WindowSizeLimits GetSizeLimits() const;
|
||||
|
||||
virtual bool Marshalling(Parcel& parcel) const override;
|
||||
static WindowProperty* Unmarshalling(Parcel& parcel);
|
||||
@@ -120,6 +125,10 @@ private:
|
||||
static void MapUnmarshalling(Parcel& parcel, WindowProperty* property);
|
||||
bool MarshallingTouchHotAreas(Parcel& parcel) const;
|
||||
static void UnmarshallingTouchHotAreas(Parcel& parcel, WindowProperty* property);
|
||||
bool MarshallingTransform(Parcel& parcel) const;
|
||||
static void UnmarshallingTransform(Parcel& parcel, WindowProperty* property);
|
||||
bool MarshallingWindowSizeLimits(Parcel& parcel) const;
|
||||
static void UnmarshallingWindowSizeLimits(Parcel& parcel, WindowProperty* property);
|
||||
|
||||
std::string windowName_;
|
||||
Rect requestRect_ { 0, 0, 0, 0 }; // window rect requested by the client (without decoration size)
|
||||
@@ -146,7 +155,10 @@ private:
|
||||
uint32_t parentId_ { 0 };
|
||||
PointInfo hitOffset_ { 0, 0 };
|
||||
uint32_t animationFlag_ { static_cast<uint32_t>(WindowAnimation::DEFAULT) };
|
||||
// modeSupportInfo_ means supported modes in runtime, which can be changed
|
||||
uint32_t modeSupportInfo_ {WindowModeSupport::WINDOW_MODE_SUPPORT_ALL};
|
||||
// requestModeSupportInfo_ is configured in abilityInfo, usually can't be changed
|
||||
uint32_t requestModeSupportInfo_ {WindowModeSupport::WINDOW_MODE_SUPPORT_ALL};
|
||||
WindowSizeChangeReason windowSizeChangeReason_ = WindowSizeChangeReason::UNDEFINED;
|
||||
std::unordered_map<WindowType, SystemBarProperty> sysBarPropMap_ {
|
||||
{ WindowType::WINDOW_TYPE_STATUS_BAR, SystemBarProperty() },
|
||||
@@ -158,7 +170,10 @@ private:
|
||||
DragType dragType_ = DragType::DRAG_UNDEFINED;
|
||||
std::vector<Rect> touchHotAreas_; // coordinates relative to window.
|
||||
uint32_t accessTokenId_ { 0 };
|
||||
Transform trans_;
|
||||
DEFINE_VAR_DEFAULT_FUNC_GET_SET(Orientation, RequestedOrientation, requestedOrientation, Orientation::UNSPECIFIED);
|
||||
DEFINE_VAR_DEFAULT_FUNC_GET_SET(bool, CustomAnimation, isCustomAnimation, false);
|
||||
WindowSizeLimits sizeLimits_;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,6 +52,8 @@ public:
|
||||
void SetWindowType(WindowType windowType);
|
||||
WindowType GetWindowType();
|
||||
void SetShowFlagWhenLocked(bool isShow);
|
||||
void SetWindowSupportModes(const std::vector<uint32_t> supportModes);
|
||||
std::vector<uint32_t> GetWindowSupportModes();
|
||||
bool GetShowFlagWhenLocked();
|
||||
void SetTransitionReason(TransitionReason reason);
|
||||
TransitionReason GetTransitionReason();
|
||||
@@ -68,6 +70,7 @@ private:
|
||||
bool isShowWhenLocked_ = false;
|
||||
bool isRecent_ = false;
|
||||
TransitionReason reason_ = TransitionReason::ABILITY_TRANSITION;
|
||||
std::vector<uint32_t> supportWindowModes_;
|
||||
};
|
||||
} // Rosen
|
||||
} // OHOS
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
#ifndef OHOS_ROSEN_WM_COMMON_INNER_H
|
||||
#define OHOS_ROSEN_WM_COMMON_INNER_H
|
||||
|
||||
#include <cfloat>
|
||||
#include <cinttypes>
|
||||
#include "wm_common.h"
|
||||
|
||||
@@ -84,6 +85,7 @@ enum class PropertyChangeAction : uint32_t {
|
||||
ACTION_UPDATE_SET_BRIGHTNESS = 1 << 10,
|
||||
ACTION_UPDATE_MODE_SUPPORT_INFO = 1 << 11,
|
||||
ACTION_UPDATE_TOUCH_HOT_AREA = 1 << 12,
|
||||
ACTION_UPDATE_TRANSFORM_PROPERTY = 1 << 13,
|
||||
};
|
||||
|
||||
struct ModeChangeHotZonesConfig {
|
||||
@@ -93,16 +95,19 @@ struct ModeChangeHotZonesConfig {
|
||||
uint32_t secondaryRange_;
|
||||
};
|
||||
|
||||
struct FloatingWindowLimitsConfig {
|
||||
bool isFloatingWindowLimitsConfigured_;
|
||||
struct WindowSizeLimits {
|
||||
uint32_t maxWidth_;
|
||||
uint32_t maxHeight_;
|
||||
uint32_t minWidth_;
|
||||
uint32_t minHeight_;
|
||||
float maxRatio_;
|
||||
float minRatio_;
|
||||
FloatingWindowLimitsConfig() : isFloatingWindowLimitsConfigured_(false), maxWidth_(0), maxHeight_(0), minWidth_(0),
|
||||
minHeight_(0), maxRatio_(0.0f), minRatio_(0.0f) {}
|
||||
WindowSizeLimits() : maxWidth_(UINT32_MAX), maxHeight_(UINT32_MAX), minWidth_(0),
|
||||
minHeight_(0), maxRatio_(FLT_MAX), minRatio_(0.0f) {}
|
||||
WindowSizeLimits(uint32_t maxWidth, uint32_t maxHeight, uint32_t minWidth,
|
||||
uint32_t minHeight, float maxRatio, float minRatio)
|
||||
: maxWidth_(maxWidth), maxHeight_(maxHeight), minWidth_(minWidth),
|
||||
minHeight_(minHeight), maxRatio_(maxRatio), minRatio_(minRatio) {}
|
||||
};
|
||||
|
||||
struct ModeChangeHotZones {
|
||||
@@ -135,6 +140,7 @@ enum class TraceTaskId : int32_t {
|
||||
namespace {
|
||||
constexpr float DEFAULT_SPLIT_RATIO = 0.5;
|
||||
constexpr float DEFAULT_ASPECT_RATIO = 0.66;
|
||||
constexpr int32_t IVALID_DIALOG_WINDOW_ID = -1;
|
||||
constexpr uint32_t DIVIDER_WIDTH = 8;
|
||||
constexpr uint32_t WINDOW_TITLE_BAR_HEIGHT = 37;
|
||||
constexpr uint32_t WINDOW_FRAME_WIDTH = 5;
|
||||
@@ -146,6 +152,7 @@ namespace {
|
||||
constexpr uint32_t MIN_HORIZONTAL_SPLIT_WIDTH = 320;
|
||||
constexpr uint32_t MAX_FLOATING_SIZE = 2560;
|
||||
const Rect INVALID_EMPTY_RECT = {0, 0, 0, 0};
|
||||
const Rect DEFAULT_PLACE_HOLDER_RECT = {0, 0, 512, 512};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,195 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2022-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.
|
||||
*/
|
||||
|
||||
#include "draw_surface.h"
|
||||
#include "image/bitmap.h"
|
||||
#include "image_source.h"
|
||||
#include "image_type.h"
|
||||
#include "image_utils.h"
|
||||
#include "pixel_map.h"
|
||||
#include "window_manager_hilog.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Rosen {
|
||||
namespace {
|
||||
constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_WINDOW, "DrawSurface"};
|
||||
} // namespace
|
||||
|
||||
bool DrawSurface::DrawImage(std::shared_ptr<OHOS::Rosen::RSSurfaceNode> surfaceNode, int32_t bufferWidth, int32_t bufferHeight,
|
||||
const std::string& imagePath)
|
||||
{
|
||||
sptr<OHOS::Surface> layer = GetLayer(surfaceNode);
|
||||
if (layer == nullptr) {
|
||||
WLOGFE("layer is nullptr");
|
||||
return false;
|
||||
}
|
||||
sptr<OHOS::SurfaceBuffer> buffer = GetSurfaceBuffer(layer, bufferWidth, bufferHeight);
|
||||
if (buffer == nullptr || buffer->GetVirAddr() == nullptr) {
|
||||
return false;
|
||||
}
|
||||
auto addr = static_cast<uint8_t *>(buffer->GetVirAddr());
|
||||
if (!DoDraw(addr, buffer->GetWidth(), buffer->GetHeight(), imagePath)) {
|
||||
WLOGE("draw window pixel failed");
|
||||
return false;
|
||||
}
|
||||
OHOS::BufferFlushConfig flushConfig = {
|
||||
.damage = {
|
||||
.w = buffer->GetWidth(),
|
||||
.h = buffer->GetHeight(),
|
||||
},
|
||||
};
|
||||
OHOS::SurfaceError ret = layer->FlushBuffer(buffer, -1, flushConfig);
|
||||
if (ret != OHOS::SurfaceError::SURFACE_ERROR_OK) {
|
||||
WLOGFE("draw pointer FlushBuffer ret:%{public}s", SurfaceErrorStr(ret).c_str());
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool DrawSurface::DrawColor(std::shared_ptr<OHOS::Rosen::RSSurfaceNode> surfaceNode, int32_t bufferWidth, int32_t bufferHeight,
|
||||
uint32_t color)
|
||||
{
|
||||
sptr<OHOS::Surface> layer = GetLayer(surfaceNode);
|
||||
if (layer == nullptr) {
|
||||
WLOGFE("layer is nullptr");
|
||||
return false;
|
||||
}
|
||||
sptr<OHOS::SurfaceBuffer> buffer = GetSurfaceBuffer(layer, bufferWidth, bufferHeight);
|
||||
if (buffer == nullptr || buffer->GetVirAddr() == nullptr) {
|
||||
return false;
|
||||
}
|
||||
auto addr = static_cast<uint8_t *>(buffer->GetVirAddr());
|
||||
if (!DoDraw(addr, buffer->GetWidth(), buffer->GetHeight(), color)) {
|
||||
WLOGE("draw window color failed");
|
||||
return false;
|
||||
}
|
||||
OHOS::BufferFlushConfig flushConfig = {
|
||||
.damage = {
|
||||
.w = buffer->GetWidth(),
|
||||
.h = buffer->GetHeight(),
|
||||
},
|
||||
};
|
||||
OHOS::SurfaceError ret = layer->FlushBuffer(buffer, -1, flushConfig);
|
||||
if (ret != OHOS::SurfaceError::SURFACE_ERROR_OK) {
|
||||
WLOGFE("draw pointer FlushBuffer ret:%{public}s", SurfaceErrorStr(ret).c_str());
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
sptr<OHOS::Surface> DrawSurface::GetLayer(std::shared_ptr<OHOS::Rosen::RSSurfaceNode> surfaceNode)
|
||||
{
|
||||
if (surfaceNode == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
return surfaceNode->GetSurface();
|
||||
}
|
||||
|
||||
sptr<OHOS::SurfaceBuffer> DrawSurface::GetSurfaceBuffer(sptr<OHOS::Surface> layer,
|
||||
int32_t bufferWidth, int32_t bufferHeight)
|
||||
{
|
||||
sptr<OHOS::SurfaceBuffer> buffer;
|
||||
int32_t releaseFence = 0;
|
||||
OHOS::BufferRequestConfig config = {
|
||||
.width = bufferWidth,
|
||||
.height = bufferHeight,
|
||||
.strideAlignment = 0x8,
|
||||
.format = PIXEL_FMT_RGBA_8888,
|
||||
.usage = HBM_USE_CPU_READ | HBM_USE_CPU_WRITE | HBM_USE_MEM_DMA,
|
||||
};
|
||||
|
||||
OHOS::SurfaceError ret = layer->RequestBuffer(buffer, releaseFence, config);
|
||||
if (ret != OHOS::SURFACE_ERROR_OK) {
|
||||
WLOGFE("request buffer ret:%{public}s", SurfaceErrorStr(ret).c_str());
|
||||
return nullptr;
|
||||
}
|
||||
return buffer;
|
||||
}
|
||||
|
||||
std::unique_ptr<OHOS::Media::PixelMap> DrawSurface::DecodeImageToPixelMap(const std::string &imagePath)
|
||||
{
|
||||
OHOS::Media::SourceOptions opts;
|
||||
opts.formatHint = "image/png";
|
||||
uint32_t ret = 0;
|
||||
auto imageSource = OHOS::Media::ImageSource::CreateImageSource(imagePath, opts, ret);
|
||||
// CHKPP(imageSource);
|
||||
std::set<std::string> formats;
|
||||
ret = imageSource->GetSupportedFormats(formats);
|
||||
WLOGFD("get supported format ret:%{public}u", ret);
|
||||
|
||||
OHOS::Media::DecodeOptions decodeOpts;
|
||||
std::unique_ptr<OHOS::Media::PixelMap> pixelMap = imageSource->CreatePixelMap(decodeOpts, ret);
|
||||
if (pixelMap == nullptr) {
|
||||
WLOGFE("pixelMap is nullptr");
|
||||
}
|
||||
return pixelMap;
|
||||
}
|
||||
|
||||
void DrawSurface::DrawPixelmap(OHOS::Rosen::Drawing::Canvas &canvas, const std::string& imagePath)
|
||||
{
|
||||
std::unique_ptr<OHOS::Media::PixelMap> pixelmap = DecodeImageToPixelMap(imagePath);
|
||||
if (pixelmap == nullptr) {
|
||||
WLOGFE("drawing pixel map is nullptr");
|
||||
return;
|
||||
}
|
||||
OHOS::Rosen::Drawing::Pen pen;
|
||||
pen.SetAntiAlias(true);
|
||||
pen.SetColor(OHOS::Rosen::Drawing::Color::COLOR_BLUE);
|
||||
OHOS::Rosen::Drawing::scalar penWidth = 1;
|
||||
pen.SetWidth(penWidth);
|
||||
canvas.AttachPen(pen);
|
||||
canvas.DrawBitmap(*pixelmap, 0, 0);
|
||||
}
|
||||
|
||||
bool DrawSurface::DoDraw(uint8_t *addr, uint32_t width, uint32_t height, const std::string& imagePath)
|
||||
{
|
||||
OHOS::Rosen::Drawing::Bitmap bitmap;
|
||||
OHOS::Rosen::Drawing::BitmapFormat format { OHOS::Rosen::Drawing::COLORTYPE_RGBA_8888,
|
||||
OHOS::Rosen::Drawing::ALPHATYPE_OPAQUYE };
|
||||
bitmap.Build(width, height, format);
|
||||
OHOS::Rosen::Drawing::Canvas canvas;
|
||||
canvas.Bind(bitmap);
|
||||
canvas.Clear(OHOS::Rosen::Drawing::Color::COLOR_TRANSPARENT);
|
||||
DrawPixelmap(canvas, imagePath);
|
||||
static constexpr uint32_t stride = 4;
|
||||
uint32_t addrSize = width * height * stride;
|
||||
errno_t ret = memcpy_s(addr, addrSize, bitmap.GetPixels(), addrSize);
|
||||
if (ret != EOK) {
|
||||
WLOGFE("draw failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
bool DrawSurface::DoDraw(uint8_t *addr, uint32_t width, uint32_t height, uint32_t color)
|
||||
{
|
||||
OHOS::Rosen::Drawing::Bitmap bitmap;
|
||||
OHOS::Rosen::Drawing::BitmapFormat format { OHOS::Rosen::Drawing::COLORTYPE_RGBA_8888,
|
||||
OHOS::Rosen::Drawing::ALPHATYPE_OPAQUYE };
|
||||
bitmap.Build(width, height, format);
|
||||
OHOS::Rosen::Drawing::Canvas canvas;
|
||||
canvas.Bind(bitmap);
|
||||
canvas.Clear(color);
|
||||
|
||||
static constexpr uint32_t stride = 4;
|
||||
uint32_t addrSize = width * height * stride;
|
||||
errno_t ret = memcpy_s(addr, addrSize, bitmap.GetPixels(), addrSize);
|
||||
if (ret != EOK) {
|
||||
WLOGFE("draw failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
} // Rosen
|
||||
} // OHOS
|
||||
+87
-219
@@ -19,11 +19,7 @@
|
||||
#include <surface.h>
|
||||
#include <ui/rs_surface_extractor.h>
|
||||
#include "window_manager_hilog.h"
|
||||
#include "include/core/SkCanvas.h"
|
||||
#include "include/codec/SkCodec.h"
|
||||
#include "include/core/SkData.h"
|
||||
#include "include/core/SkImage.h"
|
||||
#include "include/core/SkPixmap.h"
|
||||
|
||||
#include "image/bitmap.h"
|
||||
#include "image_source.h"
|
||||
#include "image_type.h"
|
||||
@@ -36,213 +32,8 @@ namespace {
|
||||
constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_WINDOW, "SurfaceDraw"};
|
||||
} // namespace
|
||||
|
||||
void SurfaceDraw::Init()
|
||||
{
|
||||
#ifdef ACE_ENABLE_GL
|
||||
WLOGFI("Draw divider on gpu");
|
||||
if (!rc_) {
|
||||
rc_ = std::make_unique<RenderContext>();
|
||||
rc_->InitializeEglContext();
|
||||
WLOGFI("Draw Init Success");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
std::shared_ptr<RSSurface> SurfaceDraw::PrepareDraw(std::shared_ptr<RSSurfaceNode> surfaceNode,
|
||||
std::unique_ptr<RSSurfaceFrame>& frame, SkCanvas*& canvas, uint32_t width, uint32_t height)
|
||||
{
|
||||
std::shared_ptr<RSSurface> rsSurface = RSSurfaceExtractor::ExtractRSSurface(surfaceNode);
|
||||
if (rsSurface == nullptr) {
|
||||
WLOGFE("RSSurface is nullptr");
|
||||
return nullptr;
|
||||
}
|
||||
#ifdef ACE_ENABLE_GL
|
||||
rsSurface->SetRenderContext(rc_.get());
|
||||
#endif
|
||||
frame = rsSurface->RequestFrame(width, height);
|
||||
if (frame == nullptr) {
|
||||
WLOGFE("DrawBackgroundColor frameptr is nullptr");
|
||||
return nullptr;
|
||||
}
|
||||
canvas = frame->GetCanvas();
|
||||
if (canvas == nullptr) {
|
||||
WLOGFE("DrawBackgroundColor canvas is nullptr");
|
||||
return nullptr;
|
||||
}
|
||||
return rsSurface;
|
||||
}
|
||||
|
||||
void SurfaceDraw::DrawBackgroundColor(std::shared_ptr<RSSurfaceNode> surfaceNode, Rect winRect, uint32_t bkgColor)
|
||||
{
|
||||
WLOGFI("DrawBackgroundColor winRect, [%{public}d, %{public}d, %{public}d, %{public}d], bkgColor:%{public}x",
|
||||
winRect.posX_, winRect.posY_, winRect.width_, winRect.height_, bkgColor);
|
||||
auto width = winRect.width_;
|
||||
auto height = winRect.height_;
|
||||
std::unique_ptr<RSSurfaceFrame> frame;
|
||||
SkCanvas* canvas;
|
||||
auto rsSurface = PrepareDraw(surfaceNode, frame, canvas, width, height);
|
||||
if (rsSurface == nullptr) {
|
||||
return;
|
||||
}
|
||||
SkPaint bkgPaint;
|
||||
bkgPaint.setColor(bkgColor);
|
||||
canvas->drawRect(SkRect::MakeXYWH(0.0, 0.0, width, height), bkgPaint);
|
||||
rsSurface->FlushFrame(frame);
|
||||
}
|
||||
|
||||
// just for test
|
||||
static bool g_isLoaded = false;
|
||||
|
||||
bool SurfaceDraw::DecodeImageFile(const char* filename, SkBitmap& bitmap)
|
||||
{
|
||||
if (g_isLoaded) {
|
||||
return true;
|
||||
}
|
||||
sk_sp<SkData> data(SkData::MakeFromFileName(filename));
|
||||
std::unique_ptr<SkCodec> codec = SkCodec::MakeFromData(std::move(data));
|
||||
if (codec == nullptr) {
|
||||
return false;
|
||||
}
|
||||
SkColorType colorType = kN32_SkColorType;
|
||||
SkImageInfo info = codec->getInfo().makeColorType(colorType);
|
||||
if (!bitmap.tryAllocPixels(info)) {
|
||||
return false;
|
||||
}
|
||||
g_isLoaded = true;
|
||||
return SkCodec::kSuccess == codec->getPixels(info, bitmap.getPixels(), bitmap.rowBytes());
|
||||
}
|
||||
|
||||
void SurfaceDraw::DrawBitmap(std::shared_ptr<RSSurfaceNode> surfaceNode, Rect winRect,
|
||||
SkBitmap& bitmap, uint32_t bkgColor)
|
||||
{
|
||||
if (bitmap.isNull() || bitmap.width() == 0 || bitmap.height() == 0) {
|
||||
WLOGFE("bitmap is empty or width/height is 0");
|
||||
return;
|
||||
}
|
||||
WLOGFI("DrawBitmap winRect, x : %{public}d, y : %{public}d, width: %{public}d, height: %{public}d",
|
||||
winRect.posX_, winRect.posY_, winRect.width_, winRect.height_);
|
||||
auto width = static_cast<int32_t>(winRect.width_);
|
||||
auto height = static_cast<int32_t>(winRect.height_);
|
||||
std::unique_ptr<RSSurfaceFrame> frame;
|
||||
SkCanvas* canvas;
|
||||
auto rsSurface = PrepareDraw(surfaceNode, frame, canvas, width, height);
|
||||
if (rsSurface == nullptr) {
|
||||
return;
|
||||
}
|
||||
SkPaint bkgPaint;
|
||||
bkgPaint.setColor(bkgColor);
|
||||
canvas->drawRect(SkRect::MakeXYWH(0.0, 0.0, width, height), bkgPaint);
|
||||
SkPaint paint;
|
||||
SkRect rect;
|
||||
int realHeight = std::min(height, bitmap.height()); // need to scale
|
||||
int realWidth = std::min(width, bitmap.width());
|
||||
int pointX = (width - realWidth) / 2;
|
||||
int pointY = (height - realHeight) / 2;
|
||||
rect.setXYWH(pointX, pointY, realWidth, realHeight);
|
||||
sk_sp<SkImage> image = SkImage::MakeFromBitmap(bitmap);
|
||||
if (!image) {
|
||||
WLOGFE("image is nullptr");
|
||||
return;
|
||||
}
|
||||
canvas->drawImageRect(image.get(), rect, &paint);
|
||||
rsSurface->FlushFrame(frame);
|
||||
}
|
||||
|
||||
static SkAlphaType AlphaTypeToSkAlphaType(const sptr<Media::PixelMap>& pixmap)
|
||||
{
|
||||
switch (pixmap->GetAlphaType()) {
|
||||
case Media::AlphaType::IMAGE_ALPHA_TYPE_UNKNOWN:
|
||||
return SkAlphaType::kUnknown_SkAlphaType;
|
||||
case Media::AlphaType::IMAGE_ALPHA_TYPE_OPAQUE:
|
||||
return SkAlphaType::kOpaque_SkAlphaType;
|
||||
case Media::AlphaType::IMAGE_ALPHA_TYPE_PREMUL:
|
||||
return SkAlphaType::kPremul_SkAlphaType;
|
||||
case Media::AlphaType::IMAGE_ALPHA_TYPE_UNPREMUL:
|
||||
return SkAlphaType::kUnpremul_SkAlphaType;
|
||||
default:
|
||||
return SkAlphaType::kUnknown_SkAlphaType;
|
||||
}
|
||||
}
|
||||
|
||||
static SkColorType PixelFormatToSkColorType(const sptr<Media::PixelMap>& pixmap)
|
||||
{
|
||||
switch (pixmap->GetPixelFormat()) {
|
||||
case Media::PixelFormat::RGB_565:
|
||||
return SkColorType::kRGB_565_SkColorType;
|
||||
case Media::PixelFormat::RGBA_8888:
|
||||
return SkColorType::kRGBA_8888_SkColorType;
|
||||
case Media::PixelFormat::BGRA_8888:
|
||||
return SkColorType::kBGRA_8888_SkColorType;
|
||||
case Media::PixelFormat::ALPHA_8:
|
||||
return SkColorType::kAlpha_8_SkColorType;
|
||||
case Media::PixelFormat::RGBA_F16:
|
||||
return SkColorType::kRGBA_F16_SkColorType;
|
||||
case Media::PixelFormat::UNKNOWN:
|
||||
case Media::PixelFormat::ARGB_8888:
|
||||
case Media::PixelFormat::RGB_888:
|
||||
case Media::PixelFormat::NV21:
|
||||
case Media::PixelFormat::NV12:
|
||||
case Media::PixelFormat::CMYK:
|
||||
default:
|
||||
return SkColorType::kUnknown_SkColorType;
|
||||
}
|
||||
}
|
||||
|
||||
static SkImageInfo MakeSkImageInfoFromPixelMap(sptr<Media::PixelMap>& pixmap)
|
||||
{
|
||||
SkColorType colorType = PixelFormatToSkColorType(pixmap);
|
||||
SkAlphaType alphaType = AlphaTypeToSkAlphaType(pixmap);
|
||||
sk_sp<SkColorSpace> colorSpace = SkColorSpace::MakeSRGB();
|
||||
return SkImageInfo::Make(pixmap->GetWidth(), pixmap->GetHeight(), colorType, alphaType, colorSpace);
|
||||
}
|
||||
|
||||
void SurfaceDraw::DrawSkImage(std::shared_ptr<RSSurfaceNode> surfaceNode, Rect winRect,
|
||||
sptr<Media::PixelMap> pixelMap, uint32_t bkgColor)
|
||||
{
|
||||
// Get canvas
|
||||
WLOGFI("DrawSkImage winRect, [%{public}d, %{public}d, %{public}d, %{public}d], bkgColor:%{public}x",
|
||||
winRect.posX_, winRect.posY_, winRect.width_, winRect.height_, bkgColor);
|
||||
auto width = static_cast<int32_t>(winRect.width_);
|
||||
auto height = static_cast<int32_t>(winRect.height_);
|
||||
std::unique_ptr<RSSurfaceFrame> frame;
|
||||
SkCanvas* canvas;
|
||||
auto rsSurface = PrepareDraw(surfaceNode, frame, canvas, width, height);
|
||||
if (rsSurface == nullptr) {
|
||||
return;
|
||||
}
|
||||
SkPaint bkgPaint;
|
||||
bkgPaint.setColor(bkgColor);
|
||||
canvas->drawRect(SkRect::MakeXYWH(0.0, 0.0, width, height), bkgPaint);
|
||||
|
||||
// Create SkPixmap from PixelMap
|
||||
auto imageInfo = MakeSkImageInfoFromPixelMap(pixelMap);
|
||||
SkPixmap imagePixmap(imageInfo, reinterpret_cast<const void*>(pixelMap->GetPixels()), pixelMap->GetRowBytes());
|
||||
|
||||
// Create SkImage from SkPixmap
|
||||
sk_sp<SkImage> skImage = SkImage::MakeFromRaster(imagePixmap, nullptr, nullptr);
|
||||
if (!skImage) {
|
||||
WLOGFE("sk image is null");
|
||||
return;
|
||||
}
|
||||
|
||||
SkPaint paint;
|
||||
SkRect rect;
|
||||
int realHeight = std::min(height, skImage->height()); // need to scale
|
||||
int realWidth = std::min(width, skImage->width());
|
||||
int pointX = (width - realWidth) / 2; // 2 is mid point
|
||||
int pointY = (height - realHeight) / 2; // 2 is mid point
|
||||
rect.setXYWH(pointX, pointY, realWidth, realHeight);
|
||||
|
||||
canvas->drawImageRect(skImage.get(), rect, &paint);
|
||||
if (!rsSurface->FlushFrame(frame)) {
|
||||
WLOGFE("fail to flush frame");
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
bool SurfaceDraw::DrawImage(std::shared_ptr<OHOS::Rosen::RSSurfaceNode> surfaceNode, int32_t bufferWidth, int32_t bufferHeight,
|
||||
const std::string& imagePath)
|
||||
bool SurfaceDraw::DrawImage(std::shared_ptr<OHOS::Rosen::RSSurfaceNode> surfaceNode, int32_t bufferWidth,
|
||||
int32_t bufferHeight, const std::string& imagePath)
|
||||
{
|
||||
sptr<OHOS::Surface> layer = GetLayer(surfaceNode);
|
||||
if (layer == nullptr) {
|
||||
@@ -272,8 +63,8 @@ bool SurfaceDraw::DrawImage(std::shared_ptr<OHOS::Rosen::RSSurfaceNode> surfaceN
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SurfaceDraw::DrawColor(std::shared_ptr<OHOS::Rosen::RSSurfaceNode> surfaceNode, int32_t bufferWidth, int32_t bufferHeight,
|
||||
uint32_t color)
|
||||
bool SurfaceDraw::DrawColor(std::shared_ptr<OHOS::Rosen::RSSurfaceNode> surfaceNode, int32_t bufferWidth,
|
||||
int32_t bufferHeight, uint32_t color)
|
||||
{
|
||||
sptr<OHOS::Surface> layer = GetLayer(surfaceNode);
|
||||
if (layer == nullptr) {
|
||||
@@ -338,7 +129,10 @@ std::unique_ptr<OHOS::Media::PixelMap> SurfaceDraw::DecodeImageToPixelMap(const
|
||||
opts.formatHint = "image/png";
|
||||
uint32_t ret = 0;
|
||||
auto imageSource = OHOS::Media::ImageSource::CreateImageSource(imagePath, opts, ret);
|
||||
// CHKPP(imageSource);
|
||||
if (imageSource == nullptr) {
|
||||
WLOGFE("invalid image path.");
|
||||
return nullptr;
|
||||
}
|
||||
std::set<std::string> formats;
|
||||
ret = imageSource->GetSupportedFormats(formats);
|
||||
WLOGFD("get supported format ret:%{public}u", ret);
|
||||
@@ -370,8 +164,8 @@ void SurfaceDraw::DrawPixelmap(OHOS::Rosen::Drawing::Canvas &canvas, const std::
|
||||
bool SurfaceDraw::DoDraw(uint8_t *addr, uint32_t width, uint32_t height, const std::string& imagePath)
|
||||
{
|
||||
OHOS::Rosen::Drawing::Bitmap bitmap;
|
||||
OHOS::Rosen::Drawing::BitmapFormat format { OHOS::Rosen::Drawing::COLORTYPE_RGBA_8888,
|
||||
OHOS::Rosen::Drawing::ALPHATYPE_OPAQUYE };
|
||||
OHOS::Rosen::Drawing::BitmapFormat format { OHOS::Rosen::Drawing::ColorType::COLORTYPE_RGBA_8888,
|
||||
OHOS::Rosen::Drawing::AlphaType::ALPHATYPE_OPAQUYE };
|
||||
bitmap.Build(width, height, format);
|
||||
OHOS::Rosen::Drawing::Canvas canvas;
|
||||
canvas.Bind(bitmap);
|
||||
@@ -390,8 +184,8 @@ bool SurfaceDraw::DoDraw(uint8_t *addr, uint32_t width, uint32_t height, const s
|
||||
bool SurfaceDraw::DoDraw(uint8_t *addr, uint32_t width, uint32_t height, uint32_t color)
|
||||
{
|
||||
OHOS::Rosen::Drawing::Bitmap bitmap;
|
||||
OHOS::Rosen::Drawing::BitmapFormat format { OHOS::Rosen::Drawing::COLORTYPE_RGBA_8888,
|
||||
OHOS::Rosen::Drawing::ALPHATYPE_OPAQUYE };
|
||||
OHOS::Rosen::Drawing::BitmapFormat format { OHOS::Rosen::Drawing::ColorType::COLORTYPE_RGBA_8888,
|
||||
OHOS::Rosen::Drawing::AlphaType::ALPHATYPE_OPAQUYE };
|
||||
bitmap.Build(width, height, format);
|
||||
OHOS::Rosen::Drawing::Canvas canvas;
|
||||
canvas.Bind(bitmap);
|
||||
@@ -406,5 +200,79 @@ bool SurfaceDraw::DoDraw(uint8_t *addr, uint32_t width, uint32_t height, uint32_
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SurfaceDraw::DrawImageRect(std::shared_ptr<RSSurfaceNode> surfaceNode, Rect rect,
|
||||
sptr<Media::PixelMap> pixelMap, uint32_t color)
|
||||
{
|
||||
int32_t winHeight = static_cast<int32_t>(rect.height_);
|
||||
int32_t winWidth = static_cast<int32_t>(rect.width_);
|
||||
sptr<OHOS::Surface> layer = GetLayer(surfaceNode);
|
||||
if (layer == nullptr) {
|
||||
WLOGFE("layer is nullptr");
|
||||
return false;
|
||||
}
|
||||
sptr<OHOS::SurfaceBuffer> buffer = GetSurfaceBuffer(layer, winWidth, winHeight);
|
||||
if (buffer == nullptr || buffer->GetVirAddr() == nullptr) {
|
||||
return false;
|
||||
}
|
||||
auto addr = static_cast<uint8_t *>(buffer->GetVirAddr());
|
||||
if (!DoDrawImageRect(addr, winWidth, winHeight, pixelMap, color)) {
|
||||
WLOGE("draw image rect failed.");
|
||||
return false;
|
||||
}
|
||||
OHOS::BufferFlushConfig flushConfig = {
|
||||
.damage = {
|
||||
.w = buffer->GetWidth(),
|
||||
.h = buffer->GetHeight(),
|
||||
},
|
||||
};
|
||||
OHOS::SurfaceError surfaceRet = layer->FlushBuffer(buffer, -1, flushConfig);
|
||||
if (surfaceRet != OHOS::SurfaceError::SURFACE_ERROR_OK) {
|
||||
WLOGFE("draw pointer FlushBuffer ret:%{public}s", SurfaceErrorStr(surfaceRet).c_str());
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SurfaceDraw::DoDrawImageRect(uint8_t *addr, int32_t winWidth, int32_t winHeight,
|
||||
sptr<Media::PixelMap> pixelMap, uint32_t color)
|
||||
{
|
||||
OHOS::Rosen::Drawing::Bitmap bitmap;
|
||||
OHOS::Rosen::Drawing::BitmapFormat format { OHOS::Rosen::Drawing::ColorType::COLORTYPE_RGBA_8888,
|
||||
OHOS::Rosen::Drawing::AlphaType::ALPHATYPE_OPAQUYE };
|
||||
bitmap.Build(winWidth, winHeight, format);
|
||||
OHOS::Rosen::Drawing::Canvas canvas;
|
||||
canvas.Bind(bitmap);
|
||||
canvas.Clear(color);
|
||||
if (pixelMap == nullptr) {
|
||||
WLOGFE("drawing pixel map is nullptr");
|
||||
return false;
|
||||
}
|
||||
uint32_t iconHeight = pixelMap->GetHeight();
|
||||
uint32_t iconWidth = pixelMap->GetWidth();
|
||||
Drawing::Image image;
|
||||
OHOS::Rosen::Drawing::Bitmap iconBitmap;
|
||||
iconBitmap.Build(iconWidth, iconHeight, format);
|
||||
iconBitmap.SetPixels(const_cast<uint8_t*>(pixelMap->GetPixels()));
|
||||
image.BuildFromBitmap(iconBitmap);
|
||||
Drawing::SamplingOptions sampling = Drawing::SamplingOptions(Drawing::FilterMode::NEAREST,
|
||||
Drawing::MipmapMode::NEAREST);
|
||||
|
||||
int realHeight = std::min(winHeight, pixelMap->GetHeight()); // need to scale
|
||||
int realWidth = std::min(winWidth, pixelMap->GetWidth());
|
||||
int pointX = (winWidth - realWidth) / 2; // 2 is mid point
|
||||
int pointY = (winHeight - realHeight) / 2; // 2 is mid point
|
||||
Drawing::Rect dst(pointX, pointY, pointX + realWidth, pointY + realHeight);
|
||||
canvas.DrawImageRect(image, dst, sampling);
|
||||
|
||||
uint32_t stride = 4;
|
||||
uint32_t addrSize = winWidth * winHeight * stride;
|
||||
errno_t ret = memcpy_s(addr, addrSize, bitmap.GetPixels(), addrSize);
|
||||
if (ret != EOK) {
|
||||
WLOGFE("draw failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
} // Rosen
|
||||
} // OHOS
|
||||
@@ -51,7 +51,7 @@ void WindowProperty::SetWindowType(WindowType type)
|
||||
|
||||
void WindowProperty::SetWindowMode(WindowMode mode)
|
||||
{
|
||||
if (!WindowHelper::IsValidWindowMode(mode)) {
|
||||
if (!WindowHelper::IsValidWindowMode(mode) || !WindowHelper::IsWindowModeSupported(modeSupportInfo_, mode)) {
|
||||
return;
|
||||
}
|
||||
if (!WindowHelper::IsSplitWindowMode(mode_)) {
|
||||
@@ -62,6 +62,9 @@ void WindowProperty::SetWindowMode(WindowMode mode)
|
||||
|
||||
void WindowProperty::SetLastWindowMode(WindowMode mode)
|
||||
{
|
||||
if (!WindowHelper::IsWindowModeSupported(modeSupportInfo_, mode)) {
|
||||
return;
|
||||
}
|
||||
lastMode_ = mode;
|
||||
}
|
||||
|
||||
@@ -103,6 +106,11 @@ void WindowProperty::SetAlpha(float alpha)
|
||||
alpha_ = alpha;
|
||||
}
|
||||
|
||||
void WindowProperty::SetTransform(const Transform& trans)
|
||||
{
|
||||
trans_ = trans;
|
||||
}
|
||||
|
||||
void WindowProperty::SetBrightness(float brightness)
|
||||
{
|
||||
brightness_ = brightness;
|
||||
@@ -133,6 +141,11 @@ void WindowProperty::SetWindowFlags(uint32_t flags)
|
||||
flags_ = flags;
|
||||
}
|
||||
|
||||
void WindowProperty::SetSizeLimits(const WindowSizeLimits& sizeLimits)
|
||||
{
|
||||
sizeLimits_ = sizeLimits;
|
||||
}
|
||||
|
||||
void WindowProperty::AddWindowFlag(WindowFlag flag)
|
||||
{
|
||||
flags_ |= static_cast<uint32_t>(flag);
|
||||
@@ -192,6 +205,9 @@ WindowSizeChangeReason WindowProperty::GetWindowSizeChangeReason() const
|
||||
|
||||
void WindowProperty::ResumeLastWindowMode()
|
||||
{
|
||||
if (!WindowHelper::IsWindowModeSupported(modeSupportInfo_, lastMode_)) {
|
||||
return;
|
||||
}
|
||||
mode_ = lastMode_;
|
||||
}
|
||||
|
||||
@@ -270,6 +286,11 @@ float WindowProperty::GetAlpha() const
|
||||
return alpha_;
|
||||
}
|
||||
|
||||
Transform WindowProperty::GetTransform() const
|
||||
{
|
||||
return trans_;
|
||||
}
|
||||
|
||||
float WindowProperty::GetBrightness() const
|
||||
{
|
||||
return brightness_;
|
||||
@@ -325,6 +346,11 @@ void WindowProperty::SetModeSupportInfo(uint32_t modeSupportInfo)
|
||||
modeSupportInfo_ = modeSupportInfo;
|
||||
}
|
||||
|
||||
void WindowProperty::SetRequestModeSupportInfo(uint32_t requestModeSupportInfo)
|
||||
{
|
||||
requestModeSupportInfo_ = requestModeSupportInfo;
|
||||
}
|
||||
|
||||
uint32_t WindowProperty::GetWindowId() const
|
||||
{
|
||||
return windowId_;
|
||||
@@ -350,6 +376,11 @@ uint32_t WindowProperty::GetModeSupportInfo() const
|
||||
return modeSupportInfo_;
|
||||
}
|
||||
|
||||
uint32_t WindowProperty::GetRequestModeSupportInfo() const
|
||||
{
|
||||
return requestModeSupportInfo_;
|
||||
}
|
||||
|
||||
bool WindowProperty::GetTokenState() const
|
||||
{
|
||||
return tokenState_;
|
||||
@@ -370,6 +401,11 @@ bool WindowProperty::GetStretchable() const
|
||||
return isStretchable_;
|
||||
}
|
||||
|
||||
WindowSizeLimits WindowProperty::GetSizeLimits() const
|
||||
{
|
||||
return sizeLimits_;
|
||||
}
|
||||
|
||||
void WindowProperty::SetTouchHotAreas(const std::vector<Rect>& rects)
|
||||
{
|
||||
touchHotAreas_ = rects;
|
||||
@@ -407,7 +443,6 @@ bool WindowProperty::MapMarshalling(Parcel& parcel) const
|
||||
|
||||
void WindowProperty::MapUnmarshalling(Parcel& parcel, WindowProperty* property)
|
||||
{
|
||||
std::unordered_map<WindowType, SystemBarProperty> sysBarPropMap;
|
||||
uint32_t size = parcel.ReadUint32();
|
||||
for (uint32_t i = 0; i < size; i++) {
|
||||
WindowType type = static_cast<WindowType>(parcel.ReadUint32());
|
||||
@@ -440,6 +475,48 @@ void WindowProperty::UnmarshallingTouchHotAreas(Parcel& parcel, WindowProperty*
|
||||
}
|
||||
}
|
||||
|
||||
bool WindowProperty::MarshallingTransform(Parcel& parcel) const
|
||||
{
|
||||
return parcel.WriteFloat(trans_.pivotX_) && parcel.WriteFloat(trans_.pivotY_) &&
|
||||
parcel.WriteFloat(trans_.scaleX_) && parcel.WriteFloat(trans_.scaleY_) &&
|
||||
parcel.WriteFloat(trans_.rotationX_) && parcel.WriteFloat(trans_.rotationY_) &&
|
||||
parcel.WriteFloat(trans_.rotationZ_) && parcel.WriteFloat(trans_.translateX_) &&
|
||||
parcel.WriteFloat(trans_.translateY_) && parcel.WriteFloat(trans_.translateZ_);
|
||||
}
|
||||
|
||||
void WindowProperty::UnmarshallingTransform(Parcel& parcel, WindowProperty* property)
|
||||
{
|
||||
Transform trans;
|
||||
trans.pivotX_ = parcel.ReadFloat();
|
||||
trans.pivotY_ = parcel.ReadFloat();
|
||||
trans.scaleX_ = parcel.ReadFloat();
|
||||
trans.scaleY_ = parcel.ReadFloat();
|
||||
trans.rotationX_ = parcel.ReadFloat();
|
||||
trans.rotationY_ = parcel.ReadFloat();
|
||||
trans.rotationZ_ = parcel.ReadFloat();
|
||||
trans.translateX_ = parcel.ReadFloat();
|
||||
trans.translateY_ = parcel.ReadFloat();
|
||||
trans.translateZ_ = parcel.ReadFloat();
|
||||
property->SetTransform(trans);
|
||||
}
|
||||
|
||||
bool WindowProperty::MarshallingWindowSizeLimits(Parcel& parcel) const
|
||||
{
|
||||
if (parcel.WriteUint32(sizeLimits_.maxWidth_) && parcel.WriteUint32(sizeLimits_.maxHeight_) &&
|
||||
parcel.WriteUint32(sizeLimits_.minWidth_) && parcel.WriteUint32(sizeLimits_.minHeight_) &&
|
||||
parcel.WriteFloat(sizeLimits_.maxRatio_) && parcel.WriteFloat(sizeLimits_.minRatio_)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void WindowProperty::UnmarshallingWindowSizeLimits(Parcel& parcel, WindowProperty* property)
|
||||
{
|
||||
WindowSizeLimits sizeLimits = { parcel.ReadUint32(), parcel.ReadUint32(), parcel.ReadUint32(), parcel.ReadUint32(),
|
||||
parcel.ReadFloat(), parcel.ReadFloat() };
|
||||
property->SetSizeLimits(sizeLimits);
|
||||
}
|
||||
|
||||
bool WindowProperty::Marshalling(Parcel& parcel) const
|
||||
{
|
||||
return parcel.WriteString(windowName_) && parcel.WriteInt32(windowRect_.posX_) &&
|
||||
@@ -458,9 +535,12 @@ bool WindowProperty::Marshalling(Parcel& parcel) const
|
||||
parcel.WriteUint32(static_cast<uint32_t>(windowSizeChangeReason_)) && parcel.WriteBool(tokenState_) &&
|
||||
parcel.WriteUint32(callingWindow_) && parcel.WriteUint32(static_cast<uint32_t>(requestedOrientation_)) &&
|
||||
parcel.WriteBool(turnScreenOn_) && parcel.WriteBool(keepScreenOn_) &&
|
||||
parcel.WriteUint32(modeSupportInfo_) && parcel.WriteUint32(static_cast<uint32_t>(dragType_)) &&
|
||||
parcel.WriteUint32(modeSupportInfo_) && parcel.WriteUint32(requestModeSupportInfo_) &&
|
||||
parcel.WriteUint32(static_cast<uint32_t>(dragType_)) &&
|
||||
parcel.WriteUint32(originRect_.width_) && parcel.WriteUint32(originRect_.height_) &&
|
||||
parcel.WriteBool(isStretchable_) && MarshallingTouchHotAreas(parcel) && parcel.WriteUint32(accessTokenId_);
|
||||
parcel.WriteBool(isStretchable_) && MarshallingTouchHotAreas(parcel) && parcel.WriteUint32(accessTokenId_) &&
|
||||
parcel.WriteBool(isCustomAnimation_) && MarshallingTransform(parcel) &&
|
||||
MarshallingWindowSizeLimits(parcel);
|
||||
}
|
||||
|
||||
WindowProperty* WindowProperty::Unmarshalling(Parcel& parcel)
|
||||
@@ -502,6 +582,7 @@ WindowProperty* WindowProperty::Unmarshalling(Parcel& parcel)
|
||||
property->SetTurnScreenOn(parcel.ReadBool());
|
||||
property->SetKeepScreenOn(parcel.ReadBool());
|
||||
property->SetModeSupportInfo(parcel.ReadUint32());
|
||||
property->SetRequestModeSupportInfo(parcel.ReadUint32());
|
||||
property->SetDragType(static_cast<DragType>(parcel.ReadUint32()));
|
||||
uint32_t w = parcel.ReadUint32();
|
||||
uint32_t h = parcel.ReadUint32();
|
||||
@@ -509,6 +590,9 @@ WindowProperty* WindowProperty::Unmarshalling(Parcel& parcel)
|
||||
property->SetStretchable(parcel.ReadBool());
|
||||
UnmarshallingTouchHotAreas(parcel, property);
|
||||
property->SetAccessTokenId(parcel.ReadUint32());
|
||||
property->SetCustomAnimation(parcel.ReadBool());
|
||||
UnmarshallingTransform(parcel, property);
|
||||
UnmarshallingWindowSizeLimits(parcel, property);
|
||||
return property;
|
||||
}
|
||||
|
||||
@@ -560,6 +644,9 @@ bool WindowProperty::Write(Parcel& parcel, PropertyChangeAction action)
|
||||
case PropertyChangeAction::ACTION_UPDATE_TOUCH_HOT_AREA:
|
||||
ret &= MarshallingTouchHotAreas(parcel);
|
||||
break;
|
||||
case PropertyChangeAction::ACTION_UPDATE_TRANSFORM_PROPERTY:
|
||||
ret &= MarshallingTransform(parcel);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -613,6 +700,9 @@ void WindowProperty::Read(Parcel& parcel, PropertyChangeAction action)
|
||||
case PropertyChangeAction::ACTION_UPDATE_TOUCH_HOT_AREA:
|
||||
UnmarshallingTouchHotAreas(parcel, this);
|
||||
break;
|
||||
case PropertyChangeAction::ACTION_UPDATE_TRANSFORM_PROPERTY:
|
||||
UnmarshallingTransform(parcel, this);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -650,11 +740,15 @@ void WindowProperty::CopyFrom(const sptr<WindowProperty>& property)
|
||||
turnScreenOn_ = property->turnScreenOn_;
|
||||
keepScreenOn_ = property->keepScreenOn_;
|
||||
modeSupportInfo_ = property->modeSupportInfo_;
|
||||
requestModeSupportInfo_ = property->requestModeSupportInfo_;
|
||||
dragType_ = property->dragType_;
|
||||
originRect_ = property->originRect_;
|
||||
isStretchable_ = property->isStretchable_;
|
||||
touchHotAreas_ = property->touchHotAreas_;
|
||||
accessTokenId_ = property->accessTokenId_;
|
||||
isCustomAnimation_ = property->isCustomAnimation_;
|
||||
trans_ = property->trans_;
|
||||
sizeLimits_ = property->sizeLimits_;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@ WindowTransitionInfo::WindowTransitionInfo(sptr<AAFwk::AbilityTransitionInfo> in
|
||||
displayId_ = info->displayId_;
|
||||
isShowWhenLocked_ = info->isShowWhenLocked_;
|
||||
isRecent_ = info->isRecent_;
|
||||
supportWindowModes_ = { 0, 1, 2 }; // 0:fullScreen 1:split 2:floating
|
||||
}
|
||||
|
||||
void WindowTransitionInfo::SetBundleName(std::string name)
|
||||
@@ -103,6 +104,16 @@ void WindowTransitionInfo::SetShowFlagWhenLocked(bool isShow)
|
||||
isShowWhenLocked_ = isShow;
|
||||
}
|
||||
|
||||
void WindowTransitionInfo::SetWindowSupportModes(const std::vector<uint32_t> supportModes)
|
||||
{
|
||||
supportWindowModes_.assign(supportModes.begin(), supportModes.end());
|
||||
}
|
||||
|
||||
std::vector<uint32_t> WindowTransitionInfo::GetWindowSupportModes()
|
||||
{
|
||||
return supportWindowModes_;
|
||||
}
|
||||
|
||||
bool WindowTransitionInfo::GetShowFlagWhenLocked()
|
||||
{
|
||||
return isShowWhenLocked_;
|
||||
|
||||
+1
-1
@@ -73,7 +73,7 @@ ohos_shared_library("libwm") {
|
||||
"ability_base:want",
|
||||
"ability_runtime:ability_context_native",
|
||||
"ability_runtime:ability_manager",
|
||||
"ace_engine_standard:ace_uicontent",
|
||||
"ace_engine:ace_uicontent",
|
||||
"bundle_framework:appexecfwk_base",
|
||||
"bundle_framework:appexecfwk_core",
|
||||
"graphic_standard:surface",
|
||||
|
||||
@@ -43,7 +43,6 @@ public:
|
||||
virtual WMError RequestFocus(uint32_t windowId);
|
||||
virtual WMError GetAvoidAreaByType(uint32_t windowId, AvoidAreaType type, AvoidArea& avoidRect);
|
||||
virtual WMError SetWindowBackgroundBlur(uint32_t windowId, WindowBlurLevel level);
|
||||
virtual WMError SetAlpha(uint32_t windowId, float alpha);
|
||||
virtual WMError GetTopWindowId(uint32_t mainWinId, uint32_t& topWinId);
|
||||
virtual void ProcessPointDown(uint32_t windowId, bool isStartDrag = false);
|
||||
virtual void ProcessPointUp(uint32_t windowId);
|
||||
|
||||
@@ -29,6 +29,7 @@ public:
|
||||
~WindowAgent() = default;
|
||||
void UpdateWindowRect(const struct Rect& rect, bool decoStatus, WindowSizeChangeReason reason) override;
|
||||
void UpdateWindowMode(WindowMode mode) override;
|
||||
void UpdateWindowModeSupportInfo(uint32_t modeSupportInfo) override;
|
||||
void UpdateFocusStatus(bool focused) override;
|
||||
void UpdateAvoidArea(const sptr<AvoidArea>& avoidArea, AvoidAreaType type) override;
|
||||
void UpdateWindowState(WindowState state) override;
|
||||
|
||||
@@ -116,7 +116,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 override;
|
||||
uint32_t GetRequestModeSupportInfo() const override;
|
||||
inline NotifyNativeWinDestroyFunc GetNativeDestroyCallback()
|
||||
{
|
||||
return notifyNativefunc_;
|
||||
@@ -127,13 +127,15 @@ public:
|
||||
virtual WMError SetWindowType(WindowType type) override;
|
||||
virtual WMError SetWindowMode(WindowMode mode) override;
|
||||
virtual WMError SetWindowBackgroundBlur(WindowBlurLevel level) override;
|
||||
virtual WMError SetAlpha(float alpha) override;
|
||||
virtual void SetAlpha(float alpha) override;
|
||||
virtual void SetTransform(const Transform& trans) override;
|
||||
virtual WMError AddWindowFlag(WindowFlag flag) override;
|
||||
virtual WMError RemoveWindowFlag(WindowFlag flag) override;
|
||||
virtual WMError SetWindowFlags(uint32_t flags) override;
|
||||
virtual WMError SetSystemBarProperty(WindowType type, const SystemBarProperty& property) override;
|
||||
virtual WMError SetLayoutFullScreen(bool status) override;
|
||||
virtual WMError SetFullScreen(bool status) override;
|
||||
virtual Transform GetTransform() const override;
|
||||
inline void SetWindowState(WindowState state)
|
||||
{
|
||||
state_ = state;
|
||||
@@ -143,8 +145,8 @@ public:
|
||||
WMError Create(const std::string& parentName,
|
||||
const std::shared_ptr<AbilityRuntime::Context>& context = nullptr);
|
||||
virtual WMError Destroy() override;
|
||||
virtual WMError Show(uint32_t reason = 0) override;
|
||||
virtual WMError Hide(uint32_t reason = 0) override;
|
||||
virtual WMError Show(uint32_t reason = 0, bool isCustomAnimation = false) override;
|
||||
virtual WMError Hide(uint32_t reason = 0, bool isCustomAnimation = false) override;
|
||||
virtual WMError MoveTo(int32_t x, int32_t y) override;
|
||||
virtual WMError Resize(uint32_t width, uint32_t height) override;
|
||||
virtual WMError SetKeepScreenOn(bool keepScreenOn) override;
|
||||
@@ -189,9 +191,10 @@ public:
|
||||
virtual void RegisterTouchOutsideListener(const sptr<ITouchOutsideListener>& listener) override;
|
||||
virtual void UnregisterTouchOutsideListener(const sptr<ITouchOutsideListener>& listener) override;
|
||||
virtual void SetAceAbilityHandler(const sptr<IAceAbilityHandler>& handler) override;
|
||||
virtual void SetModeSupportInfo(uint32_t modeSupportInfo) override;
|
||||
virtual void SetRequestModeSupportInfo(uint32_t modeSupportInfo) override;
|
||||
void UpdateRect(const struct Rect& rect, bool decoStatus, WindowSizeChangeReason reason);
|
||||
void UpdateMode(WindowMode mode);
|
||||
void UpdateModeSupportInfo(uint32_t modeSupportInfo);
|
||||
virtual void ConsumeKeyEvent(std::shared_ptr<MMI::KeyEvent>& inputEvent) override;
|
||||
virtual void ConsumePointerEvent(std::shared_ptr<MMI::PointerEvent>& inputEvent) override;
|
||||
virtual void RequestFrame() override;
|
||||
@@ -337,7 +340,10 @@ private:
|
||||
void UpdateDragType();
|
||||
void InitListenerHandler();
|
||||
bool CheckCameraFloatingWindowMultiCreated(WindowType type);
|
||||
void SetOrientationFromAbility();
|
||||
void GetConfigurationFromAbilityInfo();
|
||||
void UpdateTitleButtonVisibility();
|
||||
void SetModeSupportInfo(uint32_t modeSupportInfo);
|
||||
uint32_t GetModeSupportInfo() const;
|
||||
|
||||
// colorspace, gamut
|
||||
using ColorSpaceConvertMap = struct {
|
||||
|
||||
@@ -31,6 +31,7 @@ public:
|
||||
enum class WindowMessage : uint32_t {
|
||||
TRANS_ID_UPDATE_WINDOW_RECT,
|
||||
TRANS_ID_UPDATE_WINDOW_MODE,
|
||||
TRANS_ID_UPDATE_MODE_SUPPORT_INFO,
|
||||
TRANS_ID_UPDATE_FOCUS_STATUS,
|
||||
TRANS_ID_UPDATE_AVOID_AREA,
|
||||
TRANS_ID_UPDATE_WINDOW_STATE,
|
||||
@@ -45,6 +46,7 @@ public:
|
||||
|
||||
virtual void UpdateWindowRect(const struct Rect& rect, bool decoStatus, WindowSizeChangeReason reason) = 0;
|
||||
virtual void UpdateWindowMode(WindowMode mode) = 0;
|
||||
virtual void UpdateWindowModeSupportInfo(uint32_t modeSupportInfo) = 0;
|
||||
virtual void UpdateFocusStatus(bool focused) = 0;
|
||||
virtual void UpdateAvoidArea(const sptr<AvoidArea>& avoidArea, AvoidAreaType type) = 0;
|
||||
virtual void UpdateWindowState(WindowState state) = 0;
|
||||
|
||||
@@ -30,6 +30,7 @@ public:
|
||||
|
||||
void UpdateWindowRect(const struct Rect& rect, bool decoStatus, WindowSizeChangeReason reason) override;
|
||||
void UpdateWindowMode(WindowMode mode) override;
|
||||
void UpdateWindowModeSupportInfo(uint32_t modeSupportInfo) override;
|
||||
void UpdateFocusStatus(bool focused) override;
|
||||
void UpdateAvoidArea(const sptr<AvoidArea>& avoidArea, AvoidAreaType type) override;
|
||||
void UpdateWindowState(WindowState state) override;
|
||||
|
||||
@@ -113,13 +113,6 @@ WMError WindowAdapter::SetWindowBackgroundBlur(uint32_t windowId, WindowBlurLeve
|
||||
return windowManagerServiceProxy_->SetWindowBackgroundBlur(windowId, level);
|
||||
}
|
||||
|
||||
WMError WindowAdapter::SetAlpha(uint32_t windowId, float alpha)
|
||||
{
|
||||
INIT_PROXY_CHECK_RETURN(WMError::WM_ERROR_SAMGR);
|
||||
|
||||
return windowManagerServiceProxy_->SetAlpha(windowId, alpha);
|
||||
}
|
||||
|
||||
void WindowAdapter::ProcessPointDown(uint32_t windowId, bool isStartDrag)
|
||||
{
|
||||
INIT_PROXY_CHECK_RETURN();
|
||||
|
||||
@@ -46,6 +46,15 @@ void WindowAgent::UpdateWindowMode(WindowMode mode)
|
||||
window_->UpdateMode(mode);
|
||||
}
|
||||
|
||||
void WindowAgent::UpdateWindowModeSupportInfo(uint32_t modeSupportInfo)
|
||||
{
|
||||
if (window_ == nullptr) {
|
||||
WLOGFE("window_ is nullptr");
|
||||
return;
|
||||
}
|
||||
window_->UpdateModeSupportInfo(modeSupportInfo);
|
||||
}
|
||||
|
||||
void WindowAgent::UpdateFocusStatus(bool focused)
|
||||
{
|
||||
if (window_ == nullptr) {
|
||||
|
||||
+150
-64
@@ -48,7 +48,8 @@ const WindowImpl::ColorSpaceConvertMap WindowImpl::colorSpaceConvertMap[] = {
|
||||
std::map<std::string, std::pair<uint32_t, sptr<Window>>> WindowImpl::windowMap_;
|
||||
std::map<uint32_t, std::vector<sptr<WindowImpl>>> WindowImpl::subWindowMap_;
|
||||
std::map<uint32_t, std::vector<sptr<WindowImpl>>> WindowImpl::appFloatingWindowMap_;
|
||||
|
||||
static int ctorCnt = 0;
|
||||
static int dtorCnt = 0;
|
||||
WindowImpl::WindowImpl(const sptr<WindowOption>& option)
|
||||
{
|
||||
property_ = new (std::nothrow) WindowProperty();
|
||||
@@ -57,7 +58,6 @@ WindowImpl::WindowImpl(const sptr<WindowOption>& option)
|
||||
property_->SetWindowType(option->GetWindowType());
|
||||
property_->SetWindowMode(option->GetWindowMode());
|
||||
property_->SetWindowBackgroundBlur(option->GetWindowBackgroundBlur());
|
||||
property_->SetAlpha(option->GetAlpha());
|
||||
property_->SetFullScreen(option->GetWindowMode() == WindowMode::WINDOW_MODE_FULLSCREEN);
|
||||
property_->SetFocusable(option->GetFocusable());
|
||||
property_->SetTouchable(option->GetTouchable());
|
||||
@@ -81,6 +81,7 @@ WindowImpl::WindowImpl(const sptr<WindowOption>& option)
|
||||
struct RSSurfaceNodeConfig rsSurfaceNodeConfig;
|
||||
rsSurfaceNodeConfig.SurfaceNodeName = property_->GetWindowName();
|
||||
surfaceNode_ = RSSurfaceNode::Create(rsSurfaceNodeConfig);
|
||||
WLOGFI("WindowImpl constructor Count: %{public}d name: %{public}s", ++ctorCnt, property_->GetWindowName().c_str());
|
||||
}
|
||||
|
||||
void WindowImpl::InitListenerHandler()
|
||||
@@ -104,7 +105,8 @@ WindowImpl::~WindowImpl()
|
||||
if (eventHandler_ != nullptr) {
|
||||
eventHandler_.reset();
|
||||
}
|
||||
WLOGFI("windowName: %{public}s, windowId: %{public}d", GetWindowName().c_str(), GetWindowId());
|
||||
WLOGFI("windowName: %{public}s, windowId: %{public}d, dtorCnt: %{public}d, surfaceNode:%{public}d",
|
||||
GetWindowName().c_str(), GetWindowId(), ++dtorCnt, static_cast<uint32_t>(surfaceNode_.use_count()));
|
||||
Destroy();
|
||||
}
|
||||
|
||||
@@ -276,6 +278,11 @@ uint32_t WindowImpl::GetWindowFlags() const
|
||||
return property_->GetWindowFlags();
|
||||
}
|
||||
|
||||
uint32_t WindowImpl::GetRequestModeSupportInfo() const
|
||||
{
|
||||
return property_->GetRequestModeSupportInfo();
|
||||
}
|
||||
|
||||
uint32_t WindowImpl::GetModeSupportInfo() const
|
||||
{
|
||||
return property_->GetModeSupportInfo();
|
||||
@@ -364,14 +371,29 @@ WMError WindowImpl::SetWindowBackgroundBlur(WindowBlurLevel level)
|
||||
return SingletonContainer::Get<WindowAdapter>().SetWindowBackgroundBlur(property_->GetWindowId(), level);
|
||||
}
|
||||
|
||||
WMError WindowImpl::SetAlpha(float alpha)
|
||||
void WindowImpl::SetAlpha(float alpha)
|
||||
{
|
||||
WLOGFI("[Client] Window %{public}u alpha %{public}f", property_->GetWindowId(), alpha);
|
||||
if (!IsWindowValid()) {
|
||||
return WMError::WM_ERROR_INVALID_WINDOW;
|
||||
return;
|
||||
}
|
||||
property_->SetAlpha(alpha);
|
||||
return SingletonContainer::Get<WindowAdapter>().SetAlpha(property_->GetWindowId(), alpha);
|
||||
surfaceNode_->SetAlpha(alpha);
|
||||
}
|
||||
|
||||
void WindowImpl::SetTransform(const Transform& trans)
|
||||
{
|
||||
WLOGFI("[Client] Window %{public}u SetTransform", property_->GetWindowId());
|
||||
if (!IsWindowValid()) {
|
||||
return;
|
||||
}
|
||||
property_->SetTransform(trans);
|
||||
UpdateProperty(PropertyChangeAction::ACTION_UPDATE_TRANSFORM_PROPERTY);
|
||||
}
|
||||
|
||||
Transform WindowImpl::GetTransform() const
|
||||
{
|
||||
return property_->GetTransform();
|
||||
}
|
||||
|
||||
WMError WindowImpl::AddWindowFlag(WindowFlag flag)
|
||||
@@ -448,9 +470,11 @@ WMError WindowImpl::SetUIContent(const std::string& contentInfo,
|
||||
} else {
|
||||
uiContent->Initialize(this, contentInfo, storage);
|
||||
}
|
||||
// make uiContent_ available after Initialize/Restore
|
||||
// make uiContent available after Initialize/Restore
|
||||
uiContent_ = std::move(uiContent);
|
||||
|
||||
if (state_ == WindowState::STATE_SHOWN) {
|
||||
UpdateTitleButtonVisibility();
|
||||
Ace::ViewportConfig config;
|
||||
Rect rect = GetRect();
|
||||
config.SetSize(rect.width_, rect.height_);
|
||||
@@ -561,7 +585,9 @@ WMError WindowImpl::SetSystemBarProperty(WindowType type, const SystemBarPropert
|
||||
WMError WindowImpl::SetLayoutFullScreen(bool status)
|
||||
{
|
||||
WLOGFI("[Client] Window %{public}u SetLayoutFullScreen: %{public}u", property_->GetWindowId(), status);
|
||||
if (!IsWindowValid()) {
|
||||
if (!IsWindowValid() ||
|
||||
!WindowHelper::IsWindowModeSupported(GetModeSupportInfo(), WindowMode::WINDOW_MODE_FULLSCREEN)) {
|
||||
WLOGFE("invalid window or fullscreen mode is not be supported, winId:%{public}u", property_->GetWindowId());
|
||||
return WMError::WM_ERROR_INVALID_WINDOW;
|
||||
}
|
||||
WMError ret = SetWindowMode(WindowMode::WINDOW_MODE_FULLSCREEN);
|
||||
@@ -591,6 +617,11 @@ WMError WindowImpl::SetLayoutFullScreen(bool status)
|
||||
WMError WindowImpl::SetFullScreen(bool status)
|
||||
{
|
||||
WLOGFI("[Client] Window %{public}u SetFullScreen: %{public}d", property_->GetWindowId(), status);
|
||||
if (!IsWindowValid() ||
|
||||
!WindowHelper::IsWindowModeSupported(GetModeSupportInfo(), WindowMode::WINDOW_MODE_FULLSCREEN)) {
|
||||
WLOGFE("invalid window or fullscreen mode is not be supported, winId:%{public}u", property_->GetWindowId());
|
||||
return WMError::WM_ERROR_INVALID_WINDOW;
|
||||
}
|
||||
SystemBarProperty statusProperty = GetSystemBarPropertyByType(
|
||||
WindowType::WINDOW_TYPE_STATUS_BAR);
|
||||
SystemBarProperty naviProperty = GetSystemBarPropertyByType(
|
||||
@@ -643,6 +674,68 @@ WMError WindowImpl::UpdateProperty(PropertyChangeAction action)
|
||||
return SingletonContainer::Get<WindowAdapter>().UpdateProperty(property_, action);
|
||||
}
|
||||
|
||||
void WindowImpl::GetConfigurationFromAbilityInfo()
|
||||
{
|
||||
auto abilityContext = AbilityRuntime::Context::ConvertTo<AbilityRuntime::AbilityContext>(context_);
|
||||
if (abilityContext == nullptr) {
|
||||
WLOGFE("id:%{public}u is not ability Window", property_->GetWindowId());
|
||||
return;
|
||||
}
|
||||
auto abilityInfo = abilityContext->GetAbilityInfo();
|
||||
if (abilityInfo == nullptr) {
|
||||
WLOGFE("id:%{public}u Ability window get ability info failed", property_->GetWindowId());
|
||||
return;
|
||||
}
|
||||
|
||||
// get support modes configuration
|
||||
uint32_t modeSupportInfo = 0;
|
||||
const auto& supportModes = abilityInfo->windowModes;
|
||||
for (auto& mode : supportModes) {
|
||||
if (static_cast<uint32_t>(mode) == static_cast<uint32_t>(0)) { // 0 : fullScreen
|
||||
modeSupportInfo |= WindowModeSupport::WINDOW_MODE_SUPPORT_FULLSCREEN;
|
||||
} else if (static_cast<uint32_t>(mode) == static_cast<uint32_t>(1)) { // 1 : split
|
||||
modeSupportInfo |= (WindowModeSupport::WINDOW_MODE_SUPPORT_SPLIT_PRIMARY |
|
||||
WindowModeSupport::WINDOW_MODE_SUPPORT_SPLIT_SECONDARY);
|
||||
} else if (static_cast<uint32_t>(mode) == static_cast<uint32_t>(2)) { // 2 : floating
|
||||
modeSupportInfo |= WindowModeSupport::WINDOW_MODE_SUPPORT_FLOATING;
|
||||
}
|
||||
}
|
||||
if (modeSupportInfo == 0) {
|
||||
WLOGFI("mode config param is 0, set all modes");
|
||||
modeSupportInfo = WindowModeSupport::WINDOW_MODE_SUPPORT_ALL;
|
||||
}
|
||||
SetRequestModeSupportInfo(modeSupportInfo);
|
||||
|
||||
// get window size limits configuration
|
||||
WindowSizeLimits sizeLimits;
|
||||
sizeLimits.maxWidth_ = abilityInfo->maxWindowWidth;
|
||||
sizeLimits.maxHeight_ = abilityInfo->maxWindowHeight;
|
||||
sizeLimits.minWidth_ = abilityInfo->minWindowWidth;
|
||||
sizeLimits.minHeight_ = abilityInfo->minWindowHeight;
|
||||
sizeLimits.maxRatio_ = static_cast<float>(abilityInfo->maxWindowRatio);
|
||||
sizeLimits.minRatio_ = static_cast<float>(abilityInfo->minWindowRatio);
|
||||
property_->SetSizeLimits(sizeLimits);
|
||||
|
||||
// get orientation configuration
|
||||
DisplayOrientation displayOrientation = static_cast<DisplayOrientation>(
|
||||
static_cast<uint32_t>(abilityInfo->orientation));
|
||||
if (ABILITY_TO_WMS_ORIENTATION_MAP.count(displayOrientation) == 0) {
|
||||
WLOGFE("id:%{public}u Do not support this Orientation type", property_->GetWindowId());
|
||||
return;
|
||||
}
|
||||
Orientation orientation = ABILITY_TO_WMS_ORIENTATION_MAP.at(displayOrientation);
|
||||
if (orientation < Orientation::BEGIN || orientation > Orientation::END) {
|
||||
WLOGFE("Set orientation from ability failed");
|
||||
return;
|
||||
}
|
||||
property_->SetRequestedOrientation(orientation);
|
||||
}
|
||||
|
||||
void WindowImpl::UpdateTitleButtonVisibility()
|
||||
{
|
||||
WLOGFI("[Client] UpdateTitleButtonVisibility");
|
||||
}
|
||||
|
||||
WMError WindowImpl::Create(const std::string& parentName, const std::shared_ptr<AbilityRuntime::Context>& context)
|
||||
{
|
||||
WLOGFI("[Client] Window [name:%{public}s] Create", name_.c_str());
|
||||
@@ -688,7 +781,7 @@ WMError WindowImpl::Create(const std::string& parentName, const std::shared_ptr<
|
||||
WLOGFI("get stretchable enable:%{public}d", windowSystemConfig_.isStretchable_);
|
||||
property_->SetStretchable(windowSystemConfig_.isStretchable_);
|
||||
}
|
||||
SetOrientationFromAbility();
|
||||
GetConfigurationFromAbilityInfo();
|
||||
}
|
||||
WMError ret = SingletonContainer::Get<WindowAdapter>().CreateWindow(windowAgent, property_, surfaceNode_,
|
||||
windowId, token);
|
||||
@@ -728,12 +821,13 @@ void WindowImpl::DestroyFloatingWindow()
|
||||
|
||||
// Destroy app floating window if exist
|
||||
if (appFloatingWindowMap_.count(GetWindowId()) > 0) {
|
||||
auto floatingWindows = appFloatingWindowMap_.at(GetWindowId());
|
||||
for (auto& floatingWindow : floatingWindows) {
|
||||
if (floatingWindow == nullptr) {
|
||||
auto& floatingWindows = appFloatingWindowMap_.at(GetWindowId());
|
||||
for (auto iter = floatingWindows.begin(); iter != floatingWindows.end(); iter = floatingWindows.begin()) {
|
||||
if ((*iter) == nullptr) {
|
||||
floatingWindows.erase(iter);
|
||||
continue;
|
||||
}
|
||||
floatingWindow->Destroy();
|
||||
(*iter)->Destroy();
|
||||
}
|
||||
appFloatingWindowMap_.erase(GetWindowId());
|
||||
}
|
||||
@@ -755,12 +849,13 @@ void WindowImpl::DestroySubWindow()
|
||||
}
|
||||
|
||||
if (subWindowMap_.count(GetWindowId()) > 0) { // remove from subWindowMap_ and windowMap_
|
||||
std::vector<sptr<WindowImpl>>& subWindows = subWindowMap_.at(GetWindowId());
|
||||
for (auto& subWindow : subWindows) {
|
||||
if (subWindow == nullptr) {
|
||||
auto& subWindows = subWindowMap_.at(GetWindowId());
|
||||
for (auto iter = subWindows.begin(); iter != subWindows.end(); iter = subWindows.begin()) {
|
||||
if ((*iter) == nullptr) {
|
||||
subWindows.erase(iter);
|
||||
continue;
|
||||
}
|
||||
subWindow->Destroy(false);
|
||||
(*iter)->Destroy(false);
|
||||
}
|
||||
subWindowMap_[GetWindowId()].clear();
|
||||
subWindowMap_.erase(GetWindowId());
|
||||
@@ -833,7 +928,7 @@ WMError WindowImpl::Destroy(bool needNotifyServer)
|
||||
return ret;
|
||||
}
|
||||
|
||||
WMError WindowImpl::Show(uint32_t reason)
|
||||
WMError WindowImpl::Show(uint32_t reason, bool isCustomAnimation)
|
||||
{
|
||||
WLOGFI("[Client] Window [name:%{public}s, id:%{public}u] Show, reason:%{public}u",
|
||||
name_.c_str(), property_->GetWindowId(), reason);
|
||||
@@ -864,6 +959,21 @@ WMError WindowImpl::Show(uint32_t reason)
|
||||
return WMError::WM_OK;
|
||||
}
|
||||
SetDefaultOption();
|
||||
// set true success when transitionController exist; set false when complete transition
|
||||
property_->SetCustomAnimation(isCustomAnimation);
|
||||
|
||||
// show failed when current mode is not support or window only supports split mode and can show when locked
|
||||
bool isShowWhenLocked = GetWindowFlags() & static_cast<uint32_t>(WindowFlag::WINDOW_FLAG_SHOW_WHEN_LOCKED);
|
||||
if (!WindowHelper::IsWindowModeSupported(GetModeSupportInfo(), GetMode()) ||
|
||||
WindowHelper::IsOnlySupportSplitAndShowWhenLocked(isShowWhenLocked, GetModeSupportInfo())) {
|
||||
WLOGFE("current mode is not be supported, windowId: %{public}u", property_->GetWindowId());
|
||||
NotifyForegroundFailed();
|
||||
return WMError::WM_ERROR_INVALID_WINDOW;
|
||||
}
|
||||
|
||||
// update title button visibility when show
|
||||
UpdateTitleButtonVisibility();
|
||||
|
||||
WMError ret = SingletonContainer::Get<WindowAdapter>().AddWindow(property_);
|
||||
RecordLifeCycleExceptionEvent(LifeCycleEvent::SHOW_EVENT, ret);
|
||||
if (ret == WMError::WM_OK || ret == WMError::WM_ERROR_DEATH_RECIPIENT) {
|
||||
@@ -876,7 +986,7 @@ WMError WindowImpl::Show(uint32_t reason)
|
||||
return ret;
|
||||
}
|
||||
|
||||
WMError WindowImpl::Hide(uint32_t reason)
|
||||
WMError WindowImpl::Hide(uint32_t reason, bool isCustomAnimation)
|
||||
{
|
||||
WLOGFI("[Client] Window [name:%{public}s, id:%{public}u] Hide", name_.c_str(), property_->GetWindowId());
|
||||
if (!IsWindowValid()) {
|
||||
@@ -892,6 +1002,7 @@ WMError WindowImpl::Hide(uint32_t reason)
|
||||
WLOGFI("window is already hidden id: %{public}u", property_->GetWindowId());
|
||||
return WMError::WM_OK;
|
||||
}
|
||||
property_->SetCustomAnimation(isCustomAnimation);
|
||||
WMError ret = SingletonContainer::Get<WindowAdapter>().RemoveWindow(property_->GetWindowId());
|
||||
RecordLifeCycleExceptionEvent(LifeCycleEvent::HIDE_EVENT, ret);
|
||||
if (ret != WMError::WM_OK) {
|
||||
@@ -1196,6 +1307,9 @@ WMError WindowImpl::NotifyWindowTransition(TransitionReason reason)
|
||||
return WMError::WM_ERROR_NO_MEM;
|
||||
}
|
||||
auto abilityInfo = abilityContext->GetAbilityInfo();
|
||||
if (abilityInfo == nullptr) {
|
||||
return WMError::WM_ERROR_NULLPTR;
|
||||
}
|
||||
fromInfo->SetBundleName(context_->GetBundleName());
|
||||
fromInfo->SetAbilityName(abilityInfo->name);
|
||||
fromInfo->SetWindowMode(property_->GetWindowMode());
|
||||
@@ -1207,32 +1321,6 @@ WMError WindowImpl::NotifyWindowTransition(TransitionReason reason)
|
||||
return SingletonContainer::Get<WindowAdapter>().NotifyWindowTransition(fromInfo, toInfo);
|
||||
}
|
||||
|
||||
void WindowImpl::SetOrientationFromAbility()
|
||||
{
|
||||
auto abilityContext = AbilityRuntime::Context::ConvertTo<AbilityRuntime::AbilityContext>(context_);
|
||||
if (abilityContext == nullptr) {
|
||||
WLOGFE("id:%{public}d is not ability Window", property_->GetWindowId());
|
||||
return;
|
||||
}
|
||||
auto abilityInfo = abilityContext->GetAbilityInfo();
|
||||
if (abilityInfo == nullptr) {
|
||||
WLOGFE("id:%{public}d Ability window get ability info failed", property_->GetWindowId());
|
||||
return;
|
||||
}
|
||||
DisplayOrientation displayOrientation = static_cast<DisplayOrientation>(
|
||||
static_cast<uint32_t>(abilityInfo->orientation));
|
||||
if (ABILITY_TO_WMS_ORIENTATION_MAP.count(displayOrientation) == 0) {
|
||||
WLOGFE("id:%{public}d Do not support this Orientation type", property_->GetWindowId());
|
||||
return;
|
||||
}
|
||||
Orientation orientation = ABILITY_TO_WMS_ORIENTATION_MAP.at(displayOrientation);
|
||||
if (orientation < Orientation::BEGIN || orientation > Orientation::END) {
|
||||
WLOGFE("Set orientation from ability failed");
|
||||
return;
|
||||
}
|
||||
property_->SetRequestedOrientation(orientation);
|
||||
}
|
||||
|
||||
WMError WindowImpl::Minimize()
|
||||
{
|
||||
WLOGFI("[Client] Window %{public}u Minimize", property_->GetWindowId());
|
||||
@@ -1526,20 +1614,15 @@ void WindowImpl::SetAceAbilityHandler(const sptr<IAceAbilityHandler>& handler)
|
||||
aceAbilityHandler_ = handler;
|
||||
}
|
||||
|
||||
void WindowImpl::SetRequestModeSupportInfo(uint32_t modeSupportInfo)
|
||||
{
|
||||
property_->SetRequestModeSupportInfo(modeSupportInfo);
|
||||
SetModeSupportInfo(modeSupportInfo);
|
||||
}
|
||||
|
||||
void WindowImpl::SetModeSupportInfo(uint32_t modeSupportInfo)
|
||||
{
|
||||
property_->SetModeSupportInfo(modeSupportInfo);
|
||||
UpdateProperty(PropertyChangeAction::ACTION_UPDATE_MODE_SUPPORT_INFO);
|
||||
if (!WindowHelper::IsWindowModeSupported(modeSupportInfo, GetMode())) {
|
||||
WLOGFI("current window mode is not supported, force to transform to appropriate mode. window id:%{public}u",
|
||||
GetWindowId());
|
||||
WindowMode mode = WindowHelper::GetWindowModeFromModeSupportInfo(modeSupportInfo);
|
||||
if (mode != WindowMode::WINDOW_MODE_UNDEFINED) {
|
||||
SetWindowMode(mode);
|
||||
} else {
|
||||
WLOGFE("invalid modeSupportInfo %{public}u", modeSupportInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void WindowImpl::UpdateRect(const struct Rect& rect, bool decoStatus, WindowSizeChangeReason reason)
|
||||
@@ -1559,7 +1642,7 @@ void WindowImpl::UpdateRect(const struct Rect& rect, bool decoStatus, WindowSize
|
||||
return;
|
||||
}
|
||||
property_->SetWindowRect(rect);
|
||||
const Rect& originRect = property_->GetOriginRect();
|
||||
|
||||
// update originRect when floating window show for the first time.
|
||||
if (!isOriginRectSet_ && WindowHelper::IsMainFloatingWindow(GetType(), GetMode())) {
|
||||
property_->SetOriginRect(rect);
|
||||
@@ -1571,12 +1654,13 @@ void WindowImpl::UpdateRect(const struct Rect& rect, bool decoStatus, WindowSize
|
||||
if (reason == WindowSizeChangeReason::DRAG || reason == WindowSizeChangeReason::DRAG_END ||
|
||||
reason == WindowSizeChangeReason::DRAG_START || reason == WindowSizeChangeReason::RECOVER ||
|
||||
reason == WindowSizeChangeReason::MOVE) {
|
||||
rectToAce = originRect;
|
||||
rectToAce = property_->GetOriginRect();
|
||||
} else {
|
||||
property_->SetOriginRect(rect);
|
||||
}
|
||||
}
|
||||
WLOGFI("sizeChange callback size: %{public}lu", (unsigned long)windowChangeListeners_.size());
|
||||
|
||||
NotifySizeChange(rectToAce, reason);
|
||||
if (uiContent_ != nullptr) {
|
||||
Ace::ViewportConfig config;
|
||||
@@ -1601,6 +1685,13 @@ void WindowImpl::UpdateMode(WindowMode mode)
|
||||
}
|
||||
}
|
||||
|
||||
void WindowImpl::UpdateModeSupportInfo(uint32_t modeSupportInfo)
|
||||
{
|
||||
WLOGI("modeSupportInfo: %{public}u, winId: %{public}u", modeSupportInfo, GetWindowId());
|
||||
SetModeSupportInfo(modeSupportInfo);
|
||||
UpdateTitleButtonVisibility();
|
||||
}
|
||||
|
||||
void WindowImpl::ConsumeKeyEvent(std::shared_ptr<MMI::KeyEvent>& keyEvent)
|
||||
{
|
||||
NotifyKeyEvent(keyEvent);
|
||||
@@ -2023,8 +2114,7 @@ void WindowImpl::UpdateWindowState(WindowState state)
|
||||
WLOGFD("MinimizeAbility, id: %{public}u", GetWindowId());
|
||||
AAFwk::AbilityManagerClient::GetInstance()->MinimizeAbility(abilityContext->GetToken(), true);
|
||||
} else {
|
||||
state_ = WindowState::STATE_HIDDEN;
|
||||
NotifyAfterBackground();
|
||||
Hide(static_cast<uint32_t>(WindowStateChangeReason::TOGGLING));
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -2305,10 +2395,6 @@ void WindowImpl::SetDefaultOption()
|
||||
property_->SetFocusable(false);
|
||||
break;
|
||||
}
|
||||
case WindowType::WINDOW_TYPE_PLACE_HOLDER: {
|
||||
AddWindowFlag(WindowFlag::WINDOW_FLAG_FORBID_SPLIT_MOVE);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -50,11 +50,6 @@ void WindowOption::SetWindowBackgroundBlur(WindowBlurLevel level)
|
||||
level_ = level;
|
||||
}
|
||||
|
||||
void WindowOption::SetAlpha(float alpha)
|
||||
{
|
||||
alpha_ = alpha;
|
||||
}
|
||||
|
||||
void WindowOption::SetFocusable(bool isFocusable)
|
||||
{
|
||||
focusable_ = isFocusable;
|
||||
@@ -122,11 +117,6 @@ WindowBlurLevel WindowOption::GetWindowBackgroundBlur() const
|
||||
return level_;
|
||||
}
|
||||
|
||||
float WindowOption::GetAlpha() const
|
||||
{
|
||||
return alpha_;
|
||||
}
|
||||
|
||||
bool WindowOption::GetFocusable() const
|
||||
{
|
||||
return focusable_;
|
||||
|
||||
@@ -76,6 +76,27 @@ void WindowProxy::UpdateWindowMode(WindowMode mode)
|
||||
return;
|
||||
}
|
||||
|
||||
void WindowProxy::UpdateWindowModeSupportInfo(uint32_t modeSupportInfo)
|
||||
{
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
MessageOption option(MessageOption::TF_ASYNC);
|
||||
if (!data.WriteInterfaceToken(GetDescriptor())) {
|
||||
WLOGFE("WriteInterfaceToken failed");
|
||||
return;
|
||||
}
|
||||
if (!data.WriteUint32(modeSupportInfo)) {
|
||||
WLOGFE("Write WindowMode failed");
|
||||
return;
|
||||
}
|
||||
|
||||
if (Remote()->SendRequest(static_cast<uint32_t>(WindowMessage::TRANS_ID_UPDATE_MODE_SUPPORT_INFO),
|
||||
data, reply, option) != ERR_NONE) {
|
||||
WLOGFE("SendRequest failed");
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
void WindowProxy::UpdateFocusStatus(bool focused)
|
||||
{
|
||||
MessageParcel data;
|
||||
|
||||
@@ -45,6 +45,11 @@ int WindowStub::OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParce
|
||||
UpdateWindowMode(mode);
|
||||
break;
|
||||
}
|
||||
case WindowMessage::TRANS_ID_UPDATE_MODE_SUPPORT_INFO: {
|
||||
uint32_t modeSupportInfo = data.ReadUint32();
|
||||
UpdateWindowModeSupportInfo(modeSupportInfo);
|
||||
break;
|
||||
}
|
||||
case WindowMessage::TRANS_ID_UPDATE_FOCUS_STATUS: {
|
||||
bool focused = data.ReadBool();
|
||||
UpdateFocusStatus(focused);
|
||||
|
||||
@@ -77,9 +77,6 @@ size_t InitWindowOption1(WindowOption &windowOption, const uint8_t *data, size_t
|
||||
uint32_t level;
|
||||
startPos += GetObject<uint32_t>(level, data + startPos, size - startPos);
|
||||
windowOption.SetWindowBackgroundBlur(static_cast<WindowBlurLevel>(level));
|
||||
float alpha;
|
||||
startPos += GetObject<float>(alpha, data + startPos, size - startPos);
|
||||
windowOption.SetAlpha(alpha);
|
||||
bool focusable;
|
||||
startPos += GetObject<bool>(focusable, data + startPos, size - startPos);
|
||||
windowOption.SetFocusable(focusable);
|
||||
|
||||
@@ -23,7 +23,7 @@ using namespace testing::ext;
|
||||
|
||||
namespace OHOS {
|
||||
namespace Rosen {
|
||||
using utils = WindowTestUtils;
|
||||
using Utils = WindowTestUtils;
|
||||
const int WAIT_CALLBACK_US = 100000; // 100000 us
|
||||
|
||||
class TestDragListener : public IWindowDragListener {
|
||||
@@ -49,9 +49,9 @@ public:
|
||||
|
||||
static sptr<TestDragListener> firstWindowDragListener_;
|
||||
static sptr<TestDragListener> secondWindowDragListener_;
|
||||
utils::TestWindowInfo dragWindowInfo_;
|
||||
utils::TestWindowInfo firstWindowInfo_;
|
||||
utils::TestWindowInfo secondWindowInfo_;
|
||||
Utils::TestWindowInfo dragWindowInfo_;
|
||||
Utils::TestWindowInfo firstWindowInfo_;
|
||||
Utils::TestWindowInfo secondWindowInfo_;
|
||||
};
|
||||
|
||||
sptr<TestDragListener> WindowDragTest::firstWindowDragListener_ =
|
||||
@@ -77,7 +77,7 @@ void WindowDragTest::SetUp()
|
||||
|
||||
firstWindowInfo_ = {
|
||||
.name = "firstWindow",
|
||||
.rect = utils::customAppRect_,
|
||||
.rect = Utils::customAppRect_,
|
||||
.type = WindowType::WINDOW_TYPE_APP_MAIN_WINDOW,
|
||||
.mode = WindowMode::WINDOW_MODE_FULLSCREEN,
|
||||
.needAvoid = false,
|
||||
@@ -87,7 +87,7 @@ void WindowDragTest::SetUp()
|
||||
|
||||
secondWindowInfo_ = {
|
||||
.name = "secondWindow",
|
||||
.rect = utils::customAppRect_,
|
||||
.rect = Utils::customAppRect_,
|
||||
.type = WindowType::WINDOW_TYPE_APP_MAIN_WINDOW,
|
||||
.mode = WindowMode::WINDOW_MODE_FLOATING,
|
||||
.needAvoid = false,
|
||||
@@ -105,12 +105,12 @@ namespace {
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(WindowDragTest, DragIn, Function | MediumTest | Level3) {
|
||||
const sptr<Window> &firstWindow = utils::CreateTestWindow(firstWindowInfo_);
|
||||
const sptr<Window> &firstWindow = Utils::CreateTestWindow(firstWindowInfo_);
|
||||
firstWindow->RegisterDragListener(firstWindowDragListener_);
|
||||
firstWindow->SetTurnScreenOn(true);
|
||||
firstWindow->Show();
|
||||
|
||||
const sptr<Window> &dragWindow = utils::CreateTestWindow(dragWindowInfo_);
|
||||
const sptr<Window> &dragWindow = Utils::CreateTestWindow(dragWindowInfo_);
|
||||
dragWindow->Show();
|
||||
dragWindow->MoveTo(300, 300);
|
||||
usleep(WAIT_CALLBACK_US);
|
||||
@@ -129,12 +129,12 @@ HWTEST_F(WindowDragTest, DragIn, Function | MediumTest | Level3) {
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(WindowDragTest, DragMove, Function | MediumTest | Level3) {
|
||||
const sptr<Window> &firstWindow = utils::CreateTestWindow(firstWindowInfo_);
|
||||
const sptr<Window> &firstWindow = Utils::CreateTestWindow(firstWindowInfo_);
|
||||
firstWindow->RegisterDragListener(firstWindowDragListener_);
|
||||
firstWindow->SetTurnScreenOn(true);
|
||||
firstWindow->Show();
|
||||
|
||||
const sptr<Window> &dragWindow = utils::CreateTestWindow(dragWindowInfo_);
|
||||
const sptr<Window> &dragWindow = Utils::CreateTestWindow(dragWindowInfo_);
|
||||
dragWindow->Show();
|
||||
dragWindow->MoveTo(300, 300);
|
||||
usleep(WAIT_CALLBACK_US);
|
||||
@@ -159,17 +159,17 @@ HWTEST_F(WindowDragTest, DragMove, Function | MediumTest | Level3) {
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(WindowDragTest, DragOut, Function | MediumTest | Level3) {
|
||||
const sptr<Window> &firstWindow = utils::CreateTestWindow(firstWindowInfo_);
|
||||
const sptr<Window> &firstWindow = Utils::CreateTestWindow(firstWindowInfo_);
|
||||
firstWindow->RegisterDragListener(firstWindowDragListener_);
|
||||
firstWindow->SetTurnScreenOn(true);
|
||||
firstWindow->Show();
|
||||
|
||||
secondWindowInfo_.rect = {500, 500, 500, 500};
|
||||
const sptr<Window> &secondWindow = utils::CreateTestWindow(secondWindowInfo_);
|
||||
const sptr<Window> &secondWindow = Utils::CreateTestWindow(secondWindowInfo_);
|
||||
secondWindow->RegisterDragListener(secondWindowDragListener_);
|
||||
secondWindow->Show();
|
||||
|
||||
const sptr<Window> &dragWindow = utils::CreateTestWindow(dragWindowInfo_);
|
||||
const sptr<Window> &dragWindow = Utils::CreateTestWindow(dragWindowInfo_);
|
||||
dragWindow->Show();
|
||||
dragWindow->MoveTo(300, 300);
|
||||
usleep(WAIT_CALLBACK_US);
|
||||
@@ -203,12 +203,12 @@ HWTEST_F(WindowDragTest, DragOut, Function | MediumTest | Level3) {
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(WindowDragTest, DragEnd, Function | MediumTest | Level3) {
|
||||
const sptr<Window> &firstWindow = utils::CreateTestWindow(firstWindowInfo_);
|
||||
const sptr<Window> &firstWindow = Utils::CreateTestWindow(firstWindowInfo_);
|
||||
firstWindow->RegisterDragListener(firstWindowDragListener_);
|
||||
firstWindow->SetTurnScreenOn(true);
|
||||
firstWindow->Show();
|
||||
|
||||
const sptr<Window> &dragWindow = utils::CreateTestWindow(dragWindowInfo_);
|
||||
const sptr<Window> &dragWindow = Utils::CreateTestWindow(dragWindowInfo_);
|
||||
dragWindow->Show();
|
||||
dragWindow->MoveTo(199, 199);
|
||||
usleep(WAIT_CALLBACK_US);
|
||||
|
||||
@@ -21,14 +21,14 @@ using namespace testing::ext;
|
||||
|
||||
namespace OHOS {
|
||||
namespace Rosen {
|
||||
using utils = WindowTestUtils;
|
||||
using Utils = WindowTestUtils;
|
||||
class WindowEffectTest : public testing::Test {
|
||||
public:
|
||||
static void SetUpTestCase();
|
||||
static void TearDownTestCase();
|
||||
virtual void SetUp() override;
|
||||
virtual void TearDown() override;
|
||||
utils::TestWindowInfo fullScreenAppInfo_;
|
||||
Utils::TestWindowInfo fullScreenAppInfo_;
|
||||
};
|
||||
|
||||
void WindowEffectTest::SetUpTestCase()
|
||||
@@ -43,7 +43,7 @@ void WindowEffectTest::SetUp()
|
||||
{
|
||||
fullScreenAppInfo_ = {
|
||||
.name = "FullWindow",
|
||||
.rect = utils::customAppRect_,
|
||||
.rect = Utils::customAppRect_,
|
||||
.type = WindowType::WINDOW_TYPE_APP_MAIN_WINDOW,
|
||||
.mode = WindowMode::WINDOW_MODE_FULLSCREEN,
|
||||
.needAvoid = false,
|
||||
@@ -64,7 +64,7 @@ namespace {
|
||||
*/
|
||||
HWTEST_F(WindowEffectTest, WindowEffect01, Function | MediumTest | Level3)
|
||||
{
|
||||
const sptr<Window>& window = utils::CreateTestWindow(fullScreenAppInfo_);
|
||||
const sptr<Window>& window = Utils::CreateTestWindow(fullScreenAppInfo_);
|
||||
|
||||
ASSERT_EQ(WMError::WM_OK, window->SetWindowBackgroundBlur(WindowBlurLevel::WINDOW_BLUR_LOW));
|
||||
ASSERT_EQ(WindowBlurLevel::WINDOW_BLUR_LOW, window->GetWindowBackgroundBlur());
|
||||
@@ -78,9 +78,9 @@ HWTEST_F(WindowEffectTest, WindowEffect01, Function | MediumTest | Level3)
|
||||
*/
|
||||
HWTEST_F(WindowEffectTest, WindowEffect02, Function | MediumTest | Level3)
|
||||
{
|
||||
const sptr<Window>& window = utils::CreateTestWindow(fullScreenAppInfo_);
|
||||
const sptr<Window>& window = Utils::CreateTestWindow(fullScreenAppInfo_);
|
||||
|
||||
ASSERT_EQ(WMError::WM_OK, window->SetAlpha(1.0f));
|
||||
window->SetAlpha(1.0f);
|
||||
ASSERT_EQ(1.0f, window->GetAlpha());
|
||||
|
||||
window->Destroy();
|
||||
|
||||
@@ -27,7 +27,7 @@ namespace {
|
||||
constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_WINDOW, "WindowFocusTest"};
|
||||
}
|
||||
|
||||
using utils = WindowTestUtils;
|
||||
using Utils = WindowTestUtils;
|
||||
const int WAIT_ASYNC_US = 100000; // 100000us
|
||||
|
||||
class TestFocusChangedListener : public IFocusChangedListener {
|
||||
@@ -45,9 +45,9 @@ public:
|
||||
virtual void SetUp() override;
|
||||
virtual void TearDown() override;
|
||||
static sptr<TestFocusChangedListener> testFocusChangedListener_;
|
||||
utils::TestWindowInfo fullScreenAppInfo_;
|
||||
utils::TestWindowInfo floatAppInfo_;
|
||||
utils::TestWindowInfo subAppInfo_;
|
||||
Utils::TestWindowInfo fullScreenAppInfo_;
|
||||
Utils::TestWindowInfo floatAppInfo_;
|
||||
Utils::TestWindowInfo subAppInfo_;
|
||||
};
|
||||
|
||||
sptr<TestFocusChangedListener> WindowFocusTest::testFocusChangedListener_ =
|
||||
@@ -72,7 +72,7 @@ void WindowFocusTest::SetUpTestCase()
|
||||
WLOGFI("GetDefaultDisplay: id %{public}" PRIu64", w %{public}d, h %{public}d, fps %{public}u",
|
||||
display->GetId(), display->GetWidth(), display->GetHeight(), display->GetRefreshRate());
|
||||
Rect displayRect = {0, 0, display->GetWidth(), display->GetHeight()};
|
||||
utils::InitByDisplayRect(displayRect);
|
||||
Utils::InitByDisplayRect(displayRect);
|
||||
}
|
||||
|
||||
void WindowFocusTest::TearDownTestCase()
|
||||
@@ -83,7 +83,7 @@ void WindowFocusTest::SetUp()
|
||||
{
|
||||
fullScreenAppInfo_ = {
|
||||
.name = "FullWindow",
|
||||
.rect = utils::customAppRect_,
|
||||
.rect = Utils::customAppRect_,
|
||||
.type = WindowType::WINDOW_TYPE_APP_MAIN_WINDOW,
|
||||
.mode = WindowMode::WINDOW_MODE_FULLSCREEN,
|
||||
.needAvoid = false,
|
||||
@@ -92,7 +92,7 @@ void WindowFocusTest::SetUp()
|
||||
};
|
||||
floatAppInfo_ = {
|
||||
.name = "ParentWindow",
|
||||
.rect = utils::customAppRect_,
|
||||
.rect = Utils::customAppRect_,
|
||||
.type = WindowType::WINDOW_TYPE_APP_MAIN_WINDOW,
|
||||
.mode = WindowMode::WINDOW_MODE_FLOATING,
|
||||
.needAvoid = false,
|
||||
@@ -101,7 +101,7 @@ void WindowFocusTest::SetUp()
|
||||
};
|
||||
subAppInfo_ = {
|
||||
.name = "SubWindow",
|
||||
.rect = utils::customAppRect_,
|
||||
.rect = Utils::customAppRect_,
|
||||
.type = WindowType::WINDOW_TYPE_APP_SUB_WINDOW,
|
||||
.mode = WindowMode::WINDOW_MODE_FLOATING,
|
||||
.needAvoid = false,
|
||||
@@ -126,23 +126,23 @@ HWTEST_F(WindowFocusTest, FocusChangedTest01, Function | MediumTest | Level3)
|
||||
{
|
||||
fullScreenAppInfo_.name = "FocusChangedTest01_1";
|
||||
fullScreenAppInfo_.focusable_ = false;
|
||||
const sptr<Window>& window1 = utils::CreateTestWindow(fullScreenAppInfo_);
|
||||
const sptr<Window>& window1 = Utils::CreateTestWindow(fullScreenAppInfo_);
|
||||
ASSERT_NE(nullptr, window1);
|
||||
|
||||
floatAppInfo_.name = "FocusChangedTest01_2";
|
||||
floatAppInfo_.rect = { 10, 200, 300, 400 };
|
||||
const sptr<Window>& window2 = utils::CreateTestWindow(floatAppInfo_);
|
||||
const sptr<Window>& window2 = Utils::CreateTestWindow(floatAppInfo_);
|
||||
ASSERT_NE(nullptr, window2);
|
||||
|
||||
floatAppInfo_.name = "FocusChangedTest01_3";
|
||||
floatAppInfo_.rect = { 250, 150, 300, 500 };
|
||||
const sptr<Window>& window3 = utils::CreateTestWindow(floatAppInfo_);
|
||||
const sptr<Window>& window3 = Utils::CreateTestWindow(floatAppInfo_);
|
||||
ASSERT_NE(nullptr, window3);
|
||||
|
||||
subAppInfo_.name = "FocusChangedTest01_4";
|
||||
subAppInfo_.rect = { 400, 200, 100, 100 };
|
||||
subAppInfo_.parentName = window3->GetWindowName();
|
||||
const sptr<Window>& subWindow = utils::CreateTestWindow(subAppInfo_);
|
||||
const sptr<Window>& subWindow = Utils::CreateTestWindow(subAppInfo_);
|
||||
|
||||
ASSERT_EQ(WMError::WM_OK, window3->Show());
|
||||
// Await 100ms and get callback result in listener.
|
||||
@@ -181,14 +181,14 @@ HWTEST_F(WindowFocusTest, FocusChangedTest02, Function | MediumTest | Level3)
|
||||
{
|
||||
floatAppInfo_.name = "FocusChangedTest02_1";
|
||||
floatAppInfo_.rect = { 10, 200, 300, 400 };
|
||||
const sptr<Window>& mainWindow = utils::CreateTestWindow(floatAppInfo_);
|
||||
const sptr<Window>& mainWindow = Utils::CreateTestWindow(floatAppInfo_);
|
||||
ASSERT_NE(nullptr, mainWindow);
|
||||
ASSERT_EQ(WMError::WM_OK, mainWindow->Show());
|
||||
|
||||
subAppInfo_.name = "FocusChangedTest02_2";
|
||||
subAppInfo_.rect = { 400, 200, 100, 100 };
|
||||
subAppInfo_.parentName = mainWindow->GetWindowName();
|
||||
const sptr<Window>& subWindow = utils::CreateTestWindow(subAppInfo_);
|
||||
const sptr<Window>& subWindow = Utils::CreateTestWindow(subAppInfo_);
|
||||
ASSERT_NE(nullptr, subWindow);
|
||||
ASSERT_EQ(WMError::WM_OK, subWindow->Show());
|
||||
usleep(WAIT_ASYNC_US);
|
||||
@@ -212,20 +212,20 @@ HWTEST_F(WindowFocusTest, FocusChangedTest03, Function | MediumTest | Level3)
|
||||
{
|
||||
floatAppInfo_.name = "FocusChangedTest03_1";
|
||||
floatAppInfo_.rect = { 10, 200, 300, 400 };
|
||||
const sptr<Window>& mainWindow1 = utils::CreateTestWindow(floatAppInfo_);
|
||||
const sptr<Window>& mainWindow1 = Utils::CreateTestWindow(floatAppInfo_);
|
||||
ASSERT_NE(nullptr, mainWindow1);
|
||||
ASSERT_EQ(WMError::WM_OK, mainWindow1->Show());
|
||||
|
||||
subAppInfo_.name = "FocusChangedTest03_2";
|
||||
subAppInfo_.rect = { 400, 200, 100, 100 };
|
||||
subAppInfo_.parentName = mainWindow1->GetWindowName();
|
||||
const sptr<Window>& aboveSubWindow = utils::CreateTestWindow(subAppInfo_);
|
||||
const sptr<Window>& aboveSubWindow = Utils::CreateTestWindow(subAppInfo_);
|
||||
ASSERT_NE(nullptr, aboveSubWindow);
|
||||
ASSERT_EQ(WMError::WM_OK, aboveSubWindow->Show());
|
||||
|
||||
floatAppInfo_.name = "FocusChangedTest03_3";
|
||||
floatAppInfo_.rect = { 200, 200, 100, 100 };
|
||||
const sptr<Window>& mainWindow2 = utils::CreateTestWindow(floatAppInfo_);
|
||||
const sptr<Window>& mainWindow2 = Utils::CreateTestWindow(floatAppInfo_);
|
||||
ASSERT_NE(nullptr, mainWindow2);
|
||||
ASSERT_EQ(WMError::WM_OK, mainWindow2->Show());
|
||||
usleep(WAIT_ASYNC_US);
|
||||
@@ -251,7 +251,7 @@ HWTEST_F(WindowFocusTest, FocusChangedTest04, Function | MediumTest | Level3)
|
||||
{
|
||||
floatAppInfo_.name = "FocusChangedTest04_1";
|
||||
floatAppInfo_.rect = { 10, 200, 300, 400 };
|
||||
const sptr<Window>& mainWindow1 = utils::CreateTestWindow(floatAppInfo_);
|
||||
const sptr<Window>& mainWindow1 = Utils::CreateTestWindow(floatAppInfo_);
|
||||
ASSERT_NE(nullptr, mainWindow1);
|
||||
ASSERT_EQ(WMError::WM_OK, mainWindow1->Show());
|
||||
|
||||
@@ -259,13 +259,13 @@ HWTEST_F(WindowFocusTest, FocusChangedTest04, Function | MediumTest | Level3)
|
||||
subAppInfo_.rect = { 400, 200, 100, 100 };
|
||||
subAppInfo_.parentName = mainWindow1->GetWindowName();
|
||||
subAppInfo_.type = WindowType::WINDOW_TYPE_MEDIA;
|
||||
const sptr<Window>& belowSubWindow = utils::CreateTestWindow(subAppInfo_);
|
||||
const sptr<Window>& belowSubWindow = Utils::CreateTestWindow(subAppInfo_);
|
||||
ASSERT_NE(nullptr, belowSubWindow);
|
||||
ASSERT_EQ(WMError::WM_OK, belowSubWindow->Show());
|
||||
|
||||
floatAppInfo_.name = "FocusChangedTest04_3";
|
||||
floatAppInfo_.rect = { 200, 200, 100, 100 };
|
||||
const sptr<Window>& mainWindow2 = utils::CreateTestWindow(floatAppInfo_);
|
||||
const sptr<Window>& mainWindow2 = Utils::CreateTestWindow(floatAppInfo_);
|
||||
ASSERT_NE(nullptr, mainWindow2);
|
||||
ASSERT_EQ(WMError::WM_OK, mainWindow2->Show());
|
||||
usleep(WAIT_ASYNC_US);
|
||||
@@ -291,13 +291,13 @@ HWTEST_F(WindowFocusTest, FocusChangedTest05, Function | MediumTest | Level3)
|
||||
{
|
||||
floatAppInfo_.name = "FocusChangedTest05_1";
|
||||
floatAppInfo_.rect = { 10, 200, 300, 400 };
|
||||
const sptr<Window>& mainWindow1 = utils::CreateTestWindow(floatAppInfo_);
|
||||
const sptr<Window>& mainWindow1 = Utils::CreateTestWindow(floatAppInfo_);
|
||||
ASSERT_NE(nullptr, mainWindow1);
|
||||
ASSERT_EQ(WMError::WM_OK, mainWindow1->Show());
|
||||
|
||||
floatAppInfo_.name = "FocusChangedTest05_2";
|
||||
floatAppInfo_.rect = { 200, 200, 100, 100 };
|
||||
const sptr<Window>& mainWindow2 = utils::CreateTestWindow(floatAppInfo_);
|
||||
const sptr<Window>& mainWindow2 = Utils::CreateTestWindow(floatAppInfo_);
|
||||
ASSERT_NE(nullptr, mainWindow2);
|
||||
ASSERT_EQ(WMError::WM_OK, mainWindow2->Show());
|
||||
|
||||
@@ -305,7 +305,7 @@ HWTEST_F(WindowFocusTest, FocusChangedTest05, Function | MediumTest | Level3)
|
||||
subAppInfo_.rect = { 400, 200, 100, 100 };
|
||||
subAppInfo_.parentName = mainWindow2->GetWindowName();
|
||||
subAppInfo_.type = WindowType::WINDOW_TYPE_MEDIA;
|
||||
const sptr<Window>& belowSubWindow = utils::CreateTestWindow(subAppInfo_);
|
||||
const sptr<Window>& belowSubWindow = Utils::CreateTestWindow(subAppInfo_);
|
||||
ASSERT_NE(nullptr, belowSubWindow);
|
||||
ASSERT_EQ(WMError::WM_OK, belowSubWindow->Show());
|
||||
usleep(WAIT_ASYNC_US);
|
||||
@@ -340,7 +340,7 @@ HWTEST_F(WindowFocusTest, FocusChangedTest06, Function | MediumTest | Level3)
|
||||
{
|
||||
floatAppInfo_.name = "FocusChangedTest06_1";
|
||||
floatAppInfo_.rect = { 10, 200, 300, 400 };
|
||||
const sptr<Window>& mainWindow = utils::CreateTestWindow(floatAppInfo_);
|
||||
const sptr<Window>& mainWindow = Utils::CreateTestWindow(floatAppInfo_);
|
||||
ASSERT_NE(nullptr, mainWindow);
|
||||
ASSERT_EQ(WMError::WM_OK, mainWindow->Show());
|
||||
|
||||
@@ -348,7 +348,7 @@ HWTEST_F(WindowFocusTest, FocusChangedTest06, Function | MediumTest | Level3)
|
||||
subAppInfo_.rect = { 100, 200, 100, 100 };
|
||||
subAppInfo_.parentName = mainWindow->GetWindowName();
|
||||
subAppInfo_.type = WindowType::WINDOW_TYPE_MEDIA;
|
||||
const sptr<Window>& belowSubWindow = utils::CreateTestWindow(subAppInfo_);
|
||||
const sptr<Window>& belowSubWindow = Utils::CreateTestWindow(subAppInfo_);
|
||||
ASSERT_NE(nullptr, belowSubWindow);
|
||||
ASSERT_EQ(WMError::WM_OK, belowSubWindow->Show());
|
||||
|
||||
@@ -356,7 +356,7 @@ HWTEST_F(WindowFocusTest, FocusChangedTest06, Function | MediumTest | Level3)
|
||||
subAppInfo_.rect = { 400, 200, 100, 100 };
|
||||
subAppInfo_.parentName = mainWindow->GetWindowName();
|
||||
subAppInfo_.type = WindowType::WINDOW_TYPE_APP_SUB_WINDOW;
|
||||
const sptr<Window>& aboveSubWindow = utils::CreateTestWindow(subAppInfo_);
|
||||
const sptr<Window>& aboveSubWindow = Utils::CreateTestWindow(subAppInfo_);
|
||||
ASSERT_NE(nullptr, aboveSubWindow);
|
||||
ASSERT_EQ(WMError::WM_OK, aboveSubWindow->Show());
|
||||
usleep(WAIT_ASYNC_US);
|
||||
@@ -377,19 +377,19 @@ HWTEST_F(WindowFocusTest, FocusChangedTest07, Function | MediumTest | Level3)
|
||||
{
|
||||
floatAppInfo_.name = "FocusChangedTest07_1";
|
||||
floatAppInfo_.rect = { 10, 200, 300, 400 };
|
||||
const sptr<Window>& mainWindow1 = utils::CreateTestWindow(floatAppInfo_);
|
||||
const sptr<Window>& mainWindow1 = Utils::CreateTestWindow(floatAppInfo_);
|
||||
ASSERT_NE(nullptr, mainWindow1);
|
||||
ASSERT_EQ(WMError::WM_OK, mainWindow1->Show());
|
||||
|
||||
floatAppInfo_.name = "FocusChangedTest07_2";
|
||||
floatAppInfo_.rect = { 250, 150, 300, 500 };
|
||||
const sptr<Window>& mainWindow2 = utils::CreateTestWindow(floatAppInfo_);
|
||||
const sptr<Window>& mainWindow2 = Utils::CreateTestWindow(floatAppInfo_);
|
||||
ASSERT_NE(nullptr, mainWindow2);
|
||||
ASSERT_EQ(WMError::WM_OK, mainWindow2->Show());
|
||||
|
||||
floatAppInfo_.name = "FocusChangedTest07_3";
|
||||
floatAppInfo_.rect = { 300, 400, 10, 400 };
|
||||
const sptr<Window>& mainWindow3 = utils::CreateTestWindow(floatAppInfo_);
|
||||
const sptr<Window>& mainWindow3 = Utils::CreateTestWindow(floatAppInfo_);
|
||||
ASSERT_NE(nullptr, mainWindow3);
|
||||
ASSERT_EQ(WMError::WM_OK, mainWindow3->Show());
|
||||
|
||||
@@ -397,21 +397,21 @@ HWTEST_F(WindowFocusTest, FocusChangedTest07, Function | MediumTest | Level3)
|
||||
subAppInfo_.rect = { 20, 100, 100, 100 };
|
||||
subAppInfo_.parentName = mainWindow1->GetWindowName();
|
||||
subAppInfo_.type = WindowType::WINDOW_TYPE_MEDIA;
|
||||
const sptr<Window>& belowSubWindow1 = utils::CreateTestWindow(subAppInfo_);
|
||||
const sptr<Window>& belowSubWindow1 = Utils::CreateTestWindow(subAppInfo_);
|
||||
ASSERT_NE(nullptr, belowSubWindow1);
|
||||
|
||||
subAppInfo_.name = "FocusChangedTest07_5";
|
||||
subAppInfo_.rect = { 400, 200, 100, 100 };
|
||||
subAppInfo_.parentName = mainWindow2->GetWindowName();
|
||||
subAppInfo_.type = WindowType::WINDOW_TYPE_APP_SUB_WINDOW;
|
||||
const sptr<Window>& aboveSubWindow = utils::CreateTestWindow(subAppInfo_);
|
||||
const sptr<Window>& aboveSubWindow = Utils::CreateTestWindow(subAppInfo_);
|
||||
ASSERT_NE(nullptr, aboveSubWindow);
|
||||
|
||||
subAppInfo_.name = "FocusChangedTest07_6";
|
||||
subAppInfo_.rect = { 310, 410, 100, 100 };
|
||||
subAppInfo_.parentName = mainWindow3->GetWindowName();
|
||||
subAppInfo_.type = WindowType::WINDOW_TYPE_MEDIA;
|
||||
const sptr<Window>& belowSubWindow2 = utils::CreateTestWindow(subAppInfo_);
|
||||
const sptr<Window>& belowSubWindow2 = Utils::CreateTestWindow(subAppInfo_);
|
||||
ASSERT_NE(nullptr, belowSubWindow2);
|
||||
|
||||
ASSERT_EQ(WMError::WM_OK, aboveSubWindow->Show());
|
||||
@@ -448,13 +448,13 @@ HWTEST_F(WindowFocusTest, FocusChangedTest08, Function | MediumTest | Level3)
|
||||
{
|
||||
floatAppInfo_.name = "FocusChangedTest08_1";
|
||||
floatAppInfo_.rect = { 10, 200, 300, 400 };
|
||||
const sptr<Window>& mainWindow1 = utils::CreateTestWindow(floatAppInfo_);
|
||||
const sptr<Window>& mainWindow1 = Utils::CreateTestWindow(floatAppInfo_);
|
||||
ASSERT_NE(nullptr, mainWindow1);
|
||||
ASSERT_EQ(WMError::WM_OK, mainWindow1->Show());
|
||||
|
||||
floatAppInfo_.name = "FocusChangedTest08_2";
|
||||
floatAppInfo_.rect = { 250, 150, 300, 500 };
|
||||
const sptr<Window>& mainWindow2 = utils::CreateTestWindow(floatAppInfo_);
|
||||
const sptr<Window>& mainWindow2 = Utils::CreateTestWindow(floatAppInfo_);
|
||||
ASSERT_NE(nullptr, mainWindow2);
|
||||
ASSERT_EQ(WMError::WM_OK, mainWindow2->Show());
|
||||
|
||||
@@ -462,7 +462,7 @@ HWTEST_F(WindowFocusTest, FocusChangedTest08, Function | MediumTest | Level3)
|
||||
subAppInfo_.rect = { 20, 100, 100, 100 };
|
||||
subAppInfo_.parentName = mainWindow1->GetWindowName();
|
||||
subAppInfo_.type = WindowType::WINDOW_TYPE_MEDIA;
|
||||
const sptr<Window>& belowSubWindow = utils::CreateTestWindow(subAppInfo_);
|
||||
const sptr<Window>& belowSubWindow = Utils::CreateTestWindow(subAppInfo_);
|
||||
ASSERT_NE(nullptr, belowSubWindow);
|
||||
ASSERT_EQ(WMError::WM_OK, belowSubWindow->Show());
|
||||
usleep(WAIT_ASYNC_US);
|
||||
|
||||
@@ -21,7 +21,7 @@ using namespace testing::ext;
|
||||
|
||||
namespace OHOS {
|
||||
namespace Rosen {
|
||||
using utils = WindowTestUtils;
|
||||
using Utils = WindowTestUtils;
|
||||
constexpr uint32_t MAX_WAIT_COUNT = 100;
|
||||
constexpr uint32_t WAIT_DUR = 10 * 1000;
|
||||
|
||||
@@ -31,7 +31,7 @@ public:
|
||||
static void TearDownTestCase();
|
||||
virtual void SetUp() override;
|
||||
virtual void TearDown() override;
|
||||
utils::TestWindowInfo fullScreenAppInfo_;
|
||||
Utils::TestWindowInfo fullScreenAppInfo_;
|
||||
};
|
||||
|
||||
void WindowGamutTest::SetUpTestCase()
|
||||
@@ -46,7 +46,7 @@ void WindowGamutTest::SetUp()
|
||||
{
|
||||
fullScreenAppInfo_ = {
|
||||
.name = "FullWindow",
|
||||
.rect = utils::customAppRect_,
|
||||
.rect = Utils::customAppRect_,
|
||||
.type = WindowType::WINDOW_TYPE_APP_MAIN_WINDOW,
|
||||
.mode = WindowMode::WINDOW_MODE_FULLSCREEN,
|
||||
.needAvoid = false,
|
||||
@@ -67,7 +67,7 @@ namespace {
|
||||
*/
|
||||
HWTEST_F(WindowGamutTest, IsSupportWideGamut01, Function | MediumTest | Level3)
|
||||
{
|
||||
const sptr<Window>& window = utils::CreateTestWindow(fullScreenAppInfo_);
|
||||
const sptr<Window>& window = Utils::CreateTestWindow(fullScreenAppInfo_);
|
||||
|
||||
ASSERT_EQ(true, window->IsSupportWideGamut());
|
||||
|
||||
@@ -81,7 +81,7 @@ HWTEST_F(WindowGamutTest, IsSupportWideGamut01, Function | MediumTest | Level3)
|
||||
*/
|
||||
HWTEST_F(WindowGamutTest, GetColorSpace01, Function | MediumTest | Level3)
|
||||
{
|
||||
const sptr<Window>& window = utils::CreateTestWindow(fullScreenAppInfo_);
|
||||
const sptr<Window>& window = Utils::CreateTestWindow(fullScreenAppInfo_);
|
||||
|
||||
ASSERT_EQ(ColorSpace::COLOR_SPACE_DEFAULT, window->GetColorSpace());
|
||||
|
||||
@@ -101,7 +101,7 @@ HWTEST_F(WindowGamutTest, SetColorSpace01, Function | MediumTest | Level3)
|
||||
ColorSpace::COLOR_SPACE_WIDE_GAMUT
|
||||
};
|
||||
ColorSpace colorSpace;
|
||||
const sptr<Window>& window = utils::CreateTestWindow(fullScreenAppInfo_);
|
||||
const sptr<Window>& window = Utils::CreateTestWindow(fullScreenAppInfo_);
|
||||
|
||||
ColorSpace colorSpaceBackup = window->GetColorSpace(); // backup origin
|
||||
|
||||
@@ -130,7 +130,7 @@ HWTEST_F(WindowGamutTest, SetColorSpace01, Function | MediumTest | Level3)
|
||||
*/
|
||||
HWTEST_F(WindowGamutTest, SetColorSpace02, Function | MediumTest | Level3)
|
||||
{
|
||||
const sptr<Window>& window = utils::CreateTestWindow(fullScreenAppInfo_);
|
||||
const sptr<Window>& window = Utils::CreateTestWindow(fullScreenAppInfo_);
|
||||
|
||||
ColorSpace colorSpaceBackup = window->GetColorSpace();
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ namespace {
|
||||
const float RATIO = 0.3;
|
||||
}
|
||||
|
||||
using utils = WindowTestUtils;
|
||||
using Utils = WindowTestUtils;
|
||||
const int WAIT_ASYNC_US = 100000; // 100000us
|
||||
|
||||
class TestSystemBarChangedListener : public ISystemBarChangedListener {
|
||||
@@ -79,8 +79,8 @@ public:
|
||||
static vector<Rect> fullScreenExpecteds_;
|
||||
static sptr<TestSystemBarChangedListener> testSystemBarChangedListener_;
|
||||
static sptr<TestAvoidAreaChangedListener> testAvoidAreaChangedListener_;
|
||||
utils::TestWindowInfo fullScreenAppinfo_;
|
||||
utils::TestWindowInfo avoidBarInfo_;
|
||||
Utils::TestWindowInfo fullScreenAppinfo_;
|
||||
Utils::TestWindowInfo avoidBarInfo_;
|
||||
uint32_t leftAvoidW_;
|
||||
uint32_t leftAvoidH_;
|
||||
uint32_t topAvoidW_;
|
||||
@@ -200,7 +200,7 @@ void WindowImmersiveTest::SetUpTestCase()
|
||||
WLOGFI("GetDefaultDisplay: id %{public}" PRIu64", w %{public}d, h %{public}d, fps %{public}u",
|
||||
display->GetId(), display->GetWidth(), display->GetHeight(), display->GetRefreshRate());
|
||||
Rect displayRect = {0, 0, display->GetWidth(), display->GetHeight()};
|
||||
utils::InitByDisplayRect(displayRect);
|
||||
Utils::InitByDisplayRect(displayRect);
|
||||
}
|
||||
|
||||
void WindowImmersiveTest::TearDownTestCase()
|
||||
@@ -211,7 +211,7 @@ void WindowImmersiveTest::SetUp()
|
||||
{
|
||||
fullScreenAppinfo_ = {
|
||||
.name = "main",
|
||||
.rect = utils::customAppRect_,
|
||||
.rect = Utils::customAppRect_,
|
||||
.type = WindowType::WINDOW_TYPE_APP_MAIN_WINDOW,
|
||||
.mode = WindowMode::WINDOW_MODE_FULLSCREEN, // immersive setting
|
||||
.needAvoid = false, // immersive setting
|
||||
@@ -225,11 +225,11 @@ void WindowImmersiveTest::SetUp()
|
||||
.mode = WindowMode::WINDOW_MODE_FLOATING,
|
||||
};
|
||||
// makesure left avoid win w < h
|
||||
leftAvoidW_ = std::min(utils::displayRect_.width_, static_cast<uint32_t>(utils::displayRect_.height_ * RATIO));
|
||||
leftAvoidH_ = utils::displayRect_.height_;
|
||||
leftAvoidW_ = std::min(Utils::displayRect_.width_, static_cast<uint32_t>(Utils::displayRect_.height_ * RATIO));
|
||||
leftAvoidH_ = Utils::displayRect_.height_;
|
||||
// makesure top avoid win h < w
|
||||
topAvoidW_ = utils::displayRect_.width_;
|
||||
topAvoidH_ = std::min(utils::displayRect_.height_, static_cast<uint32_t>(utils::displayRect_.width_ * RATIO));
|
||||
topAvoidW_ = Utils::displayRect_.width_;
|
||||
topAvoidH_ = std::min(Utils::displayRect_.height_, static_cast<uint32_t>(Utils::displayRect_.width_ * RATIO));
|
||||
|
||||
WindowManager::GetInstance().RegisterSystemBarChangedListener(testSystemBarChangedListener_);
|
||||
activeWindows_.clear();
|
||||
@@ -253,7 +253,7 @@ namespace {
|
||||
HWTEST_F(WindowImmersiveTest, ImmersiveTest01, Function | MediumTest | Level3)
|
||||
{
|
||||
fullScreenAppinfo_.name = "immer01";
|
||||
const sptr<Window>& window = utils::CreateTestWindow(fullScreenAppinfo_);
|
||||
const sptr<Window>& window = Utils::CreateTestWindow(fullScreenAppinfo_);
|
||||
activeWindows_.push_back(window);
|
||||
SetWindowSystemProps(window, TEST_PROPS_1);
|
||||
ASSERT_EQ(WMError::WM_OK, window->Show());
|
||||
@@ -268,11 +268,11 @@ HWTEST_F(WindowImmersiveTest, ImmersiveTest01, Function | MediumTest | Level3)
|
||||
*/
|
||||
HWTEST_F(WindowImmersiveTest, ImmersiveTest02, Function | MediumTest | Level3)
|
||||
{
|
||||
const sptr<Window>& window1 = utils::CreateTestWindow(fullScreenAppinfo_);
|
||||
const sptr<Window>& window1 = Utils::CreateTestWindow(fullScreenAppinfo_);
|
||||
activeWindows_.push_back(window1);
|
||||
SetWindowSystemProps(window1, TEST_PROPS_1);
|
||||
fullScreenAppinfo_.name = "Immer02";
|
||||
const sptr<Window>& window2 = utils::CreateTestWindow(fullScreenAppinfo_);
|
||||
const sptr<Window>& window2 = Utils::CreateTestWindow(fullScreenAppinfo_);
|
||||
activeWindows_.push_back(window2);
|
||||
SetWindowSystemProps(window2, TEST_PROPS_2);
|
||||
ASSERT_EQ(WMError::WM_OK, window1->Show());
|
||||
@@ -292,12 +292,12 @@ HWTEST_F(WindowImmersiveTest, ImmersiveTest02, Function | MediumTest | Level3)
|
||||
*/
|
||||
HWTEST_F(WindowImmersiveTest, ImmersiveTest03, Function | MediumTest | Level3)
|
||||
{
|
||||
const sptr<Window>& window1 = utils::CreateTestWindow(fullScreenAppinfo_);
|
||||
const sptr<Window>& window1 = Utils::CreateTestWindow(fullScreenAppinfo_);
|
||||
activeWindows_.push_back(window1);
|
||||
SetWindowSystemProps(window1, TEST_PROPS_1);
|
||||
fullScreenAppinfo_.name = "Immer03";
|
||||
fullScreenAppinfo_.needAvoid = true; // no immersive setting
|
||||
const sptr<Window>& window2 = utils::CreateTestWindow(fullScreenAppinfo_);
|
||||
const sptr<Window>& window2 = Utils::CreateTestWindow(fullScreenAppinfo_);
|
||||
activeWindows_.push_back(window2);
|
||||
SetWindowSystemProps(window2, TEST_PROPS_2);
|
||||
ASSERT_EQ(WMError::WM_OK, window1->Show());
|
||||
@@ -316,7 +316,7 @@ HWTEST_F(WindowImmersiveTest, ImmersiveTest03, Function | MediumTest | Level3)
|
||||
HWTEST_F(WindowImmersiveTest, ImmersiveTest04, Function | MediumTest | Level3)
|
||||
{
|
||||
fullScreenAppinfo_.needAvoid = true; // no immersive setting
|
||||
const sptr<Window>& window1 = utils::CreateTestWindow(fullScreenAppinfo_);
|
||||
const sptr<Window>& window1 = Utils::CreateTestWindow(fullScreenAppinfo_);
|
||||
activeWindows_.push_back(window1);
|
||||
SetWindowSystemProps(window1, TEST_PROPS_1);
|
||||
ASSERT_EQ(WMError::WM_OK, window1->Show());
|
||||
@@ -338,7 +338,7 @@ HWTEST_F(WindowImmersiveTest, ImmersiveTest04, Function | MediumTest | Level3)
|
||||
HWTEST_F(WindowImmersiveTest, ImmersiveTest05, Function | MediumTest | Level3)
|
||||
{
|
||||
fullScreenAppinfo_.needAvoid = true; // no immersive setting
|
||||
const sptr<Window>& window1 = utils::CreateTestWindow(fullScreenAppinfo_);
|
||||
const sptr<Window>& window1 = Utils::CreateTestWindow(fullScreenAppinfo_);
|
||||
activeWindows_.push_back(window1);
|
||||
SetWindowSystemProps(window1, TEST_PROPS_1);
|
||||
ASSERT_EQ(WMError::WM_OK, window1->Show());
|
||||
@@ -362,7 +362,7 @@ HWTEST_F(WindowImmersiveTest, ImmersiveNegativeTest01, Function | MediumTest | L
|
||||
{ WindowType::WINDOW_TYPE_KEYGUARD, SYS_BAR_PROP_1, SYS_BAR_REGION_NULL },
|
||||
{ WindowType::WINDOW_TYPE_POINTER, SYS_BAR_PROP_2, SYS_BAR_REGION_NULL },
|
||||
};
|
||||
const sptr<Window>& window = utils::CreateTestWindow(fullScreenAppinfo_);
|
||||
const sptr<Window>& window = Utils::CreateTestWindow(fullScreenAppinfo_);
|
||||
activeWindows_.push_back(window);
|
||||
SetWindowSystemProps(window, TEST_PROPS_NEGATIVE);
|
||||
ASSERT_EQ(WMError::WM_OK, window->Show());
|
||||
@@ -379,17 +379,17 @@ HWTEST_F(WindowImmersiveTest, ImmersiveNegativeTest01, Function | MediumTest | L
|
||||
HWTEST_F(WindowImmersiveTest, GetAvoidAreaByTypeTest01, Function | MediumTest | Level3)
|
||||
{
|
||||
// Add full screenwindow for call GetAvoidArea, and push_back in activeWindows_
|
||||
const sptr<Window>& win = utils::CreateTestWindow(fullScreenAppinfo_);
|
||||
const sptr<Window>& win = Utils::CreateTestWindow(fullScreenAppinfo_);
|
||||
activeWindows_.push_back(win);
|
||||
|
||||
// Test GetAvoidArea
|
||||
AvoidArea avoidarea;
|
||||
WMError ret = win->GetAvoidAreaByType(AvoidAreaType::TYPE_CUTOUT, avoidarea);
|
||||
ASSERT_EQ(WMError::WM_OK, ret);
|
||||
ASSERT_TRUE(utils::RectEqualToRect(EMPTY_RECT, avoidarea.leftRect_));
|
||||
ASSERT_TRUE(utils::RectEqualToRect(EMPTY_RECT, avoidarea.rightRect_));
|
||||
ASSERT_TRUE(utils::RectEqualToRect(EMPTY_RECT, avoidarea.topRect_));
|
||||
ASSERT_TRUE(utils::RectEqualToRect(EMPTY_RECT, avoidarea.bottomRect_));
|
||||
ASSERT_TRUE(Utils::RectEqualToRect(EMPTY_RECT, avoidarea.leftRect_));
|
||||
ASSERT_TRUE(Utils::RectEqualToRect(EMPTY_RECT, avoidarea.rightRect_));
|
||||
ASSERT_TRUE(Utils::RectEqualToRect(EMPTY_RECT, avoidarea.topRect_));
|
||||
ASSERT_TRUE(Utils::RectEqualToRect(EMPTY_RECT, avoidarea.bottomRect_));
|
||||
ASSERT_EQ(WMError::WM_OK, win->Hide());
|
||||
}
|
||||
|
||||
@@ -400,10 +400,10 @@ HWTEST_F(WindowImmersiveTest, GetAvoidAreaByTypeTest01, Function | MediumTest |
|
||||
*/
|
||||
HWTEST_F(WindowImmersiveTest, DockWindowTest01, Function | MediumTest | Level3)
|
||||
{
|
||||
const sptr<Window>& dockWindow = utils::CreateDockWindow();
|
||||
const sptr<Window>& dockWindow = Utils::CreateDockWindow();
|
||||
ASSERT_EQ(WMError::WM_OK, dockWindow->Show());
|
||||
|
||||
const sptr<Window>& window = utils::CreateTestWindow(fullScreenAppinfo_);
|
||||
const sptr<Window>& window = Utils::CreateTestWindow(fullScreenAppinfo_);
|
||||
|
||||
usleep(WAIT_ASYNC_US);
|
||||
auto act = testSystemBarChangedListener_->tints_;
|
||||
|
||||
@@ -21,15 +21,15 @@ using namespace testing::ext;
|
||||
|
||||
namespace OHOS {
|
||||
namespace Rosen {
|
||||
using utils = WindowTestUtils;
|
||||
using Utils = WindowTestUtils;
|
||||
class WindowInputMethodTest : public testing::Test {
|
||||
public:
|
||||
static void SetUpTestCase();
|
||||
static void TearDownTestCase();
|
||||
virtual void SetUp() override;
|
||||
virtual void TearDown() override;
|
||||
utils::TestWindowInfo inputMethodWindowInfo_;
|
||||
utils::TestWindowInfo keyGuardWindowInfo_;
|
||||
Utils::TestWindowInfo inputMethodWindowInfo_;
|
||||
Utils::TestWindowInfo keyGuardWindowInfo_;
|
||||
};
|
||||
|
||||
void WindowInputMethodTest::SetUpTestCase()
|
||||
@@ -37,7 +37,7 @@ void WindowInputMethodTest::SetUpTestCase()
|
||||
auto display = DisplayManager::GetInstance().GetDisplayById(0);
|
||||
ASSERT_TRUE((display != nullptr));
|
||||
Rect displayRect = {0, 0, display->GetWidth(), display->GetHeight()};
|
||||
utils::InitByDisplayRect(displayRect);
|
||||
Utils::InitByDisplayRect(displayRect);
|
||||
}
|
||||
|
||||
void WindowInputMethodTest::TearDownTestCase()
|
||||
@@ -48,7 +48,7 @@ void WindowInputMethodTest::SetUp()
|
||||
{
|
||||
inputMethodWindowInfo_ = {
|
||||
.name = "",
|
||||
.rect = utils::customAppRect_,
|
||||
.rect = Utils::customAppRect_,
|
||||
.type = WindowType::WINDOW_TYPE_INPUT_METHOD_FLOAT,
|
||||
.mode = WindowMode::WINDOW_MODE_FLOATING,
|
||||
.needAvoid = false,
|
||||
@@ -57,7 +57,7 @@ void WindowInputMethodTest::SetUp()
|
||||
};
|
||||
keyGuardWindowInfo_ = {
|
||||
.name = "",
|
||||
.rect = utils::customAppRect_,
|
||||
.rect = Utils::customAppRect_,
|
||||
.type = WindowType::WINDOW_TYPE_KEYGUARD,
|
||||
.mode = WindowMode::WINDOW_MODE_FULLSCREEN,
|
||||
.needAvoid = false,
|
||||
@@ -79,7 +79,7 @@ namespace {
|
||||
HWTEST_F(WindowInputMethodTest, InputMethodWindow01, Function | MediumTest | Level3)
|
||||
{
|
||||
inputMethodWindowInfo_.name = "input_method.1";
|
||||
const sptr<Window>& window = utils::CreateTestWindow(inputMethodWindowInfo_);
|
||||
const sptr<Window>& window = Utils::CreateTestWindow(inputMethodWindowInfo_);
|
||||
ASSERT_EQ(WindowType::WINDOW_TYPE_INPUT_METHOD_FLOAT, window->GetType());
|
||||
ASSERT_EQ(WMError::WM_OK, window->Show());
|
||||
ASSERT_EQ(WMError::WM_OK, window->Hide());
|
||||
@@ -93,7 +93,7 @@ HWTEST_F(WindowInputMethodTest, InputMethodWindow01, Function | MediumTest | Lev
|
||||
HWTEST_F(WindowInputMethodTest, InputMethodWindow02, Function | MediumTest | Level3)
|
||||
{
|
||||
keyGuardWindowInfo_.name = "keyGuard.1";
|
||||
const sptr<Window>& window = utils::CreateTestWindow(keyGuardWindowInfo_);
|
||||
const sptr<Window>& window = Utils::CreateTestWindow(keyGuardWindowInfo_);
|
||||
ASSERT_EQ(WindowType::WINDOW_TYPE_KEYGUARD, window->GetType());
|
||||
ASSERT_EQ(WMError::WM_OK, window->Show());
|
||||
ASSERT_EQ(WMError::WM_OK, window->Hide());
|
||||
@@ -108,12 +108,12 @@ HWTEST_F(WindowInputMethodTest, InputMethodWindow03, Function | MediumTest | Lev
|
||||
{
|
||||
inputMethodWindowInfo_.name = "input_method.2";
|
||||
keyGuardWindowInfo_.name = "keyGuard.2";
|
||||
const sptr<Window>& inputMethodWindow = utils::CreateTestWindow(inputMethodWindowInfo_);
|
||||
const sptr<Window>& keyGuardWindow = utils::CreateTestWindow(keyGuardWindowInfo_);
|
||||
const sptr<Window>& inputMethodWindow = Utils::CreateTestWindow(inputMethodWindowInfo_);
|
||||
const sptr<Window>& keyGuardWindow = Utils::CreateTestWindow(keyGuardWindowInfo_);
|
||||
keyGuardWindow->Show();
|
||||
inputMethodWindow->Show();
|
||||
ASSERT_TRUE(utils::RectEqualTo(keyGuardWindow, utils::displayRect_));
|
||||
ASSERT_TRUE(utils::RectEqualTo(inputMethodWindow, utils::customAppRect_));
|
||||
ASSERT_TRUE(Utils::RectEqualTo(keyGuardWindow, Utils::displayRect_));
|
||||
ASSERT_TRUE(Utils::RectEqualTo(inputMethodWindow, Utils::customAppRect_));
|
||||
}
|
||||
} // namespace
|
||||
} // namespace Rosen
|
||||
|
||||
@@ -24,14 +24,14 @@ namespace Rosen {
|
||||
namespace {
|
||||
constexpr uint32_t WAIT_ASYNC_US = 100000; // 100ms
|
||||
}
|
||||
using utils = WindowTestUtils;
|
||||
using Utils = WindowTestUtils;
|
||||
class WindowInputTest : public testing::Test {
|
||||
public:
|
||||
static void SetUpTestCase();
|
||||
static void TearDownTestCase();
|
||||
virtual void SetUp() override;
|
||||
virtual void TearDown() override;
|
||||
utils::TestWindowInfo fullScreenWindow_;
|
||||
Utils::TestWindowInfo fullScreenWindow_;
|
||||
};
|
||||
|
||||
void WindowInputTest::SetUpTestCase()
|
||||
@@ -39,7 +39,7 @@ void WindowInputTest::SetUpTestCase()
|
||||
auto display = DisplayManager::GetInstance().GetDisplayById(0);
|
||||
ASSERT_TRUE((display != nullptr));
|
||||
Rect displayRect = {0, 0, display->GetWidth(), display->GetHeight()};
|
||||
utils::InitByDisplayRect(displayRect);
|
||||
Utils::InitByDisplayRect(displayRect);
|
||||
}
|
||||
|
||||
void WindowInputTest::TearDownTestCase()
|
||||
@@ -50,7 +50,7 @@ void WindowInputTest::SetUp()
|
||||
{
|
||||
fullScreenWindow_ = {
|
||||
.name = "FullWindow",
|
||||
.rect = utils::customAppRect_,
|
||||
.rect = Utils::customAppRect_,
|
||||
.type = WindowType::WINDOW_TYPE_APP_MAIN_WINDOW,
|
||||
.mode = WindowMode::WINDOW_MODE_FULLSCREEN,
|
||||
.needAvoid = false,
|
||||
@@ -72,7 +72,7 @@ namespace {
|
||||
HWTEST_F(WindowInputTest, SetTouchHotAreas01, Function | MediumTest | Level3)
|
||||
{
|
||||
fullScreenWindow_.name = "window_hot_areas.1";
|
||||
const sptr<Window>& window = utils::CreateTestWindow(fullScreenWindow_);
|
||||
const sptr<Window>& window = Utils::CreateTestWindow(fullScreenWindow_);
|
||||
ASSERT_EQ(WMError::WM_OK, window->Show());
|
||||
|
||||
std::vector<Rect> requestedTouchHotAreas;
|
||||
@@ -121,7 +121,7 @@ HWTEST_F(WindowInputTest, SetTouchHotAreas01, Function | MediumTest | Level3)
|
||||
HWTEST_F(WindowInputTest, SetTouchHotAreas02, Function | MediumTest | Level3)
|
||||
{
|
||||
fullScreenWindow_.name = "window_hot_areas.2";
|
||||
const sptr<Window>& window = utils::CreateTestWindow(fullScreenWindow_);
|
||||
const sptr<Window>& window = Utils::CreateTestWindow(fullScreenWindow_);
|
||||
ASSERT_EQ(WMError::WM_OK, window->Show());
|
||||
|
||||
usleep(WAIT_ASYNC_US);
|
||||
|
||||
@@ -22,7 +22,7 @@ using namespace testing::ext;
|
||||
|
||||
namespace OHOS {
|
||||
namespace Rosen {
|
||||
using utils = WindowTestUtils;
|
||||
using Utils = WindowTestUtils;
|
||||
class WindowLayoutTest : public testing::Test {
|
||||
public:
|
||||
static void SetUpTestCase();
|
||||
@@ -44,30 +44,30 @@ void WindowLayoutTest::SetUpTestCase()
|
||||
auto display = DisplayManager::GetInstance().GetDisplayById(0);
|
||||
ASSERT_TRUE((display != nullptr));
|
||||
Rect displayRect = {0, 0, display->GetWidth(), display->GetHeight()};
|
||||
utils::InitByDisplayRect(displayRect);
|
||||
Utils::InitByDisplayRect(displayRect);
|
||||
|
||||
virtualPixelRatio_ = WindowTestUtils::GetVirtualPixelRatio(0);
|
||||
|
||||
// calc expected rects
|
||||
Rect expected = { // 0. only statusBar
|
||||
0,
|
||||
utils::statusBarRect_.height_,
|
||||
utils::displayRect_.width_,
|
||||
utils::displayRect_.height_ - utils::statusBarRect_.height_,
|
||||
Utils::statusBarRect_.height_,
|
||||
Utils::displayRect_.width_,
|
||||
Utils::displayRect_.height_ - Utils::statusBarRect_.height_,
|
||||
};
|
||||
fullScreenExpecteds_.push_back(expected);
|
||||
expected = { // 1. both statusBar and naviBar
|
||||
0,
|
||||
utils::statusBarRect_.height_,
|
||||
utils::displayRect_.width_,
|
||||
utils::displayRect_.height_ - utils::statusBarRect_.height_ - utils::naviBarRect_.height_,
|
||||
Utils::statusBarRect_.height_,
|
||||
Utils::displayRect_.width_,
|
||||
Utils::displayRect_.height_ - Utils::statusBarRect_.height_ - Utils::naviBarRect_.height_,
|
||||
};
|
||||
fullScreenExpecteds_.push_back(expected);
|
||||
expected = { // 2. only naviBar
|
||||
0,
|
||||
0,
|
||||
utils::displayRect_.width_,
|
||||
utils::displayRect_.height_ - utils::naviBarRect_.height_,
|
||||
Utils::displayRect_.width_,
|
||||
Utils::displayRect_.height_ - Utils::naviBarRect_.height_,
|
||||
};
|
||||
fullScreenExpecteds_.push_back(expected);
|
||||
}
|
||||
@@ -102,7 +102,7 @@ HWTEST_F(WindowLayoutTest, LayoutWindow01, Function | MediumTest | Level3)
|
||||
WindowManager::GetInstance().SetWindowLayoutMode(WindowLayoutMode::TILE);
|
||||
WindowManager::GetInstance().SetWindowLayoutMode(WindowLayoutMode::CASCADE);
|
||||
|
||||
utils::TestWindowInfo info = {
|
||||
Utils::TestWindowInfo info = {
|
||||
.name = "main",
|
||||
.rect = {0, 0, 0, 0},
|
||||
.type = WindowType::WINDOW_TYPE_APP_MAIN_WINDOW,
|
||||
@@ -111,11 +111,11 @@ HWTEST_F(WindowLayoutTest, LayoutWindow01, Function | MediumTest | Level3)
|
||||
.parentLimit = false,
|
||||
.parentName = "",
|
||||
};
|
||||
const sptr<Window>& window = utils::CreateTestWindow(info);
|
||||
const sptr<Window>& window = Utils::CreateTestWindow(info);
|
||||
activeWindows_.push_back(window);
|
||||
Rect expect = utils::GetDefaultFloatingRect(window);
|
||||
Rect expect = Utils::GetDefaultFloatingRect(window);
|
||||
ASSERT_EQ(WMError::WM_OK, window->Show());
|
||||
ASSERT_TRUE(utils::RectEqualTo(window, expect));
|
||||
ASSERT_TRUE(Utils::RectEqualTo(window, expect));
|
||||
ASSERT_EQ(WMError::WM_OK, window->Hide());
|
||||
}
|
||||
|
||||
@@ -126,24 +126,24 @@ HWTEST_F(WindowLayoutTest, LayoutWindow01, Function | MediumTest | Level3)
|
||||
*/
|
||||
HWTEST_F(WindowLayoutTest, LayoutWindow02, Function | MediumTest | Level3)
|
||||
{
|
||||
utils::TestWindowInfo info = {
|
||||
Utils::TestWindowInfo info = {
|
||||
.name = "main",
|
||||
.rect = utils::customAppRect_,
|
||||
.rect = Utils::customAppRect_,
|
||||
.type = WindowType::WINDOW_TYPE_APP_MAIN_WINDOW,
|
||||
.mode = WindowMode::WINDOW_MODE_FLOATING,
|
||||
.needAvoid = true,
|
||||
.parentLimit = false,
|
||||
.parentName = "",
|
||||
};
|
||||
const sptr<Window>& window = utils::CreateTestWindow(info);
|
||||
const sptr<Window>& window = Utils::CreateTestWindow(info);
|
||||
activeWindows_.push_back(window);
|
||||
|
||||
ASSERT_EQ(WMError::WM_OK, window->Show());
|
||||
Rect res = utils::GetFloatingLimitedRect(utils::customAppRect_, virtualPixelRatio_);
|
||||
Rect res = Utils::GetFloatingLimitedRect(Utils::customAppRect_, virtualPixelRatio_);
|
||||
if (window->IsDecorEnable()) {
|
||||
ASSERT_TRUE(utils::RectEqualTo(window, utils::GetDecorateRect(res, virtualPixelRatio_)));
|
||||
ASSERT_TRUE(Utils::RectEqualTo(window, Utils::GetDecorateRect(res, virtualPixelRatio_)));
|
||||
} else {
|
||||
ASSERT_TRUE(utils::RectEqualTo(window, res));
|
||||
ASSERT_TRUE(Utils::RectEqualTo(window, res));
|
||||
}
|
||||
ASSERT_EQ(WMError::WM_OK, window->Hide());
|
||||
}
|
||||
@@ -156,40 +156,40 @@ HWTEST_F(WindowLayoutTest, LayoutWindow02, Function | MediumTest | Level3)
|
||||
HWTEST_F(WindowLayoutTest, LayoutWindow04, Function | MediumTest | Level3)
|
||||
{
|
||||
// app window
|
||||
utils::TestWindowInfo info = {
|
||||
Utils::TestWindowInfo info = {
|
||||
.name = "main",
|
||||
.rect = utils::customAppRect_,
|
||||
.rect = Utils::customAppRect_,
|
||||
.type = WindowType::WINDOW_TYPE_APP_MAIN_WINDOW,
|
||||
.mode = WindowMode::WINDOW_MODE_FLOATING,
|
||||
.needAvoid = true,
|
||||
.parentLimit = false,
|
||||
.parentName = "",
|
||||
};
|
||||
sptr<Window> appWin = utils::CreateTestWindow(info);
|
||||
sptr<Window> appWin = Utils::CreateTestWindow(info);
|
||||
activeWindows_.push_back(appWin);
|
||||
|
||||
// statusBar window
|
||||
sptr<Window> statBar = utils::CreateStatusBarWindow();
|
||||
sptr<Window> statBar = Utils::CreateStatusBarWindow();
|
||||
activeWindows_.push_back(statBar);
|
||||
|
||||
ASSERT_EQ(WMError::WM_OK, appWin->Show());
|
||||
Rect res = utils::GetFloatingLimitedRect(utils::customAppRect_, virtualPixelRatio_);
|
||||
Rect res = Utils::GetFloatingLimitedRect(Utils::customAppRect_, virtualPixelRatio_);
|
||||
if (appWin->IsDecorEnable()) {
|
||||
ASSERT_TRUE(utils::RectEqualTo(appWin, utils::GetDecorateRect(res, virtualPixelRatio_)));
|
||||
ASSERT_TRUE(Utils::RectEqualTo(appWin, Utils::GetDecorateRect(res, virtualPixelRatio_)));
|
||||
} else {
|
||||
ASSERT_TRUE(utils::RectEqualTo(appWin, res));
|
||||
ASSERT_TRUE(Utils::RectEqualTo(appWin, res));
|
||||
}
|
||||
ASSERT_EQ(WMError::WM_OK, statBar->Show());
|
||||
if (appWin->IsDecorEnable()) {
|
||||
ASSERT_TRUE(utils::RectEqualTo(appWin, utils::GetDecorateRect(res, virtualPixelRatio_)));
|
||||
ASSERT_TRUE(Utils::RectEqualTo(appWin, Utils::GetDecorateRect(res, virtualPixelRatio_)));
|
||||
} else {
|
||||
ASSERT_TRUE(utils::RectEqualTo(appWin, res));
|
||||
ASSERT_TRUE(Utils::RectEqualTo(appWin, res));
|
||||
}
|
||||
ASSERT_EQ(WMError::WM_OK, statBar->Hide());
|
||||
if (appWin->IsDecorEnable()) {
|
||||
ASSERT_TRUE(utils::RectEqualTo(appWin, utils::GetDecorateRect(res, virtualPixelRatio_)));
|
||||
ASSERT_TRUE(Utils::RectEqualTo(appWin, Utils::GetDecorateRect(res, virtualPixelRatio_)));
|
||||
} else {
|
||||
ASSERT_TRUE(utils::RectEqualTo(appWin, res));
|
||||
ASSERT_TRUE(Utils::RectEqualTo(appWin, res));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -201,33 +201,33 @@ HWTEST_F(WindowLayoutTest, LayoutWindow04, Function | MediumTest | Level3)
|
||||
HWTEST_F(WindowLayoutTest, LayoutWindow06, Function | MediumTest | Level3)
|
||||
{
|
||||
// statusBar window
|
||||
sptr<Window> statBar = utils::CreateStatusBarWindow();
|
||||
sptr<Window> statBar = Utils::CreateStatusBarWindow();
|
||||
activeWindows_.push_back(statBar);
|
||||
|
||||
// naviBar window
|
||||
sptr<Window> naviBar = utils::CreateNavigationBarWindow();
|
||||
sptr<Window> naviBar = Utils::CreateNavigationBarWindow();
|
||||
activeWindows_.push_back(naviBar);
|
||||
|
||||
// sys window
|
||||
utils::TestWindowInfo info = {
|
||||
Utils::TestWindowInfo info = {
|
||||
.name = "main",
|
||||
.rect = utils::customAppRect_,
|
||||
.rect = Utils::customAppRect_,
|
||||
.type = WindowType::WINDOW_TYPE_PANEL,
|
||||
.mode = WindowMode::WINDOW_MODE_FULLSCREEN,
|
||||
.needAvoid = false,
|
||||
.parentLimit = true,
|
||||
.parentName = "",
|
||||
};
|
||||
sptr<Window> sysWin = utils::CreateTestWindow(info);
|
||||
sptr<Window> sysWin = Utils::CreateTestWindow(info);
|
||||
activeWindows_.push_back(sysWin);
|
||||
|
||||
ASSERT_EQ(WMError::WM_OK, statBar->Show());
|
||||
ASSERT_EQ(WMError::WM_OK, sysWin->Show());
|
||||
ASSERT_TRUE(utils::RectEqualTo(sysWin, utils::displayRect_));
|
||||
ASSERT_TRUE(Utils::RectEqualTo(sysWin, Utils::displayRect_));
|
||||
ASSERT_EQ(WMError::WM_OK, naviBar->Show());
|
||||
ASSERT_TRUE(utils::RectEqualTo(sysWin, utils::displayRect_));
|
||||
ASSERT_TRUE(Utils::RectEqualTo(sysWin, Utils::displayRect_));
|
||||
ASSERT_EQ(WMError::WM_OK, statBar->Hide());
|
||||
ASSERT_TRUE(utils::RectEqualTo(sysWin, utils::displayRect_));
|
||||
ASSERT_TRUE(Utils::RectEqualTo(sysWin, Utils::displayRect_));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -238,33 +238,33 @@ HWTEST_F(WindowLayoutTest, LayoutWindow06, Function | MediumTest | Level3)
|
||||
HWTEST_F(WindowLayoutTest, LayoutWindow07, Function | MediumTest | Level3)
|
||||
{
|
||||
// statusBar window
|
||||
sptr<Window> statBar = utils::CreateStatusBarWindow();
|
||||
sptr<Window> statBar = Utils::CreateStatusBarWindow();
|
||||
activeWindows_.push_back(statBar);
|
||||
|
||||
// naviBar window
|
||||
sptr<Window> naviBar = utils::CreateNavigationBarWindow();
|
||||
sptr<Window> naviBar = Utils::CreateNavigationBarWindow();
|
||||
activeWindows_.push_back(naviBar);
|
||||
|
||||
// sys window
|
||||
utils::TestWindowInfo info = {
|
||||
Utils::TestWindowInfo info = {
|
||||
.name = "main",
|
||||
.rect = utils::customAppRect_,
|
||||
.rect = Utils::customAppRect_,
|
||||
.type = WindowType::WINDOW_TYPE_PANEL,
|
||||
.mode = WindowMode::WINDOW_MODE_FLOATING,
|
||||
.needAvoid = false,
|
||||
.parentLimit = true,
|
||||
.parentName = "",
|
||||
};
|
||||
sptr<Window> sysWin = utils::CreateTestWindow(info);
|
||||
sptr<Window> sysWin = Utils::CreateTestWindow(info);
|
||||
activeWindows_.push_back(sysWin);
|
||||
|
||||
ASSERT_EQ(WMError::WM_OK, statBar->Show());
|
||||
ASSERT_EQ(WMError::WM_OK, sysWin->Show());
|
||||
ASSERT_TRUE(utils::RectEqualTo(sysWin, utils::customAppRect_));
|
||||
ASSERT_TRUE(Utils::RectEqualTo(sysWin, Utils::customAppRect_));
|
||||
ASSERT_EQ(WMError::WM_OK, naviBar->Show());
|
||||
ASSERT_TRUE(utils::RectEqualTo(sysWin, utils::customAppRect_));
|
||||
ASSERT_TRUE(Utils::RectEqualTo(sysWin, Utils::customAppRect_));
|
||||
ASSERT_EQ(WMError::WM_OK, statBar->Hide());
|
||||
ASSERT_TRUE(utils::RectEqualTo(sysWin, utils::customAppRect_));
|
||||
ASSERT_TRUE(Utils::RectEqualTo(sysWin, Utils::customAppRect_));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -274,7 +274,7 @@ HWTEST_F(WindowLayoutTest, LayoutWindow07, Function | MediumTest | Level3)
|
||||
*/
|
||||
HWTEST_F(WindowLayoutTest, LayoutWindow08, Function | MediumTest | Level3)
|
||||
{
|
||||
utils::TestWindowInfo info = {
|
||||
Utils::TestWindowInfo info = {
|
||||
.name = "main",
|
||||
.rect = {0, 0, 0, 0},
|
||||
.type = WindowType::WINDOW_TYPE_APP_MAIN_WINDOW,
|
||||
@@ -283,11 +283,11 @@ HWTEST_F(WindowLayoutTest, LayoutWindow08, Function | MediumTest | Level3)
|
||||
.parentLimit = false,
|
||||
.parentName = "",
|
||||
};
|
||||
const sptr<Window>& window = utils::CreateTestWindow(info);
|
||||
const sptr<Window>& window = Utils::CreateTestWindow(info);
|
||||
activeWindows_.push_back(window);
|
||||
Rect expect = utils::GetDefaultFloatingRect(window);
|
||||
Rect expect = Utils::GetDefaultFloatingRect(window);
|
||||
ASSERT_EQ(WMError::WM_OK, window->Show());
|
||||
ASSERT_TRUE(utils::RectEqualTo(window, expect));
|
||||
ASSERT_TRUE(Utils::RectEqualTo(window, expect));
|
||||
ASSERT_EQ(WMError::WM_OK, window->Hide());
|
||||
}
|
||||
|
||||
@@ -298,7 +298,7 @@ HWTEST_F(WindowLayoutTest, LayoutWindow08, Function | MediumTest | Level3)
|
||||
*/
|
||||
HWTEST_F(WindowLayoutTest, LayoutWindow09, Function | MediumTest | Level3)
|
||||
{
|
||||
utils::TestWindowInfo info = {
|
||||
Utils::TestWindowInfo info = {
|
||||
.name = "main",
|
||||
.rect = {0, 0, 0, 0},
|
||||
.type = WindowType::WINDOW_TYPE_APP_MAIN_WINDOW,
|
||||
@@ -307,17 +307,17 @@ HWTEST_F(WindowLayoutTest, LayoutWindow09, Function | MediumTest | Level3)
|
||||
.parentLimit = false,
|
||||
.parentName = "",
|
||||
};
|
||||
const sptr<Window>& window = utils::CreateTestWindow(info);
|
||||
const sptr<Window>& window = Utils::CreateTestWindow(info);
|
||||
activeWindows_.push_back(window);
|
||||
Rect expect = utils::GetDefaultFloatingRect(window);
|
||||
Rect expect = Utils::GetDefaultFloatingRect(window);
|
||||
|
||||
ASSERT_EQ(WMError::WM_OK, window->Show());
|
||||
ASSERT_TRUE(utils::RectEqualTo(window, expect));
|
||||
ASSERT_TRUE(Utils::RectEqualTo(window, expect));
|
||||
|
||||
ASSERT_EQ(WMError::WM_OK, window->Resize(2u, 2u)); // 2: custom min size
|
||||
Rect finalExcept = { expect.posX_, expect.posY_, 2u, 2u}; // 2: custom min size
|
||||
finalExcept = utils::GetFloatingLimitedRect(finalExcept, virtualPixelRatio_);
|
||||
ASSERT_TRUE(utils::RectEqualTo(window, finalExcept));
|
||||
finalExcept = Utils::GetFloatingLimitedRect(finalExcept, virtualPixelRatio_);
|
||||
ASSERT_TRUE(Utils::RectEqualTo(window, finalExcept));
|
||||
ASSERT_EQ(WMError::WM_OK, window->Hide());
|
||||
}
|
||||
|
||||
@@ -328,7 +328,7 @@ HWTEST_F(WindowLayoutTest, LayoutWindow09, Function | MediumTest | Level3)
|
||||
*/
|
||||
HWTEST_F(WindowLayoutTest, LayoutWindow10, Function | MediumTest | Level3)
|
||||
{
|
||||
utils::TestWindowInfo info = {
|
||||
Utils::TestWindowInfo info = {
|
||||
.name = "main",
|
||||
.rect = {0, 0, 0, 0},
|
||||
.type = WindowType::WINDOW_TYPE_APP_MAIN_WINDOW,
|
||||
@@ -337,15 +337,15 @@ HWTEST_F(WindowLayoutTest, LayoutWindow10, Function | MediumTest | Level3)
|
||||
.parentLimit = false,
|
||||
.parentName = "",
|
||||
};
|
||||
const sptr<Window>& window = utils::CreateTestWindow(info);
|
||||
const sptr<Window>& window = Utils::CreateTestWindow(info);
|
||||
activeWindows_.push_back(window);
|
||||
Rect expect = utils::GetDefaultFloatingRect(window);
|
||||
Rect expect = Utils::GetDefaultFloatingRect(window);
|
||||
ASSERT_EQ(WMError::WM_OK, window->Show());
|
||||
ASSERT_TRUE(utils::RectEqualTo(window, expect));
|
||||
ASSERT_TRUE(Utils::RectEqualTo(window, expect));
|
||||
ASSERT_EQ(WMError::WM_OK, window->Maximize());
|
||||
ASSERT_TRUE(utils::RectEqualTo(window, utils::displayRect_));
|
||||
ASSERT_TRUE(Utils::RectEqualTo(window, Utils::displayRect_));
|
||||
ASSERT_EQ(WMError::WM_OK, window->Recover());
|
||||
ASSERT_TRUE(utils::RectEqualTo(window, expect));
|
||||
ASSERT_TRUE(Utils::RectEqualTo(window, expect));
|
||||
ASSERT_EQ(WMError::WM_OK, window->Minimize());
|
||||
ASSERT_EQ(WMError::WM_OK, window->Close());
|
||||
}
|
||||
@@ -357,7 +357,7 @@ HWTEST_F(WindowLayoutTest, LayoutWindow10, Function | MediumTest | Level3)
|
||||
*/
|
||||
HWTEST_F(WindowLayoutTest, LayoutTile01, Function | MediumTest | Level3)
|
||||
{
|
||||
utils::TestWindowInfo info = {
|
||||
Utils::TestWindowInfo info = {
|
||||
.name = "main",
|
||||
.rect = {0, 0, 0, 0},
|
||||
.type = WindowType::WINDOW_TYPE_APP_MAIN_WINDOW,
|
||||
@@ -367,47 +367,47 @@ HWTEST_F(WindowLayoutTest, LayoutTile01, Function | MediumTest | Level3)
|
||||
.parentName = "",
|
||||
};
|
||||
|
||||
const sptr<Window>& window = utils::CreateTestWindow(info);
|
||||
const sptr<Window>& window = Utils::CreateTestWindow(info);
|
||||
activeWindows_.push_back(window);
|
||||
Rect expect = utils::GetDefaultFloatingRect(window);
|
||||
Rect expect = Utils::GetDefaultFloatingRect(window);
|
||||
ASSERT_EQ(WMError::WM_OK, window->Show());
|
||||
// init tile window rects and get max tile window num
|
||||
utils::InitTileWindowRects(window);
|
||||
uint32_t maxTileNum = utils::GetMaxTileWinNum();
|
||||
Utils::InitTileWindowRects(window);
|
||||
uint32_t maxTileNum = Utils::GetMaxTileWinNum();
|
||||
|
||||
usleep(WAIT_SYANC_US);
|
||||
ASSERT_TRUE(utils::RectEqualTo(window, expect));
|
||||
ASSERT_TRUE(Utils::RectEqualTo(window, expect));
|
||||
WindowManager::GetInstance().SetWindowLayoutMode(WindowLayoutMode::TILE);
|
||||
usleep(WAIT_SYANC_US);
|
||||
ASSERT_TRUE(utils::RectEqualTo(window, utils::singleTileRect_));
|
||||
ASSERT_TRUE(Utils::RectEqualTo(window, Utils::singleTileRect_));
|
||||
|
||||
info.name = "test1";
|
||||
const sptr<Window>& test1 = utils::CreateTestWindow(info);
|
||||
const sptr<Window>& test1 = Utils::CreateTestWindow(info);
|
||||
activeWindows_.push_back(test1);
|
||||
ASSERT_EQ(WMError::WM_OK, test1->Show());
|
||||
usleep(WAIT_SYANC_US);
|
||||
if (maxTileNum == 1) {
|
||||
ASSERT_TRUE(utils::RectEqualTo(test1, utils::singleTileRect_));
|
||||
ASSERT_TRUE(Utils::RectEqualTo(test1, Utils::singleTileRect_));
|
||||
WindowManager::GetInstance().SetWindowLayoutMode(WindowLayoutMode::CASCADE);
|
||||
return;
|
||||
}
|
||||
ASSERT_TRUE(utils::RectEqualTo(window, utils::doubleTileRects_[0]));
|
||||
ASSERT_TRUE(utils::RectEqualTo(test1, utils::doubleTileRects_[1]));
|
||||
ASSERT_TRUE(Utils::RectEqualTo(window, Utils::doubleTileRects_[0]));
|
||||
ASSERT_TRUE(Utils::RectEqualTo(test1, Utils::doubleTileRects_[1]));
|
||||
|
||||
info.name = "test2";
|
||||
const sptr<Window>& test2 = utils::CreateTestWindow(info);
|
||||
const sptr<Window>& test2 = Utils::CreateTestWindow(info);
|
||||
activeWindows_.push_back(test2);
|
||||
ASSERT_EQ(WMError::WM_OK, test2->Show());
|
||||
usleep(WAIT_SYANC_US);
|
||||
if (maxTileNum == 2) {
|
||||
ASSERT_TRUE(utils::RectEqualTo(test1, utils::doubleTileRects_[0]));
|
||||
ASSERT_TRUE(utils::RectEqualTo(test2, utils::doubleTileRects_[1]));
|
||||
ASSERT_TRUE(Utils::RectEqualTo(test1, Utils::doubleTileRects_[0]));
|
||||
ASSERT_TRUE(Utils::RectEqualTo(test2, Utils::doubleTileRects_[1]));
|
||||
WindowManager::GetInstance().SetWindowLayoutMode(WindowLayoutMode::CASCADE);
|
||||
return;
|
||||
}
|
||||
ASSERT_TRUE(utils::RectEqualTo(window, utils::tripleTileRects_[0]));
|
||||
ASSERT_TRUE(utils::RectEqualTo(test1, utils::tripleTileRects_[1]));
|
||||
ASSERT_TRUE(utils::RectEqualTo(test2, utils::tripleTileRects_[2])); // 2 is second rect idx
|
||||
ASSERT_TRUE(Utils::RectEqualTo(window, Utils::tripleTileRects_[0]));
|
||||
ASSERT_TRUE(Utils::RectEqualTo(test1, Utils::tripleTileRects_[1]));
|
||||
ASSERT_TRUE(Utils::RectEqualTo(test2, Utils::tripleTileRects_[2])); // 2 is second rect idx
|
||||
WindowManager::GetInstance().SetWindowLayoutMode(WindowLayoutMode::CASCADE);
|
||||
}
|
||||
|
||||
@@ -418,7 +418,7 @@ HWTEST_F(WindowLayoutTest, LayoutTile01, Function | MediumTest | Level3)
|
||||
*/
|
||||
HWTEST_F(WindowLayoutTest, LayoutTileNegative01, Function | MediumTest | Level3)
|
||||
{
|
||||
utils::TestWindowInfo info = {
|
||||
Utils::TestWindowInfo info = {
|
||||
.name = "main",
|
||||
.rect = {-1, -100, -1, -100}, // -1, -100, -1, -100 is typical negative case nums
|
||||
.type = WindowType::WINDOW_TYPE_APP_MAIN_WINDOW,
|
||||
@@ -427,45 +427,45 @@ HWTEST_F(WindowLayoutTest, LayoutTileNegative01, Function | MediumTest | Level3)
|
||||
.parentLimit = false,
|
||||
.parentName = "",
|
||||
};
|
||||
const sptr<Window>& window = utils::CreateTestWindow(info);
|
||||
const sptr<Window>& window = Utils::CreateTestWindow(info);
|
||||
activeWindows_.push_back(window);
|
||||
ASSERT_EQ(WMError::WM_OK, window->Show());
|
||||
// init tile window rects and get max tile window num
|
||||
utils::InitTileWindowRects(window);
|
||||
uint32_t maxTileNum = utils::GetMaxTileWinNum();
|
||||
Utils::InitTileWindowRects(window);
|
||||
uint32_t maxTileNum = Utils::GetMaxTileWinNum();
|
||||
|
||||
usleep(WAIT_SYANC_US);
|
||||
WindowManager::GetInstance().SetWindowLayoutMode(WindowLayoutMode::TILE);
|
||||
usleep(WAIT_SYANC_US);
|
||||
ASSERT_TRUE(utils::RectEqualTo(window, utils::singleTileRect_));
|
||||
ASSERT_TRUE(Utils::RectEqualTo(window, Utils::singleTileRect_));
|
||||
|
||||
info.name = "test1";
|
||||
const sptr<Window>& test1 = utils::CreateTestWindow(info);
|
||||
const sptr<Window>& test1 = Utils::CreateTestWindow(info);
|
||||
activeWindows_.push_back(test1);
|
||||
ASSERT_EQ(WMError::WM_OK, test1->Show());
|
||||
usleep(WAIT_SYANC_US);
|
||||
if (maxTileNum == 1) {
|
||||
ASSERT_TRUE(utils::RectEqualTo(test1, utils::singleTileRect_));
|
||||
ASSERT_TRUE(Utils::RectEqualTo(test1, Utils::singleTileRect_));
|
||||
WindowManager::GetInstance().SetWindowLayoutMode(WindowLayoutMode::CASCADE);
|
||||
return;
|
||||
}
|
||||
ASSERT_TRUE(utils::RectEqualTo(window, utils::doubleTileRects_[0]));
|
||||
ASSERT_TRUE(utils::RectEqualTo(test1, utils::doubleTileRects_[1]));
|
||||
ASSERT_TRUE(Utils::RectEqualTo(window, Utils::doubleTileRects_[0]));
|
||||
ASSERT_TRUE(Utils::RectEqualTo(test1, Utils::doubleTileRects_[1]));
|
||||
|
||||
info.name = "test2";
|
||||
const sptr<Window>& test2 = utils::CreateTestWindow(info);
|
||||
const sptr<Window>& test2 = Utils::CreateTestWindow(info);
|
||||
activeWindows_.push_back(test2);
|
||||
ASSERT_EQ(WMError::WM_OK, test2->Show());
|
||||
usleep(WAIT_SYANC_US);
|
||||
if (maxTileNum == 2) {
|
||||
ASSERT_TRUE(utils::RectEqualTo(test1, utils::doubleTileRects_[0]));
|
||||
ASSERT_TRUE(utils::RectEqualTo(test2, utils::doubleTileRects_[1]));
|
||||
ASSERT_TRUE(Utils::RectEqualTo(test1, Utils::doubleTileRects_[0]));
|
||||
ASSERT_TRUE(Utils::RectEqualTo(test2, Utils::doubleTileRects_[1]));
|
||||
WindowManager::GetInstance().SetWindowLayoutMode(WindowLayoutMode::CASCADE);
|
||||
return;
|
||||
}
|
||||
ASSERT_TRUE(utils::RectEqualTo(window, utils::tripleTileRects_[0]));
|
||||
ASSERT_TRUE(utils::RectEqualTo(test1, utils::tripleTileRects_[1]));
|
||||
ASSERT_TRUE(utils::RectEqualTo(test2, utils::tripleTileRects_[2])); // 2 is second rect idx
|
||||
ASSERT_TRUE(Utils::RectEqualTo(window, Utils::tripleTileRects_[0]));
|
||||
ASSERT_TRUE(Utils::RectEqualTo(test1, Utils::tripleTileRects_[1]));
|
||||
ASSERT_TRUE(Utils::RectEqualTo(test2, Utils::tripleTileRects_[2])); // 2 is second rect idx
|
||||
WindowManager::GetInstance().SetWindowLayoutMode(WindowLayoutMode::CASCADE);
|
||||
}
|
||||
|
||||
@@ -476,7 +476,7 @@ HWTEST_F(WindowLayoutTest, LayoutTileNegative01, Function | MediumTest | Level3)
|
||||
*/
|
||||
HWTEST_F(WindowLayoutTest, LayoutNegative01, Function | MediumTest | Level3)
|
||||
{
|
||||
utils::TestWindowInfo info = {
|
||||
Utils::TestWindowInfo info = {
|
||||
.name = "main",
|
||||
.rect = {0, 0, 0, 0},
|
||||
.type = WindowType::WINDOW_TYPE_APP_MAIN_WINDOW,
|
||||
@@ -485,12 +485,12 @@ HWTEST_F(WindowLayoutTest, LayoutNegative01, Function | MediumTest | Level3)
|
||||
.parentLimit = false,
|
||||
.parentName = "",
|
||||
};
|
||||
const sptr<Window>& window = utils::CreateTestWindow(info);
|
||||
const sptr<Window>& window = Utils::CreateTestWindow(info);
|
||||
activeWindows_.push_back(window);
|
||||
Rect expect = utils::GetDefaultFloatingRect(window);
|
||||
Rect expect = Utils::GetDefaultFloatingRect(window);
|
||||
ASSERT_EQ(WMError::WM_OK, window->Show());
|
||||
usleep(WAIT_SYANC_US);
|
||||
ASSERT_TRUE(utils::RectEqualTo(window, expect));
|
||||
ASSERT_TRUE(Utils::RectEqualTo(window, expect));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -502,7 +502,7 @@ HWTEST_F(WindowLayoutTest, LayoutNegative02, Function | MediumTest | Level3)
|
||||
{
|
||||
const uint32_t negativeW = 0;
|
||||
const uint32_t negativeH = 0;
|
||||
utils::TestWindowInfo info = {
|
||||
Utils::TestWindowInfo info = {
|
||||
.name = "main",
|
||||
.rect = {0, 0, 0, 0},
|
||||
.type = WindowType::WINDOW_TYPE_APP_MAIN_WINDOW,
|
||||
@@ -511,17 +511,17 @@ HWTEST_F(WindowLayoutTest, LayoutNegative02, Function | MediumTest | Level3)
|
||||
.parentLimit = false,
|
||||
.parentName = "",
|
||||
};
|
||||
const sptr<Window>& window = utils::CreateTestWindow(info);
|
||||
const sptr<Window>& window = Utils::CreateTestWindow(info);
|
||||
activeWindows_.push_back(window);
|
||||
Rect expect = utils::GetDefaultFloatingRect(window);
|
||||
Rect expect = Utils::GetDefaultFloatingRect(window);
|
||||
ASSERT_EQ(WMError::WM_OK, window->Show());
|
||||
usleep(WAIT_SYANC_US);
|
||||
ASSERT_TRUE(utils::RectEqualTo(window, expect));
|
||||
ASSERT_TRUE(Utils::RectEqualTo(window, expect));
|
||||
window->Resize(negativeW, negativeH);
|
||||
usleep(WAIT_SYANC_US);
|
||||
Rect expect2 = {expect.posX_, expect.posY_, negativeW, negativeH};
|
||||
expect2 = utils::CalcLimitedRect(expect2, virtualPixelRatio_);
|
||||
ASSERT_TRUE(utils::RectEqualTo(window, expect2));
|
||||
expect2 = Utils::CalcLimitedRect(expect2, virtualPixelRatio_);
|
||||
ASSERT_TRUE(Utils::RectEqualTo(window, expect2));
|
||||
}
|
||||
}
|
||||
} // namespace Rosen
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 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
|
||||
@@ -22,15 +22,15 @@ using namespace testing::ext;
|
||||
|
||||
namespace OHOS {
|
||||
namespace Rosen {
|
||||
using utils = WindowTestUtils;
|
||||
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_;
|
||||
Utils::TestWindowInfo fullAppInfo_1_;
|
||||
Utils::TestWindowInfo fullAppInfo_2_;
|
||||
private:
|
||||
static constexpr uint32_t WAIT_SYANC_US = 100000;
|
||||
};
|
||||
@@ -40,7 +40,7 @@ void WindowModeSupportInfoTest::SetUpTestCase()
|
||||
auto display = DisplayManager::GetInstance().GetDisplayById(0);
|
||||
ASSERT_TRUE((display != nullptr));
|
||||
Rect displayRect = {0, 0, display->GetWidth(), display->GetHeight()};
|
||||
utils::InitByDisplayRect(displayRect);
|
||||
Utils::InitByDisplayRect(displayRect);
|
||||
}
|
||||
|
||||
void WindowModeSupportInfoTest::TearDownTestCase()
|
||||
@@ -49,18 +49,18 @@ void WindowModeSupportInfoTest::TearDownTestCase()
|
||||
|
||||
void WindowModeSupportInfoTest::SetUp()
|
||||
{
|
||||
fullScreenAppInfo_ = {
|
||||
fullAppInfo_1_ = {
|
||||
.name = "FullWindow",
|
||||
.rect = utils::customAppRect_,
|
||||
.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_,
|
||||
fullAppInfo_2_ = {
|
||||
.name = "FullWindow2",
|
||||
.rect = Utils::customAppRect_,
|
||||
.type = WindowType::WINDOW_TYPE_APP_MAIN_WINDOW,
|
||||
.mode = WindowMode::WINDOW_MODE_FULLSCREEN,
|
||||
.needAvoid = false,
|
||||
@@ -76,99 +76,101 @@ void WindowModeSupportInfoTest::TearDown()
|
||||
namespace {
|
||||
/**
|
||||
* @tc.name: WindowModeSupportInfo01
|
||||
* @tc.desc: SetModeSupportInfo | GetModeSupportInfo
|
||||
* @tc.desc: SetRequestModeSupportInfo | GetRequestModeSupportInfo
|
||||
* @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());
|
||||
const sptr<Window>& window = Utils::CreateTestWindow(fullAppInfo_1_);
|
||||
|
||||
window->SetRequestModeSupportInfo(WindowModeSupport::WINDOW_MODE_SUPPORT_FULLSCREEN);
|
||||
ASSERT_EQ(WindowModeSupport::WINDOW_MODE_SUPPORT_FULLSCREEN, window->GetRequestModeSupportInfo());
|
||||
window->Destroy();
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: WindowModeSupportInfo02
|
||||
* @tc.desc: modeSupportInfo test for single window
|
||||
* @tc.desc: modeSupportInfo test for single window, only support fullScreen mode
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(WindowModeSupportInfoTest, WindowModeSupportInfo02, Function | MediumTest | Level3)
|
||||
{
|
||||
const sptr<Window>& window = utils::CreateTestWindow(fullScreenAppInfo_);
|
||||
const sptr<Window>& window = Utils::CreateTestWindow(fullAppInfo_1_);
|
||||
|
||||
window->SetModeSupportInfo(WindowModeSupport::WINDOW_MODE_SUPPORT_FULLSCREEN |
|
||||
WindowModeSupport::WINDOW_MODE_SUPPORT_FLOATING);
|
||||
window->SetRequestModeSupportInfo(WindowModeSupport::WINDOW_MODE_SUPPORT_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_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());
|
||||
|
||||
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.desc: modeSupportInfo test for single window, support both fullScreen and floating mode
|
||||
* @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);
|
||||
const sptr<Window>& window = Utils::CreateTestWindow(fullAppInfo_1_);
|
||||
|
||||
window->SetRequestModeSupportInfo(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());
|
||||
|
||||
window->SetWindowMode(WindowMode::WINDOW_MODE_FLOATING);
|
||||
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->SetWindowMode(WindowMode::WINDOW_MODE_FULLSCREEN);
|
||||
ASSERT_EQ(WindowMode::WINDOW_MODE_FULLSCREEN, window->GetMode());
|
||||
|
||||
window->SetWindowMode(WindowMode::WINDOW_MODE_SPLIT_PRIMARY);
|
||||
ASSERT_EQ(WindowMode::WINDOW_MODE_FULLSCREEN, window->GetMode());
|
||||
|
||||
window->SetWindowMode(WindowMode::WINDOW_MODE_SPLIT_SECONDARY);
|
||||
ASSERT_EQ(WindowMode::WINDOW_MODE_FULLSCREEN, window->GetMode());
|
||||
|
||||
ASSERT_EQ(WMError::WM_OK, window->Hide());
|
||||
window->Destroy();
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: WindowModeSupportInfo04
|
||||
* @tc.desc: modeSupportInfo test for layout cascade
|
||||
* @tc.desc: modeSupportInfo test for single window, window mode is not supported when show, show failed
|
||||
* @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);
|
||||
const sptr<Window>& window = Utils::CreateTestWindow(fullAppInfo_1_);
|
||||
window->SetRequestModeSupportInfo(WindowModeSupport::WINDOW_MODE_SUPPORT_FLOATING |
|
||||
WindowModeSupport::WINDOW_MODE_SUPPORT_SPLIT_PRIMARY |
|
||||
WindowModeSupport::WINDOW_MODE_SUPPORT_SPLIT_SECONDARY);
|
||||
ASSERT_NE(WMError::WM_OK, window->Show());
|
||||
ASSERT_EQ(WMError::WM_OK, window->Hide());
|
||||
window->Destroy();
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: WindowModeSupportInfo05
|
||||
* @tc.desc: modeSupportInfo test for layout cascade
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(WindowModeSupportInfoTest, WindowModeSupportInfo05, Function | MediumTest | Level3)
|
||||
{
|
||||
const sptr<Window>& window1 = Utils::CreateTestWindow(fullAppInfo_1_);
|
||||
window1->SetRequestModeSupportInfo(WindowModeSupport::WINDOW_MODE_SUPPORT_FULLSCREEN);
|
||||
const sptr<Window>& window2 = Utils::CreateTestWindow(fullAppInfo_2_);
|
||||
window2->SetRequestModeSupportInfo(WindowModeSupport::WINDOW_MODE_SUPPORT_ALL);
|
||||
ASSERT_EQ(WMError::WM_OK, window1->Show());
|
||||
ASSERT_EQ(WMError::WM_OK, window2->Show());
|
||||
WindowManager::GetInstance().SetWindowLayoutMode(WindowLayoutMode::CASCADE);
|
||||
@@ -182,14 +184,14 @@ HWTEST_F(WindowModeSupportInfoTest, WindowModeSupportInfo04, Function | MediumTe
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: WindowModeSupportInfo05
|
||||
* @tc.name: WindowModeSupportInfo06
|
||||
* @tc.desc: modeSupportInfo test for layout tile
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(WindowModeSupportInfoTest, WindowModeSupportInfo05, Function | MediumTest | Level3)
|
||||
HWTEST_F(WindowModeSupportInfoTest, WindowModeSupportInfo06, Function | MediumTest | Level3)
|
||||
{
|
||||
const sptr<Window>& window = utils::CreateTestWindow(fullScreenAppInfo_);
|
||||
window->SetModeSupportInfo(WindowModeSupport::WINDOW_MODE_SUPPORT_FULLSCREEN);
|
||||
const sptr<Window>& window = Utils::CreateTestWindow(fullAppInfo_1_);
|
||||
window->SetRequestModeSupportInfo(WindowModeSupport::WINDOW_MODE_SUPPORT_FULLSCREEN);
|
||||
ASSERT_EQ(WMError::WM_OK, window->Show());
|
||||
WindowManager::GetInstance().SetWindowLayoutMode(WindowLayoutMode::TILE);
|
||||
usleep(WAIT_SYANC_US);
|
||||
@@ -200,38 +202,6 @@ HWTEST_F(WindowModeSupportInfoTest, WindowModeSupportInfo05, Function | MediumTe
|
||||
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
|
||||
@@ -30,7 +30,7 @@ namespace {
|
||||
constexpr float DRAG_HOTZONE_RATIO = 0.6;
|
||||
constexpr int WAIT_SYANC_MS = 100000;
|
||||
}
|
||||
using utils = WindowTestUtils;
|
||||
using Utils = WindowTestUtils;
|
||||
class WindowMoveDragTest : public testing::Test {
|
||||
public:
|
||||
static void SetUpTestCase();
|
||||
@@ -81,7 +81,7 @@ void WindowMoveDragTest::SetUp()
|
||||
WLOGFI("GetDefaultDisplay: id %{public}llu, w %{public}d, h %{public}d, fps %{public}u\n",
|
||||
(unsigned long long)display->GetId(), display->GetWidth(), display->GetHeight(), display->GetRefreshRate());
|
||||
Rect displayRect = {0, 0, display->GetWidth(), display->GetHeight()};
|
||||
utils::InitByDisplayRect(displayRect);
|
||||
Utils::InitByDisplayRect(displayRect);
|
||||
|
||||
virtualPixelRatio_ = WindowTestUtils::GetVirtualPixelRatio(0);
|
||||
hotZone_ = static_cast<uint32_t>(HOTZONE * virtualPixelRatio_);
|
||||
@@ -127,19 +127,19 @@ void WindowMoveDragTest::DoMoveOrDrag(bool isMove, bool isDrag)
|
||||
std::shared_ptr<MMI::PointerEvent> pointerEvent =
|
||||
CreatePointerEvent(startPointX_, startPointY_, pointerId_, MMI::PointerEvent::POINTER_ACTION_DOWN);
|
||||
window_->ConsumePointerEvent(pointerEvent);
|
||||
ASSERT_TRUE(utils::RectEqualToRect(window_->GetRect(), startPointRect_));
|
||||
ASSERT_TRUE(Utils::RectEqualToRect(window_->GetRect(), startPointRect_));
|
||||
|
||||
pointerEvent = CreatePointerEvent(pointX_, pointY_, pointerId_, MMI::PointerEvent::POINTER_ACTION_MOVE);
|
||||
window_->ConsumePointerEvent(pointerEvent);
|
||||
CalExpectRects();
|
||||
usleep(WAIT_SYANC_MS);
|
||||
ASSERT_TRUE(utils::RectEqualToRect(window_->GetRect(), expectRect_));
|
||||
ASSERT_TRUE(Utils::RectEqualToRect(window_->GetRect(), expectRect_));
|
||||
ASSERT_EQ(isMove, window_->startMoveFlag_);
|
||||
ASSERT_EQ(isDrag, window_->startDragFlag_);
|
||||
|
||||
pointerEvent = CreatePointerEvent(pointX_, pointY_, pointerId_, MMI::PointerEvent::POINTER_ACTION_UP);
|
||||
window_->ConsumePointerEvent(pointerEvent);
|
||||
ASSERT_TRUE(utils::RectEqualToRect(window_->GetRect(), expectRect_));
|
||||
ASSERT_TRUE(Utils::RectEqualToRect(window_->GetRect(), expectRect_));
|
||||
}
|
||||
|
||||
void WindowMoveDragTest::CalExpectRects()
|
||||
@@ -180,7 +180,7 @@ void WindowMoveDragTest::CalExpectRects()
|
||||
hasStartMove_ = false;
|
||||
}
|
||||
}
|
||||
bool isVertical = (utils::displayRect_.width_ < utils::displayRect_.height_) ? true : false;
|
||||
bool isVertical = (Utils::displayRect_.width_ < Utils::displayRect_.height_) ? true : false;
|
||||
expectRect_ = WindowHelper::GetFixedWindowRectByLimitSize(oriRect, startPointRect_, isVertical, virtualPixelRatio_);
|
||||
}
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ using namespace testing::ext;
|
||||
|
||||
namespace OHOS {
|
||||
namespace Rosen {
|
||||
using utils = WindowTestUtils;
|
||||
using Utils = WindowTestUtils;
|
||||
class WindowMultiAbilityTest : public testing::Test {
|
||||
public:
|
||||
static void SetUpTestCase();
|
||||
@@ -54,7 +54,7 @@ static void ShowHideWindowSceneCallable(int i)
|
||||
{
|
||||
unsigned int sleepTimeMs = i * SLEEP_MS;
|
||||
usleep(sleepTimeMs);
|
||||
sptr<WindowScene> scene = utils::CreateWindowScene();
|
||||
sptr<WindowScene> scene = Utils::CreateWindowScene();
|
||||
const int loop = 10;
|
||||
int j = 0;
|
||||
for (; j < loop; j++) {
|
||||
@@ -74,7 +74,7 @@ static void CreateDestroyWindowSceneCallable(int i)
|
||||
int j = 0;
|
||||
for (; j < loop; j++) {
|
||||
usleep(sleepTimeMs);
|
||||
sptr<WindowScene> scene = utils::CreateWindowScene();
|
||||
sptr<WindowScene> scene = Utils::CreateWindowScene();
|
||||
usleep(sleepTimeMs);
|
||||
ASSERT_EQ(WMError::WM_OK, scene->GoForeground());
|
||||
usleep(sleepTimeMs);
|
||||
@@ -94,11 +94,11 @@ static void CreateDestroyWindowSceneCallable(int i)
|
||||
*/
|
||||
HWTEST_F(WindowMultiAbilityTest, MultiAbilityWindow01, Function | MediumTest | Level2)
|
||||
{
|
||||
sptr<WindowScene> scene1 = utils::CreateWindowScene();
|
||||
sptr<WindowScene> scene2 = utils::CreateWindowScene();
|
||||
sptr<WindowScene> scene3 = utils::CreateWindowScene();
|
||||
sptr<WindowScene> scene4 = utils::CreateWindowScene();
|
||||
sptr<WindowScene> scene5 = utils::CreateWindowScene();
|
||||
sptr<WindowScene> scene1 = Utils::CreateWindowScene();
|
||||
sptr<WindowScene> scene2 = Utils::CreateWindowScene();
|
||||
sptr<WindowScene> scene3 = Utils::CreateWindowScene();
|
||||
sptr<WindowScene> scene4 = Utils::CreateWindowScene();
|
||||
sptr<WindowScene> scene5 = Utils::CreateWindowScene();
|
||||
|
||||
ASSERT_EQ(WMError::WM_OK, scene1->GoForeground());
|
||||
ASSERT_EQ(WMError::WM_OK, scene2->GoForeground());
|
||||
@@ -162,27 +162,27 @@ HWTEST_F(WindowMultiAbilityTest, MultiAbilityWindow03, Function | MediumTest | L
|
||||
*/
|
||||
HWTEST_F(WindowMultiAbilityTest, MultiAbilityWindow04, Function | MediumTest | Level3)
|
||||
{
|
||||
sptr<WindowScene> scene1 = utils::CreateWindowScene();
|
||||
sptr<WindowScene> scene1 = Utils::CreateWindowScene();
|
||||
ASSERT_EQ(WMError::WM_OK, scene1->GoForeground());
|
||||
ASSERT_EQ(WMError::WM_OK, scene1->GoBackground());
|
||||
ASSERT_EQ(WMError::WM_OK, scene1->GoDestroy());
|
||||
|
||||
sptr<WindowScene> scene2 = utils::CreateWindowScene();
|
||||
sptr<WindowScene> scene2 = Utils::CreateWindowScene();
|
||||
ASSERT_EQ(WMError::WM_OK, scene2->GoForeground());
|
||||
ASSERT_EQ(WMError::WM_OK, scene2->GoBackground());
|
||||
ASSERT_EQ(WMError::WM_OK, scene2->GoDestroy());
|
||||
|
||||
sptr<WindowScene> scene3 = utils::CreateWindowScene();
|
||||
sptr<WindowScene> scene3 = Utils::CreateWindowScene();
|
||||
ASSERT_EQ(WMError::WM_OK, scene3->GoForeground());
|
||||
ASSERT_EQ(WMError::WM_OK, scene3->GoBackground());
|
||||
ASSERT_EQ(WMError::WM_OK, scene3->GoDestroy());
|
||||
|
||||
sptr<WindowScene> scene4 = utils::CreateWindowScene();
|
||||
sptr<WindowScene> scene4 = Utils::CreateWindowScene();
|
||||
ASSERT_EQ(WMError::WM_OK, scene4->GoForeground());
|
||||
ASSERT_EQ(WMError::WM_OK, scene4->GoBackground());
|
||||
ASSERT_EQ(WMError::WM_OK, scene4->GoDestroy());
|
||||
|
||||
sptr<WindowScene> scene5 = utils::CreateWindowScene();
|
||||
sptr<WindowScene> scene5 = Utils::CreateWindowScene();
|
||||
ASSERT_EQ(WMError::WM_OK, scene5->GoForeground());
|
||||
ASSERT_EQ(WMError::WM_OK, scene5->GoBackground());
|
||||
ASSERT_EQ(WMError::WM_OK, scene5->GoDestroy());
|
||||
@@ -195,19 +195,19 @@ HWTEST_F(WindowMultiAbilityTest, MultiAbilityWindow04, Function | MediumTest | L
|
||||
*/
|
||||
HWTEST_F(WindowMultiAbilityTest, MultiAbilityWindow05, Function | MediumTest | Level3)
|
||||
{
|
||||
sptr<WindowScene> scene1 = utils::CreateWindowScene();
|
||||
sptr<WindowScene> scene1 = Utils::CreateWindowScene();
|
||||
ASSERT_EQ(WMError::WM_OK, scene1->GoForeground());
|
||||
sptr<WindowScene> scene2 = utils::CreateWindowScene();
|
||||
sptr<WindowScene> scene3 = utils::CreateWindowScene();
|
||||
sptr<WindowScene> scene2 = Utils::CreateWindowScene();
|
||||
sptr<WindowScene> scene3 = Utils::CreateWindowScene();
|
||||
ASSERT_EQ(WMError::WM_OK, scene3->GoForeground());
|
||||
ASSERT_EQ(WMError::WM_OK, scene1->GoBackground());
|
||||
ASSERT_EQ(WMError::WM_OK, scene1->GoDestroy());
|
||||
sptr<WindowScene> scene4 = utils::CreateWindowScene();
|
||||
sptr<WindowScene> scene4 = Utils::CreateWindowScene();
|
||||
ASSERT_EQ(WMError::WM_OK, scene3->GoBackground());
|
||||
ASSERT_EQ(WMError::WM_OK, scene2->GoForeground());
|
||||
ASSERT_EQ(WMError::WM_OK, scene4->GoForeground());
|
||||
ASSERT_EQ(WMError::WM_OK, scene2->GoBackground());
|
||||
sptr<WindowScene> scene5 = utils::CreateWindowScene();
|
||||
sptr<WindowScene> scene5 = Utils::CreateWindowScene();
|
||||
ASSERT_EQ(WMError::WM_OK, scene3->GoDestroy());
|
||||
ASSERT_EQ(WMError::WM_OK, scene5->GoForeground());
|
||||
ASSERT_EQ(WMError::WM_OK, scene5->GoBackground());
|
||||
|
||||
@@ -26,7 +26,7 @@ namespace {
|
||||
constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_WINDOW, "WindowOccupiedAreaChangeTest"};
|
||||
}
|
||||
|
||||
using utils = WindowTestUtils;
|
||||
using Utils = WindowTestUtils;
|
||||
const int WAIT_ASYNC_US = 100000; // 100000us
|
||||
|
||||
class TestOccupiedAreaChangeListener : public IOccupiedAreaChangeListener {
|
||||
@@ -43,8 +43,8 @@ public:
|
||||
virtual void SetUp() override;
|
||||
virtual void TearDown() override;
|
||||
static sptr<TestOccupiedAreaChangeListener> testOccupiedAreaChangeListener_;
|
||||
utils::TestWindowInfo fullScreenAppInfo_;
|
||||
utils::TestWindowInfo imeAppInfo_;
|
||||
Utils::TestWindowInfo fullScreenAppInfo_;
|
||||
Utils::TestWindowInfo imeAppInfo_;
|
||||
};
|
||||
|
||||
sptr<TestOccupiedAreaChangeListener> WindowOccupiedAreaChangeTest::testOccupiedAreaChangeListener_ =
|
||||
@@ -65,7 +65,7 @@ void WindowOccupiedAreaChangeTest::SetUpTestCase()
|
||||
WLOGFI("GetDefaultDisplay: id %{public}" PRIu64", w %{public}d, h %{public}d, fps %{public}u",
|
||||
display->GetId(), display->GetWidth(), display->GetHeight(), display->GetRefreshRate());
|
||||
Rect displayRect = {0, 0, display->GetWidth(), display->GetHeight()};
|
||||
utils::InitByDisplayRect(displayRect);
|
||||
Utils::InitByDisplayRect(displayRect);
|
||||
}
|
||||
|
||||
void WindowOccupiedAreaChangeTest::TearDownTestCase()
|
||||
@@ -76,7 +76,7 @@ void WindowOccupiedAreaChangeTest::SetUp()
|
||||
{
|
||||
fullScreenAppInfo_ = {
|
||||
.name = "FullWindow",
|
||||
.rect = utils::customAppRect_,
|
||||
.rect = Utils::customAppRect_,
|
||||
.type = WindowType::WINDOW_TYPE_APP_MAIN_WINDOW,
|
||||
.mode = WindowMode::WINDOW_MODE_FULLSCREEN,
|
||||
.needAvoid = false,
|
||||
@@ -85,7 +85,7 @@ void WindowOccupiedAreaChangeTest::SetUp()
|
||||
};
|
||||
imeAppInfo_ = {
|
||||
.name = "ImeWindow",
|
||||
.rect = utils::customAppRect_,
|
||||
.rect = Utils::customAppRect_,
|
||||
.type = WindowType::WINDOW_TYPE_INPUT_METHOD_FLOAT,
|
||||
.mode = WindowMode::WINDOW_MODE_FLOATING,
|
||||
};
|
||||
@@ -104,13 +104,13 @@ namespace {
|
||||
HWTEST_F(WindowOccupiedAreaChangeTest, KeyboardHeightChangeTest01, Function | MediumTest | Level3)
|
||||
{
|
||||
fullScreenAppInfo_.name = "KeyboardHeightChangeTest01";
|
||||
const sptr<Window>& window1 = utils::CreateTestWindow(fullScreenAppInfo_);
|
||||
const sptr<Window>& window1 = Utils::CreateTestWindow(fullScreenAppInfo_);
|
||||
ASSERT_NE(nullptr, window1);
|
||||
window1->RegisterOccupiedAreaChangeListener(testOccupiedAreaChangeListener_);
|
||||
|
||||
imeAppInfo_.name = "imeWindow1";
|
||||
imeAppInfo_.rect = { 10, 200, 300, 400 };
|
||||
const sptr<Window>& window2 = utils::CreateTestWindow(imeAppInfo_);
|
||||
const sptr<Window>& window2 = Utils::CreateTestWindow(imeAppInfo_);
|
||||
ASSERT_NE(nullptr, window2);
|
||||
|
||||
ASSERT_EQ(WMError::WM_OK, window1->Show());
|
||||
@@ -133,13 +133,13 @@ HWTEST_F(WindowOccupiedAreaChangeTest, KeyboardHeightChangeTest01, Function | Me
|
||||
HWTEST_F(WindowOccupiedAreaChangeTest, KeyboardHeightChangeTest02, Function | MediumTest | Level3)
|
||||
{
|
||||
fullScreenAppInfo_.name = "KeyboardHeightChangeTest02";
|
||||
const sptr<Window>& window1 = utils::CreateTestWindow(fullScreenAppInfo_);
|
||||
const sptr<Window>& window1 = Utils::CreateTestWindow(fullScreenAppInfo_);
|
||||
ASSERT_NE(nullptr, window1);
|
||||
window1->RegisterOccupiedAreaChangeListener(testOccupiedAreaChangeListener_);
|
||||
|
||||
imeAppInfo_.name = "imeWindow2";
|
||||
imeAppInfo_.rect = { 10, 200, 300, 400 };
|
||||
const sptr<Window>& window2 = utils::CreateTestWindow(imeAppInfo_);
|
||||
const sptr<Window>& window2 = Utils::CreateTestWindow(imeAppInfo_);
|
||||
ASSERT_NE(nullptr, window2);
|
||||
|
||||
ASSERT_EQ(WMError::WM_OK, window1->Show());
|
||||
@@ -162,13 +162,13 @@ HWTEST_F(WindowOccupiedAreaChangeTest, KeyboardHeightChangeTest02, Function | Me
|
||||
HWTEST_F(WindowOccupiedAreaChangeTest, KeyboardHeightChangeTest03, Function | MediumTest | Level3)
|
||||
{
|
||||
fullScreenAppInfo_.name = "KeyboardHeightChangeTest03";
|
||||
const sptr<Window>& window1 = utils::CreateTestWindow(fullScreenAppInfo_);
|
||||
const sptr<Window>& window1 = Utils::CreateTestWindow(fullScreenAppInfo_);
|
||||
ASSERT_NE(nullptr, window1);
|
||||
window1->RegisterOccupiedAreaChangeListener(testOccupiedAreaChangeListener_);
|
||||
|
||||
imeAppInfo_.name = "imeWindow3";
|
||||
imeAppInfo_.rect = { 10, 200, 300, 400 };
|
||||
const sptr<Window>& window2 = utils::CreateTestWindow(imeAppInfo_);
|
||||
const sptr<Window>& window2 = Utils::CreateTestWindow(imeAppInfo_);
|
||||
ASSERT_NE(nullptr, window2);
|
||||
|
||||
ASSERT_EQ(WMError::WM_OK, window1->Show());
|
||||
|
||||
@@ -27,7 +27,7 @@ using namespace testing::ext;
|
||||
|
||||
namespace OHOS {
|
||||
namespace Rosen {
|
||||
using utils = WindowTestUtils;
|
||||
using Utils = WindowTestUtils;
|
||||
class DisplayListener : public DisplayManager::IDisplayListener {
|
||||
public:
|
||||
virtual void OnCreate(DisplayId) override;
|
||||
@@ -51,7 +51,7 @@ public:
|
||||
virtual void SetUp() override;
|
||||
virtual void TearDown() override;
|
||||
std::vector<sptr<Window>> activeWindows_;
|
||||
utils::TestWindowInfo fullInfo_;
|
||||
Utils::TestWindowInfo fullInfo_;
|
||||
sptr<DisplayListener> displayListener_;
|
||||
sptr<ScreenListener> screenListener_;
|
||||
private:
|
||||
@@ -97,7 +97,7 @@ void WindowRotationTest::SetUp()
|
||||
{
|
||||
fullInfo_ = {
|
||||
.name = "",
|
||||
.rect = utils::customAppRect_,
|
||||
.rect = Utils::customAppRect_,
|
||||
.type = WindowType::WINDOW_TYPE_APP_MAIN_WINDOW,
|
||||
.mode = WindowMode::WINDOW_MODE_FULLSCREEN,
|
||||
.needAvoid = true,
|
||||
@@ -132,7 +132,7 @@ HWTEST_F(WindowRotationTest, WindowRotationTest1, Function | MediumTest | Level3
|
||||
{
|
||||
fullInfo_.name = "fullscreen.1";
|
||||
fullInfo_.orientation_ = Orientation::UNSPECIFIED;
|
||||
const sptr<Window>& fullWindow = utils::CreateTestWindow(fullInfo_);
|
||||
const sptr<Window>& fullWindow = Utils::CreateTestWindow(fullInfo_);
|
||||
activeWindows_.push_back(fullWindow);
|
||||
ASSERT_EQ(WMError::WM_OK, fullWindow->Show());
|
||||
ASSERT_EQ(WindowMode::WINDOW_MODE_FULLSCREEN, fullWindow->GetMode());
|
||||
@@ -163,7 +163,7 @@ HWTEST_F(WindowRotationTest, WindowRotationTest2, Function | MediumTest | Level3
|
||||
{
|
||||
fullInfo_.name = "fullscreen.2";
|
||||
fullInfo_.orientation_ = Orientation::REVERSE_HORIZONTAL;
|
||||
const sptr<Window>& fullWindow = utils::CreateTestWindow(fullInfo_);
|
||||
const sptr<Window>& fullWindow = Utils::CreateTestWindow(fullInfo_);
|
||||
activeWindows_.push_back(fullWindow);
|
||||
ASSERT_EQ(WMError::WM_OK, fullWindow->Show());
|
||||
ASSERT_EQ(WindowMode::WINDOW_MODE_FULLSCREEN, fullWindow->GetMode());
|
||||
@@ -201,7 +201,7 @@ HWTEST_F(WindowRotationTest, WindowRotationTest3, Function | MediumTest | Level3
|
||||
fullInfo_.name = "fullscreen.4";
|
||||
fullInfo_.orientation_ = Orientation::REVERSE_HORIZONTAL;
|
||||
fullInfo_.mode = WindowMode::WINDOW_MODE_FLOATING;
|
||||
const sptr<Window>& fullWindow = utils::CreateTestWindow(fullInfo_);
|
||||
const sptr<Window>& fullWindow = Utils::CreateTestWindow(fullInfo_);
|
||||
fullInfo_.mode = WindowMode::WINDOW_MODE_FULLSCREEN;
|
||||
activeWindows_.push_back(fullWindow);
|
||||
ASSERT_EQ(WMError::WM_OK, fullWindow->Show());
|
||||
@@ -233,7 +233,7 @@ HWTEST_F(WindowRotationTest, WindowRotationTest4, Function | MediumTest | Level3
|
||||
defaultScreen->SetOrientation(Orientation::REVERSE_HORIZONTAL);
|
||||
fullInfo_.name = "fullscreen.5";
|
||||
fullInfo_.orientation_ = Orientation::HORIZONTAL;
|
||||
const sptr<Window>& fullWindow = utils::CreateTestWindow(fullInfo_);
|
||||
const sptr<Window>& fullWindow = Utils::CreateTestWindow(fullInfo_);
|
||||
activeWindows_.push_back(fullWindow);
|
||||
ASSERT_EQ(WMError::WM_OK, fullWindow->Show());
|
||||
ASSERT_EQ(WindowMode::WINDOW_MODE_FULLSCREEN, fullWindow->GetMode());
|
||||
@@ -276,7 +276,7 @@ HWTEST_F(WindowRotationTest, WindowRotationTest5, Function | MediumTest | Level3
|
||||
defaultScreen->SetOrientation(Orientation::REVERSE_HORIZONTAL);
|
||||
fullInfo_.name = "fullscreen.5";
|
||||
fullInfo_.orientation_ = Orientation::HORIZONTAL;
|
||||
const sptr<Window>& fullWindow = utils::CreateTestWindow(fullInfo_);
|
||||
const sptr<Window>& fullWindow = Utils::CreateTestWindow(fullInfo_);
|
||||
activeWindows_.push_back(fullWindow);
|
||||
ASSERT_EQ(WMError::WM_OK, fullWindow->Show());
|
||||
ASSERT_EQ(WindowMode::WINDOW_MODE_FULLSCREEN, fullWindow->GetMode());
|
||||
|
||||
@@ -23,7 +23,7 @@ using namespace testing::ext;
|
||||
|
||||
namespace OHOS {
|
||||
namespace Rosen {
|
||||
using utils = WindowTestUtils;
|
||||
using Utils = WindowTestUtils;
|
||||
|
||||
class WindowSplitImmersiveTest : public testing::Test {
|
||||
public:
|
||||
@@ -35,8 +35,8 @@ public:
|
||||
void HideAndUnregister(const sptr<Window>& fullWindow, const sptr<Window>& priWindow, const sptr<Window>& top);
|
||||
|
||||
std::vector<sptr<Window>> activeWindows_;
|
||||
utils::TestWindowInfo fullInfo_;
|
||||
utils::TestWindowInfo splitInfo_;
|
||||
Utils::TestWindowInfo fullInfo_;
|
||||
Utils::TestWindowInfo splitInfo_;
|
||||
|
||||
private:
|
||||
static constexpr uint32_t SPLIT_TEST_SLEEP_S = 1; // split test sleep time
|
||||
@@ -54,7 +54,7 @@ void WindowSplitImmersiveTest::SetUp()
|
||||
{
|
||||
fullInfo_ = {
|
||||
.name = "fullscreen.1",
|
||||
.rect = utils::customAppRect_,
|
||||
.rect = Utils::customAppRect_,
|
||||
.type = WindowType::WINDOW_TYPE_APP_MAIN_WINDOW,
|
||||
.mode = WindowMode::WINDOW_MODE_FULLSCREEN,
|
||||
.needAvoid = true,
|
||||
@@ -64,7 +64,7 @@ void WindowSplitImmersiveTest::SetUp()
|
||||
|
||||
splitInfo_ = {
|
||||
.name = "primary.1",
|
||||
.rect = utils::customAppRect_,
|
||||
.rect = Utils::customAppRect_,
|
||||
.type = WindowType::WINDOW_TYPE_APP_MAIN_WINDOW,
|
||||
.mode = WindowMode::WINDOW_MODE_FULLSCREEN,
|
||||
.needAvoid = true,
|
||||
@@ -92,14 +92,14 @@ namespace {
|
||||
HWTEST_F(WindowSplitImmersiveTest, SplitImmersive01, Function | MediumTest | Level3)
|
||||
{
|
||||
// create fullscreen win and show
|
||||
const sptr<Window>& fullWindow = utils::CreateTestWindow(fullInfo_);
|
||||
const sptr<Window>& fullWindow = Utils::CreateTestWindow(fullInfo_);
|
||||
activeWindows_.push_back(fullWindow);
|
||||
ASSERT_EQ(WMError::WM_OK, fullWindow->Show());
|
||||
sleep(SPLIT_TEST_SLEEP_S);
|
||||
|
||||
// enter split mode
|
||||
splitInfo_.mode = WindowMode::WINDOW_MODE_SPLIT_PRIMARY;
|
||||
const sptr<Window>& priWindow = utils::CreateTestWindow(splitInfo_);
|
||||
const sptr<Window>& priWindow = Utils::CreateTestWindow(splitInfo_);
|
||||
activeWindows_.push_back(priWindow);
|
||||
ASSERT_EQ(WMError::WM_OK, priWindow->Show());
|
||||
sleep(SPLIT_TEST_SLEEP_S);
|
||||
|
||||
@@ -21,7 +21,7 @@ using namespace testing::ext;
|
||||
|
||||
namespace OHOS {
|
||||
namespace Rosen {
|
||||
using utils = WindowTestUtils;
|
||||
using Utils = WindowTestUtils;
|
||||
class WindowSplitTest : public testing::Test {
|
||||
public:
|
||||
static void SetUpTestCase();
|
||||
@@ -29,8 +29,8 @@ public:
|
||||
virtual void SetUp() override;
|
||||
virtual void TearDown() override;
|
||||
std::vector<sptr<Window>> activeWindows_;
|
||||
utils::TestWindowInfo fullInfo_;
|
||||
utils::TestWindowInfo splitInfo_;
|
||||
Utils::TestWindowInfo fullInfo_;
|
||||
Utils::TestWindowInfo splitInfo_;
|
||||
|
||||
private:
|
||||
static constexpr uint32_t SPLIT_TEST_SLEEP_S = 1; // split test sleep time
|
||||
@@ -48,7 +48,7 @@ void WindowSplitTest::SetUp()
|
||||
{
|
||||
fullInfo_ = {
|
||||
.name = "",
|
||||
.rect = utils::customAppRect_,
|
||||
.rect = Utils::customAppRect_,
|
||||
.type = WindowType::WINDOW_TYPE_APP_MAIN_WINDOW,
|
||||
.mode = WindowMode::WINDOW_MODE_FULLSCREEN,
|
||||
.needAvoid = true,
|
||||
@@ -58,7 +58,7 @@ void WindowSplitTest::SetUp()
|
||||
|
||||
splitInfo_ = {
|
||||
.name = "",
|
||||
.rect = utils::customAppRect_,
|
||||
.rect = Utils::customAppRect_,
|
||||
.type = WindowType::WINDOW_TYPE_APP_MAIN_WINDOW,
|
||||
.mode = WindowMode::WINDOW_MODE_FULLSCREEN,
|
||||
.needAvoid = true,
|
||||
@@ -89,12 +89,12 @@ HWTEST_F(WindowSplitTest, SplitWindow01, Function | MediumTest | Level3)
|
||||
splitInfo_.name = "primary.1";
|
||||
splitInfo_.mode = WindowMode::WINDOW_MODE_SPLIT_PRIMARY;
|
||||
|
||||
const sptr<Window>& fullWindow = utils::CreateTestWindow(fullInfo_);
|
||||
const sptr<Window>& fullWindow = Utils::CreateTestWindow(fullInfo_);
|
||||
activeWindows_.push_back(fullWindow);
|
||||
ASSERT_EQ(WMError::WM_OK, fullWindow->Show());
|
||||
sleep(SPLIT_TEST_SLEEP_S);
|
||||
|
||||
const sptr<Window>& priWindow = utils::CreateTestWindow(splitInfo_);
|
||||
const sptr<Window>& priWindow = Utils::CreateTestWindow(splitInfo_);
|
||||
activeWindows_.push_back(priWindow);
|
||||
ASSERT_EQ(WMError::WM_OK, priWindow->Show());
|
||||
sleep(SPLIT_TEST_SLEEP_S);
|
||||
@@ -120,11 +120,11 @@ HWTEST_F(WindowSplitTest, SplitWindow02, Function | MediumTest | Level3)
|
||||
splitInfo_.name = "secondary.2";
|
||||
splitInfo_.mode = WindowMode::WINDOW_MODE_SPLIT_SECONDARY;
|
||||
|
||||
const sptr<Window>& fullWindow = utils::CreateTestWindow(fullInfo_);
|
||||
const sptr<Window>& fullWindow = Utils::CreateTestWindow(fullInfo_);
|
||||
activeWindows_.push_back(fullWindow);
|
||||
ASSERT_EQ(WMError::WM_OK, fullWindow->Show());
|
||||
sleep(SPLIT_TEST_SLEEP_S);
|
||||
const sptr<Window>& secWindow = utils::CreateTestWindow(splitInfo_);
|
||||
const sptr<Window>& secWindow = Utils::CreateTestWindow(splitInfo_);
|
||||
activeWindows_.push_back(secWindow);
|
||||
ASSERT_EQ(WMError::WM_OK, secWindow->Show());
|
||||
sleep(SPLIT_TEST_SLEEP_S);
|
||||
@@ -150,21 +150,21 @@ HWTEST_F(WindowSplitTest, SplitScreen03, Function | MediumTest | Level3)
|
||||
splitInfo_.name = "primary.3";
|
||||
splitInfo_.mode = WindowMode::WINDOW_MODE_SPLIT_PRIMARY;
|
||||
|
||||
ASSERT_TRUE(utils::InitSplitRects());
|
||||
ASSERT_TRUE(Utils::InitSplitRects());
|
||||
|
||||
const sptr<Window>& fullWindow = utils::CreateTestWindow(fullInfo_);
|
||||
const sptr<Window>& fullWindow = Utils::CreateTestWindow(fullInfo_);
|
||||
activeWindows_.push_back(fullWindow);
|
||||
ASSERT_EQ(WMError::WM_OK, fullWindow->Show());
|
||||
sleep(SPLIT_TEST_SLEEP_S);
|
||||
const sptr<Window>& priWindow = utils::CreateTestWindow(splitInfo_);
|
||||
const sptr<Window>& priWindow = Utils::CreateTestWindow(splitInfo_);
|
||||
activeWindows_.push_back(priWindow);
|
||||
ASSERT_EQ(WMError::WM_OK, priWindow->Show());
|
||||
sleep(SPLIT_TEST_SLEEP_S);
|
||||
|
||||
utils::UpdateSplitRects(fullWindow);
|
||||
Utils::UpdateSplitRects(fullWindow);
|
||||
|
||||
ASSERT_TRUE(utils::RectEqualTo(fullWindow, utils::splitRects_.secondaryRect));
|
||||
ASSERT_TRUE(utils::RectEqualTo(priWindow, utils::splitRects_.primaryRect));
|
||||
ASSERT_TRUE(Utils::RectEqualTo(fullWindow, Utils::splitRects_.secondaryRect));
|
||||
ASSERT_TRUE(Utils::RectEqualTo(priWindow, Utils::splitRects_.primaryRect));
|
||||
|
||||
ASSERT_EQ(WMError::WM_OK, fullWindow->Hide());
|
||||
sleep(SPLIT_TEST_SLEEP_S);
|
||||
@@ -183,21 +183,21 @@ HWTEST_F(WindowSplitTest, SplitScreen04, Function | MediumTest | Level3)
|
||||
splitInfo_.name = "secondary.4";
|
||||
splitInfo_.mode = WindowMode::WINDOW_MODE_SPLIT_SECONDARY;
|
||||
|
||||
ASSERT_TRUE(utils::InitSplitRects());
|
||||
ASSERT_TRUE(Utils::InitSplitRects());
|
||||
|
||||
const sptr<Window>& fullWindow = utils::CreateTestWindow(fullInfo_);
|
||||
const sptr<Window>& fullWindow = Utils::CreateTestWindow(fullInfo_);
|
||||
activeWindows_.push_back(fullWindow);
|
||||
ASSERT_EQ(WMError::WM_OK, fullWindow->Show());
|
||||
sleep(SPLIT_TEST_SLEEP_S);
|
||||
const sptr<Window>& secWindow = utils::CreateTestWindow(splitInfo_);
|
||||
const sptr<Window>& secWindow = Utils::CreateTestWindow(splitInfo_);
|
||||
activeWindows_.push_back(secWindow);
|
||||
ASSERT_EQ(WMError::WM_OK, secWindow->Show());
|
||||
sleep(SPLIT_TEST_SLEEP_S);
|
||||
|
||||
utils::UpdateSplitRects(fullWindow);
|
||||
Utils::UpdateSplitRects(fullWindow);
|
||||
|
||||
ASSERT_TRUE(utils::RectEqualTo(fullWindow, utils::splitRects_.primaryRect));
|
||||
ASSERT_TRUE(utils::RectEqualTo(secWindow, utils::splitRects_.secondaryRect));
|
||||
ASSERT_TRUE(Utils::RectEqualTo(fullWindow, Utils::splitRects_.primaryRect));
|
||||
ASSERT_TRUE(Utils::RectEqualTo(secWindow, Utils::splitRects_.secondaryRect));
|
||||
|
||||
ASSERT_EQ(WMError::WM_OK, fullWindow->Hide());
|
||||
sleep(SPLIT_TEST_SLEEP_S);
|
||||
@@ -216,12 +216,12 @@ HWTEST_F(WindowSplitTest, SplitScreen05, Function | MediumTest | Level3)
|
||||
splitInfo_.name = "primary.5";
|
||||
splitInfo_.mode = WindowMode::WINDOW_MODE_SPLIT_PRIMARY;
|
||||
|
||||
const sptr<Window>& fullWindow = utils::CreateTestWindow(fullInfo_);
|
||||
const sptr<Window>& fullWindow = Utils::CreateTestWindow(fullInfo_);
|
||||
activeWindows_.push_back(fullWindow);
|
||||
ASSERT_EQ(WMError::WM_OK, fullWindow->Show());
|
||||
sleep(SPLIT_TEST_SLEEP_S);
|
||||
|
||||
const sptr<Window>& priWindow = utils::CreateTestWindow(splitInfo_);
|
||||
const sptr<Window>& priWindow = Utils::CreateTestWindow(splitInfo_);
|
||||
activeWindows_.push_back(priWindow);
|
||||
ASSERT_EQ(WMError::WM_OK, priWindow->Show());
|
||||
sleep(SPLIT_TEST_SLEEP_S);
|
||||
@@ -229,13 +229,13 @@ HWTEST_F(WindowSplitTest, SplitScreen05, Function | MediumTest | Level3)
|
||||
ASSERT_EQ(WindowMode::WINDOW_MODE_SPLIT_PRIMARY, priWindow->GetMode());
|
||||
ASSERT_EQ(WindowMode::WINDOW_MODE_SPLIT_SECONDARY, fullWindow->GetMode());
|
||||
|
||||
utils::TestWindowInfo dividerInfo;
|
||||
Utils::TestWindowInfo dividerInfo;
|
||||
dividerInfo.name = "divider0";
|
||||
dividerInfo.type = WindowType::WINDOW_TYPE_DOCK_SLICE;
|
||||
dividerInfo.mode = WindowMode::WINDOW_MODE_FLOATING;
|
||||
dividerInfo.focusable_ = false;
|
||||
|
||||
const sptr<Window>& divider = utils::CreateTestWindow(dividerInfo);
|
||||
const sptr<Window>& divider = Utils::CreateTestWindow(dividerInfo);
|
||||
activeWindows_.push_back(divider);
|
||||
ASSERT_EQ(WMError::WM_OK, divider->Show());
|
||||
sleep(SPLIT_TEST_SLEEP_S);
|
||||
@@ -271,26 +271,23 @@ HWTEST_F(WindowSplitTest, SplitScreen06, Function | MediumTest | Level3)
|
||||
splitInfo_.name = "primary.6";
|
||||
splitInfo_.mode = WindowMode::WINDOW_MODE_SPLIT_PRIMARY;
|
||||
|
||||
const sptr<Window>& fullWindow = utils::CreateTestWindow(fullInfo_);
|
||||
const sptr<Window>& fullWindow = Utils::CreateTestWindow(fullInfo_);
|
||||
activeWindows_.push_back(fullWindow);
|
||||
ASSERT_EQ(WMError::WM_OK, fullWindow->Show());
|
||||
sleep(SPLIT_TEST_SLEEP_S);
|
||||
|
||||
const sptr<Window>& priWindow = utils::CreateTestWindow(splitInfo_);
|
||||
const sptr<Window>& priWindow = Utils::CreateTestWindow(splitInfo_);
|
||||
activeWindows_.push_back(priWindow);
|
||||
ASSERT_EQ(WMError::WM_OK, priWindow->Show());
|
||||
sleep(SPLIT_TEST_SLEEP_S);
|
||||
|
||||
ASSERT_EQ(WindowMode::WINDOW_MODE_SPLIT_PRIMARY, priWindow->GetMode());
|
||||
ASSERT_EQ(WindowMode::WINDOW_MODE_SPLIT_SECONDARY, fullWindow->GetMode());
|
||||
|
||||
utils::TestWindowInfo dividerInfo;
|
||||
Utils::TestWindowInfo dividerInfo;
|
||||
dividerInfo.name = "divider0";
|
||||
dividerInfo.type = WindowType::WINDOW_TYPE_DOCK_SLICE;
|
||||
dividerInfo.mode = WindowMode::WINDOW_MODE_FLOATING;
|
||||
dividerInfo.focusable_ = false;
|
||||
|
||||
const sptr<Window>& divider = utils::CreateTestWindow(dividerInfo);
|
||||
const sptr<Window>& divider = Utils::CreateTestWindow(dividerInfo);
|
||||
activeWindows_.push_back(divider);
|
||||
ASSERT_EQ(WMError::WM_OK, divider->Show());
|
||||
sleep(SPLIT_TEST_SLEEP_S);
|
||||
@@ -300,18 +297,22 @@ HWTEST_F(WindowSplitTest, SplitScreen06, Function | MediumTest | Level3)
|
||||
int32_t posX, posY;
|
||||
posX = posY = 0;
|
||||
std::shared_ptr<MMI::PointerEvent> pointerEvent =
|
||||
utils::CreatePointerEvent(posX, posY, pointerId, MMI::PointerEvent::POINTER_ACTION_DOWN);
|
||||
Utils::CreatePointerEvent(posX, posY, pointerId, MMI::PointerEvent::POINTER_ACTION_DOWN);
|
||||
divider->ConsumePointerEvent(pointerEvent);
|
||||
sleep(SPLIT_TEST_SLEEP_S);
|
||||
|
||||
posY += 10;
|
||||
pointerEvent = utils::CreatePointerEvent(posX, posY, pointerId, MMI::PointerEvent::POINTER_ACTION_MOVE);
|
||||
if (rect.width_ < rect.height_) {
|
||||
posX += 10;
|
||||
} else {
|
||||
posY += 10;
|
||||
}
|
||||
pointerEvent = Utils::CreatePointerEvent(posX, posY, pointerId, MMI::PointerEvent::POINTER_ACTION_MOVE);
|
||||
divider->ConsumePointerEvent(pointerEvent);
|
||||
sleep(SPLIT_TEST_SLEEP_S);
|
||||
Rect moveRect = divider->GetRect();
|
||||
ASSERT_TRUE(rect.posX_ != moveRect.posX_ || rect.posY_ != moveRect.posY_);
|
||||
|
||||
pointerEvent = utils::CreatePointerEvent(posX, posY, pointerId, MMI::PointerEvent::POINTER_ACTION_UP);
|
||||
pointerEvent = Utils::CreatePointerEvent(posX, posY, pointerId, MMI::PointerEvent::POINTER_ACTION_UP);
|
||||
divider->ConsumePointerEvent(pointerEvent);
|
||||
sleep(SPLIT_TEST_SLEEP_S);
|
||||
Rect newRect = divider->GetRect();
|
||||
|
||||
@@ -26,16 +26,16 @@ using namespace testing::ext;
|
||||
|
||||
namespace OHOS {
|
||||
namespace Rosen {
|
||||
using utils = WindowTestUtils;
|
||||
using Utils = WindowTestUtils;
|
||||
const int WAIT_CALLBACK_US = 10000; // 10000 us
|
||||
|
||||
class WindowTouchOutsideTestListener : public ITouchOutsideListener {
|
||||
public:
|
||||
void OnTouchOutside() override
|
||||
void OnTouchOutside() const override
|
||||
{
|
||||
isTouchOutside_ = true;
|
||||
}
|
||||
bool isTouchOutside_ { false };
|
||||
mutable bool isTouchOutside_ { false };
|
||||
};
|
||||
|
||||
class WindowTouchOutsideTest : public testing::Test {
|
||||
@@ -47,9 +47,9 @@ public:
|
||||
|
||||
static sptr<WindowTouchOutsideTestListener> windowlistener1_;
|
||||
static sptr<WindowTouchOutsideTestListener> windowlistener2_;
|
||||
utils::TestWindowInfo firstWindowInfo_;
|
||||
utils::TestWindowInfo secondWindowInfo_;
|
||||
utils::TestWindowInfo thirdWindowInfo_;
|
||||
Utils::TestWindowInfo firstWindowInfo_;
|
||||
Utils::TestWindowInfo secondWindowInfo_;
|
||||
Utils::TestWindowInfo thirdWindowInfo_;
|
||||
};
|
||||
|
||||
sptr<WindowTouchOutsideTestListener> WindowTouchOutsideTest::windowlistener1_ =
|
||||
@@ -106,13 +106,13 @@ void WindowTouchOutsideTest::TearDownTestCase()
|
||||
|
||||
namespace {
|
||||
/**
|
||||
* @tc.name: onTouchIutside
|
||||
* @tc.name: onTouchInside
|
||||
* @tc.desc: can't not receive a inside touch event
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(WindowTouchOutsideTest, onTouchIutside, Function | MediumTest | Level3)
|
||||
HWTEST_F(WindowTouchOutsideTest, onTouchInside, Function | MediumTest | Level3)
|
||||
{
|
||||
const sptr<Window> &firstWindow = utils::CreateTestWindow(firstWindowInfo_);
|
||||
const sptr<Window> &firstWindow = Utils::CreateTestWindow(firstWindowInfo_);
|
||||
firstWindow->RegisterTouchOutsideListener(windowlistener1_);
|
||||
firstWindow->Show();
|
||||
SingletonContainer::Get<WindowAdapter>().ProcessPointDown(firstWindow->GetWindowId());
|
||||
@@ -128,9 +128,9 @@ HWTEST_F(WindowTouchOutsideTest, onTouchIutside, Function | MediumTest | Level3)
|
||||
*/
|
||||
HWTEST_F(WindowTouchOutsideTest, onTouchOutside, Function | MediumTest | Level3)
|
||||
{
|
||||
const sptr<Window> &firstWindow = utils::CreateTestWindow(firstWindowInfo_);
|
||||
const sptr<Window> &firstWindow = Utils::CreateTestWindow(firstWindowInfo_);
|
||||
firstWindow->RegisterTouchOutsideListener(windowlistener1_);
|
||||
const sptr<Window> &secondWindow = utils::CreateTestWindow(secondWindowInfo_);
|
||||
const sptr<Window> &secondWindow = Utils::CreateTestWindow(secondWindowInfo_);
|
||||
firstWindow->Show();
|
||||
secondWindow->Show();
|
||||
SingletonContainer::Get<WindowAdapter>().ProcessPointDown(secondWindow->GetWindowId());
|
||||
@@ -147,9 +147,9 @@ HWTEST_F(WindowTouchOutsideTest, onTouchOutside, Function | MediumTest | Level3)
|
||||
*/
|
||||
HWTEST_F(WindowTouchOutsideTest, onTouchOutsideNotShow, Function | MediumTest | Level3)
|
||||
{
|
||||
const sptr<Window> &firstWindow = utils::CreateTestWindow(firstWindowInfo_);
|
||||
const sptr<Window> &firstWindow = Utils::CreateTestWindow(firstWindowInfo_);
|
||||
firstWindow->RegisterTouchOutsideListener(windowlistener1_);
|
||||
const sptr<Window> &secondWindow = utils::CreateTestWindow(secondWindowInfo_);
|
||||
const sptr<Window> &secondWindow = Utils::CreateTestWindow(secondWindowInfo_);
|
||||
secondWindow->Show();
|
||||
SingletonContainer::Get<WindowAdapter>().ProcessPointDown(secondWindow->GetWindowId());
|
||||
usleep(WAIT_CALLBACK_US);
|
||||
@@ -165,13 +165,13 @@ HWTEST_F(WindowTouchOutsideTest, onTouchOutsideNotShow, Function | MediumTest |
|
||||
*/
|
||||
HWTEST_F(WindowTouchOutsideTest, onTouchOutsideForAllWindow, Function | MediumTest | Level3)
|
||||
{
|
||||
const sptr<Window> &firstWindow = utils::CreateTestWindow(firstWindowInfo_);
|
||||
const sptr<Window> &firstWindow = Utils::CreateTestWindow(firstWindowInfo_);
|
||||
firstWindow->RegisterTouchOutsideListener(windowlistener1_);
|
||||
const sptr<Window> &secondWindow = utils::CreateTestWindow(secondWindowInfo_);
|
||||
const sptr<Window> &secondWindow = Utils::CreateTestWindow(secondWindowInfo_);
|
||||
firstWindow->RegisterTouchOutsideListener(windowlistener2_);
|
||||
firstWindow->Show();
|
||||
secondWindow->Show();
|
||||
const sptr<Window> &thirdWindow = utils::CreateTestWindow(thirdWindowInfo_);
|
||||
const sptr<Window> &thirdWindow = Utils::CreateTestWindow(thirdWindowInfo_);
|
||||
thirdWindow->Show();
|
||||
SingletonContainer::Get<WindowAdapter>().ProcessPointDown(thirdWindow->GetWindowId());
|
||||
usleep(WAIT_CALLBACK_US);
|
||||
|
||||
@@ -35,7 +35,7 @@ namespace {
|
||||
constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_WINDOW, "WindowVisibilityInfoTest"};
|
||||
}
|
||||
|
||||
using utils = WindowTestUtils;
|
||||
using Utils = WindowTestUtils;
|
||||
constexpr int WAIT_ASYNC_MS_TIME_OUT = 2000; // 2000ms
|
||||
|
||||
#define CHECK_DISPLAY_POWER_STATE_RETURN() \
|
||||
@@ -110,9 +110,9 @@ public:
|
||||
}
|
||||
|
||||
static void WaitForCallback();
|
||||
utils::TestWindowInfo fullScreenAppInfo_;
|
||||
utils::TestWindowInfo floatAppInfo_;
|
||||
utils::TestWindowInfo subAppInfo_;
|
||||
Utils::TestWindowInfo fullScreenAppInfo_;
|
||||
Utils::TestWindowInfo floatAppInfo_;
|
||||
Utils::TestWindowInfo subAppInfo_;
|
||||
};
|
||||
|
||||
void WindowVisibilityInfoTest::SetUpTestCase()
|
||||
@@ -123,7 +123,7 @@ void WindowVisibilityInfoTest::SetUpTestCase()
|
||||
display->GetId(), display->GetWidth(), display->GetHeight(), display->GetRefreshRate());
|
||||
Rect displayRect = {0, 0,
|
||||
static_cast<uint32_t>(display->GetWidth()), static_cast<uint32_t>(display->GetHeight())};
|
||||
utils::InitByDisplayRect(displayRect);
|
||||
Utils::InitByDisplayRect(displayRect);
|
||||
WindowManager::GetInstance().RegisterVisibilityChangedListener(visibilityChangedListener_);
|
||||
DisplayManager::GetInstance().RegisterDisplayPowerEventListener(displayPowerEventListener_);
|
||||
}
|
||||
@@ -138,7 +138,7 @@ void WindowVisibilityInfoTest::SetUp()
|
||||
{
|
||||
fullScreenAppInfo_ = {
|
||||
.name = "FullWindow",
|
||||
.rect = utils::customAppRect_,
|
||||
.rect = Utils::customAppRect_,
|
||||
.type = WindowType::WINDOW_TYPE_APP_MAIN_WINDOW,
|
||||
.mode = WindowMode::WINDOW_MODE_FULLSCREEN,
|
||||
.needAvoid = false,
|
||||
@@ -147,7 +147,7 @@ void WindowVisibilityInfoTest::SetUp()
|
||||
};
|
||||
floatAppInfo_ = {
|
||||
.name = "ParentWindow",
|
||||
.rect = utils::customAppRect_,
|
||||
.rect = Utils::customAppRect_,
|
||||
.type = WindowType::WINDOW_TYPE_APP_MAIN_WINDOW,
|
||||
.mode = WindowMode::WINDOW_MODE_FLOATING,
|
||||
.needAvoid = false,
|
||||
@@ -156,7 +156,7 @@ void WindowVisibilityInfoTest::SetUp()
|
||||
};
|
||||
subAppInfo_ = {
|
||||
.name = "SubWindow",
|
||||
.rect = utils::customAppRect_,
|
||||
.rect = Utils::customAppRect_,
|
||||
.type = WindowType::WINDOW_TYPE_APP_SUB_WINDOW,
|
||||
.mode = WindowMode::WINDOW_MODE_FLOATING,
|
||||
.needAvoid = false,
|
||||
@@ -189,12 +189,12 @@ HWTEST_F(WindowVisibilityInfoTest, WindowVisibilityInfoTest01, Function | Medium
|
||||
{
|
||||
floatAppInfo_.name = "window1";
|
||||
floatAppInfo_.rect = {250, 150, 300, 500};
|
||||
sptr<Window> window1 = utils::CreateTestWindow(floatAppInfo_);
|
||||
sptr<Window> window1 = Utils::CreateTestWindow(floatAppInfo_);
|
||||
|
||||
subAppInfo_.name = "subWindow1";
|
||||
subAppInfo_.rect = {400, 200, 100, 100};
|
||||
subAppInfo_.parentName = window1->GetWindowName();
|
||||
sptr<Window> subWindow1 = utils::CreateTestWindow(subAppInfo_);
|
||||
sptr<Window> subWindow1 = Utils::CreateTestWindow(subAppInfo_);
|
||||
|
||||
ASSERT_EQ(WMError::WM_OK, window1->Show());
|
||||
WaitForCallback();
|
||||
@@ -251,10 +251,10 @@ end:
|
||||
HWTEST_F(WindowVisibilityInfoTest, WindowVisibilityInfoTest02, Function | MediumTest | Level1)
|
||||
{
|
||||
fullScreenAppInfo_.name = "window1";
|
||||
sptr<Window> window1 = utils::CreateTestWindow(fullScreenAppInfo_);
|
||||
sptr<Window> window1 = Utils::CreateTestWindow(fullScreenAppInfo_);
|
||||
|
||||
fullScreenAppInfo_.name = "window2";
|
||||
sptr<Window> window2 = utils::CreateTestWindow(fullScreenAppInfo_);
|
||||
sptr<Window> window2 = Utils::CreateTestWindow(fullScreenAppInfo_);
|
||||
|
||||
ASSERT_EQ(WMError::WM_OK, window1->Show());
|
||||
WaitForCallback();
|
||||
@@ -282,20 +282,20 @@ HWTEST_F(WindowVisibilityInfoTest, WindowVisibilityInfoTest03, Function | Medium
|
||||
{
|
||||
floatAppInfo_.name = "window1";
|
||||
floatAppInfo_.rect = {0, 0, 300, 600};
|
||||
sptr<Window> window1 = utils::CreateTestWindow(floatAppInfo_);
|
||||
sptr<Window> window1 = Utils::CreateTestWindow(floatAppInfo_);
|
||||
|
||||
subAppInfo_.name = "subWindow1";
|
||||
subAppInfo_.rect = {400, 200, 100, 100};
|
||||
subAppInfo_.parentName = window1->GetWindowName();
|
||||
sptr<Window> subWindow1 = utils::CreateTestWindow(subAppInfo_);
|
||||
sptr<Window> subWindow1 = Utils::CreateTestWindow(subAppInfo_);
|
||||
|
||||
floatAppInfo_.name = "window2";
|
||||
sptr<Window> window2 = utils::CreateTestWindow(floatAppInfo_);
|
||||
sptr<Window> window2 = Utils::CreateTestWindow(floatAppInfo_);
|
||||
|
||||
subAppInfo_.name = "subWindow2";
|
||||
subAppInfo_.type = WindowType::WINDOW_TYPE_MEDIA;
|
||||
subAppInfo_.parentName = window2->GetWindowName();
|
||||
sptr<Window> subWindow2 = utils::CreateTestWindow(subAppInfo_);
|
||||
sptr<Window> subWindow2 = Utils::CreateTestWindow(subAppInfo_);
|
||||
|
||||
ASSERT_EQ(WMError::WM_OK, window2->Show());
|
||||
WaitForCallback();
|
||||
@@ -337,15 +337,15 @@ HWTEST_F(WindowVisibilityInfoTest, WindowVisibilityInfoTest04, Function | Medium
|
||||
{
|
||||
floatAppInfo_.name = "window1";
|
||||
floatAppInfo_.rect = {0, 0, 300, 600};
|
||||
sptr<Window> window1 = utils::CreateTestWindow(floatAppInfo_);
|
||||
sptr<Window> window1 = Utils::CreateTestWindow(floatAppInfo_);
|
||||
|
||||
floatAppInfo_.name = "window2";
|
||||
floatAppInfo_.rect = {0, 0, 300, 300};
|
||||
sptr<Window> window2 = utils::CreateTestWindow(floatAppInfo_);
|
||||
sptr<Window> window2 = Utils::CreateTestWindow(floatAppInfo_);
|
||||
|
||||
floatAppInfo_.name = "window3";
|
||||
floatAppInfo_.rect = {0, 300, 300, 300};
|
||||
sptr<Window> window3 = utils::CreateTestWindow(floatAppInfo_);
|
||||
sptr<Window> window3 = Utils::CreateTestWindow(floatAppInfo_);
|
||||
|
||||
ASSERT_EQ(WMError::WM_OK, window1->Show());
|
||||
WaitForCallback();
|
||||
|
||||
@@ -30,7 +30,6 @@ public:
|
||||
MOCK_METHOD0(ClearWindowAdapter, void());
|
||||
MOCK_METHOD1(DestroyWindow, WMError(uint32_t windowId));
|
||||
MOCK_METHOD2(SetWindowBackgroundBlur, WMError(uint32_t windowId, WindowBlurLevel level));
|
||||
MOCK_METHOD2(SetAlpha, WMError(uint32_t windowId, float alpha));
|
||||
MOCK_METHOD2(UpdateProperty, WMError(sptr<WindowProperty>& windowProperty, PropertyChangeAction action));
|
||||
};
|
||||
}
|
||||
|
||||
@@ -57,26 +57,10 @@ HWTEST_F(WindowEffectTest, WindowEffect01, Function | SmallTest | Level2)
|
||||
|
||||
/**
|
||||
* @tc.name: WindowEffect02
|
||||
* @tc.desc: windowOption: set window alpha/ get window alpha
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(WindowEffectTest, WindowEffect02, Function | SmallTest | Level2)
|
||||
{
|
||||
sptr<WindowOption> option = new WindowOption();
|
||||
option->SetAlpha(0.0f);
|
||||
ASSERT_EQ(0.0f, option->GetAlpha());
|
||||
option->SetAlpha(0.5f);
|
||||
ASSERT_EQ(0.5f, option->GetAlpha());
|
||||
option->SetAlpha(1.0f);
|
||||
ASSERT_EQ(1.0f, option->GetAlpha());
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: WindowEffect03
|
||||
* @tc.desc: WindowImp: Create window with no default option, get and check Property
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(WindowEffectTest, WindowEffect03, Function | SmallTest | Level2)
|
||||
HWTEST_F(WindowEffectTest, WindowEffect02, Function | SmallTest | Level2)
|
||||
{
|
||||
std::unique_ptr<Mocker> m = std::make_unique<Mocker>();
|
||||
sptr<WindowOption> option = new WindowOption();
|
||||
@@ -92,20 +76,18 @@ HWTEST_F(WindowEffectTest, WindowEffect03, Function | SmallTest | Level2)
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: WindowEffect04
|
||||
* @tc.name: WindowEffect03
|
||||
* @tc.desc: Create window with no default option, get and check Property
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(WindowEffectTest, WindowEffect04, Function | SmallTest | Level2)
|
||||
HWTEST_F(WindowEffectTest, WindowEffect03, Function | SmallTest | Level2)
|
||||
{
|
||||
std::unique_ptr<Mocker> m = std::make_unique<Mocker>();
|
||||
sptr<WindowOption> option = new WindowOption();
|
||||
option->SetAlpha(0.1f);
|
||||
|
||||
sptr<WindowImpl> window = new WindowImpl(option);
|
||||
EXPECT_CALL(m->Mock(), CreateWindow(_, _, _, _, _)).Times(1).WillOnce(Return(WMError::WM_OK));
|
||||
ASSERT_EQ(WMError::WM_OK, window->Create(""));
|
||||
|
||||
window->SetAlpha(0.1f);
|
||||
ASSERT_EQ(0.1f, window->GetAlpha());
|
||||
|
||||
EXPECT_CALL(m->Mock(), DestroyWindow(_)).Times(1).WillOnce(Return(WMError::WM_OK));
|
||||
@@ -113,11 +95,11 @@ HWTEST_F(WindowEffectTest, WindowEffect04, Function | SmallTest | Level2)
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: WindowEffect05
|
||||
* @tc.name: WindowEffect04
|
||||
* @tc.desc: set window effect parameters throw window, and check parameters.
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(WindowEffectTest, WindowEffect05, Function | SmallTest | Level2)
|
||||
HWTEST_F(WindowEffectTest, WindowEffect04, Function | SmallTest | Level2)
|
||||
{
|
||||
std::unique_ptr<Mocker> m = std::make_unique<Mocker>();
|
||||
sptr<WindowOption> option = new WindowOption();
|
||||
@@ -135,32 +117,11 @@ HWTEST_F(WindowEffectTest, WindowEffect05, Function | SmallTest | Level2)
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: WindowEffect06
|
||||
* @tc.desc: set window effect parameters throw window, and check parameters.
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(WindowEffectTest, WindowEffect06, Function | SmallTest | Level2)
|
||||
{
|
||||
std::unique_ptr<Mocker> m = std::make_unique<Mocker>();
|
||||
sptr<WindowOption> option = new WindowOption();
|
||||
sptr<WindowImpl> window = new WindowImpl(option);
|
||||
|
||||
EXPECT_CALL(m->Mock(), CreateWindow(_, _, _, _, _)).Times(1).WillOnce(Return(WMError::WM_OK));
|
||||
ASSERT_EQ(WMError::WM_OK, window->Create(""));
|
||||
EXPECT_CALL(m->Mock(), SetAlpha(_, _)).Times(1).WillOnce(Return(WMError::WM_OK));
|
||||
ASSERT_EQ(WMError::WM_OK, window->SetAlpha(0.1f));
|
||||
ASSERT_EQ(0.1f, window->GetAlpha());
|
||||
|
||||
EXPECT_CALL(m->Mock(), DestroyWindow(_)).Times(1).WillOnce(Return(WMError::WM_OK));
|
||||
window->Destroy();
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: WindowEffect07
|
||||
* @tc.name: WindowEffect05
|
||||
* @tc.desc: WindowImp: Create window with default option, get and check Property
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(WindowEffectTest, WindowEffect07, Function | SmallTest | Level2)
|
||||
HWTEST_F(WindowEffectTest, WindowEffect05, Function | SmallTest | Level2)
|
||||
{
|
||||
std::unique_ptr<Mocker> m = std::make_unique<Mocker>();
|
||||
sptr<WindowOption> option = new WindowOption();
|
||||
|
||||
+1
-1
@@ -44,6 +44,7 @@ ohos_shared_library("libwms") {
|
||||
"src/display_group_info.cpp",
|
||||
"src/drag_controller.cpp",
|
||||
"src/freeze_controller.cpp",
|
||||
"src/inner_window.cpp",
|
||||
"src/input_window_monitor.cpp",
|
||||
"src/minimize_app.cpp",
|
||||
"src/remote_animation.cpp",
|
||||
@@ -67,7 +68,6 @@ ohos_shared_library("libwms") {
|
||||
"src/window_task_looper.cpp",
|
||||
"src/window_zorder_policy.cpp",
|
||||
"src/zidl/window_manager_stub.cpp",
|
||||
"src/inner_window.cpp"
|
||||
]
|
||||
|
||||
configs = [ ":libwms_config" ]
|
||||
|
||||
@@ -16,83 +16,63 @@
|
||||
#ifndef OHOS_ROSEN_INNER_WINDOW_H
|
||||
#define OHOS_ROSEN_INNER_WINDOW_H
|
||||
|
||||
#include <unordered_map>
|
||||
#include <memory>
|
||||
#include "window.h"
|
||||
#include "window_manager_hilog.h"
|
||||
#include "wm_common_inner.h"
|
||||
#include "wm_single_instance.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Rosen {
|
||||
enum class InnerWindowState : uint32_t {
|
||||
INNER_WINDOW_STATE_NLL,
|
||||
INNER_WINDOW_STATE_CRATED,
|
||||
INNER_WINDOW_STATE_DESTROYED
|
||||
};
|
||||
class IInnerWindow : virtual public RefBase {
|
||||
public:
|
||||
virtual void Create() = 0;
|
||||
virtual void Create(std::string name, DisplayId displyId, Rect rect, WindowMode mode) = 0;
|
||||
virtual void Destroy() = 0;
|
||||
InnerWindowState GetState() {
|
||||
return state_;
|
||||
};
|
||||
protected:
|
||||
InnerWindowState state_ = InnerWindowState::INNER_WINDOW_STATE_NLL;
|
||||
};
|
||||
|
||||
class PlaceHolderWindow : public IInnerWindow, public IWindowLifeCycle, public ITouchOutsideListener,
|
||||
public IInputEventListener {
|
||||
class PlaceholderWindowListener : public IWindowLifeCycle, public ITouchOutsideListener, public IInputEventListener {
|
||||
public:
|
||||
PlaceHolderWindow(std::string name, DisplayId displyId, const Rect& rect, WindowMode mode) : name_(name),
|
||||
displayId_(displyId), rect_(rect), mode_(mode) {};
|
||||
~PlaceHolderWindow();
|
||||
void Create();
|
||||
void Destroy();
|
||||
|
||||
private:
|
||||
// touch outside listener
|
||||
virtual void OnTouchOutside();
|
||||
// input event listener
|
||||
virtual void OnKeyEvent(std::shared_ptr<MMI::KeyEvent>& keyEvent);
|
||||
virtual void OnPointerInputEvent(std::shared_ptr<MMI::PointerEvent>& pointerEvent);
|
||||
// lifecycle listener
|
||||
virtual void AfterUnfocused();
|
||||
// lifecycle do nothing
|
||||
virtual void AfterForeground() {};
|
||||
virtual void AfterBackground() {};
|
||||
virtual void AfterFocused() {};
|
||||
virtual void AfterInactive() {};
|
||||
virtual void AfterUnfocused();
|
||||
void UnRegitsterWindowListener();
|
||||
void RegitsterWindowListener();
|
||||
};
|
||||
|
||||
class PlaceHolderWindow : public IInnerWindow {
|
||||
WM_DECLARE_SINGLE_INSTANCE(PlaceHolderWindow);
|
||||
public:
|
||||
virtual void Create(std::string name, DisplayId displyId, Rect rect, WindowMode mode);
|
||||
virtual void Destroy();
|
||||
|
||||
private:
|
||||
void RegitsterWindowListener();
|
||||
void UnRegitsterWindowListener();
|
||||
|
||||
private:
|
||||
std::string name_;
|
||||
DisplayId displayId_;
|
||||
Rect rect_;
|
||||
WindowMode mode_;
|
||||
sptr<OHOS::Rosen::Window> window_;
|
||||
std::string contentImgPath_ = "/etc/window/resources/bg_place_holder.png";
|
||||
sptr<PlaceholderWindowListener> listener_;
|
||||
};
|
||||
|
||||
class DividerWindow : public IInnerWindow {
|
||||
WM_DECLARE_SINGLE_INSTANCE_BASE(DividerWindow);
|
||||
public:
|
||||
DividerWindow(std::string name, DisplayId displyId, const Rect& rect) : name_(name),
|
||||
displayId_(displyId), rect_(rect) {};
|
||||
virtual void Create(std::string name, DisplayId displayId, const Rect rect, WindowMode mode);
|
||||
virtual void Destroy();
|
||||
|
||||
protected:
|
||||
DividerWindow() = default;
|
||||
~DividerWindow();
|
||||
void Create();
|
||||
void Destroy();
|
||||
|
||||
private:
|
||||
std::string name_;
|
||||
DisplayId displayId_;
|
||||
Rect rect_;
|
||||
int32_t dialogId_ = -1;
|
||||
|
||||
};
|
||||
|
||||
class InnerWindowFactory : public RefBase {
|
||||
WM_DECLARE_SINGLE_INSTANCE(InnerWindowFactory);
|
||||
public:
|
||||
WMError CreateInnerWindow(std::string name, DisplayId displyId, Rect rect, WindowType type, WindowMode mode);
|
||||
WMError DestroyInnerWindow(DisplayId displyId, WindowType type);
|
||||
private:
|
||||
std::unordered_map<WindowType, std::unique_ptr<IInnerWindow>> innerWindowMap_;
|
||||
std::string params_;
|
||||
int32_t dialogId_ = IVALID_DIALOG_WINDOW_ID;
|
||||
};
|
||||
} // namespace Rosen
|
||||
} // namespace OHOS
|
||||
|
||||
@@ -29,6 +29,7 @@ enum class MinimizeReason : uint32_t {
|
||||
MINIMIZE_BUTTON,
|
||||
MINIMIZE_ALL,
|
||||
LAYOUT_TILE,
|
||||
LAYOUT_CASCADE,
|
||||
MAX_APP_COUNT,
|
||||
SPLIT_REPLACE,
|
||||
SPLIT_QUIT,
|
||||
|
||||
@@ -30,7 +30,8 @@ public:
|
||||
StartingWindow() = delete;
|
||||
~StartingWindow() = default;
|
||||
|
||||
static sptr<WindowNode> CreateWindowNode(sptr<WindowTransitionInfo> info, uint32_t winId);
|
||||
static sptr<WindowNode> CreateWindowNode(sptr<WindowTransitionInfo> info,
|
||||
uint32_t winId, WindowLayoutMode layoutMode);
|
||||
static void HandleClientWindowCreate(sptr<WindowNode>& node, sptr<IWindow>& window,
|
||||
uint32_t& windowId, const std::shared_ptr<RSSurfaceNode>& surfaceNode, sptr<WindowProperty>& property,
|
||||
int32_t pid, int32_t uid);
|
||||
@@ -39,7 +40,6 @@ public:
|
||||
static void UpdateRSTree(sptr<WindowNode>& node);
|
||||
static void ReleaseStartWinSurfaceNode(sptr<WindowNode>& node);
|
||||
private:
|
||||
static SurfaceDraw surfaceDraw_;
|
||||
static WMError CreateLeashAndStartingSurfaceNode(sptr<WindowNode>& node);
|
||||
static std::recursive_mutex mutex_;
|
||||
};
|
||||
|
||||
@@ -62,7 +62,7 @@ public:
|
||||
void CancelStartingWindow(sptr<IRemoteObject> abilityToken);
|
||||
void MinimizeWindowsByLauncher(std::vector<uint32_t>& windowIds, bool isAnimated,
|
||||
sptr<RSIWindowAnimationFinishedCallback>& finishCallback);
|
||||
Orientation GetFullScreenWindowRequestedOrientation(DisplayId displayId);
|
||||
Orientation GetWindowPreferredOrientation(DisplayId displayId);
|
||||
private:
|
||||
uint32_t GenWindowId();
|
||||
void FlushWindowInfo(uint32_t windowId);
|
||||
@@ -83,6 +83,7 @@ private:
|
||||
WMError UpdateTouchHotAreas(const sptr<WindowNode>& node, const std::vector<Rect>& rects);
|
||||
void NotifyTouchOutside(const sptr<WindowNode>& node);
|
||||
uint32_t GetEmbedNodeId(const std::vector<sptr<WindowNode>>& windowNodes, const sptr<WindowNode>& node);
|
||||
void NotifyWindowPropertyChanged(const sptr<WindowNode>& node);
|
||||
sptr<WindowRoot> windowRoot_;
|
||||
sptr<InputWindowMonitor> inputWindowMonitor_;
|
||||
std::atomic<uint32_t> windowId_ { INVALID_WINDOW_ID };
|
||||
|
||||
@@ -20,57 +20,35 @@
|
||||
#include "event_handler.h"
|
||||
#include "event_runner.h"
|
||||
|
||||
#include <ui/rs_surface_node.h>
|
||||
#include "draw/canvas.h"
|
||||
#include "nocopyable.h"
|
||||
#include "pixel_map.h"
|
||||
|
||||
#include "inner_window.h"
|
||||
#include "wm_common.h"
|
||||
#include "wm_single_instance.h"
|
||||
#include "window.h"
|
||||
#include "inner_window.h"
|
||||
|
||||
enum class InnerWMRunningState {
|
||||
STATE_NOT_START,
|
||||
STATE_RUNNING,
|
||||
};
|
||||
namespace OHOS {
|
||||
namespace Rosen {
|
||||
class TouchOutsideListener : public ITouchOutsideListener {
|
||||
virtual void OnTouchOutside();
|
||||
};
|
||||
class InputListener : public IInputEventListener {
|
||||
virtual void OnKeyEvent(std::shared_ptr<MMI::KeyEvent>& keyEvent);
|
||||
virtual void OnPointerInputEvent(std::shared_ptr<MMI::PointerEvent>& pointerEvent);
|
||||
};
|
||||
class LifeCycle : public IWindowLifeCycle {
|
||||
virtual void AfterForeground() {};
|
||||
virtual void AfterBackground() {};
|
||||
virtual void AfterFocused() {};
|
||||
virtual void AfterInactive() {};
|
||||
virtual void AfterUnfocused();
|
||||
};
|
||||
class WindowInnerManager : public RefBase {
|
||||
friend class TouchOutsideListener;
|
||||
friend class InputListener;
|
||||
friend class LifeCycle;
|
||||
WM_DECLARE_SINGLE_INSTANCE_BASE(WindowInnerManager);
|
||||
using EventRunner = OHOS::AppExecFwk::EventRunner;
|
||||
using EventHandler = OHOS::AppExecFwk::EventHandler;
|
||||
public:
|
||||
void Start();
|
||||
void Start(bool enableRecentholder);
|
||||
void Stop();
|
||||
void CreteInnerWindow(std::string name, DisplayId displyId, Rect rect,
|
||||
WindowType type, WindowMode mode);
|
||||
void DestroyInnerWindow(DisplayId displyId, WindowType type);
|
||||
public:
|
||||
enum class InnerWMRunningState {
|
||||
STATE_NOT_START,
|
||||
STATE_RUNNING,
|
||||
};
|
||||
void CreateInnerWindow(std::string name, DisplayId displayId, Rect rect, WindowType type, WindowMode mode);
|
||||
void DestroyInnerWindow(DisplayId displayId, WindowType type);
|
||||
|
||||
protected:
|
||||
WindowInnerManager();
|
||||
~WindowInnerManager();
|
||||
|
||||
private:
|
||||
WindowInnerManager();
|
||||
bool Init();
|
||||
|
||||
private:
|
||||
bool isRecentHolderEnable_ = false;
|
||||
std::shared_ptr<EventHandler> eventHandler_;
|
||||
std::shared_ptr<EventRunner> eventLoop_;
|
||||
InnerWMRunningState state_;
|
||||
|
||||
@@ -61,7 +61,6 @@ public:
|
||||
void ProcessDisplayCreate(DisplayId displayId, const std::map<DisplayId, Rect>& displayRectMap);
|
||||
void ProcessDisplayDestroy(DisplayId displayId, const std::map<DisplayId, Rect>& displayRectMap);
|
||||
void ProcessDisplaySizeChangeOrRotation(DisplayId displayId, const std::map<DisplayId, Rect>& displayRectMap);
|
||||
void SetFloatingWindowLimitsConfig(const FloatingWindowLimitsConfig& floatingWindowLimitsConfig);
|
||||
void SetSplitRatioConfig(const SplitRatioConfig& splitRatioConfig);
|
||||
|
||||
protected:
|
||||
@@ -91,16 +90,15 @@ protected:
|
||||
|
||||
void UpdateFloatingWindowSizeForStretchableWindow(const sptr<WindowNode>& node,
|
||||
const Rect& displayRect, Rect& winRect) const;
|
||||
void UpdateFloatingWindowSizeByCustomizedLimits(const sptr<WindowNode>& node,
|
||||
void UpdateFloatingWindowSizeBySizeLimits(const sptr<WindowNode>& node,
|
||||
const Rect& displayRect, Rect& winRect) const;
|
||||
void UpdateFloatingWindowSizeBySystemLimits(const sptr<WindowNode>& node,
|
||||
const Rect& displayRect, Rect& winRect) const;
|
||||
void LimitWindowPositionWhenInitRectOrMove(const sptr<WindowNode>& node, Rect& winRect) const;
|
||||
void LimitWindowPositionWhenDrag(const sptr<WindowNode>& node, Rect& winRect) const;
|
||||
void FixWindowSizeByRatioIfDragBeyondLimitRegion(const sptr<WindowNode>& node, Rect& winRect,
|
||||
const FloatingWindowLimitsConfig& limitConfig);
|
||||
FloatingWindowLimitsConfig GetCustomizedLimitsConfig(const Rect& displayRect, float virtualPixelRatio);
|
||||
FloatingWindowLimitsConfig GetSystemLimitsConfig(const Rect& displayRect, float virtualPixelRatio);
|
||||
void FixWindowSizeByRatioIfDragBeyondLimitRegion(const sptr<WindowNode>& node, Rect& winRect);
|
||||
void UpdateWindowSizeLimits(const sptr<WindowNode>& node);
|
||||
WindowSizeLimits GetSystemSizeLimits(const Rect& displayRect, float virtualPixelRatio);
|
||||
|
||||
const std::set<WindowType> avoidTypes_ {
|
||||
WindowType::WINDOW_TYPE_STATUS_BAR,
|
||||
@@ -122,7 +120,6 @@ protected:
|
||||
Rect displayGroupRect_;
|
||||
Rect displayGroupLimitRect_;
|
||||
bool isMultiDisplay_ = false;
|
||||
FloatingWindowLimitsConfig floatingWindowLimitsConfig_;
|
||||
SplitRatioConfig splitRatioConfig_;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ class DisplayChangeListener : public IDisplayChangeListener {
|
||||
public:
|
||||
virtual void OnDisplayStateChange(DisplayId defaultDisplayId, sptr<DisplayInfo> displayInfo,
|
||||
const std::map<DisplayId, sptr<DisplayInfo>>& displayInfoMap, DisplayStateChangeType type) override;
|
||||
virtual void OnGetFullScreenWindowRequestedOrientation(DisplayId displayId, Orientation &orientation) override;
|
||||
virtual void OnGetWindowPreferredOrientation(DisplayId displayId, Orientation &orientation) override;
|
||||
};
|
||||
|
||||
class WindowManagerServiceHandler : public AAFwk::WindowManagerServiceHandlerStub {
|
||||
@@ -77,7 +77,6 @@ public:
|
||||
WMError DestroyWindow(uint32_t windowId, bool onlySelf = false) override;
|
||||
WMError RequestFocus(uint32_t windowId) override;
|
||||
WMError SetWindowBackgroundBlur(uint32_t windowId, WindowBlurLevel level) override;
|
||||
WMError SetAlpha(uint32_t windowId, float alpha) override;
|
||||
AvoidArea GetAvoidAreaByType(uint32_t windowId, AvoidAreaType avoidAreaType) override;
|
||||
void ProcessPointDown(uint32_t windowId, bool isStartDrag) override;
|
||||
void ProcessPointUp(uint32_t windowId) override;
|
||||
@@ -103,7 +102,7 @@ public:
|
||||
void CancelStartingWindow(sptr<IRemoteObject> abilityToken);
|
||||
void MinimizeWindowsByLauncher(std::vector<uint32_t> windowIds, bool isAnimated,
|
||||
sptr<RSIWindowAnimationFinishedCallback>& finishCallback) override;
|
||||
void GetFullScreenWindowRequestedOrientation(DisplayId displayId, Orientation &orientation);
|
||||
void GetWindowPreferredOrientation(DisplayId displayId, Orientation &orientation);
|
||||
protected:
|
||||
WindowManagerService();
|
||||
virtual ~WindowManagerService() = default;
|
||||
@@ -119,7 +118,6 @@ private:
|
||||
const std::map<DisplayId, sptr<DisplayInfo>>& displayInfoMap, DisplayStateChangeType type);
|
||||
WMError GetFocusWindowInfo(sptr<IRemoteObject>& abilityToken);
|
||||
void ConfigureWindowManagerService();
|
||||
void ConfigFloatWindowLimits();
|
||||
|
||||
static inline SingletonDelegator<WindowManagerService> delegator;
|
||||
std::map<uint32_t, uint32_t> accessTokenIdMaps_;
|
||||
|
||||
@@ -54,7 +54,6 @@ public:
|
||||
void SetSystemBarProperty(WindowType type, const SystemBarProperty& property);
|
||||
void SetWindowMode(WindowMode mode);
|
||||
void SetWindowBackgroundBlur(WindowBlurLevel level);
|
||||
void SetAlpha(float alpha);
|
||||
void SetBrightness(float brightness);
|
||||
void SetFocusable(bool focusable);
|
||||
void SetTouchable(bool touchable);
|
||||
@@ -72,6 +71,7 @@ public:
|
||||
void SetDragType(DragType dragType);
|
||||
void SetOriginRect(const Rect& rect);
|
||||
void SetTouchHotAreas(const std::vector<Rect>& rects);
|
||||
void SetWindowSizeLimits(const WindowSizeLimits& sizeLimits);
|
||||
|
||||
const sptr<IWindow>& GetWindowToken() const;
|
||||
uint32_t GetWindowId() const;
|
||||
@@ -85,7 +85,6 @@ public:
|
||||
WindowType GetWindowType() const;
|
||||
WindowMode GetWindowMode() const;
|
||||
WindowBlurLevel GetWindowBackgroundBlur() const;
|
||||
float GetAlpha() const;
|
||||
float GetBrightness() const;
|
||||
bool IsTurnScreenOn() const;
|
||||
bool IsKeepScreenOn() const;
|
||||
@@ -105,7 +104,9 @@ public:
|
||||
void ResetWindowSizeChangeReason();
|
||||
void GetTouchHotAreas(std::vector<Rect>& rects) const;
|
||||
uint32_t GetAccessTokenId() const;
|
||||
WindowSizeLimits GetWindowSizeLimits() const;
|
||||
|
||||
bool EnableDefaultAnimation(bool propertyEnabled, bool animationPlayed);
|
||||
sptr<WindowNode> parent_;
|
||||
std::vector<sptr<WindowNode>> children_;
|
||||
std::shared_ptr<RSSurfaceNode> surfaceNode_;
|
||||
|
||||
@@ -67,7 +67,7 @@ public:
|
||||
bool IsForbidDockSliceMove(DisplayId displayId) const;
|
||||
bool IsDockSliceInExitSplitModeArea(DisplayId displayId) const;
|
||||
void ExitSplitMode(DisplayId displayId);
|
||||
Orientation GetFullScreenWindowRequestedOrientation();
|
||||
Orientation GetWindowPreferredOrientation();
|
||||
|
||||
bool isVerticalDisplay(DisplayId displayId) const;
|
||||
WMError RaiseZOrderForAppWindow(sptr<WindowNode>& node, sptr<WindowNode>& parentNode);
|
||||
@@ -76,6 +76,7 @@ public:
|
||||
void MinimizeAllAppWindows(DisplayId displayId);
|
||||
void MinimizeOldestAppWindow();
|
||||
WMError ToggleShownStateForAllAppWindows(std::function<bool(uint32_t, WindowMode)> restoreFunc, bool restore);
|
||||
void BackUpAllAppWindows();
|
||||
void RestoreAllAppWindows(std::function<bool(uint32_t, WindowMode)> restoreFunc);
|
||||
bool IsAppWindowsEmpty() const;
|
||||
void ProcessWindowStateChange(WindowState state, WindowStateChangeReason reason);
|
||||
@@ -108,6 +109,7 @@ public:
|
||||
void UpdateAvoidAreaListener(sptr<WindowNode>& windowNode, bool haveAvoidAreaListener);
|
||||
void BeforeProcessWindowAvoidAreaChangeWhenDisplayChange() const;
|
||||
void ProcessWindowAvoidAreaChangeWhenDisplayChange() const;
|
||||
WindowLayoutMode GetCurrentLayoutMode() const;
|
||||
|
||||
private:
|
||||
void TraverseWindowNode(sptr<WindowNode>& root, std::vector<sptr<WindowNode>>& windowNodes) const;
|
||||
@@ -149,6 +151,7 @@ private:
|
||||
const std::vector<DisplayId>& curShowingDisplays);
|
||||
void FillWindowInfo(sptr<WindowInfo>& windowInfo, const sptr<WindowNode>& node) const;
|
||||
bool CheckWindowNodeWhetherInWindowTree(const sptr<WindowNode>& node) const;
|
||||
void UpdateModeSupportInfoWhenKeyguardChange(const sptr<WindowNode>& node, bool up);
|
||||
|
||||
float displayBrightness_ = UNDEFINED_BRIGHTNESS;
|
||||
uint32_t brightnessWindow_ = INVALID_WINDOW_ID;
|
||||
@@ -160,6 +163,7 @@ private:
|
||||
std::vector<uint32_t> backupWindowIds_;
|
||||
std::map<uint32_t, WindowMode> backupWindowMode_;
|
||||
std::map<DisplayId, Rect> backupDividerWindowRect_;
|
||||
std::map<DisplayId, std::set<WindowMode>> backupDisplaySplitWindowMode_;
|
||||
sptr<WindowZorderPolicy> zorderPolicy_ = new WindowZorderPolicy();
|
||||
std::unordered_map<WindowLayoutMode, sptr<WindowLayoutPolicy>> layoutPolicies_;
|
||||
WindowLayoutMode layoutMode_ = WindowLayoutMode::CASCADE;
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
#define OHOS_ROSEN_WINDOW_PAIR_H
|
||||
|
||||
#include <refbase.h>
|
||||
#include "class_var_definition.h"
|
||||
#include "window_inner_manager.h"
|
||||
#include "window_node.h"
|
||||
#include "window_layout_policy.h"
|
||||
@@ -52,9 +53,8 @@ public:
|
||||
* Constructor used to create an empty WindowPair instance.
|
||||
*
|
||||
* @param displayId the display of window pair
|
||||
* @param appNode the window root of app window
|
||||
*/
|
||||
WindowPair(const DisplayId& displayId, DisplayGroupWindowTree& displayGroupWindowTree);
|
||||
explicit WindowPair(const DisplayId& displayId);
|
||||
|
||||
/**
|
||||
* Deconstructor used to deconstruct.
|
||||
@@ -171,13 +171,6 @@ public:
|
||||
*/
|
||||
bool IsDockSliceInExitSplitModeArea(const std::vector<int32_t>& exitSplitPoints);
|
||||
|
||||
/**
|
||||
* Set all app windows are restoring.
|
||||
*
|
||||
* @param ratio Indicates whether all app windows are restoring.
|
||||
*/
|
||||
void SetAllAppWindowsRestoring(bool isAllAppWindowsRestoring);
|
||||
|
||||
void SetInitalDividerRect(const Rect& rect);
|
||||
|
||||
private:
|
||||
@@ -220,22 +213,6 @@ private:
|
||||
*/
|
||||
void DumpPairInfo();
|
||||
|
||||
/**
|
||||
* Find pairable window from window trees.
|
||||
*
|
||||
* @param node the node waiting to be paired
|
||||
* @return window node
|
||||
*/
|
||||
sptr<WindowNode> FindPairableWindow(sptr<WindowNode>& node);
|
||||
|
||||
/**
|
||||
* Get pairable node from trees or send split broadcast.
|
||||
*
|
||||
* @param node the node waiting to be paired
|
||||
* @return pairable node
|
||||
*/
|
||||
sptr<WindowNode> GetPairableWindow(sptr<WindowNode>& node);
|
||||
|
||||
/**
|
||||
* Send broadcast message of split event.
|
||||
*
|
||||
@@ -246,15 +223,12 @@ private:
|
||||
private:
|
||||
float ratio_ = DEFAULT_SPLIT_RATIO;
|
||||
DisplayId displayId_;
|
||||
sptr<WindowNode> appWindowNode_;
|
||||
sptr<WindowNode> primary_;
|
||||
sptr<WindowNode> secondary_;
|
||||
sptr<WindowNode> divider_;
|
||||
// sptr<WindowNode> placeholder_;
|
||||
WindowPairStatus status_ = {WindowPairStatus::STATUS_EMPTY};
|
||||
DisplayGroupWindowTree& displayGroupWindowTree_;
|
||||
bool isAllAppWindowsRestoring_ { false };
|
||||
Rect initalDividerRect_ {0, 0, 0, 0};
|
||||
DEFINE_VAR_DEFAULT_FUNC_SET(bool, AllSplitAppWindowsRestoring, isAllSplitAppWindowsRestoring, false)
|
||||
};
|
||||
} // namespace Rosen
|
||||
} // namespace OHOS
|
||||
|
||||
@@ -93,10 +93,10 @@ public:
|
||||
uint32_t GetWindowIdByObject(const sptr<IRemoteObject>& remoteObject);
|
||||
sptr<WindowNode> GetWindowForDumpAceHelpInfo() const;
|
||||
void DestroyLeakStartingWindow();
|
||||
void SetFloatingWindowLimitsConfig(const FloatingWindowLimitsConfig& floatingWindowLimitsConfig);
|
||||
void SetSplitRatios(const std::vector<float>& splitRatioNumbers);
|
||||
void SetExitSplitRatios(const std::vector<float>& exitSplitRatios);
|
||||
void MinimizeTargetWindows(std::vector<uint32_t>& windowIds);
|
||||
WindowLayoutMode GetCurrentLayoutMode(DisplayId displayId);
|
||||
private:
|
||||
void OnRemoteDied(const sptr<IRemoteObject>& remoteObject);
|
||||
WMError DestroyWindowInner(sptr<WindowNode>& node);
|
||||
@@ -134,7 +134,6 @@ private:
|
||||
this, std::placeholders::_1));
|
||||
Callback callback_;
|
||||
uint32_t maxAppWindowNumber_ = 100;
|
||||
FloatingWindowLimitsConfig floatingWindowLimitsConfig_;
|
||||
SplitRatioConfig splitRatioConfig_ = {0.1, 0.9, {}};
|
||||
};
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ private:
|
||||
{ WindowType::WINDOW_TYPE_APP_COMPONENT, 2 },
|
||||
{ WindowType::WINDOW_TYPE_APP_LAUNCHING, 101 },
|
||||
{ WindowType::WINDOW_TYPE_DOCK_SLICE, 0 },
|
||||
{ WindowType::WINDOW_TYPE_PLACE_HOLDER, 0 },
|
||||
{ WindowType::WINDOW_TYPE_PLACEHOLDER, 0 },
|
||||
{ WindowType::WINDOW_TYPE_LAUNCHER_RECENT, 102 },
|
||||
{ WindowType::WINDOW_TYPE_LAUNCHER_DOCK, 103 },
|
||||
{ WindowType::WINDOW_TYPE_INCOMING_CALL, 104 },
|
||||
|
||||
@@ -69,7 +69,6 @@ public:
|
||||
virtual WMError DestroyWindow(uint32_t windowId, bool onlySelf = false) = 0;
|
||||
virtual WMError RequestFocus(uint32_t windowId) = 0;
|
||||
virtual WMError SetWindowBackgroundBlur(uint32_t windowId, WindowBlurLevel level) = 0;
|
||||
virtual WMError SetAlpha(uint32_t windowId, float alpha) = 0;
|
||||
virtual AvoidArea GetAvoidAreaByType(uint32_t windowId, AvoidAreaType type) = 0;
|
||||
virtual WMError GetTopWindowId(uint32_t mainWinId, uint32_t& topWinId) = 0;
|
||||
virtual void ProcessPointDown(uint32_t windowId, bool isStartDrag) = 0;
|
||||
|
||||
@@ -37,7 +37,6 @@ public:
|
||||
WMError DestroyWindow(uint32_t windowId, bool onlySelf = false) override;
|
||||
WMError RequestFocus(uint32_t windowId) override;
|
||||
WMError SetWindowBackgroundBlur(uint32_t windowId, WindowBlurLevel level) override;
|
||||
WMError SetAlpha(uint32_t windowId, float alpha) override;
|
||||
AvoidArea GetAvoidAreaByType(uint32_t windowId, AvoidAreaType type) override;
|
||||
WMError GetTopWindowId(uint32_t mainWinId, uint32_t& topWinId) override;
|
||||
void ProcessPointDown(uint32_t windowId, bool isStartDrag) override;
|
||||
|
||||
@@ -49,7 +49,7 @@ void DisplayGroupController::InitNewDisplay(DisplayId displayId)
|
||||
displayGroupWindowTree_.insert(std::make_pair(displayId, std::move(displayWindowTree)));
|
||||
|
||||
// window pair for display
|
||||
auto windowPair = new WindowPair(displayId, displayGroupWindowTree_);
|
||||
auto windowPair = new WindowPair(displayId);
|
||||
windowPairMap_.insert(std::make_pair(displayId, windowPair));
|
||||
}
|
||||
|
||||
|
||||
@@ -25,112 +25,62 @@ namespace {
|
||||
constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_WINDOW, "InnerWindow"};
|
||||
const std::string IMAGE_PLACE_HOLDER_PNG_PATH = "/etc/window/resources/bg_place_holder.png";
|
||||
}
|
||||
WM_IMPLEMENT_SINGLE_INSTANCE(InnerWindowFactory)
|
||||
WMError InnerWindowFactory::CreateInnerWindow(std::string name, DisplayId displyId, Rect rect,
|
||||
WindowType type, WindowMode mode)
|
||||
WM_IMPLEMENT_SINGLE_INSTANCE(PlaceHolderWindow)
|
||||
WM_IMPLEMENT_SINGLE_INSTANCE(DividerWindow)
|
||||
|
||||
void PlaceholderWindowListener::OnTouchOutside()
|
||||
{
|
||||
WLOGFI("createInnerWindow begin type: %{public}u", type);
|
||||
if ((type != WindowType::WINDOW_TYPE_DOCK_SLICE) && (type != WindowType::WINDOW_TYPE_PLACE_HOLDER)) {
|
||||
WLOGFE("create inner window failed, current type: %{public}u not surpport.", type);
|
||||
return WMError::WM_ERROR_INVALID_TYPE;
|
||||
}
|
||||
if (innerWindowMap_.find(type) != std::end(innerWindowMap_)) {
|
||||
if (innerWindowMap_[type] != nullptr && innerWindowMap_[type]->GetState() ==
|
||||
InnerWindowState::INNER_WINDOW_STATE_CRATED) {
|
||||
WLOGFW("create inner window failed, current inner window type %{public}u has created.", type);
|
||||
return WMError::WM_ERROR_INVALID_TYPE;
|
||||
}
|
||||
innerWindowMap_.erase(type);
|
||||
}
|
||||
switch (type) {
|
||||
case WindowType::WINDOW_TYPE_DOCK_SLICE : {
|
||||
innerWindowMap_[type] = std::make_unique<DividerWindow>(name, displyId, rect);
|
||||
innerWindowMap_[type]->Create();
|
||||
break;
|
||||
}
|
||||
case WindowType::WINDOW_TYPE_PLACE_HOLDER : {
|
||||
innerWindowMap_[type] = std::make_unique<PlaceHolderWindow>(name, displyId, rect, mode);
|
||||
innerWindowMap_[type]->Create();
|
||||
break;
|
||||
}
|
||||
default :
|
||||
break;
|
||||
}
|
||||
WLOGFI("createInnerWindow end");
|
||||
return WMError::WM_OK;
|
||||
WLOGFD("place holder touch outside");
|
||||
PlaceHolderWindow::GetInstance().Destroy();
|
||||
}
|
||||
|
||||
WMError InnerWindowFactory::DestroyInnerWindow(DisplayId displyId, WindowType type)
|
||||
void PlaceholderWindowListener::OnKeyEvent(std::shared_ptr<MMI::KeyEvent>& keyEvent)
|
||||
{
|
||||
WLOGFI("destroy inner window type: %{public}u begin.", type);
|
||||
if (innerWindowMap_.find(type) == std::end(innerWindowMap_)) {
|
||||
WLOGFW("current inner window has created");
|
||||
return WMError::WM_ERROR_NULLPTR;
|
||||
}
|
||||
if (innerWindowMap_[type] != nullptr) {
|
||||
innerWindowMap_[type]->Destroy();
|
||||
}
|
||||
innerWindowMap_.erase(type);
|
||||
WLOGFI("destroy inner window type: %{public}u end.", type);
|
||||
return WMError::WM_OK;
|
||||
WLOGFD("place holder get key event");
|
||||
PlaceHolderWindow::GetInstance().Destroy();
|
||||
}
|
||||
|
||||
PlaceHolderWindow::~PlaceHolderWindow()
|
||||
void PlaceholderWindowListener::OnPointerInputEvent(std::shared_ptr<MMI::PointerEvent>& pointerEvent)
|
||||
{
|
||||
Destroy();
|
||||
WLOGFD("place holder get point event");
|
||||
PlaceHolderWindow::GetInstance().Destroy();
|
||||
}
|
||||
|
||||
void PlaceHolderWindow::OnTouchOutside()
|
||||
void PlaceholderWindowListener::AfterUnfocused()
|
||||
{
|
||||
Destroy();
|
||||
WLOGFD("place holder after unfocused");
|
||||
PlaceHolderWindow::GetInstance().Destroy();
|
||||
}
|
||||
|
||||
void PlaceHolderWindow::OnKeyEvent(std::shared_ptr<MMI::KeyEvent>& keyEvent)
|
||||
void PlaceHolderWindow::Create(std::string name, DisplayId displyId, Rect rect, WindowMode mode)
|
||||
{
|
||||
Destroy();
|
||||
}
|
||||
|
||||
void PlaceHolderWindow::OnPointerInputEvent(std::shared_ptr<MMI::PointerEvent>& pointerEvent)
|
||||
{
|
||||
Destroy();
|
||||
}
|
||||
|
||||
void PlaceHolderWindow::AfterUnfocused()
|
||||
{
|
||||
Destroy();
|
||||
}
|
||||
|
||||
void PlaceHolderWindow::Create()
|
||||
{
|
||||
WLOGFI("create inner display id: %{public}" PRIu64"", displayId_);
|
||||
WLOGFD("create inner display id: %{public}" PRIu64"", displyId);
|
||||
if (window_ != nullptr) {
|
||||
WLOGFW("window has created.");
|
||||
window_->Show();
|
||||
return;
|
||||
}
|
||||
WLOGFD("create palce holder Window start");
|
||||
sptr<WindowOption> option = new (std::nothrow) WindowOption();
|
||||
if (option == nullptr) {
|
||||
WLOGFE("window option is nullptr.");
|
||||
return;
|
||||
}
|
||||
option->SetWindowType(WindowType::WINDOW_TYPE_PLACE_HOLDER);
|
||||
option->SetWindowMode(mode_);
|
||||
option->SetFocusable(false);
|
||||
option->SetWindowRect(rect_);
|
||||
window_ = Window::Create(name_, option);
|
||||
option->SetWindowMode(mode);
|
||||
option->SetWindowRect(rect);
|
||||
option->SetWindowType(WindowType::WINDOW_TYPE_PLACEHOLDER);
|
||||
window_ = Window::Create(name, option);
|
||||
if (window_ == nullptr) {
|
||||
WLOGFE("window is nullptr.");
|
||||
return;
|
||||
}
|
||||
window_->AddWindowFlag(WindowFlag::WINDOW_FLAG_FORBID_SPLIT_MOVE);
|
||||
RegitsterWindowListener();
|
||||
if (!OHOS::Rosen::SurfaceDraw::DrawImage(window_->GetSurfaceNode(), rect_.width_, rect_.height_,
|
||||
if (!OHOS::Rosen::SurfaceDraw::DrawImage(window_->GetSurfaceNode(), rect.width_, rect.height_,
|
||||
IMAGE_PLACE_HOLDER_PNG_PATH)) {
|
||||
WLOGE("draw surface failed");
|
||||
return;
|
||||
}
|
||||
window_->Show();
|
||||
state_ = InnerWindowState::INNER_WINDOW_STATE_CRATED;
|
||||
WLOGFD("create palce holder Window end");
|
||||
}
|
||||
|
||||
@@ -140,30 +90,35 @@ void PlaceHolderWindow::RegitsterWindowListener()
|
||||
WLOGFE("Window is nullptr, regitster window listener failed.");
|
||||
return;
|
||||
}
|
||||
window_->RegisterTouchOutsideListener(this);
|
||||
window_->RegisterInputEventListener(this);
|
||||
window_->RegisterLifeCycleListener(this);
|
||||
if (listener_ == nullptr) {
|
||||
listener_ = new (std::nothrow) PlaceholderWindowListener();
|
||||
}
|
||||
window_->RegisterTouchOutsideListener(listener_);
|
||||
window_->RegisterInputEventListener(listener_);
|
||||
window_->RegisterLifeCycleListener(listener_);
|
||||
}
|
||||
|
||||
void PlaceHolderWindow::UnRegitsterWindowListener()
|
||||
{
|
||||
if (window_ == nullptr) {
|
||||
WLOGFE("Window is nullptr, unregitster window listener failed.");
|
||||
if (window_ == nullptr || listener_ == nullptr) {
|
||||
WLOGFE("Window or listener is nullptr, unregitster window listener failed.");
|
||||
return;
|
||||
}
|
||||
window_->UnregisterTouchOutsideListener(this);
|
||||
window_->UnregisterInputEventListener(this);
|
||||
window_->UnregisterLifeCycleListener(this);
|
||||
window_->UnregisterTouchOutsideListener(listener_);
|
||||
window_->UnregisterInputEventListener(listener_);
|
||||
window_->UnregisterLifeCycleListener(listener_);
|
||||
}
|
||||
|
||||
void PlaceHolderWindow::Destroy()
|
||||
{
|
||||
UnRegitsterWindowListener();
|
||||
WLOGFI("destroy place holder window begin.");
|
||||
if (window_ != nullptr) {
|
||||
WLOGFI("destroy place holder window not nullptr.");
|
||||
UnRegitsterWindowListener();
|
||||
window_->Destroy();
|
||||
}
|
||||
window_ = nullptr;
|
||||
state_ = InnerWindowState::INNER_WINDOW_STATE_DESTROYED;
|
||||
WLOGFI("destroy place holder window end.");
|
||||
}
|
||||
|
||||
DividerWindow::~DividerWindow()
|
||||
@@ -171,31 +126,26 @@ DividerWindow::~DividerWindow()
|
||||
Destroy();
|
||||
}
|
||||
|
||||
void DividerWindow::Create()
|
||||
void DividerWindow::Create(std::string name, DisplayId displayId, const Rect rect, WindowMode mode)
|
||||
{
|
||||
WLOGFI("create inner display id: %{public}" PRIu64"", displayId_);
|
||||
displayId_ = displayId;
|
||||
WLOGFD("create inner display id: %{public}" PRIu64"", displayId_);
|
||||
auto dialogCallback = [this](int32_t id, const std::string& event, const std::string& params) {
|
||||
if (params == "EVENT_CANCEL_CODE") {
|
||||
Ace::UIServiceMgrClient::GetInstance()->CancelDialog(id);
|
||||
}
|
||||
WLOGFD("divider dialog window get param: %{public}s", params.c_str());
|
||||
};
|
||||
std::string params;
|
||||
Ace::UIServiceMgrClient::GetInstance()->ShowDialog(name_, params, WindowType::WINDOW_TYPE_DOCK_SLICE,
|
||||
rect_.posX_, rect_.posY_, rect_.width_, rect_.height_, dialogCallback, &dialogId_);
|
||||
state_ = InnerWindowState::INNER_WINDOW_STATE_CRATED;
|
||||
WLOGFI("create inner window id: %{public}d success", dialogId_);
|
||||
Ace::UIServiceMgrClient::GetInstance()->ShowDialog(name, params_, WindowType::WINDOW_TYPE_DOCK_SLICE,
|
||||
rect.posX_, rect.posY_, rect.width_, rect.height_, dialogCallback, &dialogId_);
|
||||
WLOGFD("create inner window id: %{public}d success", dialogId_);
|
||||
}
|
||||
|
||||
void DividerWindow::Destroy()
|
||||
{
|
||||
if (dialogId_ == -1) {
|
||||
state_ = InnerWindowState::INNER_WINDOW_STATE_DESTROYED;
|
||||
if (dialogId_ == IVALID_DIALOG_WINDOW_ID) {
|
||||
return;
|
||||
}
|
||||
WLOGFI("destroy inner window id:: %{public}d.", dialogId_);
|
||||
WLOGFD("destroy inner window id:: %{public}d.", dialogId_);
|
||||
Ace::UIServiceMgrClient::GetInstance()->CancelDialog(dialogId_);
|
||||
dialogId_ = -1;
|
||||
state_ = InnerWindowState::INNER_WINDOW_STATE_DESTROYED;
|
||||
dialogId_ = IVALID_DIALOG_WINDOW_ID;
|
||||
}
|
||||
} // Rosen
|
||||
} // OHOS
|
||||
@@ -28,16 +28,30 @@ namespace {
|
||||
const char DISABLE_WINDOW_ANIMATION_PATH[] = "/etc/disable_window_animation";
|
||||
}
|
||||
|
||||
SurfaceDraw StartingWindow::surfaceDraw_;
|
||||
static bool g_hasInit = false;
|
||||
std::recursive_mutex StartingWindow::mutex_;
|
||||
|
||||
sptr<WindowNode> StartingWindow::CreateWindowNode(sptr<WindowTransitionInfo> info, uint32_t winId)
|
||||
sptr<WindowNode> StartingWindow::CreateWindowNode(sptr<WindowTransitionInfo> info,
|
||||
uint32_t winId, WindowLayoutMode layoutMode)
|
||||
{
|
||||
sptr<WindowProperty> property = new(std::nothrow) WindowProperty();
|
||||
if (property == nullptr) {
|
||||
if (property == nullptr || info == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
uint32_t modeSupportInfo = 0;
|
||||
for (auto mode : info->GetWindowSupportModes()) {
|
||||
modeSupportInfo |= mode;
|
||||
}
|
||||
|
||||
// if mode isn't be supported or don't support floating mode in tile mode, create starting window failed
|
||||
if ((!WindowHelper::IsWindowModeSupported(modeSupportInfo, info->GetWindowMode())) ||
|
||||
((!WindowHelper::IsWindowModeSupported(modeSupportInfo, WindowMode::WINDOW_MODE_FLOATING)) &&
|
||||
(layoutMode == WindowLayoutMode::TILE)) ||
|
||||
(WindowHelper::IsOnlySupportSplitAndShowWhenLocked(info->GetShowFlagWhenLocked(), modeSupportInfo))) {
|
||||
WLOGFI("window mode is not be supported or not support floating mode in tile, cancel starting window");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
property->SetRequestRect(info->GetWindowRect());
|
||||
property->SetWindowMode(info->GetWindowMode());
|
||||
property->SetDisplayId(info->GetDisplayId());
|
||||
@@ -56,7 +70,6 @@ sptr<WindowNode> StartingWindow::CreateWindowNode(sptr<WindowTransitionInfo> inf
|
||||
if (CreateLeashAndStartingSurfaceNode(node) != WMError::WM_OK) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
@@ -89,10 +102,6 @@ void StartingWindow::DrawStartingWindow(sptr<WindowNode>& node,
|
||||
if (!isColdStart) {
|
||||
return;
|
||||
}
|
||||
if (!g_hasInit) {
|
||||
surfaceDraw_.Init();
|
||||
g_hasInit = true;
|
||||
}
|
||||
if (node->startingWinSurfaceNode_ == nullptr) {
|
||||
WLOGFE("no starting Window SurfaceNode!");
|
||||
return;
|
||||
@@ -102,10 +111,10 @@ void StartingWindow::DrawStartingWindow(sptr<WindowNode>& node,
|
||||
node->leashWinSurfaceNode_->SetBounds(rect.posX_, rect.posY_, -1, -1);
|
||||
}
|
||||
if (pixelMap == nullptr) {
|
||||
surfaceDraw_.DrawBackgroundColor(node->startingWinSurfaceNode_, rect, bkgColor);
|
||||
SurfaceDraw::DrawColor(node->startingWinSurfaceNode_, rect.width_, rect.height_, bkgColor);
|
||||
return;
|
||||
}
|
||||
surfaceDraw_.DrawSkImage(node->startingWinSurfaceNode_, rect, pixelMap, bkgColor);
|
||||
SurfaceDraw::DrawImageRect(node->startingWinSurfaceNode_, rect, pixelMap, bkgColor);
|
||||
}
|
||||
|
||||
void StartingWindow::HandleClientWindowCreate(sptr<WindowNode>& node, sptr<IWindow>& window,
|
||||
|
||||
@@ -52,12 +52,13 @@ void WindowController::StartingWindow(sptr<WindowTransitionInfo> info, sptr<Medi
|
||||
}
|
||||
WM_SCOPED_ASYNC_TRACE_BEGIN(static_cast<int32_t>(TraceTaskId::STARTING_WINDOW), "wms:async:ShowStartingWindow");
|
||||
auto node = windowRoot_->FindWindowNodeWithToken(info->GetAbilityToken());
|
||||
auto layoutMode = windowRoot_->GetCurrentLayoutMode(info->GetDisplayId());
|
||||
if (node == nullptr) {
|
||||
if (!isColdStart) {
|
||||
WLOGFE("no windowNode exists but is hot start!");
|
||||
return;
|
||||
}
|
||||
node = StartingWindow::CreateWindowNode(info, GenWindowId());
|
||||
node = StartingWindow::CreateWindowNode(info, GenWindowId(), layoutMode);
|
||||
if (node == nullptr) {
|
||||
return;
|
||||
}
|
||||
@@ -397,21 +398,6 @@ WMError WindowController::SetWindowBackgroundBlur(uint32_t windowId, WindowBlurL
|
||||
return WMError::WM_OK;
|
||||
}
|
||||
|
||||
WMError WindowController::SetAlpha(uint32_t windowId, float dstAlpha)
|
||||
{
|
||||
auto node = windowRoot_->GetWindowNode(windowId);
|
||||
if (node == nullptr) {
|
||||
WLOGFE("could not find window");
|
||||
return WMError::WM_ERROR_NULLPTR;
|
||||
}
|
||||
|
||||
WLOGFI("WindowEffect WindowController SetAlpha alpha: %{public}f", dstAlpha);
|
||||
node->SetAlpha(dstAlpha);
|
||||
|
||||
FlushWindowInfo(windowId);
|
||||
return WMError::WM_OK;
|
||||
}
|
||||
|
||||
void WindowController::NotifyDisplayStateChange(DisplayId defaultDisplayId, sptr<DisplayInfo> displayInfo,
|
||||
const std::map<DisplayId, sptr<DisplayInfo>>& displayInfoMap, DisplayStateChangeType type)
|
||||
{
|
||||
@@ -779,18 +765,22 @@ WMError WindowController::UpdateProperty(sptr<WindowProperty>& property, Propert
|
||||
}
|
||||
WLOGFI("window: [%{public}s, %{public}u] update property for action: %{public}u", node->GetWindowName().c_str(),
|
||||
node->GetWindowId(), static_cast<uint32_t>(action));
|
||||
WMError ret = WMError::WM_OK;
|
||||
switch (action) {
|
||||
case PropertyChangeAction::ACTION_UPDATE_RECT: {
|
||||
node->SetDecoStatus(property->GetDecoStatus());
|
||||
node->SetOriginRect(property->GetOriginRect());
|
||||
node->SetDragType(property->GetDragType());
|
||||
return ResizeRect(windowId, property->GetRequestRect(), property->GetWindowSizeChangeReason());
|
||||
ret = ResizeRect(windowId, property->GetRequestRect(), property->GetWindowSizeChangeReason());
|
||||
break;
|
||||
}
|
||||
case PropertyChangeAction::ACTION_UPDATE_MODE: {
|
||||
return SetWindowMode(windowId, property->GetWindowMode());
|
||||
ret = SetWindowMode(windowId, property->GetWindowMode());
|
||||
break;
|
||||
}
|
||||
case PropertyChangeAction::ACTION_UPDATE_FLAGS: {
|
||||
return SetWindowFlags(windowId, property->GetWindowFlags());
|
||||
ret = SetWindowFlags(windowId, property->GetWindowFlags());
|
||||
break;
|
||||
}
|
||||
case PropertyChangeAction::ACTION_UPDATE_OTHER_PROPS: {
|
||||
auto& props = property->GetSystemBarProperty();
|
||||
@@ -847,10 +837,24 @@ WMError WindowController::UpdateProperty(sptr<WindowProperty>& property, Propert
|
||||
property->GetTouchHotAreas(rects);
|
||||
return UpdateTouchHotAreas(node, rects);
|
||||
}
|
||||
case PropertyChangeAction::ACTION_UPDATE_TRANSFORM_PROPERTY:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return WMError::WM_OK;
|
||||
if (ret == WMError::WM_OK) {
|
||||
NotifyWindowPropertyChanged(node);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
void WindowController::NotifyWindowPropertyChanged(const sptr<WindowNode>& node)
|
||||
{
|
||||
auto windowNodeContainer = windowRoot_->GetOrCreateWindowNodeContainer(node->GetDisplayId());
|
||||
if (windowNodeContainer == nullptr) {
|
||||
WLOGFE("windowNodeContainer is null");
|
||||
return;
|
||||
}
|
||||
windowNodeContainer->NotifyAccessibilityWindowInfo(node, WindowUpdateType::WINDOW_UPDATE_PROPERTY);
|
||||
}
|
||||
|
||||
WMError WindowController::GetModeChangeHotZones(DisplayId displayId,
|
||||
@@ -964,11 +968,11 @@ void WindowController::MinimizeWindowsByLauncher(std::vector<uint32_t>& windowId
|
||||
}
|
||||
}
|
||||
|
||||
Orientation WindowController::GetFullScreenWindowRequestedOrientation(DisplayId displayId)
|
||||
Orientation WindowController::GetWindowPreferredOrientation(DisplayId displayId)
|
||||
{
|
||||
sptr<WindowNodeContainer> windowNodeContainer = windowRoot_->GetOrCreateWindowNodeContainer(displayId);
|
||||
if (windowNodeContainer != nullptr) {
|
||||
return windowNodeContainer->GetFullScreenWindowRequestedOrientation();
|
||||
return windowNodeContainer->GetWindowPreferredOrientation();
|
||||
}
|
||||
return Orientation::UNSPECIFIED;
|
||||
}
|
||||
|
||||
@@ -15,14 +15,9 @@
|
||||
|
||||
#include "window_inner_manager.h"
|
||||
|
||||
#include "surface_draw.h"
|
||||
#include "ui_service_mgr_client.h"
|
||||
#include "window_manager_hilog.h"
|
||||
#include "image/bitmap.h"
|
||||
#include "image_source.h"
|
||||
#include "image_type.h"
|
||||
#include "image_utils.h"
|
||||
#include "pixel_map.h"
|
||||
#include "window.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Rosen {
|
||||
@@ -55,8 +50,9 @@ bool WindowInnerManager::Init()
|
||||
return true;
|
||||
}
|
||||
|
||||
void WindowInnerManager::Start()
|
||||
void WindowInnerManager::Start(bool enableRecentholder)
|
||||
{
|
||||
isRecentHolderEnable_ = enableRecentholder;
|
||||
if (state_ == InnerWMRunningState::STATE_RUNNING) {
|
||||
WLOGFI("window inner manager service has already started.");
|
||||
}
|
||||
@@ -82,19 +78,47 @@ void WindowInnerManager::Stop()
|
||||
state_ = InnerWMRunningState::STATE_NOT_START;
|
||||
}
|
||||
|
||||
void WindowInnerManager::CreteInnerWindow(std::string name, DisplayId displyId, Rect rect,
|
||||
void WindowInnerManager::CreateInnerWindow(std::string name, DisplayId displayId, Rect rect,
|
||||
WindowType type, WindowMode mode)
|
||||
{
|
||||
eventHandler_->PostTask([name, displyId, rect, type, mode]() {
|
||||
InnerWindowFactory::GetInstance().CreateInnerWindow(name, displyId, rect, type, mode);
|
||||
eventHandler_->PostTask([this, name, displayId, rect, mode, type]() {
|
||||
switch (type) {
|
||||
case WindowType::WINDOW_TYPE_PLACEHOLDER: {
|
||||
if (isRecentHolderEnable_) {
|
||||
PlaceHolderWindow::GetInstance().Create(name, displayId, rect, mode);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case WindowType::WINDOW_TYPE_DOCK_SLICE: {
|
||||
DividerWindow::GetInstance().Create(name, displayId, rect, mode);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
void WindowInnerManager::DestroyInnerWindow(DisplayId displyId, WindowType type)
|
||||
void WindowInnerManager::DestroyInnerWindow(DisplayId displayId, WindowType type)
|
||||
{
|
||||
eventHandler_->PostTask([displyId, type]() {
|
||||
InnerWindowFactory::GetInstance().DestroyInnerWindow(displyId, type);
|
||||
eventHandler_->PostTask([this, type]() {
|
||||
switch (type) {
|
||||
case WindowType::WINDOW_TYPE_PLACEHOLDER: {
|
||||
if (isRecentHolderEnable_) {
|
||||
PlaceHolderWindow::GetInstance().Destroy();
|
||||
}
|
||||
break;
|
||||
}
|
||||
case WindowType::WINDOW_TYPE_DOCK_SLICE: {
|
||||
DividerWindow::GetInstance().Destroy();
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
});
|
||||
return;
|
||||
}
|
||||
} // Rosen
|
||||
} // OHOS
|
||||
@@ -455,16 +455,20 @@ void WindowLayoutPolicy::CalcAndSetNodeHotZone(const Rect& winRect, const sptr<W
|
||||
node->SetTouchHotAreas(hotAreas);
|
||||
}
|
||||
|
||||
void WindowLayoutPolicy::FixWindowSizeByRatioIfDragBeyondLimitRegion(const sptr<WindowNode>& node, Rect& winRect,
|
||||
const FloatingWindowLimitsConfig& limitConfig)
|
||||
void WindowLayoutPolicy::FixWindowSizeByRatioIfDragBeyondLimitRegion(const sptr<WindowNode>& node, Rect& winRect)
|
||||
{
|
||||
if (limitConfig.maxWidth_ == limitConfig.minWidth_ &&
|
||||
limitConfig.maxHeight_ == limitConfig.minHeight_) {
|
||||
const auto& sizeLimits = node->GetWindowSizeLimits();
|
||||
if (sizeLimits.maxWidth_ == sizeLimits.minWidth_ &&
|
||||
sizeLimits.maxHeight_ == sizeLimits.minHeight_) {
|
||||
WLOGFI("window rect can not be changed");
|
||||
return;
|
||||
}
|
||||
if (winRect.height_ == 0) {
|
||||
WLOGFE("the height of window is zero");
|
||||
return;
|
||||
}
|
||||
float curRatio = static_cast<float>(winRect.width_) / static_cast<float>(winRect.height_);
|
||||
if (limitConfig.minRatio_ <= curRatio && curRatio <= limitConfig.maxRatio_) {
|
||||
if (sizeLimits.minRatio_ <= curRatio && curRatio <= sizeLimits.maxRatio_) {
|
||||
WLOGFI("window ratio is satisfied with limit ratio, curRatio: %{public}f", curRatio);
|
||||
return;
|
||||
}
|
||||
@@ -490,10 +494,10 @@ void WindowLayoutPolicy::FixWindowSizeByRatioIfDragBeyondLimitRegion(const sptr<
|
||||
limitMaxPosX = dockWinRect.posX_ - static_cast<int32_t>(windowTitleBarH);
|
||||
}
|
||||
|
||||
float newRatio = curRatio < limitConfig.minRatio_ ? limitConfig.minRatio_ : limitConfig.maxRatio_;
|
||||
float newRatio = curRatio < sizeLimits.minRatio_ ? sizeLimits.minRatio_ : sizeLimits.maxRatio_;
|
||||
if ((winRect.posX_ + static_cast<int32_t>(winRect.width_) == limitMinPosX) || (winRect.posX_ == limitMaxPosX)) {
|
||||
// height can not be changed
|
||||
if (limitConfig.maxHeight_ == limitConfig.minHeight_) {
|
||||
if (sizeLimits.maxHeight_ == sizeLimits.minHeight_) {
|
||||
return;
|
||||
}
|
||||
winRect.height_ = static_cast<uint32_t>(static_cast<float>(winRect.width_) / newRatio);
|
||||
@@ -501,7 +505,7 @@ void WindowLayoutPolicy::FixWindowSizeByRatioIfDragBeyondLimitRegion(const sptr<
|
||||
|
||||
if ((winRect.posY_ == limitMinPosY) || (winRect.posX_ == limitMaxPosY)) {
|
||||
// width can not be changed
|
||||
if (limitConfig.maxWidth_ == limitConfig.minWidth_) {
|
||||
if (sizeLimits.maxWidth_ == sizeLimits.minWidth_) {
|
||||
return;
|
||||
}
|
||||
winRect.width_ = static_cast<uint32_t>(static_cast<float>(winRect.height_) * newRatio);
|
||||
@@ -510,79 +514,76 @@ void WindowLayoutPolicy::FixWindowSizeByRatioIfDragBeyondLimitRegion(const sptr<
|
||||
winRect.posX_, winRect.posY_, winRect.width_, winRect.height_);
|
||||
}
|
||||
|
||||
FloatingWindowLimitsConfig WindowLayoutPolicy::GetSystemLimitsConfig(const Rect& displayRect, float virtualPixelRatio)
|
||||
WindowSizeLimits WindowLayoutPolicy::GetSystemSizeLimits(const Rect& displayRect, float virtualPixelRatio)
|
||||
{
|
||||
FloatingWindowLimitsConfig limitConfig;
|
||||
limitConfig.maxWidth_ = static_cast<uint32_t>(MAX_FLOATING_SIZE * virtualPixelRatio);
|
||||
limitConfig.maxHeight_ = static_cast<uint32_t>(MAX_FLOATING_SIZE * virtualPixelRatio);
|
||||
limitConfig.minWidth_ = static_cast<uint32_t>(MIN_VERTICAL_FLOATING_WIDTH * virtualPixelRatio);
|
||||
limitConfig.minHeight_ = static_cast<uint32_t>(MIN_VERTICAL_FLOATING_HEIGHT * virtualPixelRatio);
|
||||
WindowSizeLimits systemLimits;
|
||||
systemLimits.maxWidth_ = static_cast<uint32_t>(MAX_FLOATING_SIZE * virtualPixelRatio);
|
||||
systemLimits.maxHeight_ = static_cast<uint32_t>(MAX_FLOATING_SIZE * virtualPixelRatio);
|
||||
systemLimits.minWidth_ = static_cast<uint32_t>(MIN_VERTICAL_FLOATING_WIDTH * virtualPixelRatio);
|
||||
systemLimits.minHeight_ = static_cast<uint32_t>(MIN_VERTICAL_FLOATING_HEIGHT * virtualPixelRatio);
|
||||
if (displayRect.width_ > displayRect.height_) {
|
||||
std::swap(limitConfig.minWidth_, limitConfig.minHeight_);
|
||||
std::swap(systemLimits.minWidth_, systemLimits.minHeight_);
|
||||
}
|
||||
WLOGFI("maxWidth: %{public}u, maxHeight: %{public}u, minWidth: %{public}u, minHeight: %{public}u "
|
||||
"maxRatio: %{public}f, minRatio: %{public}f", limitConfig.maxWidth_, limitConfig.maxHeight_,
|
||||
limitConfig.minWidth_, limitConfig.minHeight_, limitConfig.maxRatio_, limitConfig.minRatio_);
|
||||
return limitConfig;
|
||||
"maxRatio: %{public}f, minRatio: %{public}f", systemLimits.maxWidth_, systemLimits.maxHeight_,
|
||||
systemLimits.minWidth_, systemLimits.minHeight_, systemLimits.maxRatio_, systemLimits.minRatio_);
|
||||
return systemLimits;
|
||||
}
|
||||
|
||||
FloatingWindowLimitsConfig WindowLayoutPolicy::GetCustomizedLimitsConfig(const Rect& displayRect,
|
||||
float virtualPixelRatio)
|
||||
void WindowLayoutPolicy::UpdateWindowSizeLimits(const sptr<WindowNode>& node)
|
||||
{
|
||||
const auto& systemLimits = GetSystemLimitsConfig(displayRect, virtualPixelRatio);
|
||||
FloatingWindowLimitsConfig newLimitConfig = systemLimits;
|
||||
const auto& displayRect = displayGroupInfo_->GetDisplayRect(node->GetDisplayId());
|
||||
const auto& virtualPixelRatio = GetVirtualPixelRatio(node->GetDisplayId());
|
||||
const auto& systemLimits = GetSystemSizeLimits(displayRect, virtualPixelRatio);
|
||||
const auto& customizedLimits = node->GetWindowSizeLimits();
|
||||
WindowSizeLimits newLimits = systemLimits;
|
||||
|
||||
// configured limits of floating window
|
||||
uint32_t configuredMaxWidth = static_cast<uint32_t>(floatingWindowLimitsConfig_.maxWidth_ * virtualPixelRatio);
|
||||
uint32_t configuredMaxHeight = static_cast<uint32_t>(floatingWindowLimitsConfig_.maxHeight_ * virtualPixelRatio);
|
||||
uint32_t configuredMinWidth = static_cast<uint32_t>(floatingWindowLimitsConfig_.minWidth_ * virtualPixelRatio);
|
||||
uint32_t configuredMinHeight = static_cast<uint32_t>(floatingWindowLimitsConfig_.minHeight_ * virtualPixelRatio);
|
||||
float configuredMaxRatio = floatingWindowLimitsConfig_.maxRatio_;
|
||||
float configuredMinRatio = floatingWindowLimitsConfig_.minRatio_;
|
||||
uint32_t configuredMaxWidth = static_cast<uint32_t>(customizedLimits.maxWidth_ * virtualPixelRatio);
|
||||
uint32_t configuredMaxHeight = static_cast<uint32_t>(customizedLimits.maxHeight_ * virtualPixelRatio);
|
||||
uint32_t configuredMinWidth = static_cast<uint32_t>(customizedLimits.minWidth_ * virtualPixelRatio);
|
||||
uint32_t configuredMinHeight = static_cast<uint32_t>(customizedLimits.minHeight_ * virtualPixelRatio);
|
||||
float configuerdMaxRatio = customizedLimits.maxRatio_;
|
||||
float configuerdMinRatio = customizedLimits.minRatio_;
|
||||
|
||||
// calculate new limit size
|
||||
if (systemLimits.minWidth_ <= configuredMaxWidth && configuredMaxWidth <= systemLimits.maxWidth_) {
|
||||
newLimitConfig.maxWidth_ = configuredMaxWidth;
|
||||
newLimits.maxWidth_ = configuredMaxWidth;
|
||||
}
|
||||
if (systemLimits.minHeight_ <= configuredMaxHeight && configuredMaxHeight <= systemLimits.maxHeight_) {
|
||||
newLimitConfig.maxHeight_ = configuredMaxHeight;
|
||||
newLimits.maxHeight_ = configuredMaxHeight;
|
||||
}
|
||||
if (systemLimits.minWidth_ <= configuredMinWidth && configuredMinWidth <= newLimitConfig.maxWidth_) {
|
||||
newLimitConfig.minWidth_ = configuredMinWidth;
|
||||
if (systemLimits.minWidth_ <= configuredMinWidth && configuredMinWidth <= newLimits.maxWidth_) {
|
||||
newLimits.minWidth_ = configuredMinWidth;
|
||||
}
|
||||
if (systemLimits.minHeight_ <= configuredMinHeight && configuredMinHeight <= newLimitConfig.maxHeight_) {
|
||||
newLimitConfig.minHeight_ = configuredMinHeight;
|
||||
if (systemLimits.minHeight_ <= configuredMinHeight && configuredMinHeight <= newLimits.maxHeight_) {
|
||||
newLimits.minHeight_ = configuredMinHeight;
|
||||
}
|
||||
|
||||
// calculate new limit ratio
|
||||
newLimitConfig.maxRatio_ = static_cast<float>(newLimitConfig.maxWidth_) /
|
||||
static_cast<float>(newLimitConfig.minHeight_);
|
||||
newLimitConfig.minRatio_ = static_cast<float>(newLimitConfig.minWidth_) /
|
||||
static_cast<float>(newLimitConfig.maxHeight_);
|
||||
if (newLimitConfig.minRatio_ <= configuredMaxRatio && configuredMaxRatio <= newLimitConfig.maxRatio_) {
|
||||
newLimitConfig.maxRatio_ = configuredMaxRatio;
|
||||
newLimits.maxRatio_ = static_cast<float>(newLimits.maxWidth_) / static_cast<float>(newLimits.minHeight_);
|
||||
newLimits.minRatio_ = static_cast<float>(newLimits.minWidth_) / static_cast<float>(newLimits.maxHeight_);
|
||||
if (newLimits.minRatio_ <= configuerdMaxRatio && configuerdMaxRatio <= newLimits.maxRatio_) {
|
||||
newLimits.maxRatio_ = configuerdMaxRatio;
|
||||
}
|
||||
if (newLimitConfig.minRatio_ <= configuredMinRatio && configuredMinRatio <= newLimitConfig.maxRatio_) {
|
||||
newLimitConfig.minRatio_ = configuredMinRatio;
|
||||
if (newLimits.minRatio_ <= configuerdMinRatio && configuerdMinRatio <= newLimits.maxRatio_) {
|
||||
newLimits.minRatio_ = configuerdMinRatio;
|
||||
}
|
||||
|
||||
// recalculate limit size by new ratio
|
||||
uint32_t newMaxWidth = static_cast<uint32_t>(static_cast<float>(newLimitConfig.maxHeight_) *
|
||||
newLimitConfig.maxRatio_);
|
||||
newLimitConfig.maxWidth_ = std::min(newMaxWidth, newLimitConfig.maxWidth_);
|
||||
uint32_t newMinWidth = static_cast<uint32_t>(static_cast<float>(newLimitConfig.minHeight_) *
|
||||
newLimitConfig.minRatio_);
|
||||
newLimitConfig.minWidth_ = std::max(newMinWidth, newLimitConfig.minWidth_);
|
||||
uint32_t newMaxHeight = static_cast<uint32_t>(static_cast<float>(newLimitConfig.maxWidth_) /
|
||||
newLimitConfig.minRatio_);
|
||||
newLimitConfig.maxHeight_ = std::min(newMaxHeight, newLimitConfig.maxHeight_);
|
||||
uint32_t newMinHeight = static_cast<uint32_t>(static_cast<float>(newLimitConfig.minWidth_) /
|
||||
newLimitConfig.maxRatio_);
|
||||
newLimitConfig.minHeight_ = std::max(newMinHeight, newLimitConfig.minHeight_);
|
||||
uint32_t newMaxWidth = static_cast<uint32_t>(static_cast<float>(newLimits.maxHeight_) * newLimits.maxRatio_);
|
||||
newLimits.maxWidth_ = std::min(newMaxWidth, newLimits.maxWidth_);
|
||||
uint32_t newMinWidth = static_cast<uint32_t>(static_cast<float>(newLimits.minHeight_) * newLimits.minRatio_);
|
||||
newLimits.minWidth_ = std::max(newMinWidth, newLimits.minWidth_);
|
||||
uint32_t newMaxHeight = static_cast<uint32_t>(static_cast<float>(newLimits.maxWidth_) / newLimits.minRatio_);
|
||||
newLimits.maxHeight_ = std::min(newMaxHeight, newLimits.maxHeight_);
|
||||
uint32_t newMinHeight = static_cast<uint32_t>(static_cast<float>(newLimits.minWidth_) / newLimits.maxRatio_);
|
||||
newLimits.minHeight_ = std::max(newMinHeight, newLimits.minHeight_);
|
||||
|
||||
WLOGFI("maxWidth: %{public}u, maxHeight: %{public}u, minWidth: %{public}u, minHeight: %{public}u, "
|
||||
"maxRatio: %{public}f, minRatio: %{public}f", newLimitConfig.maxWidth_, newLimitConfig.maxHeight_,
|
||||
newLimitConfig.minWidth_, newLimitConfig.minHeight_, newLimitConfig.maxRatio_, newLimitConfig.minRatio_);
|
||||
return newLimitConfig;
|
||||
"maxRatio: %{public}f, minRatio: %{public}f", newLimits.maxWidth_, newLimits.maxHeight_,
|
||||
newLimits.minWidth_, newLimits.minHeight_, newLimits.maxRatio_, newLimits.minRatio_);
|
||||
node->SetWindowSizeLimits(newLimits);
|
||||
}
|
||||
|
||||
void WindowLayoutPolicy::UpdateFloatingWindowSizeForStretchableWindow(const sptr<WindowNode>& node,
|
||||
@@ -604,12 +605,12 @@ void WindowLayoutPolicy::UpdateFloatingWindowSizeForStretchableWindow(const sptr
|
||||
}
|
||||
}
|
||||
// limit minimum size of window
|
||||
const auto& systemLimits = const_cast<WindowLayoutPolicy*>(this)->
|
||||
GetSystemLimitsConfig(displayRect, GetVirtualPixelRatio(node->GetDisplayId()));
|
||||
float scale = std::min(static_cast<float>(winRect.width_) / systemLimits.minWidth_,
|
||||
static_cast<float>(winRect.height_) / systemLimits.minHeight_);
|
||||
|
||||
const auto& sizeLimits = node->GetWindowSizeLimits();
|
||||
float scale = std::min(static_cast<float>(winRect.width_) / sizeLimits.minWidth_,
|
||||
static_cast<float>(winRect.height_) / sizeLimits.minHeight_);
|
||||
if (scale == 0) {
|
||||
WLOGE("invalid systemLimits");
|
||||
WLOGE("invalid sizeLimits");
|
||||
return;
|
||||
}
|
||||
if (scale < 1.0f) {
|
||||
@@ -618,45 +619,47 @@ void WindowLayoutPolicy::UpdateFloatingWindowSizeForStretchableWindow(const sptr
|
||||
}
|
||||
}
|
||||
|
||||
void WindowLayoutPolicy::UpdateFloatingWindowSizeByCustomizedLimits(const sptr<WindowNode>& node,
|
||||
void WindowLayoutPolicy::UpdateFloatingWindowSizeBySizeLimits(const sptr<WindowNode>& node,
|
||||
const Rect& displayRect, Rect& winRect) const
|
||||
{
|
||||
// get new limit config with the settings of system and app
|
||||
const auto& customizedLimits = const_cast<WindowLayoutPolicy*>(this)->
|
||||
GetCustomizedLimitsConfig(displayRect, GetVirtualPixelRatio(node->GetDisplayId()));
|
||||
const auto& sizeLimits = node->GetWindowSizeLimits();
|
||||
|
||||
// limit minimum and maximum size of floating (not system type) window
|
||||
winRect.width_ = std::max(customizedLimits.minWidth_, winRect.width_);
|
||||
winRect.height_ = std::max(customizedLimits.minHeight_, winRect.height_);
|
||||
winRect.width_ = std::min(customizedLimits.maxWidth_, winRect.width_);
|
||||
winRect.height_ = std::min(customizedLimits.maxHeight_, winRect.height_);
|
||||
// limit minimum size of floating (not system type) window
|
||||
if (!WindowHelper::IsSystemWindow(node->GetWindowType()) ||
|
||||
node->GetWindowType() == WindowType::WINDOW_TYPE_FLOAT_CAMERA) {
|
||||
winRect.width_ = std::max(sizeLimits.minWidth_, winRect.width_);
|
||||
winRect.height_ = std::max(sizeLimits.minHeight_, winRect.height_);
|
||||
}
|
||||
winRect.width_ = std::min(sizeLimits.maxWidth_, winRect.width_);
|
||||
winRect.height_ = std::min(sizeLimits.maxHeight_, winRect.height_);
|
||||
WLOGFD("After limit by size, winRect: %{public}d %{public}d %{public}u %{public}u",
|
||||
winRect.posX_, winRect.posY_, winRect.width_, winRect.height_);
|
||||
|
||||
// width and height can not be changed
|
||||
if (customizedLimits.maxWidth_ == customizedLimits.minWidth_ &&
|
||||
customizedLimits.maxHeight_ == customizedLimits.minHeight_) {
|
||||
winRect.width_ = customizedLimits.maxWidth_;
|
||||
winRect.height_ = customizedLimits.maxHeight_;
|
||||
if (sizeLimits.maxWidth_ == sizeLimits.minWidth_ &&
|
||||
sizeLimits.maxHeight_ == sizeLimits.minHeight_) {
|
||||
winRect.width_ = sizeLimits.maxWidth_;
|
||||
winRect.height_ = sizeLimits.maxHeight_;
|
||||
WLOGFD("window rect can not be changed");
|
||||
return;
|
||||
}
|
||||
|
||||
float curRatio = static_cast<float>(winRect.width_) / static_cast<float>(winRect.height_);
|
||||
if ((customizedLimits.minWidth_ <= winRect.width_ && winRect.width_ <= customizedLimits.maxWidth_) &&
|
||||
(customizedLimits.minHeight_ <= winRect.height_ && winRect.height_ <= customizedLimits.maxHeight_) &&
|
||||
(customizedLimits.minRatio_ <= curRatio && curRatio <= customizedLimits.maxRatio_)) {
|
||||
WLOGFD("window size and ratio is satisfied with limit ratio, curSize: [%{public}d, %{public}d], "
|
||||
// there is no need to fix size by ratio if this is not main floating window
|
||||
if (!WindowHelper::IsMainFloatingWindow(node->GetWindowType(), node->GetWindowMode()) ||
|
||||
(sizeLimits.minRatio_ <= curRatio && curRatio <= sizeLimits.maxRatio_)) {
|
||||
WLOGFD("window is system window or ratio is satisfied with limits, curSize: [%{public}d, %{public}d], "
|
||||
"curRatio: %{public}f", winRect.width_, winRect.height_, curRatio);
|
||||
return;
|
||||
}
|
||||
|
||||
float newRatio = curRatio < customizedLimits.minRatio_ ? customizedLimits.minRatio_ : customizedLimits.maxRatio_;
|
||||
if (customizedLimits.maxWidth_ == customizedLimits.minWidth_) {
|
||||
float newRatio = curRatio < sizeLimits.minRatio_ ? sizeLimits.minRatio_ : sizeLimits.maxRatio_;
|
||||
if (sizeLimits.maxWidth_ == sizeLimits.minWidth_) {
|
||||
winRect.height_ = static_cast<uint32_t>(static_cast<float>(winRect.width_) / newRatio);
|
||||
return;
|
||||
}
|
||||
if (customizedLimits.maxHeight_ == customizedLimits.minHeight_) {
|
||||
if (sizeLimits.maxHeight_ == sizeLimits.minHeight_) {
|
||||
winRect.width_ = static_cast<uint32_t>(static_cast<float>(winRect.height_) * newRatio);
|
||||
return;
|
||||
}
|
||||
@@ -673,25 +676,6 @@ void WindowLayoutPolicy::UpdateFloatingWindowSizeByCustomizedLimits(const sptr<W
|
||||
winRect.posX_, winRect.posY_, winRect.width_, winRect.height_);
|
||||
}
|
||||
|
||||
void WindowLayoutPolicy::UpdateFloatingWindowSizeBySystemLimits(const sptr<WindowNode>& node,
|
||||
const Rect& displayRect, Rect& winRect) const
|
||||
{
|
||||
const auto& systemLimits = const_cast<WindowLayoutPolicy*>(this)->
|
||||
GetSystemLimitsConfig(displayRect, GetVirtualPixelRatio(node->GetDisplayId()));
|
||||
|
||||
// limit minimum size of floating (not system type) window
|
||||
if (!WindowHelper::IsSystemWindow(node->GetWindowType()) ||
|
||||
node->GetWindowType() == WindowType::WINDOW_TYPE_FLOAT_CAMERA) {
|
||||
winRect.width_ = std::max(systemLimits.minWidth_, winRect.width_);
|
||||
winRect.height_ = std::max(systemLimits.minHeight_, winRect.height_);
|
||||
}
|
||||
// limit maximum size of all floating window
|
||||
winRect.width_ = std::min(systemLimits.maxWidth_, winRect.width_);
|
||||
winRect.height_ = std::min(systemLimits.maxHeight_, winRect.height_);
|
||||
WLOGFI("After limit by system config, winRect: %{public}d %{public}d %{public}u %{public}u",
|
||||
winRect.posX_, winRect.posY_, winRect.width_, winRect.height_);
|
||||
}
|
||||
|
||||
void WindowLayoutPolicy::LimitFloatingWindowSize(const sptr<WindowNode>& node,
|
||||
const Rect& displayRect,
|
||||
Rect& winRect) const
|
||||
@@ -700,12 +684,7 @@ void WindowLayoutPolicy::LimitFloatingWindowSize(const sptr<WindowNode>& node,
|
||||
return;
|
||||
}
|
||||
Rect oriWinRect = winRect;
|
||||
if (floatingWindowLimitsConfig_.isFloatingWindowLimitsConfigured_ &&
|
||||
(WindowHelper::IsMainFloatingWindow(node->GetWindowType(), node->GetWindowMode()))) {
|
||||
UpdateFloatingWindowSizeByCustomizedLimits(node, displayRect, winRect);
|
||||
} else {
|
||||
UpdateFloatingWindowSizeBySystemLimits(node, displayRect, winRect);
|
||||
}
|
||||
UpdateFloatingWindowSizeBySizeLimits(node, displayRect, winRect);
|
||||
|
||||
if (node->GetStretchable() &&
|
||||
WindowHelper::IsMainFloatingWindow(node->GetWindowType(), node->GetWindowMode())) {
|
||||
@@ -736,12 +715,8 @@ void WindowLayoutPolicy::LimitMainFloatingWindowPosition(const sptr<WindowNode>&
|
||||
// if drag or move window, limit size and position
|
||||
if (reason == WindowSizeChangeReason::DRAG) {
|
||||
LimitWindowPositionWhenDrag(node, winRect);
|
||||
if (floatingWindowLimitsConfig_.isFloatingWindowLimitsConfigured_ &&
|
||||
(WindowHelper::IsMainFloatingWindow(node->GetWindowType(), node->GetWindowMode()))) {
|
||||
const auto& limitConfig = const_cast<WindowLayoutPolicy*>(this)-> GetCustomizedLimitsConfig(
|
||||
displayGroupInfo_->GetDisplayRect(node->GetDisplayId()), GetVirtualPixelRatio(node->GetDisplayId()));
|
||||
const_cast<WindowLayoutPolicy*>(this)->
|
||||
FixWindowSizeByRatioIfDragBeyondLimitRegion(node, winRect, limitConfig);
|
||||
if (WindowHelper::IsMainFloatingWindow(node->GetWindowType(), node->GetWindowMode())) {
|
||||
const_cast<WindowLayoutPolicy*>(this)->FixWindowSizeByRatioIfDragBeyondLimitRegion(node, winRect);
|
||||
}
|
||||
} else {
|
||||
// Limit window position, such as init window rect when show
|
||||
@@ -989,11 +964,6 @@ void WindowLayoutPolicy::SetSplitRatioConfig(const SplitRatioConfig& splitRatioC
|
||||
splitRatioConfig_ = splitRatioConfig;
|
||||
}
|
||||
|
||||
void WindowLayoutPolicy::SetFloatingWindowLimitsConfig(const FloatingWindowLimitsConfig& floatingWindowLimitsConfig)
|
||||
{
|
||||
floatingWindowLimitsConfig_ = floatingWindowLimitsConfig;
|
||||
}
|
||||
|
||||
Rect WindowLayoutPolicy::GetInitalDividerRect(DisplayId displayId) const
|
||||
{
|
||||
return INVALID_EMPTY_RECT;
|
||||
|
||||
@@ -14,6 +14,8 @@
|
||||
*/
|
||||
|
||||
#include "window_layout_policy_cascade.h"
|
||||
|
||||
#include "minimize_app.h"
|
||||
#include "window_helper.h"
|
||||
#include "window_inner_manager.h"
|
||||
#include "window_manager_hilog.h"
|
||||
@@ -179,6 +181,10 @@ void WindowLayoutPolicyCascade::AddWindowNode(const sptr<WindowNode>& node)
|
||||
WLOGFE("window property is nullptr.");
|
||||
return;
|
||||
}
|
||||
|
||||
// update window size limits when add window
|
||||
UpdateWindowSizeLimits(node);
|
||||
|
||||
if (WindowHelper::IsEmptyRect(property->GetRequestRect())) {
|
||||
SetCascadeRect(node);
|
||||
}
|
||||
@@ -466,6 +472,12 @@ void WindowLayoutPolicyCascade::Reorder()
|
||||
WLOGFI("get node failed or not app window.");
|
||||
continue;
|
||||
}
|
||||
// if window don't support floating mode, or default rect of cascade is not satisfied with limits
|
||||
if (!WindowHelper::IsWindowModeSupported(node->GetModeSupportInfo(), WindowMode::WINDOW_MODE_FLOATING) ||
|
||||
!WindowHelper::IsRectSatisfiedWithSizeLimits(rect, node->GetWindowSizeLimits())) {
|
||||
MinimizeApp::AddNeedMinimizeApp(node, MinimizeReason::LAYOUT_CASCADE);
|
||||
continue;
|
||||
}
|
||||
if (isFirstReorderedWindow) {
|
||||
isFirstReorderedWindow = false;
|
||||
} else {
|
||||
@@ -473,13 +485,12 @@ void WindowLayoutPolicyCascade::Reorder()
|
||||
}
|
||||
node->SetRequestRect(rect);
|
||||
node->SetDecoStatus(true);
|
||||
if (node->GetWindowMode() != WindowMode::WINDOW_MODE_FLOATING &&
|
||||
WindowHelper::IsWindowModeSupported(node->GetModeSupportInfo(), WindowMode::WINDOW_MODE_FLOATING)) {
|
||||
node->SetWindowMode(WindowMode::WINDOW_MODE_FLOATING);
|
||||
if (node->GetWindowToken()) {
|
||||
node->GetWindowToken()->UpdateWindowMode(WindowMode::WINDOW_MODE_FLOATING);
|
||||
}
|
||||
if (node->GetWindowMode() != WindowMode::WINDOW_MODE_FLOATING) {
|
||||
node->SetWindowMode(WindowMode::WINDOW_MODE_FLOATING);
|
||||
if (node->GetWindowToken()) {
|
||||
node->GetWindowToken()->UpdateWindowMode(WindowMode::WINDOW_MODE_FLOATING);
|
||||
}
|
||||
}
|
||||
WLOGFI("Cascade reorder Id: %{public}d, rect:[%{public}d, %{public}d, %{public}d, %{public}d]",
|
||||
node->GetWindowId(), rect.posX_, rect.posY_, rect.width_, rect.height_);
|
||||
}
|
||||
|
||||
@@ -118,6 +118,10 @@ void WindowLayoutPolicyTile::InitTileWindowRects(DisplayId displayId)
|
||||
void WindowLayoutPolicyTile::AddWindowNode(const sptr<WindowNode>& node)
|
||||
{
|
||||
WM_FUNCTION_TRACE();
|
||||
|
||||
// update window size limits when add window
|
||||
UpdateWindowSizeLimits(node);
|
||||
|
||||
if (WindowHelper::IsMainWindow(node->GetWindowType())) {
|
||||
DisplayId displayId = node->GetDisplayId();
|
||||
ForegroundNodeQueuePushBack(node, displayId);
|
||||
@@ -206,6 +210,12 @@ void WindowLayoutPolicyTile::ForegroundNodeQueuePushBack(const sptr<WindowNode>&
|
||||
if (iter != foregroundNodes.end()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!WindowHelper::IsWindowModeSupported(node->GetModeSupportInfo(), WindowMode::WINDOW_MODE_FLOATING)) {
|
||||
WLOGFD("window don't support tile mode, winId: %{public}d", node->GetWindowId());
|
||||
MinimizeApp::AddNeedMinimizeApp(node, MinimizeReason::LAYOUT_TILE);
|
||||
return;
|
||||
}
|
||||
WLOGFI("add win in tile, displayId: %{public}" PRIu64", winId: %{public}d", displayId, node->GetWindowId());
|
||||
while (foregroundNodes.size() >= maxTileWinNumMap_[displayId]) {
|
||||
auto removeNode = foregroundNodes.front();
|
||||
@@ -247,7 +257,8 @@ void WindowLayoutPolicyTile::AssignNodePropertyForTileWindows(DisplayId displayI
|
||||
auto rectIt = presetRect.begin();
|
||||
for (auto node : foregroundNodesMap_[displayId]) {
|
||||
auto& rect = (*rectIt);
|
||||
if (WindowHelper::IsWindowModeSupported(node->GetModeSupportInfo(), WindowMode::WINDOW_MODE_FLOATING)) {
|
||||
if (WindowHelper::IsWindowModeSupported(node->GetModeSupportInfo(), WindowMode::WINDOW_MODE_FLOATING) &&
|
||||
WindowHelper::IsRectSatisfiedWithSizeLimits(rect, node->GetWindowSizeLimits())) {
|
||||
node->SetWindowMode(WindowMode::WINDOW_MODE_FLOATING);
|
||||
if (node->GetWindowToken()) {
|
||||
node->GetWindowToken()->UpdateWindowMode(WindowMode::WINDOW_MODE_FLOATING);
|
||||
@@ -257,6 +268,8 @@ void WindowLayoutPolicyTile::AssignNodePropertyForTileWindows(DisplayId displayI
|
||||
WLOGFI("set rect for qwin id: %{public}d [%{public}d %{public}d %{public}d %{public}d]",
|
||||
node->GetWindowId(), rect.posX_, rect.posY_, rect.width_, rect.height_);
|
||||
rectIt++;
|
||||
} else {
|
||||
MinimizeApp::AddNeedMinimizeApp(node, MinimizeReason::LAYOUT_TILE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -73,14 +73,12 @@ bool WindowManagerConfig::LoadConfigXml()
|
||||
continue;
|
||||
}
|
||||
if (!xmlStrcmp(nodeName, reinterpret_cast<const xmlChar*>("maxAppWindowNumber")) ||
|
||||
!xmlStrcmp(nodeName, reinterpret_cast<const xmlChar*>("modeChangeHotZones")) ||
|
||||
!xmlStrcmp(nodeName, reinterpret_cast<const xmlChar*>("floatingWindowLimitSize"))) {
|
||||
!xmlStrcmp(nodeName, reinterpret_cast<const xmlChar*>("modeChangeHotZones"))) {
|
||||
ReadIntNumbersConfigInfo(curNodePtr);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!xmlStrcmp(nodeName, reinterpret_cast<const xmlChar*>("floatingWindowLimitRatio")) ||
|
||||
!xmlStrcmp(nodeName, reinterpret_cast<const xmlChar*>("splitRatios")) ||
|
||||
if (!xmlStrcmp(nodeName, reinterpret_cast<const xmlChar*>("splitRatios")) ||
|
||||
!xmlStrcmp(nodeName, reinterpret_cast<const xmlChar*>("exitSplitRatios"))) {
|
||||
ReadFloatNumbersConfigInfo(curNodePtr);
|
||||
continue;
|
||||
|
||||
@@ -67,7 +67,7 @@ void WindowManagerService::OnStart()
|
||||
if (!Init()) {
|
||||
return;
|
||||
}
|
||||
WindowInnerManager::GetInstance().Start();
|
||||
WindowInnerManager::GetInstance().Start(system::GetParameter("persist.window.holder.enable", "0") == "1");
|
||||
sptr<IDisplayChangeListener> listener = new DisplayChangeListener();
|
||||
DisplayManagerServiceInner::GetInstance().RegisterDisplayChangeListener(listener);
|
||||
RegisterSnapshotHandler();
|
||||
@@ -237,33 +237,6 @@ int WindowManagerService::Dump(int fd, const std::vector<std::u16string>& args)
|
||||
}).get();
|
||||
}
|
||||
|
||||
void WindowManagerService::ConfigFloatWindowLimits()
|
||||
{
|
||||
const auto& intNumbersConfig = WindowManagerConfig::GetIntNumbersConfig();
|
||||
const auto& floatNumbersConfig = WindowManagerConfig::GetFloatNumbersConfig();
|
||||
|
||||
FloatingWindowLimitsConfig floatingWindowLimitsConfig;
|
||||
if (intNumbersConfig.count("floatingWindowLimitSize") != 0) {
|
||||
auto numbers = intNumbersConfig.at("floatingWindowLimitSize");
|
||||
if (numbers.size() == 4) { // 4, limitSize
|
||||
floatingWindowLimitsConfig.maxWidth_ = static_cast<uint32_t>(numbers[0]); // 0 max width
|
||||
floatingWindowLimitsConfig.maxHeight_ = static_cast<uint32_t>(numbers[1]); // 1 max height
|
||||
floatingWindowLimitsConfig.minWidth_ = static_cast<uint32_t>(numbers[2]); // 2 min width
|
||||
floatingWindowLimitsConfig.minHeight_ = static_cast<uint32_t>(numbers[3]); // 3 min height
|
||||
floatingWindowLimitsConfig.isFloatingWindowLimitsConfigured_ = true;
|
||||
}
|
||||
}
|
||||
if (floatNumbersConfig.count("floatingWindowLimitRatio") != 0) {
|
||||
auto numbers = floatNumbersConfig.at("floatingWindowLimitRatio");
|
||||
if (numbers.size() == 2) { // 2, limitRatio
|
||||
floatingWindowLimitsConfig.maxRatio_ = static_cast<float>(numbers[0]); // 0 max ratio
|
||||
floatingWindowLimitsConfig.minRatio_ = static_cast<float>(numbers[1]); // 1 min ratio
|
||||
floatingWindowLimitsConfig.isFloatingWindowLimitsConfigured_ = true;
|
||||
}
|
||||
}
|
||||
windowRoot_->SetFloatingWindowLimitsConfig(floatingWindowLimitsConfig);
|
||||
}
|
||||
|
||||
void WindowManagerService::ConfigureWindowManagerService()
|
||||
{
|
||||
const auto& enableConfig = WindowManagerConfig::GetEnableConfig();
|
||||
@@ -301,8 +274,6 @@ void WindowManagerService::ConfigureWindowManagerService()
|
||||
}
|
||||
}
|
||||
|
||||
ConfigFloatWindowLimits();
|
||||
|
||||
if (floatNumbersConfig.count("splitRatios") != 0) {
|
||||
windowRoot_->SetSplitRatios(floatNumbersConfig.at("splitRatios"));
|
||||
}
|
||||
@@ -455,13 +426,6 @@ WMError WindowManagerService::SetWindowBackgroundBlur(uint32_t windowId, WindowB
|
||||
}).get();
|
||||
}
|
||||
|
||||
WMError WindowManagerService::SetAlpha(uint32_t windowId, float alpha)
|
||||
{
|
||||
return wmsTaskLooper_->ScheduleTask([this, windowId, alpha]() {
|
||||
return windowController_->SetAlpha(windowId, alpha);
|
||||
}).get();
|
||||
}
|
||||
|
||||
AvoidArea WindowManagerService::GetAvoidAreaByType(uint32_t windowId, AvoidAreaType avoidAreaType)
|
||||
{
|
||||
return wmsTaskLooper_->ScheduleTask([this, windowId, avoidAreaType]() {
|
||||
@@ -554,9 +518,9 @@ void DisplayChangeListener::OnDisplayStateChange(DisplayId defaultDisplayId, spt
|
||||
WindowManagerService::GetInstance().NotifyDisplayStateChange(defaultDisplayId, displayInfo, displayInfoMap, type);
|
||||
}
|
||||
|
||||
void DisplayChangeListener::OnGetFullScreenWindowRequestedOrientation(DisplayId displayId, Orientation &orientation)
|
||||
void DisplayChangeListener::OnGetWindowPreferredOrientation(DisplayId displayId, Orientation &orientation)
|
||||
{
|
||||
WindowManagerService::GetInstance().GetFullScreenWindowRequestedOrientation(displayId, orientation);
|
||||
WindowManagerService::GetInstance().GetWindowPreferredOrientation(displayId, orientation);
|
||||
}
|
||||
|
||||
void WindowManagerService::ProcessPointDown(uint32_t windowId, bool isStartDrag)
|
||||
@@ -613,6 +577,12 @@ WMError WindowManagerService::UpdateProperty(sptr<WindowProperty>& windowPropert
|
||||
WLOGFE("property is invalid");
|
||||
return WMError::WM_ERROR_NULLPTR;
|
||||
}
|
||||
if (action == PropertyChangeAction::ACTION_UPDATE_TRANSFORM_PROPERTY) {
|
||||
wmsTaskLooper_->PostTask([this, windowProperty, action]() mutable {
|
||||
windowController_->UpdateProperty(windowProperty, action);
|
||||
});
|
||||
return WMError::WM_OK;
|
||||
}
|
||||
return wmsTaskLooper_->ScheduleTask([this, &windowProperty, action]() {
|
||||
WM_SCOPED_TRACE("wms:UpdateProperty");
|
||||
WMError res = windowController_->UpdateProperty(windowProperty, action);
|
||||
@@ -659,10 +629,10 @@ void WindowManagerService::MinimizeWindowsByLauncher(std::vector<uint32_t> windo
|
||||
}).get();
|
||||
}
|
||||
|
||||
void WindowManagerService::GetFullScreenWindowRequestedOrientation(DisplayId displayId, Orientation &orientation)
|
||||
void WindowManagerService::GetWindowPreferredOrientation(DisplayId displayId, Orientation &orientation)
|
||||
{
|
||||
wmsTaskLooper_->ScheduleTask([this, displayId, &orientation]() mutable {
|
||||
orientation = windowController_->GetFullScreenWindowRequestedOrientation(displayId);
|
||||
orientation = windowController_->GetWindowPreferredOrientation(displayId);
|
||||
}).wait();
|
||||
}
|
||||
|
||||
|
||||
@@ -100,13 +100,6 @@ void WindowNode::SetWindowBackgroundBlur(WindowBlurLevel level)
|
||||
surfaceNode_->SetBackgroundFilter(RSFilter::CreateBlurFilter(blurRadiusX, blurRadiusY));
|
||||
}
|
||||
|
||||
void WindowNode::SetAlpha(float alpha)
|
||||
{
|
||||
property_->SetAlpha(alpha);
|
||||
WLOGFI("WindowEffect WinodwNode SetAlpha alpha:%{public}f", alpha);
|
||||
surfaceNode_->SetAlpha(alpha);
|
||||
}
|
||||
|
||||
void WindowNode::SetBrightness(float brightness)
|
||||
{
|
||||
property_->SetBrightness(brightness);
|
||||
@@ -203,6 +196,16 @@ void WindowNode::SetTouchHotAreas(const std::vector<Rect>& rects)
|
||||
touchHotAreas_ = rects;
|
||||
}
|
||||
|
||||
void WindowNode::SetWindowSizeLimits(const WindowSizeLimits& sizeLimits)
|
||||
{
|
||||
property_->SetSizeLimits(sizeLimits);
|
||||
}
|
||||
|
||||
WindowSizeLimits WindowNode::GetWindowSizeLimits() const
|
||||
{
|
||||
return property_->GetSizeLimits();
|
||||
}
|
||||
|
||||
DragType WindowNode::GetDragType() const
|
||||
{
|
||||
return property_->GetDragType();
|
||||
@@ -273,9 +276,9 @@ WindowBlurLevel WindowNode::GetWindowBackgroundBlur() const
|
||||
return property_->GetWindowBackgroundBlur();
|
||||
}
|
||||
|
||||
float WindowNode::GetAlpha() const
|
||||
bool WindowNode::EnableDefaultAnimation(bool propertyEnabled, bool animationPlayed)
|
||||
{
|
||||
return property_->GetAlpha();
|
||||
return (propertyEnabled && (!animationPlayed) && (!property_->GetCustomAnimation()) && (!isAppCrash_));
|
||||
}
|
||||
|
||||
float WindowNode::GetBrightness() const
|
||||
|
||||
@@ -387,6 +387,10 @@ void WindowNodeContainer::UpdateWindowTree(sptr<WindowNode>& node)
|
||||
bool WindowNodeContainer::UpdateRSTree(sptr<WindowNode>& node, DisplayId displayId, bool isAdd, bool animationPlayed)
|
||||
{
|
||||
WM_FUNCTION_TRACE();
|
||||
if (node->GetWindowProperty()->GetCustomAnimation()) {
|
||||
WLOGFI("not need to update RsTree since SystemWindowAnimation is playing");
|
||||
return false;
|
||||
}
|
||||
if (node->GetWindowType() == WindowType::WINDOW_TYPE_APP_COMPONENT) {
|
||||
WLOGFI("WINDOW_TYPE_APP_COMPONENT not need to update RsTree");
|
||||
return true;
|
||||
@@ -413,7 +417,7 @@ bool WindowNodeContainer::UpdateRSTree(sptr<WindowNode>& node, DisplayId display
|
||||
}
|
||||
};
|
||||
|
||||
if (IsWindowAnimationEnabled && !animationPlayed && !node->isAppCrash_) {
|
||||
if (node->EnableDefaultAnimation(IsWindowAnimationEnabled, animationPlayed)) {
|
||||
WLOGFI("add or remove window with animation");
|
||||
// default transition duration: 350ms
|
||||
static const RSAnimationTimingProtocol timingProtocol(350);
|
||||
@@ -460,7 +464,7 @@ const std::vector<uint32_t>& WindowNodeContainer::Destroy()
|
||||
sptr<WindowNode> WindowNodeContainer::FindRoot(WindowType type) const
|
||||
{
|
||||
if (WindowHelper::IsAppWindow(type) || type == WindowType::WINDOW_TYPE_DOCK_SLICE ||
|
||||
type == WindowType::WINDOW_TYPE_APP_COMPONENT) {
|
||||
type == WindowType::WINDOW_TYPE_APP_COMPONENT || type == WindowType::WINDOW_TYPE_PLACEHOLDER) {
|
||||
return appWindowNode_;
|
||||
}
|
||||
if (WindowHelper::IsBelowSystemWindow(type)) {
|
||||
@@ -992,7 +996,7 @@ void WindowNodeContainer::FillWindowInfo(sptr<WindowInfo>& windowInfo, const spt
|
||||
windowInfo->mode_ = node->GetWindowMode();
|
||||
windowInfo->type_ = node->GetWindowType();
|
||||
auto property = node->GetWindowProperty();
|
||||
if (!property) {
|
||||
if (property != nullptr) {
|
||||
windowInfo->isDecorEnable_ = property->GetDecorEnable();
|
||||
}
|
||||
}
|
||||
@@ -1018,6 +1022,9 @@ void WindowNodeContainer::NotifyAccessibilityWindowInfo(const sptr<WindowNode>&
|
||||
case WindowUpdateType::WINDOW_UPDATE_REMOVED:
|
||||
isNeedNotify = true;
|
||||
break;
|
||||
case WindowUpdateType::WINDOW_UPDATE_PROPERTY:
|
||||
isNeedNotify = true;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -1387,44 +1394,29 @@ WMError WindowNodeContainer::ToggleShownStateForAllAppWindows(
|
||||
std::function<bool(uint32_t, WindowMode)> restoreFunc, bool restore)
|
||||
{
|
||||
WLOGFI("ToggleShownStateForAllAppWindows");
|
||||
sptr<WindowNode> recentWindowNode = nullptr;
|
||||
for (auto node : aboveAppWindowNode_->children_) {
|
||||
if (node->GetWindowType() == WindowType::WINDOW_TYPE_LAUNCHER_RECENT) {
|
||||
return WMError::WM_DO_NOTHING;
|
||||
recentWindowNode = node;
|
||||
if (node->GetWindowMode() == WindowMode::WINDOW_MODE_FULLSCREEN) {
|
||||
return WMError::WM_OK;
|
||||
}
|
||||
}
|
||||
}
|
||||
// to do, backup reentry: 1.ToggleShownStateForAllAppWindows fast; 2.this display should reset backupWindowIds_.
|
||||
if (!restore && appWindowNode_->children_.empty() && !backupWindowIds_.empty()) {
|
||||
backupWindowIds_.clear();
|
||||
backupWindowMode_.clear();
|
||||
backupDisplaySplitWindowMode_.clear();
|
||||
backupDividerWindowRect_.clear();
|
||||
}
|
||||
if (!restore && !appWindowNode_->children_.empty() && backupWindowIds_.empty()) {
|
||||
WLOGFI("backup");
|
||||
std::set<DisplayId> displayIdSet;
|
||||
backupWindowMode_.clear();
|
||||
for (auto& appNode : appWindowNode_->children_) {
|
||||
// exclude exceptional window
|
||||
if (!WindowHelper::IsMainWindow(appNode->GetWindowType())) {
|
||||
WLOGFE("is not main window, windowId:%{public}u", appNode->GetWindowId());
|
||||
continue;
|
||||
}
|
||||
// minimize window
|
||||
WLOGFD("minimize window, windowId:%{public}u", appNode->GetWindowId());
|
||||
backupWindowIds_.emplace_back(appNode->GetWindowId());
|
||||
backupWindowMode_[appNode->GetWindowId()] = appNode->GetWindowMode();
|
||||
displayIdSet.insert(appNode->GetDisplayId());
|
||||
if (appNode->GetWindowToken()) {
|
||||
appNode->GetWindowToken()->UpdateWindowState(WindowState::STATE_HIDDEN);
|
||||
}
|
||||
}
|
||||
backupDividerWindowRect_.clear();
|
||||
for (auto displayId : displayIdSet) {
|
||||
auto windowPair = displayGroupController_->GetWindowPairByDisplayId(displayId);
|
||||
if (windowPair == nullptr || windowPair->GetDividerWindow() == nullptr) {
|
||||
continue;
|
||||
}
|
||||
backupDividerWindowRect_[displayId] = windowPair->GetDividerWindow()->GetWindowRect();
|
||||
if (recentWindowNode != nullptr && recentWindowNode->GetWindowToken() != nullptr) {
|
||||
WLOGFI("hide recent");
|
||||
recentWindowNode->GetWindowToken()->UpdateWindowState(WindowState::STATE_HIDDEN);
|
||||
}
|
||||
BackUpAllAppWindows();
|
||||
} else if (restore && !backupWindowIds_.empty()) {
|
||||
WLOGFI("restore");
|
||||
RestoreAllAppWindows(restoreFunc);
|
||||
@@ -1434,6 +1426,40 @@ WMError WindowNodeContainer::ToggleShownStateForAllAppWindows(
|
||||
return WMError::WM_OK;
|
||||
}
|
||||
|
||||
void WindowNodeContainer::BackUpAllAppWindows()
|
||||
{
|
||||
std::set<DisplayId> displayIdSet;
|
||||
backupWindowMode_.clear();
|
||||
backupDisplaySplitWindowMode_.clear();
|
||||
for (auto& appNode : appWindowNode_->children_) {
|
||||
// exclude exceptional window
|
||||
if (!WindowHelper::IsMainWindow(appNode->GetWindowType())) {
|
||||
WLOGFE("is not main window, windowId:%{public}u", appNode->GetWindowId());
|
||||
continue;
|
||||
}
|
||||
// minimize window
|
||||
WLOGFD("minimize window, windowId:%{public}u", appNode->GetWindowId());
|
||||
backupWindowIds_.emplace_back(appNode->GetWindowId());
|
||||
auto windowMode = appNode->GetWindowMode();
|
||||
backupWindowMode_[appNode->GetWindowId()] = windowMode;
|
||||
if (WindowHelper::IsSplitWindowMode(windowMode)) {
|
||||
backupDisplaySplitWindowMode_[appNode->GetWindowId()].insert(windowMode);
|
||||
}
|
||||
displayIdSet.insert(appNode->GetDisplayId());
|
||||
if (appNode->GetWindowToken()) {
|
||||
appNode->GetWindowToken()->UpdateWindowState(WindowState::STATE_HIDDEN);
|
||||
}
|
||||
}
|
||||
backupDividerWindowRect_.clear();
|
||||
for (auto displayId : displayIdSet) {
|
||||
auto windowPair = displayGroupController_->GetWindowPairByDisplayId(displayId);
|
||||
if (windowPair == nullptr || windowPair->GetDividerWindow() == nullptr) {
|
||||
continue;
|
||||
}
|
||||
backupDividerWindowRect_[displayId] = windowPair->GetDividerWindow()->GetWindowRect();
|
||||
}
|
||||
}
|
||||
|
||||
void WindowNodeContainer::RestoreAllAppWindows(std::function<bool(uint32_t, WindowMode)> restoreFunc)
|
||||
{
|
||||
std::vector<uint32_t> backupWindowIds(backupWindowIds_);
|
||||
@@ -1442,7 +1468,10 @@ void WindowNodeContainer::RestoreAllAppWindows(std::function<bool(uint32_t, Wind
|
||||
for (auto displayId : displayIds) {
|
||||
auto windowPair = displayGroupController_->GetWindowPairByDisplayId(displayId);
|
||||
if (windowPair != nullptr) {
|
||||
windowPair->SetAllAppWindowsRestoring(true);
|
||||
if (backupDisplaySplitWindowMode_[displayId].count(WindowMode::WINDOW_MODE_SPLIT_PRIMARY) > 0 &&
|
||||
backupDisplaySplitWindowMode_[displayId].count(WindowMode::WINDOW_MODE_SPLIT_SECONDARY) > 0) {
|
||||
windowPair->SetAllSplitAppWindowsRestoring(true);
|
||||
}
|
||||
windowPairs.emplace_back(windowPair);
|
||||
}
|
||||
}
|
||||
@@ -1454,7 +1483,7 @@ void WindowNodeContainer::RestoreAllAppWindows(std::function<bool(uint32_t, Wind
|
||||
WLOGFD("restore %{public}u", windowId);
|
||||
}
|
||||
for (auto windowPair : windowPairs) {
|
||||
windowPair->SetAllAppWindowsRestoring(false);
|
||||
windowPair->SetAllSplitAppWindowsRestoring(false);
|
||||
}
|
||||
layoutPolicy_->SetSplitDividerWindowRects(backupDividerWindowRect_);
|
||||
backupWindowIds_.clear();
|
||||
@@ -1533,6 +1562,25 @@ WMError WindowNodeContainer::SwitchLayoutPolicy(WindowLayoutMode dstMode, Displa
|
||||
return WMError::WM_OK;
|
||||
}
|
||||
|
||||
void WindowNodeContainer::UpdateModeSupportInfoWhenKeyguardChange(const sptr<WindowNode>& node, bool up)
|
||||
{
|
||||
if (!WindowHelper::IsWindowModeSupported(node->GetWindowProperty()->GetRequestModeSupportInfo(),
|
||||
WindowMode::WINDOW_MODE_SPLIT_PRIMARY)) {
|
||||
WLOGFD("window doesn't support split mode, winId: %{public}d", node->GetWindowId());
|
||||
return;
|
||||
}
|
||||
uint32_t modeSupportInfo;
|
||||
if (up) {
|
||||
modeSupportInfo = node->GetModeSupportInfo() & (~WindowModeSupport::WINDOW_MODE_SUPPORT_SPLIT_PRIMARY);
|
||||
} else {
|
||||
modeSupportInfo = node->GetModeSupportInfo() | WindowModeSupport::WINDOW_MODE_SUPPORT_SPLIT_PRIMARY;
|
||||
}
|
||||
node->SetModeSupportInfo(modeSupportInfo);
|
||||
if (node->GetWindowToken() != nullptr) {
|
||||
node->GetWindowToken()->UpdateWindowModeSupportInfo(modeSupportInfo);
|
||||
}
|
||||
}
|
||||
|
||||
void WindowNodeContainer::RaiseInputMethodWindowPriorityIfNeeded(const sptr<WindowNode>& node) const
|
||||
{
|
||||
if (node->GetWindowType() != WindowType::WINDOW_TYPE_INPUT_METHOD_FLOAT || !isScreenLocked_) {
|
||||
@@ -1575,6 +1623,8 @@ void WindowNodeContainer::ReZOrderShowWhenLockedWindows(bool up)
|
||||
}
|
||||
}
|
||||
|
||||
UpdateModeSupportInfoWhenKeyguardChange(needReZOrderNode, up);
|
||||
|
||||
parentNode->children_.insert(position, needReZOrderNode);
|
||||
if (up && WindowHelper::IsSplitWindowMode(needReZOrderNode->GetWindowMode())) {
|
||||
needReZOrderNode->GetWindowProperty()->ResumeLastWindowMode();
|
||||
@@ -1588,8 +1638,7 @@ void WindowNodeContainer::ReZOrderShowWhenLockedWindows(bool up)
|
||||
}
|
||||
windowPair->UpdateIfSplitRelated(needReZOrderNode);
|
||||
}
|
||||
WLOGFI("ShowWhenLocked window %{public}u re-zorder when keyguard change %{public}u",
|
||||
needReZOrderNode->GetWindowId(), up);
|
||||
WLOGFI("window %{public}u re-zorder when keyguard change %{public}u", needReZOrderNode->GetWindowId(), up);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1817,7 +1866,7 @@ sptr<DisplayInfo> WindowNodeContainer::GetDisplayInfo(DisplayId displayId)
|
||||
return displayGroupInfo_->GetDisplayInfo(displayId);
|
||||
}
|
||||
|
||||
Orientation WindowNodeContainer::GetFullScreenWindowRequestedOrientation()
|
||||
Orientation WindowNodeContainer::GetWindowPreferredOrientation()
|
||||
{
|
||||
std::vector<sptr<WindowNode>> windowNodes;
|
||||
TraverseContainer(windowNodes);
|
||||
@@ -1825,6 +1874,9 @@ Orientation WindowNodeContainer::GetFullScreenWindowRequestedOrientation()
|
||||
if (node->GetWindowMode() == WindowMode::WINDOW_MODE_FULLSCREEN) {
|
||||
return node->GetRequestedOrientation();
|
||||
}
|
||||
if (node->GetWindowType() == WindowType::WINDOW_TYPE_DOCK_SLICE) {
|
||||
return Orientation::UNSPECIFIED;
|
||||
}
|
||||
}
|
||||
return Orientation::UNSPECIFIED;
|
||||
}
|
||||
@@ -1835,5 +1887,10 @@ void WindowNodeContainer::UpdateCameraFloatWindowStatus(const sptr<WindowNode>&
|
||||
WindowManagerAgentController::GetInstance().UpdateCameraFloatWindowStatus(node->GetAccessTokenId(), isShowing);
|
||||
}
|
||||
}
|
||||
|
||||
WindowLayoutMode WindowNodeContainer::GetCurrentLayoutMode() const
|
||||
{
|
||||
return layoutMode_;
|
||||
}
|
||||
} // namespace Rosen
|
||||
} // namespace OHOS
|
||||
|
||||
@@ -31,8 +31,8 @@ namespace {
|
||||
const std::string SPLIT_SCREEN_EVENT_NAME = "common.event.SPLIT_SCREEN";
|
||||
}
|
||||
|
||||
WindowPair::WindowPair(const DisplayId& displayId, DisplayGroupWindowTree& displayGroupWindowTree)
|
||||
: displayId_(displayId), displayGroupWindowTree_(displayGroupWindowTree) {
|
||||
WindowPair::WindowPair(const DisplayId& displayId) : displayId_(displayId)
|
||||
{
|
||||
}
|
||||
|
||||
WindowPair::~WindowPair()
|
||||
@@ -183,10 +183,6 @@ void WindowPair::ExitSplitMode()
|
||||
hideWindow = secondary_;
|
||||
fullScreenWindow = primary_;
|
||||
}
|
||||
if (WindowHelper::IsWindowModeSupported(fullScreenWindow->GetModeSupportInfo(),
|
||||
WindowMode::WINDOW_MODE_FULLSCREEN)) {
|
||||
fullScreenWindow->GetWindowProperty()->SetLastWindowMode(WindowMode::WINDOW_MODE_FULLSCREEN);
|
||||
}
|
||||
MinimizeApp::AddNeedMinimizeApp(hideWindow, MinimizeReason::SPLIT_QUIT);
|
||||
MinimizeApp::ExecuteMinimizeTargetReason(MinimizeReason::SPLIT_QUIT);
|
||||
WLOGFI("Exit Split Mode, Minimize Window %{public}u", hideWindow->GetWindowId());
|
||||
@@ -209,7 +205,6 @@ void WindowPair::Clear()
|
||||
primary_ = nullptr;
|
||||
secondary_ = nullptr;
|
||||
if (divider_ != nullptr) {
|
||||
// WindowInnerManager::GetInstance().DestroyWindow();
|
||||
WindowInnerManager::GetInstance().DestroyInnerWindow(displayId_, WindowType::WINDOW_TYPE_DOCK_SLICE);
|
||||
divider_ = nullptr;
|
||||
}
|
||||
@@ -272,52 +267,6 @@ std::vector<sptr<WindowNode>> WindowPair::GetPairedWindows()
|
||||
return orderedPair;
|
||||
}
|
||||
|
||||
sptr<WindowNode> WindowPair::FindPairableWindow(sptr<WindowNode>& node)
|
||||
{
|
||||
if (node == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
if (!node->IsSplitMode()) {
|
||||
return nullptr;
|
||||
}
|
||||
auto& appNodeVec = *(displayGroupWindowTree_[displayId_][WindowRootNodeType::APP_WINDOW_NODE]);
|
||||
WindowMode dstMode = (node->GetWindowMode() == WindowMode::WINDOW_MODE_SPLIT_PRIMARY ?
|
||||
WindowMode::WINDOW_MODE_SPLIT_SECONDARY : WindowMode::WINDOW_MODE_SPLIT_PRIMARY);
|
||||
for (auto iter = appNodeVec.rbegin(); iter != appNodeVec.rend(); iter++) {
|
||||
auto pairNode = *iter;
|
||||
if (pairNode == nullptr) {
|
||||
continue;
|
||||
}
|
||||
if (pairNode->GetWindowMode() == WindowMode::WINDOW_MODE_FULLSCREEN &&
|
||||
WindowHelper::IsWindowModeSupported(pairNode->GetModeSupportInfo(), dstMode)) {
|
||||
pairNode->SetWindowMode(dstMode);
|
||||
if (pairNode->GetWindowToken() != nullptr) {
|
||||
pairNode->GetWindowToken()->UpdateWindowMode(pairNode->GetWindowMode());
|
||||
}
|
||||
WLOGFI("Find full screen pair window: %{public}u", static_cast<uint32_t>(pairNode->GetWindowId()));
|
||||
return pairNode;
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
sptr<WindowNode> WindowPair::GetPairableWindow(sptr<WindowNode>& node)
|
||||
{
|
||||
if (node == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
// get pairable window from window tree or send broadcast msg to start pair window
|
||||
sptr<WindowNode> pairableNode = FindPairableWindow(node);
|
||||
if (pairableNode == nullptr) {
|
||||
WLOGFI("Can not find pairable window from current tree.");
|
||||
SendBroadcastMsg(node);
|
||||
return nullptr;
|
||||
}
|
||||
WLOGFI("Find pairable window id: %{public}u", pairableNode->GetWindowId());
|
||||
return pairableNode;
|
||||
}
|
||||
|
||||
|
||||
void WindowPair::UpdateIfSplitRelated(sptr<WindowNode>& node)
|
||||
{
|
||||
if (node == nullptr) {
|
||||
@@ -328,29 +277,22 @@ void WindowPair::UpdateIfSplitRelated(sptr<WindowNode>& node)
|
||||
WLOGI("Window id: %{public}u is not split related and paired.", node->GetWindowId());
|
||||
return;
|
||||
}
|
||||
if ((node->GetWindowType() == WindowType::WINDOW_TYPE_PLACE_HOLDER) &&
|
||||
if ((node->GetWindowType() == WindowType::WINDOW_TYPE_PLACEHOLDER) &&
|
||||
((primary_ != nullptr && primary_->GetWindowMode() == node->GetWindowMode()) ||
|
||||
(secondary_ != nullptr && secondary_->GetWindowMode() == node->GetWindowMode()))) {
|
||||
// WindowInnerManager::GetInstance().DestroyPlaceHolderWindow();
|
||||
WindowInnerManager::GetInstance().DestroyInnerWindow(displayId_, WindowType::WINDOW_TYPE_PLACE_HOLDER);
|
||||
WindowInnerManager::GetInstance().DestroyInnerWindow(displayId_, WindowType::WINDOW_TYPE_PLACEHOLDER);
|
||||
return;
|
||||
}
|
||||
WLOGI("Current status: %{public}u, window id: %{public}u mode: %{public}u",
|
||||
status_, node->GetWindowId(), node->GetWindowMode());
|
||||
if (status_ == WindowPairStatus::STATUS_EMPTY) {
|
||||
Insert(node);
|
||||
if (!isAllAppWindowsRestoring_) {
|
||||
// find pairable window from trees or send broadcast
|
||||
// sptr<WindowNode> pairableNode = GetPairableWindow(node);
|
||||
// // insert pairable node
|
||||
// Insert(pairableNode);
|
||||
if (!isAllSplitAppWindowsRestoring_) {
|
||||
WindowMode holderMode = node->GetWindowMode() == WindowMode::WINDOW_MODE_SPLIT_PRIMARY ?
|
||||
WindowMode::WINDOW_MODE_SPLIT_SECONDARY : WindowMode::WINDOW_MODE_SPLIT_PRIMARY;
|
||||
WindowInnerManager::GetInstance().CreteInnerWindow("place_holder", displayId_,
|
||||
{0, 0, 512, 512},
|
||||
WindowType::WINDOW_TYPE_PLACE_HOLDER, holderMode);
|
||||
// WindowInnerManager::GetInstance().CreatePlaceHolderWindow(holderMode, displayId_);
|
||||
// SendBroadcastMsg(node);
|
||||
WindowInnerManager::GetInstance().CreateInnerWindow("place_holder", displayId_, DEFAULT_PLACE_HOLDER_RECT,
|
||||
WindowType::WINDOW_TYPE_PLACEHOLDER, holderMode);
|
||||
SendBroadcastMsg(node);
|
||||
}
|
||||
} else {
|
||||
if (Find(node) == nullptr) {
|
||||
@@ -382,9 +324,7 @@ void WindowPair::UpdateWindowPairStatus()
|
||||
prevStatus == WindowPairStatus::STATUS_SINGLE_SECONDARY || prevStatus == WindowPairStatus::STATUS_EMPTY) &&
|
||||
status_ == WindowPairStatus::STATUS_PAIRING) {
|
||||
// create divider
|
||||
// WindowInnerManager::GetInstance().CreateWindow("dialog_divider_ui", WindowType::WINDOW_TYPE_DOCK_SLICE,
|
||||
// initalDividerRect_);
|
||||
WindowInnerManager::GetInstance().CreteInnerWindow("divider", displayId_, initalDividerRect_,
|
||||
WindowInnerManager::GetInstance().CreateInnerWindow("dialog_divider_ui", displayId_, initalDividerRect_,
|
||||
WindowType::WINDOW_TYPE_DOCK_SLICE, WindowMode::WINDOW_MODE_FLOATING);
|
||||
} else if ((prevStatus == WindowPairStatus::STATUS_PAIRED_DONE || prevStatus == WindowPairStatus::STATUS_PAIRING) &&
|
||||
(status_ != WindowPairStatus::STATUS_PAIRED_DONE && status_ != WindowPairStatus::STATUS_PAIRING)) {
|
||||
@@ -402,16 +342,14 @@ void WindowPair::SwitchPosition()
|
||||
WLOGFI("Switch the pair pos, pri: %{public}u pri-mode: %{public}u, sec: %{public}u sec-mode: %{public}u,",
|
||||
primary_->GetWindowId(), primary_->GetWindowMode(), secondary_->GetWindowId(), secondary_->GetWindowMode());
|
||||
if (primary_->GetWindowMode() == secondary_->GetWindowMode() &&
|
||||
primary_->GetWindowMode() == WindowMode::WINDOW_MODE_SPLIT_PRIMARY &&
|
||||
WindowHelper::IsWindowModeSupported(primary_->GetModeSupportInfo(), WindowMode::WINDOW_MODE_SPLIT_SECONDARY)) {
|
||||
primary_->GetWindowMode() == WindowMode::WINDOW_MODE_SPLIT_PRIMARY) {
|
||||
primary_->SetWindowMode(WindowMode::WINDOW_MODE_SPLIT_SECONDARY);
|
||||
if (primary_->GetWindowToken() != nullptr) {
|
||||
primary_->GetWindowToken()->UpdateWindowMode(WindowMode::WINDOW_MODE_SPLIT_SECONDARY);
|
||||
}
|
||||
std::swap(primary_, secondary_);
|
||||
} else if (primary_->GetWindowMode() == secondary_->GetWindowMode() &&
|
||||
primary_->GetWindowMode() == WindowMode::WINDOW_MODE_SPLIT_SECONDARY &&
|
||||
WindowHelper::IsWindowModeSupported(secondary_->GetModeSupportInfo(), WindowMode::WINDOW_MODE_SPLIT_PRIMARY)) {
|
||||
primary_->GetWindowMode() == WindowMode::WINDOW_MODE_SPLIT_SECONDARY) {
|
||||
secondary_->SetWindowMode(WindowMode::WINDOW_MODE_SPLIT_PRIMARY);
|
||||
if (secondary_->GetWindowToken() != nullptr) {
|
||||
secondary_->GetWindowToken()->UpdateWindowMode(WindowMode::WINDOW_MODE_SPLIT_PRIMARY);
|
||||
@@ -504,11 +442,6 @@ void WindowPair::HandleRemoveWindow(sptr<WindowNode>& node)
|
||||
}
|
||||
}
|
||||
|
||||
void WindowPair::SetAllAppWindowsRestoring(bool isAllAppWindowsRestoring)
|
||||
{
|
||||
isAllAppWindowsRestoring_ = isAllAppWindowsRestoring;
|
||||
}
|
||||
|
||||
void WindowPair::SetInitalDividerRect(const Rect& rect)
|
||||
{
|
||||
initalDividerRect_ = rect;
|
||||
|
||||
@@ -117,7 +117,6 @@ sptr<WindowNodeContainer> WindowRoot::CreateWindowNodeContainer(sptr<DisplayInfo
|
||||
WLOGFE("create container failed, displayId :%{public}" PRIu64 "", displayId);
|
||||
return nullptr;
|
||||
}
|
||||
container->GetLayoutPolicy()->SetFloatingWindowLimitsConfig(floatingWindowLimitsConfig_);
|
||||
container->GetLayoutPolicy()->SetSplitRatioConfig(splitRatioConfig_);
|
||||
return container;
|
||||
}
|
||||
@@ -395,12 +394,7 @@ WMError WindowRoot::ToggleShownStateForAllAppWindows()
|
||||
WindowManagerService::GetInstance().HandleAddWindow(property);
|
||||
return true;
|
||||
};
|
||||
WMError tmpRes = WMError::WM_OK;
|
||||
if (isAllAppWindowsEmpty) {
|
||||
tmpRes = container->ToggleShownStateForAllAppWindows(restoreFunc, true);
|
||||
} else {
|
||||
tmpRes = container->ToggleShownStateForAllAppWindows(restoreFunc, false);
|
||||
}
|
||||
WMError tmpRes = tmpRes = container->ToggleShownStateForAllAppWindows(restoreFunc, isAllAppWindowsEmpty);
|
||||
res = (res == WMError::WM_OK) ? tmpRes : res;
|
||||
});
|
||||
return res;
|
||||
@@ -486,7 +480,7 @@ WMError WindowRoot::AddWindowNode(uint32_t parentId, sptr<WindowNode>& node, boo
|
||||
return res;
|
||||
}
|
||||
// limit number of main window
|
||||
int mainWindowNumber = container->GetWindowCountByType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW);
|
||||
uint32_t mainWindowNumber = container->GetWindowCountByType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW);
|
||||
if (mainWindowNumber >= maxAppWindowNumber_ && node->GetWindowType() == WindowType::WINDOW_TYPE_APP_MAIN_WINDOW) {
|
||||
container->MinimizeOldestAppWindow();
|
||||
}
|
||||
@@ -1315,9 +1309,14 @@ WMError WindowRoot::GetModeChangeHotZones(DisplayId displayId,
|
||||
return WMError::WM_OK;
|
||||
}
|
||||
|
||||
void WindowRoot::SetFloatingWindowLimitsConfig(const FloatingWindowLimitsConfig& floatingWindowLimitsConfig)
|
||||
WindowLayoutMode WindowRoot::GetCurrentLayoutMode(DisplayId displayId)
|
||||
{
|
||||
floatingWindowLimitsConfig_ = floatingWindowLimitsConfig;
|
||||
auto container = GetOrCreateWindowNodeContainer(displayId);
|
||||
if (container == nullptr) {
|
||||
WLOGFE("GetCurrentLayoutMode failed, window container could not be found");
|
||||
return WindowLayoutMode::BASE;
|
||||
}
|
||||
return container->GetCurrentLayoutMode();
|
||||
}
|
||||
} // namespace Rosen
|
||||
} // namespace OHOS
|
||||
|
||||
@@ -187,32 +187,6 @@ WMError WindowManagerProxy::SetWindowBackgroundBlur(uint32_t windowId, WindowBlu
|
||||
return static_cast<WMError>(ret);
|
||||
}
|
||||
|
||||
WMError WindowManagerProxy::SetAlpha(uint32_t windowId, float alpha)
|
||||
{
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
if (!data.WriteInterfaceToken(GetDescriptor())) {
|
||||
WLOGFE("WriteInterfaceToken failed");
|
||||
return WMError::WM_ERROR_IPC_FAILED;
|
||||
}
|
||||
if (!data.WriteUint32(windowId)) {
|
||||
WLOGFE("Write windowId failed");
|
||||
return WMError::WM_ERROR_IPC_FAILED;
|
||||
}
|
||||
if (!data.WriteFloat(alpha)) {
|
||||
WLOGFE("Write alpha failed");
|
||||
return WMError::WM_ERROR_IPC_FAILED;
|
||||
}
|
||||
if (Remote()->SendRequest(static_cast<uint32_t>(WindowManagerMessage::TRANS_ID_SET_ALPHA),
|
||||
data, reply, option) != ERR_NONE) {
|
||||
return WMError::WM_ERROR_IPC_FAILED;
|
||||
}
|
||||
|
||||
int32_t ret = reply.ReadInt32();
|
||||
return static_cast<WMError>(ret);
|
||||
}
|
||||
|
||||
AvoidArea WindowManagerProxy::GetAvoidAreaByType(uint32_t windowId, AvoidAreaType type)
|
||||
{
|
||||
MessageParcel data;
|
||||
|
||||
@@ -81,13 +81,6 @@ int32_t WindowManagerStub::OnRemoteRequest(uint32_t code, MessageParcel &data, M
|
||||
reply.WriteInt32(static_cast<int32_t>(errCode));
|
||||
break;
|
||||
}
|
||||
case WindowManagerMessage::TRANS_ID_SET_ALPHA: {
|
||||
uint32_t windowId = data.ReadUint32();
|
||||
float alpha = data.ReadFloat();
|
||||
WMError errCode = SetAlpha(windowId, alpha);
|
||||
reply.WriteInt32(static_cast<int32_t>(errCode));
|
||||
break;
|
||||
}
|
||||
case WindowManagerMessage::TRANS_ID_GET_AVOID_AREA: {
|
||||
uint32_t windowId = data.ReadUint32();
|
||||
AvoidAreaType avoidAreaType = static_cast<AvoidAreaType>(data.ReadUint32());
|
||||
|
||||
Reference in New Issue
Block a user