window manager refactoring

Signed-off-by: Fenger-hash <duanruifeng@huawei.com>
This commit is contained in:
Fenger-hash 2024-05-14 16:48:29 +08:00
parent 1087144848
commit 4643cf281b
20 changed files with 949 additions and 1205 deletions

View File

@ -41,11 +41,11 @@ public:
virtual ~WindowOption() = default;
/**
* @brief Set window rect.
* @brief Set window mode.
*
* @param rect The rect of window to set window position and size.
* @param mode The mode of window.
*/
void SetWindowRect(const struct Rect& rect);
void SetWindowMode(WindowMode mode);
/**
* @brief Set window type.
@ -55,11 +55,25 @@ public:
void SetWindowType(WindowType type);
/**
* @brief Set window mode.
* @brief Set window rect.
*
* @param mode The mode of window.
* @param rect The rect of window to set window position and size.
*/
void SetWindowMode(WindowMode mode);
void SetWindowRect(const struct Rect& rect);
/**
* @brief Set parent id.
*
* @param parentId The parent window id.
*/
void SetParentId(uint32_t parentId);
/**
* @brief Set display id.
*
* @param displayId The display id of window.
*/
void SetDisplayId(DisplayId displayId);
/**
* @brief Set window focusable.
@ -76,18 +90,11 @@ public:
void SetTouchable(bool isTouchable);
/**
* @brief Set display id.
* @brief Set bundle name.
*
* @param displayId The display id of window.
* @param bundleName The bundle name.
*/
void SetDisplayId(DisplayId displayId);
/**
* @brief Set parent id.
*
* @param parentId The parent window id.
*/
void SetParentId(uint32_t parentId);
void SetBundleName(const std::string bundleName);
/**
* @brief Set window name.
@ -97,18 +104,11 @@ public:
void SetWindowName(const std::string& windowName);
/**
* @brief Set bundle name.
* @brief Set window flags.
*
* @param bundleName The bundle name.
* @param flags The flag value.
*/
void SetBundleName(const std::string bundleName);
/**
* @brief Add window flag.
*
* @param flag The flag value added.
*/
void AddWindowFlag(WindowFlag flag);
void SetWindowFlags(uint32_t flags);
/**
* @brief Remove winodw flag.
@ -118,11 +118,18 @@ public:
void RemoveWindowFlag(WindowFlag flag);
/**
* @brief Set window flags.
* @brief Add window flag.
*
* @param flags The flag value.
* @param flag The flag value added.
*/
void SetWindowFlags(uint32_t flags);
void AddWindowFlag(WindowFlag flag);
/**
* @brief Set window tag.
*
* @param windowTag The tag of window.
*/
void SetWindowTag(WindowTag windowTag);
/**
* @brief Set system bar property.
@ -132,20 +139,6 @@ public:
*/
void SetSystemBarProperty(WindowType type, const SystemBarProperty& property);
/**
* @brief Set hit offset.
*
* @param x The position x of hit offset.
* @param y The position y of hit offset.
*/
void SetHitOffset(int32_t x, int32_t y);
/**
* @brief Set window tag.
*
* @param windowTag The tag of window.
*/
void SetWindowTag(WindowTag windowTag);
/**
* @brief Set window session type.
*
@ -154,25 +147,12 @@ public:
void SetWindowSessionType(WindowSessionType sessionType);
/**
* @brief Set keep screen on.
* @brief Set hit offset.
*
* @param keepScreenOn The window keep screen on or not.
* @param x The position x of hit offset.
* @param y The position y of hit offset.
*/
void SetKeepScreenOn(bool keepScreenOn);
/**
* @brief Is keep screen on.
*
* @return Return true means the window would keep screen on, otherwise not.
*/
bool IsKeepScreenOn() const;
/**
* @brief Set screen on.
*
* @param turnScreenOn mark the window to turn the screen on or not.
*/
void SetTurnScreenOn(bool turnScreenOn);
void SetHitOffset(int32_t x, int32_t y);
/**
* @brief Is turned screen on.
@ -182,18 +162,25 @@ public:
bool IsTurnScreenOn() const;
/**
* @brief Set window brightness.
* @brief Set screen on.
*
* @param brightness The brightness of screen. the value is between 0.0 ~ 1.0.
* @param turnScreenOn mark the window to turn the screen on or not.
*/
void SetBrightness(float brightness);
void SetTurnScreenOn(bool turnScreenOn);
/**
* @brief Set window requested orientation.
* @brief Is keep screen on.
*
* @param orientation The requested orientation of window.
* @return Return true means the window would keep screen on, otherwise not.
*/
void SetRequestedOrientation(Orientation orientation);
bool IsKeepScreenOn() const;
/**
* @brief Set keep screen on.
*
* @param keepScreenOn The window keep screen on or not.
*/
void SetKeepScreenOn(bool keepScreenOn);
/**
* @brief Set window calling window id.
@ -202,6 +189,20 @@ public:
*/
void SetCallingWindow(uint32_t windowId);
/**
* @brief Set window requested orientation.
*
* @param orientation The requested orientation of window.
*/
void SetRequestedOrientation(Orientation orientation);
/**
* @brief Set window brightness.
*
* @param brightness The brightness of screen. the value is between 0.0 ~ 1.0.
*/
void SetBrightness(float brightness);
/**
* @brief Set window main handler available.
*
@ -209,13 +210,6 @@ public:
*/
void SetMainHandlerAvailable(bool isMainHandlerAvailable);
/**
* @brief Set subwindow title.
*
* @param subWindowTitle the subwindow title.
*/
void SetSubWindowTitle(const std::string& subWindowTitle);
/**
* @brief Set subwindow decor enable.
*
@ -223,6 +217,13 @@ public:
*/
void SetSubWindowDecorEnable(bool subWindowDecorEnable);
/**
* @brief Set subwindow title.
*
* @param subWindowTitle the subwindow title.
*/
void SetSubWindowTitle(const std::string& subWindowTitle);
/**
* @brief Set only sceneboard supported.
*
@ -230,20 +231,6 @@ public:
*/
void SetOnlySupportSceneBoard(bool onlySupportSceneBoard);
/**
* @brief Get window rect.
*
* @return The rect of window.
*/
Rect GetWindowRect() const;
/**
* @brief Get window type.
*
* @return The type of window.
*/
WindowType GetWindowType() const;
/**
* @brief Get window mode.
*
@ -252,67 +239,11 @@ public:
WindowMode GetWindowMode() const;
/**
* @brief Get window focusable.
* @brief Get window type.
*
* @return Return true means the window is focusable, otherwise not.
* @return The type of window.
*/
bool GetFocusable() const;
/**
* @brief Get window touchable.
*
* @return Return true means the window is touchable, otherwise not.
*/
bool GetTouchable() const;
/**
* @brief Get display id.
*
* @return Return diplay id.
*/
DisplayId GetDisplayId() const;
/**
* @brief Get parent id.
*
* @return Return parent window id.
*/
uint32_t GetParentId() const;
/**
* @brief Get window name.
*
* @return Return the window name.
*/
const std::string& GetWindowName() const;
/**
* @brief Get bundle name.
*
* @return Return the bundle name.
*/
const std::string GetBundleName() const;
/**
* @brief Get window flags.
*
* @return Return the window flags.
*/
uint32_t GetWindowFlags() const;
/**
* @brief Get system bar property.
*
* @return Return system bar property map.
*/
const std::unordered_map<WindowType, SystemBarProperty>& GetSystemBarProperty() const;
/**
* @brief Get window hit offset.
*
* @return Return hit offset value as PointInfo.
*/
const PointInfo& GetHitOffset() const;
WindowType GetWindowType() const;
/**
* @brief Get window tag.
@ -322,18 +253,74 @@ public:
WindowTag GetWindowTag() const;
/**
* @brief Get window session type.
* @brief Get window rect.
*
* @return Return window session type.
* @return The rect of window.
*/
WindowSessionType GetWindowSessionType() const;
Rect GetWindowRect() const;
/**
* @brief Get window brightness.
* @brief Get parent id.
*
* @return Return screen brightness.
* @return Return parent window id.
*/
float GetBrightness() const;
uint32_t GetParentId() const;
/**
* @brief Get display id.
*
* @return Return diplay id.
*/
DisplayId GetDisplayId() const;
/**
* @brief Get window flags.
*
* @return Return the window flags.
*/
uint32_t GetWindowFlags() const;
/**
* @brief Get bundle name.
*
* @return Return the bundle name.
*/
const std::string GetBundleName() const;
/**
* @brief Get window name.
*
* @return Return the window name.
*/
const std::string& GetWindowName() const;
/**
* @brief Get window touchable.
*
* @return Return true means the window is touchable, otherwise not.
*/
bool GetTouchable() const;
/**
* @brief Get window focusable.
*
* @return Return true means the window is focusable, otherwise not.
*/
bool GetFocusable() const;
/**
* @brief Get window hit offset.
*
* @return Return hit offset value as PointInfo.
*/
const PointInfo& GetHitOffset() const;
/**
* @brief Get system bar property.
*
* @return Return system bar property map.
*/
const std::unordered_map<WindowType, SystemBarProperty>& GetSystemBarProperty() const;
/**
* @brief Get window request orientation.
@ -342,6 +329,13 @@ public:
*/
Orientation GetRequestedOrientation() const;
/**
* @brief Get window session type.
*
* @return Return window session type.
*/
WindowSessionType GetWindowSessionType() const;
/**
* @brief Get calling window id.
*
@ -349,6 +343,13 @@ public:
*/
uint32_t GetCallingWindow() const;
/**
* @brief Get window brightness.
*
* @return Return screen brightness.
*/
float GetBrightness() const;
/**
* @brief Get main handler available
*
@ -357,11 +358,11 @@ public:
bool GetMainHandlerAvailable() const;
/**
* @brief Get subwindow title
* @brief Get only sceneboard supported
*
* @return Return the subwindow title
* @return Return ture means only sceneboard supported, otherwise not.
*/
std::string GetSubWindowTitle() const;
bool GetOnlySupportSceneBoard() const;
/**
* @brief Get subwindow decor enable
@ -371,39 +372,40 @@ public:
bool GetSubWindowDecorEnable() const;
/**
* @brief Get only sceneboard supported
* @brief Get subwindow title
*
* @return Return ture means only sceneboard supported, otherwise not.
* @return Return the subwindow title
*/
bool GetOnlySupportSceneBoard() const;
std::string GetSubWindowTitle() const;
private:
Rect windowRect_ { 0, 0, 0, 0 };
std::string windowName_ { "" };
std::string bundleName_ { "" };
std::string subWindowTitle_ = { "" };
WindowType type_ { WindowType::WINDOW_TYPE_APP_MAIN_WINDOW };
WindowMode mode_ { WindowMode::WINDOW_MODE_UNDEFINED };
bool focusable_ { true };
bool touchable_ { true };
bool subWindowDecorEnable_ = false;
bool onlySupportSceneBoard_ = false;
bool keepScreenOn_ = false;
bool turnScreenOn_ = false;
bool isMainHandlerAvailable_ = true;
DisplayId displayId_ { 0 };
uint32_t parentId_ = INVALID_WINDOW_ID;
std::string windowName_ { "" };
std::string bundleName_ { "" };
uint32_t callingWindow_ = INVALID_WINDOW_ID;
uint32_t flags_ { 0 };
PointInfo hitOffset_ { 0, 0 };
WindowTag windowTag_;
WindowSessionType sessionType_ { WindowSessionType::SCENE_SESSION };
bool keepScreenOn_ = false;
bool turnScreenOn_ = false;
bool isMainHandlerAvailable_ = true;
float brightness_ = UNDEFINED_BRIGHTNESS;
uint32_t callingWindow_ = INVALID_WINDOW_ID;
Orientation requestedOrientation_ { Orientation::UNSPECIFIED };
std::unordered_map<WindowType, SystemBarProperty> sysBarPropMap_ {
{ WindowType::WINDOW_TYPE_STATUS_BAR, SystemBarProperty() },
{ WindowType::WINDOW_TYPE_NAVIGATION_BAR, SystemBarProperty() },
};
Orientation requestedOrientation_ { Orientation::UNSPECIFIED };
std::string subWindowTitle_ = { "" };
bool subWindowDecorEnable_ = false;
bool onlySupportSceneBoard_ = false;
};
} // namespace Rosen
} // namespace OHOS

View File

@ -23,13 +23,14 @@
namespace OHOS {
namespace Rosen {
using DisplayId = uint64_t;
/**
* @brief Enumerates type of window.
*/
enum class WindowType : uint32_t {
APP_WINDOW_BASE = 1,
APP_MAIN_WINDOW_BASE = APP_WINDOW_BASE,
WINDOW_TYPE_APP_MAIN_WINDOW = APP_MAIN_WINDOW_BASE,
WINDOW_TYPE_APP_MAIN_WINDOW = APP_WINDOW_BASE,
APP_MAIN_WINDOW_END,
APP_SUB_WINDOW_BASE = 1000,
@ -90,31 +91,17 @@ enum class WindowType : uint32_t {
};
/**
* @brief Enumerates mode of window.
* @brief Enumerates state of window.
*/
enum class WindowMode : uint32_t {
WINDOW_MODE_UNDEFINED = 0,
WINDOW_MODE_FULLSCREEN = 1,
WINDOW_MODE_SPLIT_PRIMARY = 100,
WINDOW_MODE_SPLIT_SECONDARY,
WINDOW_MODE_FLOATING,
WINDOW_MODE_PIP
};
/**
* @brief Enumerates mode supported of window.
*/
enum WindowModeSupport : uint32_t {
WINDOW_MODE_SUPPORT_FULLSCREEN = 1 << 0,
WINDOW_MODE_SUPPORT_FLOATING = 1 << 1,
WINDOW_MODE_SUPPORT_SPLIT_PRIMARY = 1 << 2,
WINDOW_MODE_SUPPORT_SPLIT_SECONDARY = 1 << 3,
WINDOW_MODE_SUPPORT_PIP = 1 << 4,
WINDOW_MODE_SUPPORT_ALL = WINDOW_MODE_SUPPORT_FULLSCREEN |
WINDOW_MODE_SUPPORT_SPLIT_PRIMARY |
WINDOW_MODE_SUPPORT_SPLIT_SECONDARY |
WINDOW_MODE_SUPPORT_FLOATING |
WINDOW_MODE_SUPPORT_PIP
enum class WindowState : uint32_t {
STATE_INITIAL,
STATE_CREATED,
STATE_SHOWN,
STATE_HIDDEN,
STATE_FROZEN,
STATE_UNFROZEN,
STATE_DESTROYED,
STATE_BOTTOM = STATE_DESTROYED // Add state type after STATE_DESTROYED is not allowed.
};
/**
@ -128,17 +115,43 @@ enum class WindowBlurStyle : uint32_t {
};
/**
* @brief Enumerates state of window.
* @brief Enumerates mode supported of window.
*/
enum class WindowState : uint32_t {
STATE_INITIAL,
STATE_CREATED,
STATE_SHOWN,
STATE_HIDDEN,
STATE_FROZEN,
STATE_UNFROZEN,
STATE_DESTROYED,
STATE_BOTTOM = STATE_DESTROYED, // Add state type after STATE_DESTROYED is not allowed
enum WindowModeSupport : uint32_t {
WINDOW_MODE_SUPPORT_FULLSCREEN = 1 << 0,
WINDOW_MODE_SUPPORT_FLOATING = 1 << 1,
WINDOW_MODE_SUPPORT_SPLIT_PRIMARY = 1 << 2,
WINDOW_MODE_SUPPORT_SPLIT_SECONDARY = 1 << 3,
WINDOW_MODE_SUPPORT_PIP = 1 << 4,
WINDOW_MODE_SUPPORT_ALL = WINDOW_MODE_SUPPORT_FLOATING |
WINDOW_MODE_SUPPORT_FULLSCREEN |
WINDOW_MODE_SUPPORT_SPLIT_PRIMARY |
WINDOW_MODE_SUPPORT_SPLIT_SECONDARY |
WINDOW_MODE_SUPPORT_PIP
};
/**
* @brief Enumerates mode of window.
*/
enum class WindowMode : uint32_t {
WINDOW_MODE_UNDEFINED = 0,
WINDOW_MODE_FULLSCREEN = 1,
WINDOW_MODE_SPLIT_PRIMARY = 100,
WINDOW_MODE_SPLIT_SECONDARY,
WINDOW_MODE_FLOATING,
WINDOW_MODE_PIP
};
/**
* @brief Enumerates status of window.
*/
enum class WindowStatus : uint32_t {
WINDOW_STATUS_UNDEFINED = 0,
WINDOW_STATUS_FULLSCREEN = 1,
WINDOW_STATUS_MAXMIZE,
WINDOW_STATUS_MINIMIZE,
WINDOW_STATUS_FLOATING,
WINDOW_STATUS_SPLITSCREEN
};
/**
@ -162,9 +175,9 @@ enum class WMError : int32_t {
WM_ERROR_INVALID_SESSION,
WM_ERROR_INVALID_CALLING,
WM_ERROR_DEVICE_NOT_SUPPORT = 801, // the value do not change.It is defined on all system
WM_ERROR_DEVICE_NOT_SUPPORT = 801, // the value do not change.It is defined on all system.
WM_ERROR_NEED_REPORT_BASE = 1000, // error code > 1000 means need report
WM_ERROR_NEED_REPORT_BASE = 1000, // error code > 1000 means need report.
WM_ERROR_NULLPTR,
WM_ERROR_INVALID_TYPE,
WM_ERROR_INVALID_PARAM,
@ -176,7 +189,7 @@ enum class WMError : int32_t {
WM_ERROR_PIP_STATE_ABNORMALLY,
WM_ERROR_PIP_CREATE_FAILED,
WM_ERROR_PIP_INTERNAL_ERROR,
WM_ERROR_PIP_REPEAT_OPERATION,
WM_ERROR_PIP_REPEAT_OPERATION
};
/**
@ -188,6 +201,7 @@ enum class WmErrorCode : int32_t {
WM_ERROR_NOT_SYSTEM_APP = 202,
WM_ERROR_INVALID_PARAM = 401,
WM_ERROR_DEVICE_NOT_SUPPORT = 801,
WM_ERROR_REPEAT_OPERATION = 1300001,
WM_ERROR_STATE_ABNORMALLY = 1300002,
WM_ERROR_SYSTEM_ABNORMALLY = 1300003,
@ -202,24 +216,11 @@ enum class WmErrorCode : int32_t {
WM_ERROR_PIP_STATE_ABNORMALLY = 1300012,
WM_ERROR_PIP_CREATE_FAILED = 1300013,
WM_ERROR_PIP_INTERNAL_ERROR = 1300014,
WM_ERROR_PIP_REPEAT_OPERATION = 1300015,
};
/**
* @brief Enumerates status of window.
*/
enum class WindowStatus : uint32_t {
WINDOW_STATUS_UNDEFINED = 0,
WINDOW_STATUS_FULLSCREEN = 1,
WINDOW_STATUS_MAXMIZE,
WINDOW_STATUS_MINIMIZE,
WINDOW_STATUS_FLOATING,
WINDOW_STATUS_SPLITSCREEN
WM_ERROR_PIP_REPEAT_OPERATION = 1300015
};
/**
* @brief Enumerates setting flag of systemStatusBar
* @brief Enumerates setting flag of systemStatusBar.
*/
enum class SystemBarSettingFlag : uint32_t {
DEFAULT_SETTING = 0,
@ -228,6 +229,20 @@ enum class SystemBarSettingFlag : uint32_t {
ALL_SETTING = 0b11
};
/**
* @brief Enumerates flag of window.
*/
enum class WindowFlag : uint32_t {
WINDOW_FLAG_NEED_AVOID = 1,
WINDOW_FLAG_PARENT_LIMIT = 1 << 1,
WINDOW_FLAG_SHOW_WHEN_LOCKED = 1 << 2,
WINDOW_FLAG_FORBID_SPLIT_MOVE = 1 << 3,
WINDOW_FLAG_WATER_MARK = 1 << 4,
WINDOW_FLAG_IS_MODAL = 1 << 5,
WINDOW_FLAG_HANDWRITING = 1 << 6,
WINDOW_FLAG_END = 1 << 7
};
/**
* @brief Used to map from WMError to WmErrorCode.
*/
@ -255,20 +270,6 @@ const std::map<WMError, WmErrorCode> WM_JS_TO_ERROR_CODE_MAP {
{WMError::WM_ERROR_START_ABILITY_FAILED, WmErrorCode::WM_ERROR_START_ABILITY_FAILED },
};
/**
* @brief Enumerates flag of window.
*/
enum class WindowFlag : uint32_t {
WINDOW_FLAG_NEED_AVOID = 1,
WINDOW_FLAG_PARENT_LIMIT = 1 << 1,
WINDOW_FLAG_SHOW_WHEN_LOCKED = 1 << 2,
WINDOW_FLAG_FORBID_SPLIT_MOVE = 1 << 3,
WINDOW_FLAG_WATER_MARK = 1 << 4,
WINDOW_FLAG_IS_MODAL = 1 << 5,
WINDOW_FLAG_HANDWRITING = 1 << 6,
WINDOW_FLAG_END = 1 << 7,
};
/**
* @brief Enumerates window size change reason.
*/
@ -292,7 +293,42 @@ enum class WindowSizeChangeReason : uint32_t {
PIP_START,
PIP_SHOW,
PIP_RATIO_CHANGE,
END,
END
};
/**
* @brief Enumerates window gravity.
*/
enum class WindowGravity : uint32_t {
WINDOW_GRAVITY_FLOAT = 0,
WINDOW_GRAVITY_BOTTOM
};
/**
* @brief Enumerates window session type.
*/
enum class WindowSessionType : uint32_t {
SCENE_SESSION = 0,
EXTENSION_SESSION = 1
};
/**
* @brief Enumerates window tag.
*/
enum class WindowTag : uint32_t {
MAIN_WINDOW = 0,
SUB_WINDOW = 1,
SYSTEM_WINDOW = 2
};
/**
* @brief Enumerates drag event.
*/
enum class DragEvent : uint32_t {
DRAG_EVENT_IN = 1,
DRAG_EVENT_OUT,
DRAG_EVENT_MOVE,
DRAG_EVENT_END
};
/**
@ -305,62 +341,28 @@ enum class WindowLayoutMode : uint32_t {
END,
};
/**
* @brief Enumerates drag event.
*/
enum class DragEvent : uint32_t {
DRAG_EVENT_IN = 1,
DRAG_EVENT_OUT,
DRAG_EVENT_MOVE,
DRAG_EVENT_END,
};
namespace {
constexpr uint32_t SYSTEM_COLOR_WHITE = 0xE5FFFFFF;
constexpr uint32_t SYSTEM_COLOR_BLACK = 0x66000000;
constexpr float UNDEFINED_BRIGHTNESS = -1.0f;
constexpr float MINIMUM_BRIGHTNESS = 0.0f;
constexpr float MAXIMUM_BRIGHTNESS = 1.0f;
/**
* @brief Enumerates window tag.
*/
enum class WindowTag : uint32_t {
MAIN_WINDOW = 0,
SUB_WINDOW = 1,
SYSTEM_WINDOW = 2,
};
/**
* @brief Enumerates window session type.
*/
enum class WindowSessionType : uint32_t {
SCENE_SESSION = 0,
EXTENSION_SESSION = 1,
};
/**
* @brief Enumerates window gravity.
*/
enum class WindowGravity : uint32_t {
WINDOW_GRAVITY_FLOAT = 0,
WINDOW_GRAVITY_BOTTOM,
};
constexpr uint32_t INVALID_WINDOW_ID = 0;
constexpr int32_t INVALID_PID = -1;
constexpr int32_t INVALID_UID = -1;
}
/**
* @struct PointInfo.
*
* @brief point Info.
* @brief Point info.
*/
struct PointInfo {
int32_t x;
int32_t y;
};
namespace {
constexpr uint32_t SYSTEM_COLOR_WHITE = 0xE5FFFFFF;
constexpr uint32_t SYSTEM_COLOR_BLACK = 0x66000000;
constexpr uint32_t INVALID_WINDOW_ID = 0;
constexpr float UNDEFINED_BRIGHTNESS = -1.0f;
constexpr float MINIMUM_BRIGHTNESS = 0.0f;
constexpr float MAXIMUM_BRIGHTNESS = 1.0f;
constexpr int32_t INVALID_PID = -1;
constexpr int32_t INVALID_UID = -1;
}
/**
* @class Transform
*
@ -376,17 +378,17 @@ public:
bool operator==(const Transform& right) const
{
return NearZero(pivotX_ - right.pivotX_) &&
NearZero(pivotY_ - right.pivotY_) &&
NearZero(scaleX_ - right.scaleX_) &&
return NearZero(scaleX_ - right.scaleX_) &&
NearZero(scaleY_ - right.scaleY_) &&
NearZero(scaleZ_ - right.scaleZ_) &&
NearZero(rotationX_ - right.rotationX_) &&
NearZero(rotationY_ - right.rotationY_) &&
NearZero(rotationZ_ - right.rotationZ_) &&
NearZero(pivotX_ - right.pivotX_) &&
NearZero(pivotY_ - right.pivotY_) &&
NearZero(translateX_ - right.translateX_) &&
NearZero(translateY_ - right.translateY_) &&
NearZero(translateZ_ - right.translateZ_);
NearZero(translateZ_ - right.translateZ_) &&
NearZero(rotationX_ - right.rotationX_) &&
NearZero(rotationY_ - right.rotationY_) &&
NearZero(rotationZ_ - right.rotationZ_);
}
bool operator!=(const Transform& right) const
@ -394,24 +396,24 @@ public:
return !(*this == right);
}
float pivotX_;
float pivotY_;
float scaleX_;
float scaleY_;
float scaleZ_;
float rotationX_;
float rotationY_;
float rotationZ_;
float translateX_;
float translateY_;
float translateZ_;
static const Transform& Identity()
{
static Transform I;
return I;
}
float pivotX_;
float pivotY_;
float scaleX_;
float scaleY_;
float scaleZ_;
float translateX_;
float translateY_;
float translateZ_;
float rotationX_;
float rotationY_;
float rotationZ_;
bool Marshalling(Parcel& parcel) const
{
return parcel.WriteFloat(pivotX_) && parcel.WriteFloat(pivotY_) &&
@ -422,18 +424,19 @@ public:
void Unmarshalling(Parcel& parcel)
{
pivotX_ = parcel.ReadFloat();
pivotY_ = parcel.ReadFloat();
scaleX_ = parcel.ReadFloat();
scaleY_ = parcel.ReadFloat();
scaleZ_ = parcel.ReadFloat();
rotationX_ = parcel.ReadFloat();
rotationY_ = parcel.ReadFloat();
rotationZ_ = parcel.ReadFloat();
pivotX_ = parcel.ReadFloat();
pivotY_ = parcel.ReadFloat();
translateX_ = parcel.ReadFloat();
translateY_ = parcel.ReadFloat();
translateZ_ = parcel.ReadFloat();
rotationX_ = parcel.ReadFloat();
rotationY_ = parcel.ReadFloat();
rotationZ_ = parcel.ReadFloat();
}
private:
static inline bool NearZero(float val)
{
@ -441,46 +444,16 @@ private:
}
};
/**
* @struct SystemBarProperty
*
* @brief Property of system bar
*/
struct SystemBarProperty {
bool enable_;
uint32_t backgroundColor_;
uint32_t contentColor_;
bool enableAnimation_;
SystemBarSettingFlag settingFlag_;
SystemBarProperty() : enable_(true), backgroundColor_(SYSTEM_COLOR_BLACK), contentColor_(SYSTEM_COLOR_WHITE),
enableAnimation_(false), settingFlag_(SystemBarSettingFlag::DEFAULT_SETTING) {}
SystemBarProperty(bool enable, uint32_t background, uint32_t content)
: enable_(enable), backgroundColor_(background), contentColor_(content), enableAnimation_(false),
settingFlag_(SystemBarSettingFlag::DEFAULT_SETTING) {}
SystemBarProperty(bool enable, uint32_t background, uint32_t content, bool enableAnimation)
: enable_(enable), backgroundColor_(background), contentColor_(content), enableAnimation_(enableAnimation),
settingFlag_(SystemBarSettingFlag::DEFAULT_SETTING) {}
SystemBarProperty(bool enable, uint32_t background, uint32_t content,
bool enableAnimation, SystemBarSettingFlag settingFlag)
: enable_(enable), backgroundColor_(background), contentColor_(content), enableAnimation_(enableAnimation),
settingFlag_(settingFlag) {}
bool operator == (const SystemBarProperty& a) const
{
return (enable_ == a.enable_ && backgroundColor_ == a.backgroundColor_ && contentColor_ == a.contentColor_ &&
enableAnimation_ == a.enableAnimation_);
}
};
/**
* @struct Rect
*
* @brief Window Rect
*/
struct Rect {
int32_t posX_;
int32_t posY_;
uint32_t width_;
uint32_t height_;
int32_t posX_;
int32_t posY_;
bool operator==(const Rect& a) const
{
@ -492,36 +465,60 @@ struct Rect {
return !this->operator==(a);
}
bool IsUninitializedRect() const
{
return (posX_ == 0 && posY_ == 0 && width_ == 0 && height_ == 0);
}
bool IsInsideOf(const Rect& a) const
{
return (posX_ >= a.posX_ && posY_ >= a.posY_ &&
posX_ + width_ <= a.posX_ + a.width_ && posY_ + height_ <= a.posY_ + a.height_);
}
bool IsUninitializedRect() const
{
return (posX_ == 0 && posY_ == 0 && width_ == 0 && height_ == 0);
}
};
/**
* @struct SystemBarProperty
*
* @brief Property of system bar
*/
struct SystemBarProperty {
bool enable_;
bool enableAnimation_;
uint32_t contentColor_;
uint32_t backgroundColor_;
SystemBarSettingFlag settingFlag_;
SystemBarProperty() : enable_(true), backgroundColor_(SYSTEM_COLOR_BLACK), contentColor_(SYSTEM_COLOR_WHITE),
enableAnimation_(false), settingFlag_(SystemBarSettingFlag::DEFAULT_SETTING) {}
SystemBarProperty(bool enable, uint32_t background, uint32_t content, bool enableAnimation)
: enable_(enable), backgroundColor_(background), contentColor_(content), enableAnimation_(enableAnimation),
settingFlag_(SystemBarSettingFlag::DEFAULT_SETTING) {}
SystemBarProperty(bool enable, uint32_t background, uint32_t content)
: enable_(enable), backgroundColor_(background), contentColor_(content), enableAnimation_(false),
settingFlag_(SystemBarSettingFlag::DEFAULT_SETTING) {}
SystemBarProperty(bool enable, uint32_t background, uint32_t content,
bool enableAnimation, SystemBarSettingFlag settingFlag)
: enable_(enable), backgroundColor_(background), contentColor_(content), enableAnimation_(enableAnimation),
settingFlag_(settingFlag) {}
bool operator == (const SystemBarProperty& a) const
{
return (enable_ == a.enable_ && backgroundColor_ == a.backgroundColor_ && contentColor_ == a.contentColor_ &&
enableAnimation_ == a.enableAnimation_);
}
};
/**
* @brief Enumerates avoid area type.
*/
enum class AvoidAreaType : uint32_t {
TYPE_SYSTEM, // area of SystemUI
TYPE_CUTOUT, // cutout of screen
TYPE_SYSTEM_GESTURE, // area for system gesture
TYPE_KEYBOARD, // area for soft input keyboard
TYPE_SYSTEM, // area of SystemUI
TYPE_CUTOUT, // cutout of screen
TYPE_SYSTEM_GESTURE, // area for system gesture
TYPE_KEYBOARD, // area for soft input keyboard
TYPE_NAVIGATION_INDICATOR, // area for navigation indicator
};
/**
* @brief Enumerates occupied area type.
*/
enum class OccupiedAreaType : uint32_t {
TYPE_INPUT, // area of input window
};
/**
* @brief Enumerates color space.
*/
@ -531,13 +528,10 @@ enum class ColorSpace : uint32_t {
};
/**
* @brief Enumerates window animation.
* @brief Enumerates occupied area type.
*/
enum class WindowAnimation : uint32_t {
NONE,
DEFAULT,
INPUTE,
CUSTOM,
enum class OccupiedAreaType : uint32_t {
TYPE_INPUT, // area of input window
};
/**
@ -546,7 +540,17 @@ enum class WindowAnimation : uint32_t {
enum class MaximizeMode : uint32_t {
MODE_AVOID_SYSTEM_BAR,
MODE_FULL_FILL,
MODE_RECOVER,
MODE_RECOVER
};
/**
* @brief Enumerates window animation.
*/
enum class WindowAnimation : uint32_t {
NONE,
DEFAULT,
INPUTE,
CUSTOM
};
/**
@ -556,14 +560,14 @@ enum class MaximizeMode : uint32_t {
*/
class AvoidArea : public Parcelable {
public:
Rect topRect_ { 0, 0, 0, 0 };
Rect leftRect_ { 0, 0, 0, 0 };
Rect topRect_ { 0, 0, 0, 0 };
Rect rightRect_ { 0, 0, 0, 0 };
Rect bottomRect_ { 0, 0, 0, 0 };
bool operator==(const AvoidArea& a) const
{
return (leftRect_ == a.leftRect_ && topRect_ == a.topRect_ &&
return (topRect_ == a.topRect_ && leftRect_ == a.leftRect_ &&
rightRect_ == a.rightRect_ && bottomRect_ == a.bottomRect_);
}
@ -572,10 +576,10 @@ public:
return !this->operator==(a);
}
bool isEmptyAvoidArea() const
static inline bool ReadParcel(Parcel& parcel, Rect& rect)
{
return topRect_.IsUninitializedRect() && leftRect_.IsUninitializedRect() &&
rightRect_.IsUninitializedRect() && bottomRect_.IsUninitializedRect();
return parcel.ReadInt32(rect.posX_) && parcel.ReadInt32(rect.posY_) &&
parcel.ReadUint32(rect.width_) && parcel.ReadUint32(rect.height_);
}
static inline bool WriteParcel(Parcel& parcel, const Rect& rect)
@ -584,15 +588,9 @@ public:
parcel.WriteUint32(rect.width_) && parcel.WriteUint32(rect.height_);
}
static inline bool ReadParcel(Parcel& parcel, Rect& rect)
{
return parcel.ReadInt32(rect.posX_) && parcel.ReadInt32(rect.posY_) &&
parcel.ReadUint32(rect.width_) && parcel.ReadUint32(rect.height_);
}
virtual bool Marshalling(Parcel& parcel) const override
{
return (WriteParcel(parcel, leftRect_) && WriteParcel(parcel, topRect_) &&
return (WriteParcel(parcel, topRect_) && WriteParcel(parcel, leftRect_) &&
WriteParcel(parcel, rightRect_) && WriteParcel(parcel, bottomRect_));
}
@ -602,25 +600,19 @@ public:
if (avoidArea == nullptr) {
return nullptr;
}
if (ReadParcel(parcel, avoidArea->leftRect_) && ReadParcel(parcel, avoidArea->topRect_) &&
if (ReadParcel(parcel, avoidArea->topRect_) && ReadParcel(parcel, avoidArea->leftRect_) &&
ReadParcel(parcel, avoidArea->rightRect_) && ReadParcel(parcel, avoidArea->bottomRect_)) {
return avoidArea;
}
delete avoidArea;
return nullptr;
}
};
/**
* @brief Enumerates window update type.
*/
enum class WindowUpdateType : int32_t {
WINDOW_UPDATE_ADDED = 1,
WINDOW_UPDATE_REMOVED,
WINDOW_UPDATE_FOCUSED,
WINDOW_UPDATE_BOUNDS,
WINDOW_UPDATE_ACTIVE,
WINDOW_UPDATE_PROPERTY,
bool isEmptyAvoidArea() const
{
return topRect_.IsUninitializedRect() && leftRect_.IsUninitializedRect() &&
rightRect_.IsUninitializedRect() && bottomRect_.IsUninitializedRect();
}
};
using OnCallback = std::function<void(int64_t)>;
@ -634,13 +626,26 @@ struct VsyncCallback {
OnCallback onCallback;
};
/**
* @brief Enumerates window update type.
*/
enum class WindowUpdateType : int32_t {
WINDOW_UPDATE_ADDED = 1,
WINDOW_UPDATE_REMOVED,
WINDOW_UPDATE_FOCUSED,
WINDOW_UPDATE_BOUNDS,
WINDOW_UPDATE_ACTIVE,
WINDOW_UPDATE_PROPERTY
};
struct WindowLimits {
uint32_t maxWidth_;
uint32_t maxHeight_;
uint32_t minWidth_;
uint32_t maxHeight_;
uint32_t minHeight_;
float maxRatio_;
float minRatio_;
WindowLimits() : maxWidth_(UINT32_MAX), maxHeight_(UINT32_MAX), minWidth_(0), minHeight_(0), maxRatio_(FLT_MAX),
minRatio_(0.0f) {}
WindowLimits(uint32_t maxWidth, uint32_t maxHeight, uint32_t minWidth, uint32_t minHeight, float maxRatio,
@ -649,7 +654,7 @@ struct WindowLimits {
bool IsEmpty() const
{
return (maxWidth_ == 0 || minWidth_ == 0 || maxHeight_ == 0 || minHeight_ == 0);
return (maxHeight_ == 0 || minHeight_ == 0 || maxWidth_ == 0 || minWidth_ == 0);
}
};
@ -659,10 +664,10 @@ struct WindowLimits {
* @brief An area of title buttons relative to the upper right corner of the window.
*/
struct TitleButtonRect {
int32_t posX_;
int32_t posY_;
uint32_t width_;
uint32_t height_;
int32_t posX_;
int32_t posY_;
bool operator==(const TitleButtonRect& a) const
{
@ -674,16 +679,16 @@ struct TitleButtonRect {
return !this->operator==(a);
}
bool IsUninitializedRect() const
{
return (posX_ == 0 && posY_ == 0 && width_ == 0 && height_ == 0);
}
bool IsInsideOf(const TitleButtonRect& a) const
{
return (posX_ >= a.posX_ && posY_ >= a.posY_ &&
posX_ + width_ <= a.posX_ + a.width_ && posY_ + height_ <= a.posY_ + a.height_);
}
bool IsUninitializedRect() const
{
return (posX_ == 0 && posY_ == 0 && width_ == 0 && height_ == 0);
}
};
/*
@ -691,10 +696,10 @@ struct TitleButtonRect {
*/
class KeyboardAnimationConfig : public Parcelable {
public:
std::string curveType_ = "";
std::vector<float> curveParams_ = {};
uint32_t durationIn_ = 0;
uint32_t durationOut_ = 0;
std::string curveType_ = "";
std::vector<float> curveParams_ = {};
virtual bool Marshalling(Parcel& parcel) const override
{
@ -703,7 +708,11 @@ public:
}
auto paramSize = curveParams_.size();
if (paramSize == 4) { // 4: param size
if (paramSize != 4) {
if (!parcel.WriteUint32(0)) {
return false;
}
} else { // 4: param size
if (!parcel.WriteUint32(static_cast<uint32_t>(paramSize))) {
return false;
}
@ -712,10 +721,6 @@ public:
return false;
}
}
} else {
if (!parcel.WriteUint32(0)) {
return false;
}
}
if (!parcel.WriteUint32(durationIn_) || !parcel.WriteUint32(durationOut_)) {
@ -728,9 +733,9 @@ public:
{
KeyboardAnimationConfig* config = new KeyboardAnimationConfig;
config->curveType_ = parcel.ReadString();
auto paramSize = parcel.ReadUint32();
if (paramSize == 4) { // 4: param size
for (uint32_t i = 0; i < paramSize; i++) {
auto parameterSize = parcel.ReadUint32();
if (parameterSize == 4) { // 4: param size
for (uint32_t i = 0; i < parameterSize; i++) {
config->curveParams_.push_back(parcel.ReadFloat());
}
}
@ -740,19 +745,19 @@ public:
}
};
/**
* maximize layout show type
*/
enum ShowType : int32_t {
SHOW, // normally show
HIDE, // show when hover, but hide normally
FORBIDDEN // hide always
};
struct MaximizeLayoutOption {
ShowType decor = ShowType::HIDE;
ShowType dock = ShowType::HIDE;
};
/**
* maximize layout show type
*/
enum ShowType : int32_t {
SHOW, // normally show
HIDE, // show when hover, but hide normally
FORBIDDEN // hide always
};
}
}
#endif // OHOS_ROSEN_WM_COMMON_H

View File

@ -25,11 +25,6 @@ WindowOption::WindowOption(): windowTag_(WindowTag::SYSTEM_WINDOW)
AddWindowFlag(WindowFlag::WINDOW_FLAG_NEED_AVOID);
}
void WindowOption::SetWindowType(WindowType type)
{
type_ = type;
}
void WindowOption::SetWindowMode(WindowMode mode)
{
if (!WindowHelper::IsValidWindowMode(mode)) {
@ -38,6 +33,21 @@ void WindowOption::SetWindowMode(WindowMode mode)
mode_ = mode;
}
void WindowOption::SetWindowType(WindowType type)
{
type_ = type;
}
void WindowOption::SetParentId(uint32_t parentId)
{
parentId_ = parentId;
}
void WindowOption::SetDisplayId(DisplayId displayId)
{
displayId_ = displayId;
}
void WindowOption::SetFocusable(bool isFocusable)
{
focusable_ = isFocusable;
@ -48,24 +58,14 @@ void WindowOption::SetTouchable(bool isTouchable)
touchable_ = isTouchable;
}
void WindowOption::SetDisplayId(DisplayId displayId)
{
displayId_ = displayId;
}
void WindowOption::SetParentId(uint32_t parentId)
{
parentId_ = parentId;
}
void WindowOption::SetWindowName(const std::string& windowName)
{
windowName_ = windowName;
}
void WindowOption::AddWindowFlag(WindowFlag flag)
void WindowOption::SetWindowFlags(uint32_t flags)
{
flags_ |= static_cast<uint32_t>(flag);
flags_ = flags;
}
void WindowOption::RemoveWindowFlag(WindowFlag flag)
@ -73,9 +73,14 @@ void WindowOption::RemoveWindowFlag(WindowFlag flag)
flags_ &= ~(static_cast<uint32_t>(flag));
}
void WindowOption::SetWindowFlags(uint32_t flags)
void WindowOption::AddWindowFlag(WindowFlag flag)
{
flags_ = flags;
flags_ |= static_cast<uint32_t>(flag);
}
void WindowOption::SetWindowTag(WindowTag windowTag)
{
windowTag_ = windowTag;
}
void WindowOption::SetSystemBarProperty(WindowType type, const SystemBarProperty& property)
@ -85,47 +90,9 @@ void WindowOption::SetSystemBarProperty(WindowType type, const SystemBarProperty
}
}
Rect WindowOption::GetWindowRect() const
void WindowOption::SetWindowSessionType(WindowSessionType sessionType)
{
return windowRect_;
}
WindowType WindowOption::GetWindowType() const
{
return type_;
}
WindowMode WindowOption::GetWindowMode() const
{
return mode_;
}
bool WindowOption::GetFocusable() const
{
return focusable_;
}
bool WindowOption::GetTouchable() const
{
return touchable_;
}
DisplayId WindowOption::GetDisplayId() const
{
return displayId_;
}
uint32_t WindowOption::GetParentId() const
{
return parentId_;
}
const std::string& WindowOption::GetWindowName() const
{
return windowName_;
}
uint32_t WindowOption::GetWindowFlags() const
{
return flags_;
sessionType_ = sessionType;
}
void WindowOption::SetHitOffset(int32_t x, int32_t y)
@ -134,54 +101,9 @@ void WindowOption::SetHitOffset(int32_t x, int32_t y)
hitOffset_.y = y;
}
void WindowOption::SetWindowTag(WindowTag windowTag)
bool WindowOption::IsTurnScreenOn() const
{
windowTag_ = windowTag;
}
WindowTag WindowOption::GetWindowTag() const
{
return windowTag_;
}
void WindowOption::SetWindowSessionType(WindowSessionType sessionType)
{
sessionType_ = sessionType;
}
WindowSessionType WindowOption::GetWindowSessionType() const
{
return sessionType_;
}
void WindowOption::SetMainHandlerAvailable(bool isMainHandlerAvailable)
{
isMainHandlerAvailable_ = isMainHandlerAvailable;
}
bool WindowOption::GetMainHandlerAvailable() const
{
return isMainHandlerAvailable_;
}
const PointInfo& WindowOption::GetHitOffset() const
{
return hitOffset_;
}
const std::unordered_map<WindowType, SystemBarProperty>& WindowOption::GetSystemBarProperty() const
{
return sysBarPropMap_;
}
void WindowOption::SetKeepScreenOn(bool keepScreenOn)
{
keepScreenOn_ = keepScreenOn;
}
bool WindowOption::IsKeepScreenOn() const
{
return keepScreenOn_;
return turnScreenOn_;
}
void WindowOption::SetTurnScreenOn(bool turnScreenOn)
@ -189,19 +111,14 @@ void WindowOption::SetTurnScreenOn(bool turnScreenOn)
turnScreenOn_ = turnScreenOn;
}
bool WindowOption::IsTurnScreenOn() const
bool WindowOption::IsKeepScreenOn() const
{
return turnScreenOn_;
return keepScreenOn_;
}
void WindowOption::SetBrightness(float brightness)
void WindowOption::SetKeepScreenOn(bool keepScreenOn)
{
brightness_ = brightness;
}
float WindowOption::GetBrightness() const
{
return brightness_;
keepScreenOn_ = keepScreenOn;
}
void WindowOption::SetCallingWindow(uint32_t windowId)
@ -209,29 +126,19 @@ void WindowOption::SetCallingWindow(uint32_t windowId)
callingWindow_ = windowId;
}
uint32_t WindowOption::GetCallingWindow() const
{
return callingWindow_;
}
Orientation WindowOption::GetRequestedOrientation() const
{
return requestedOrientation_;
}
void WindowOption::SetRequestedOrientation(Orientation orientation)
{
requestedOrientation_ = orientation;
}
void WindowOption::SetSubWindowTitle(const std::string& subWindowTitle)
void WindowOption::SetBrightness(float brightness)
{
subWindowTitle_ = subWindowTitle;
brightness_ = brightness;
}
std::string WindowOption::GetSubWindowTitle() const
void WindowOption::SetMainHandlerAvailable(bool isMainHandlerAvailable)
{
return subWindowTitle_;
isMainHandlerAvailable_ = isMainHandlerAvailable;
}
void WindowOption::SetSubWindowDecorEnable(bool subWindowDecorEnable)
@ -239,9 +146,9 @@ void WindowOption::SetSubWindowDecorEnable(bool subWindowDecorEnable)
subWindowDecorEnable_ = subWindowDecorEnable;
}
bool WindowOption::GetSubWindowDecorEnable() const
void WindowOption::SetSubWindowTitle(const std::string& subWindowTitle)
{
return subWindowDecorEnable_;
subWindowTitle_ = subWindowTitle;
}
void WindowOption::SetOnlySupportSceneBoard(bool onlySupportSceneBoard)
@ -249,10 +156,105 @@ void WindowOption::SetOnlySupportSceneBoard(bool onlySupportSceneBoard)
onlySupportSceneBoard_ = onlySupportSceneBoard;
}
WindowMode WindowOption::GetWindowMode() const
{
return mode_;
}
WindowType WindowOption::GetWindowType() const
{
return type_;
}
Rect WindowOption::GetWindowRect() const
{
return windowRect_;
}
WindowTag WindowOption::GetWindowTag() const
{
return windowTag_;
}
uint32_t WindowOption::GetParentId() const
{
return parentId_;
}
DisplayId WindowOption::GetDisplayId() const
{
return displayId_;
}
uint32_t WindowOption::GetWindowFlags() const
{
return flags_;
}
bool WindowOption::GetTouchable() const
{
return touchable_;
}
bool WindowOption::GetFocusable() const
{
return focusable_;
}
const PointInfo& WindowOption::GetHitOffset() const
{
return hitOffset_;
}
const std::string& WindowOption::GetWindowName() const
{
return windowName_;
}
WindowSessionType WindowOption::GetWindowSessionType() const
{
return sessionType_;
}
bool WindowOption::GetMainHandlerAvailable() const
{
return isMainHandlerAvailable_;
}
const std::unordered_map<WindowType, SystemBarProperty>& WindowOption::GetSystemBarProperty() const
{
return sysBarPropMap_;
}
bool WindowOption::GetOnlySupportSceneBoard() const
{
return onlySupportSceneBoard_;
}
float WindowOption::GetBrightness() const
{
return brightness_;
}
Orientation WindowOption::GetRequestedOrientation() const
{
return requestedOrientation_;
}
uint32_t WindowOption::GetCallingWindow() const
{
return callingWindow_;
}
bool WindowOption::GetSubWindowDecorEnable() const
{
return subWindowDecorEnable_;
}
std::string WindowOption::GetSubWindowTitle() const
{
return subWindowTitle_;
}
} // namespace Rosen
} // namespace OHOS

View File

@ -34,11 +34,6 @@ public:
Rect() : left_(0), top_(0), right_(0), bottom_(0) {}
Rect(int l, int t, int r, int b) : left_(l), top_(t), right_(r), bottom_(b) {}
bool IsEmpty() const
{
return left_ >= right_ || top_ >= bottom_;
}
std::string GetRectInfo() const
{
return std::string("[" +
@ -47,6 +42,11 @@ public:
std::to_string(right_ - left_) + ", " +
std::to_string(bottom_ - top_) + "]");
}
bool IsEmpty() const
{
return left_ >= right_ || top_ >= bottom_;
}
};
std::ostream& operator<<(std::ostream& os, const Rect& r);
@ -61,19 +61,20 @@ public:
// Use different value to differentiate lhs and rhs ranges
enum Type { OPEN = 1, CLOSE = -1, VOID_OPEN = 2, VOID_CLOSE = -2 };
int y_ = 0;
Type type_ = Type::OPEN;
int left_ = 0;
int right_ = 0;
Type type_ = Type::OPEN;
Event(int y, Type type, int l, int r) : y_(y), type_(type), left_(l), right_(r) {}
};
bool EventSortByY(const Event& e1, const Event& e2);
class Range {
public:
int start_ = 0;
int end_ = 0;
Range(int s, int e) : start_(s), end_(e) {}
Range(int start, int end) : start_(start), end_(end) {}
bool operator==(const Range& r)
{
return start_ == r.start_ && end_ == r.end_;
@ -85,22 +86,27 @@ public:
int start_ = 0;
int end_ = 0;
int mid_ = 0;
int positive_count_ = 0; // used for counting current lhs ranges
int negative_count_ = 0; // used for counting current rhs ranges
Node* left_ = nullptr;
Node* right_ = nullptr;
int positive_count_ = 0; // used for counting current lhs ranges
int negative_count_ = 0; // used for counting current rhs ranges
Node(int s, int e) : start_(s), end_(e), mid_((s + e) >> 1) {}
~Node()
{
if (left_ != nullptr) {
delete left_;
left_ = nullptr;
}
if (right_ != nullptr) {
delete right_;
right_ = nullptr;
}
if (left_ != nullptr) {
delete left_;
left_ = nullptr;
}
}
inline bool IsLeaf()
{
return left_ == nullptr && right_ == nullptr;
}
// push current node [start, end] into range result, merge last range if possible
@ -114,21 +120,16 @@ public:
}
}
inline bool IsLeaf()
{
return left_ == nullptr && right_ == nullptr;
}
// update segment tree
void Update(int updateStart, int updateEnd, Event::Type type);
// get ranges where positive_count_ and negtive_count_ are both positive
void GetAndRange(std::vector<Range>& res, bool isParentNodePos, bool isParentNodeNeg);
// get ranges where positive_count_ or negtive_count_ is positive
void GetOrRange(std::vector<Range>& res, bool isParentNodePos, bool isParentNodeNeg);
// get ranges where either positive_count_ and negtive_count_ are both positive
void GetXOrRange(std::vector<Range>& res, bool isParentNodePos, bool isParentNodeNeg);
// get ranges where positive_count_ and negtive_count_ are both positive
void GetAndRange(std::vector<Range>& res, bool isParentNodePos, bool isParentNodeNeg);
// get ranges where positive_count_ is positive and negtive_count_ not
void GetSubRange(std::vector<Range>& res, bool isParentNodePos, bool isParentNodeNeg);
// get ranges where either positive_count_ and negtive_count_ are both positive
void GetXOrRange(std::vector<Range>& res, bool isParentNodePos, bool isParentNodeNeg);
};
class Region {
@ -144,44 +145,29 @@ public:
};
Region() = default;
explicit Region(Rect& r)
explicit Region(Rect& rect)
{
rects_.push_back(r);
bound_ = Rect { r };
rects_.push_back(rect);
bound_ = Rect { rect };
}
Region(const Region& reg) : rects_(reg.rects_), bound_(reg.bound_) {}
Region& operator=(const Region& reg)
Region(const Region& region) : rects_(region.rects_), bound_(region.bound_) {}
Region& operator=(const Region& region)
{
rects_ = reg.rects_;
bound_ = reg.bound_;
rects_ = region.rects_;
bound_ = region.bound_;
return *this;
}
~Region() {}
std::vector<Rect> GetRegionRects() const
{
return rects_;
}
std::vector<Rect>& GetRegionRects()
{
return rects_;
}
int GetSize() const
std::vector<Rect> GetRegionRects() const
{
return rects_.size();
}
Rect GetBound() const
{
return bound_;
}
Rect& GetBoundRef()
{
return bound_;
return rects_;
}
bool IsEmpty() const
@ -189,75 +175,90 @@ public:
return rects_.size() == 0;
}
int GetSize() const
{
return rects_.size();
}
Rect& GetBoundRef()
{
return bound_;
}
Rect GetBound() const
{
return bound_;
}
std::string GetRegionInfo() const
{
std::string info = "{ Region Size " + std::to_string(rects_.size()) + ": ";
for (auto& r : rects_) {
info.append(r.GetRectInfo());
for (auto& rect : rects_) {
info.append(rect.GetRectInfo());
}
info.append(" }");
return info;
}
inline std::vector<Rect>::const_iterator CBegin() const
{
return rects_.cbegin();
}
inline std::vector<Rect>::const_iterator CEnd() const
{
return rects_.cend();
}
inline std::vector<Rect>::iterator Begin()
{
return rects_.begin();
}
inline std::vector<Rect>::const_iterator End()
{
return rects_.end();
}
inline size_t Size() const
{
return rects_.size();
}
// bound of all region rects
void MakeBound();
inline std::vector<Rect>::const_iterator CBegin() const
{
return rects_.cbegin();
}
inline std::vector<Rect>::iterator Begin()
{
return rects_.begin();
}
inline std::vector<Rect>::const_iterator CEnd() const
{
return rects_.cend();
}
inline std::vector<Rect>::const_iterator End()
{
return rects_.end();
}
/* core Region logic operation function, the return region's rects is guaranteed no-intersection
(rect in rects_ do not intersect with each other)
*/
void RegionOp(Region& r1, Region& r2, Region& res, Region::OP op);
void RegionOpLocal(Region& r1, Region& r2, Region& res, Region::OP op);
// bound of all region rects
void MakeBound();
Region& OperationSelf(Region& r, Region::OP op);
// replace region with and result
Region& AndSelf(Region& r);
// replace region with or result
Region& OrSelf(Region& r);
// replace region with xor result
Region& XOrSelf(Region& r);
// replace region with sub result
Region& SubSelf(Region& r);
// return intersection region
Region And(Region& r);
// return merge region
Region Or(Region& r);
// return merge region subtract intersection region
Region Xor(Region& r);
// return intersection region
Region And(Region& r);
// return region belongs to Region(lhs) but not Region(rhs)
Region Sub(Region& r);
// return merge region subtract intersection region
Region Xor(Region& r);
Region& OperationSelf(Region& r, Region::OP op);
// replace region with or result
Region& OrSelf(Region& r);
// replace region with and result
Region& AndSelf(Region& r);
// replace region with sub result
Region& SubSelf(Region& r);
// replace region with xor result
Region& XOrSelf(Region& r);
private:
class Rects {
public:
std::vector<Rect> preRects;
std::vector<Rect> curRects;
int preY = 0;
int curY = 0;
std::vector<Rect> preRects;
std::vector<Rect> curRects;
};
// get ranges from segmentTree node according to logical operation type
void getRange(std::vector<Range>& ranges, Node& node, OP op);
@ -265,8 +266,8 @@ private:
void UpdateRects(Rects& r, std::vector<Range>& ranges, std::vector<int>& indexAt, Region& res);
private:
std::vector<Rect> rects_;
Rect bound_;
std::vector<Rect> rects_;
static bool _s_so_loaded_;
};
std::ostream& operator<<(std::ostream& os, const Region& r);

View File

@ -28,6 +28,29 @@ std::ostream& operator<<(std::ostream& os, const Rect& r)
return os;
}
void Node::Update(int updateStart, int updateEnd, Event::Type type)
{
if (updateStart >= updateEnd) {
return;
}
if (updateStart == start_ && updateEnd == end_) {
if (type == Event::Type::CLOSE || type == Event::Type::OPEN) {
positive_count_ += type;
} else {
negative_count_ += type;
}
} else {
if (right_ == nullptr) {
right_ = new Node { mid_, end_ };
}
if (left_ == nullptr) {
left_ = new Node { start_, mid_ };
}
left_->Update(updateStart, mid_ < updateEnd ? mid_ : updateEnd, type);
right_->Update(mid_ > updateStart ? mid_ : updateStart, updateEnd, type);
}
}
bool EventSortByY(const Event& e1, const Event& e2)
{
if (e1.y_ == e2.y_) {
@ -36,50 +59,12 @@ bool EventSortByY(const Event& e1, const Event& e2)
return e1.y_ < e2.y_;
}
void Node::Update(int updateStart, int updateEnd, Event::Type type)
{
if (updateStart >= updateEnd) {
return;
}
if (updateStart == start_ && updateEnd == end_) {
if (type == Event::Type::OPEN || type == Event::Type::CLOSE) {
positive_count_ += type;
} else {
negative_count_ += type;
}
} else {
if (left_ == nullptr) {
left_ = new Node { start_, mid_ };
}
if (right_ == nullptr) {
right_ = new Node { mid_, end_ };
}
left_->Update(updateStart, mid_ < updateEnd ? mid_ : updateEnd, type);
right_->Update(mid_ > updateStart ? mid_ : updateStart, updateEnd, type);
}
}
void Node::GetAndRange(std::vector<Range>& res, bool isParentNodePos = false, bool isParentNodeNeg = false)
{
bool isPos = isParentNodePos || (positive_count_ > 0);
bool isNeg = isParentNodeNeg || (negative_count_ > 0);
if (isPos && isNeg) {
PushRange(res);
} else {
if (left_ != nullptr) {
left_->GetAndRange(res, isPos, isNeg);
}
if (right_ != nullptr) {
right_->GetAndRange(res, isPos, isNeg);
}
}
}
void Node::GetOrRange(std::vector<Range>& res, bool isParentNodePos = false, bool isParentNodeNeg = false)
{
bool isPos = isParentNodePos || (positive_count_ > 0);
bool isNeg = isParentNodeNeg || (negative_count_ > 0);
if (isPos || isNeg) {
bool isPos = isParentNodePos || (positive_count_ > 0);
if (isNeg || isPos) {
PushRange(res);
} else {
if (left_ != nullptr) {
@ -91,29 +76,29 @@ void Node::GetOrRange(std::vector<Range>& res, bool isParentNodePos = false, boo
}
}
void Node::GetXOrRange(std::vector<Range>& res, bool isParentNodePos = false, bool isParentNodeNeg = false)
void Node::GetAndRange(std::vector<Range>& res, bool isParentNodePos = false, bool isParentNodeNeg = false)
{
bool isPos = isParentNodePos || (positive_count_ > 0);
bool isNeg = isParentNodeNeg || (negative_count_ > 0);
if (((isPos && !isNeg) || (!isPos && isNeg)) && IsLeaf()) {
bool isPos = isParentNodePos || (positive_count_ > 0);
if (isNeg && isPos) {
PushRange(res);
} else if (isPos && isNeg) {
return;
} else {
if (left_ != nullptr) {
left_->GetXOrRange(res, isPos, isNeg);
left_->GetAndRange(res, isPos, isNeg);
}
if (right_ != nullptr) {
right_->GetXOrRange(res, isPos, isNeg);
right_->GetAndRange(res, isPos, isNeg);
}
}
}
void Node::GetSubRange(std::vector<Range>& res, bool isParentNodePos = false, bool isParentNodeNeg = false)
{
bool isPos = isParentNodePos || (positive_count_ > 0);
bool isNeg = isParentNodeNeg || (negative_count_ > 0);
if (IsLeaf() && isPos && !isNeg) {
bool isPos = isParentNodePos || (positive_count_ > 0);
if (isPos && !isNeg && IsLeaf()) {
PushRange(res);
} else if (isNeg) {
return;
@ -127,16 +112,23 @@ void Node::GetSubRange(std::vector<Range>& res, bool isParentNodePos = false, bo
}
}
void MakeEnumerate(std::set<int>& ys, std::map<int, int>& indexOf, std::vector<int>& indexAt)
void Node::GetXOrRange(std::vector<Range>& res, bool isParentNodePos = false, bool isParentNodeNeg = false)
{
auto it = ys.begin();
int index = 0;
while (it != ys.end()) {
indexOf[*it] = index++;
indexAt.push_back(*it);
++it;
bool isNeg = isParentNodeNeg || (negative_count_ > 0);
bool isPos = isParentNodePos || (positive_count_ > 0);
if (((isPos && !isNeg) || (!isPos && isNeg)) && IsLeaf()) {
PushRange(res);
} else if (isNeg && isPos) {
return;
} else {
if (left_ != nullptr) {
left_->GetXOrRange(res, isPos, isNeg);
}
if (right_ != nullptr) {
right_->GetXOrRange(res, isPos, isNeg);
}
}
return;
}
void Region::getRange(std::vector<Range>& ranges, Node& node, Region::OP op)
@ -145,21 +137,33 @@ void Region::getRange(std::vector<Range>& ranges, Node& node, Region::OP op)
case Region::OP::AND:
node.GetAndRange(ranges);
break;
case Region::OP::SUB:
node.GetSubRange(ranges);
break;
case Region::OP::OR:
node.GetOrRange(ranges);
break;
case Region::OP::XOR:
node.GetXOrRange(ranges);
break;
case Region::OP::SUB:
node.GetSubRange(ranges);
break;
default:
break;
}
return;
}
void MakeEnumerate(std::set<int>& ys, std::map<int, int>& indexOf, std::vector<int>& indexAt)
{
int index = 0;
auto it = ys.begin();
while (it != ys.end()) {
indexOf[*it] = index++;
indexAt.push_back(*it);
++it;
}
return;
}
void Region::UpdateRects(Rects& r, std::vector<Range>& ranges, std::vector<int>& indexAt, Region& res)
{
uint32_t i = 0;
@ -167,8 +171,8 @@ void Region::UpdateRects(Rects& r, std::vector<Range>& ranges, std::vector<int>&
while (i < r.preRects.size() && j < ranges.size()) {
if (r.preRects[i].left_ == indexAt[ranges[j].start_] && r.preRects[i].right_ == indexAt[ranges[j].end_]) {
r.curRects.emplace_back(Rect { r.preRects[i].left_, r.preRects[i].top_, r.preRects[i].right_, r.curY });
i++;
j++;
i++;
} else if (r.preRects[i].right_ < indexAt[ranges[j].end_]) {
res.GetRegionRects().push_back(r.preRects[i]);
i++;
@ -177,6 +181,7 @@ void Region::UpdateRects(Rects& r, std::vector<Range>& ranges, std::vector<int>&
j++;
}
}
for (; j < ranges.size(); j++) {
r.curRects.emplace_back(Rect { indexAt[ranges[j].start_], r.preY, indexAt[ranges[j].end_], r.curY });
}
@ -193,46 +198,41 @@ void Region::MakeBound()
if (rects_.size()) {
bound_ = rects_[0];
for (const auto& r : rects_) {
bound_.left_ = std::min(r.left_, bound_.left_);
bound_.top_ = std::min(r.top_, bound_.top_);
bound_.left_ = std::min(r.left_, bound_.left_);
bound_.right_ = std::max(r.right_, bound_.right_);
bound_.bottom_ = std::max(r.bottom_, bound_.bottom_);
}
}
}
void Region::RegionOp(Region& r1, Region& r2, Region& res, Region::OP op)
{
RegionOpLocal(r1, r2, res, op);
}
void Region::RegionOpLocal(Region& r1, Region& r2, Region& res, Region::OP op)
{
r1.MakeBound();
r2.MakeBound();
res.GetRegionRects().clear();
std::vector<Event> events;
std::set<int> xs;
std::vector<Event> events;
for (auto& r : r1.GetRegionRects()) {
events.emplace_back(Event { r.top_, Event::Type::OPEN, r.left_, r.right_ });
events.emplace_back(Event { r.bottom_, Event::Type::CLOSE, r.left_, r.right_ });
xs.insert(r.left_);
xs.insert(r.right_);
for (auto& rect : r1.GetRegionRects()) {
events.emplace_back(Event { rect.top_, Event::Type::OPEN, rect.left_, rect.right_ });
events.emplace_back(Event { rect.bottom_, Event::Type::CLOSE, rect.left_, rect.right_ });
xs.insert(rect.left_);
xs.insert(rect.right_);
}
for (auto& r : r2.GetRegionRects()) {
events.emplace_back(Event { r.top_, Event::Type::VOID_OPEN, r.left_, r.right_ });
events.emplace_back(Event { r.bottom_, Event::Type::VOID_CLOSE, r.left_, r.right_ });
xs.insert(r.left_);
xs.insert(r.right_);
for (auto& rect : r2.GetRegionRects()) {
events.emplace_back(Event { rect.top_, Event::Type::VOID_OPEN, rect.left_, rect.right_ });
events.emplace_back(Event { rect.bottom_, Event::Type::VOID_CLOSE, rect.left_, rect.right_ });
xs.insert(rect.left_);
xs.insert(rect.right_);
}
if (events.size() == 0) {
if (events.empty()) {
return;
}
std::map<int, int> indexOf;
std::vector<int> indexAt;
std::map<int, int> indexOf;
MakeEnumerate(xs, indexOf, indexAt);
sort(events.begin(), events.end(), EventSortByY);
size_t indexOfSize = indexOf.size() > 0 ? (indexOf.size() - 1) : 0;
@ -240,22 +240,27 @@ void Region::RegionOpLocal(Region& r1, Region& r2, Region& res, Region::OP op)
std::vector<Range> ranges;
Rects r;
r.preY = events[0].y_;
r.curY = events[0].y_;
for (auto& e : events) {
r.curY = e.y_;
r.preY = events[0].y_;
for (auto& event : events) {
r.curY = event.y_;
ranges.clear();
getRange(ranges, rootNode, op);
if (r.curY > r.preY) {
UpdateRects(r, ranges, indexAt, res);
}
rootNode.Update(indexOf[e.left_], indexOf[e.right_], e.type_);
rootNode.Update(indexOf[event.left_], indexOf[event.right_], event.type_);
r.preY = r.curY;
}
copy(r.preRects.begin(), r.preRects.end(), back_inserter(res.GetRegionRects()));
res.MakeBound();
}
void Region::RegionOp(Region& r1, Region& r2, Region& res, Region::OP op)
{
RegionOpLocal(r1, r2, res, op);
}
Region& Region::OperationSelf(Region& r, Region::OP op)
{
Region r1(*this);
@ -263,33 +268,6 @@ Region& Region::OperationSelf(Region& r, Region::OP op)
return *this;
}
Region& Region::AndSelf(Region& r)
{
return OperationSelf(r, Region::OP::AND);
}
Region& Region::OrSelf(Region& r)
{
return OperationSelf(r, Region::OP::OR);
}
Region& Region::XOrSelf(Region& r)
{
return OperationSelf(r, Region::OP::XOR);
}
Region& Region::SubSelf(Region& r)
{
return OperationSelf(r, Region::OP::SUB);
}
Region Region::And(Region& r)
{
Region res;
RegionOp(*this, r, res, Region::OP::AND);
return res;
}
Region Region::Or(Region& r)
{
Region res;
@ -297,10 +275,10 @@ Region Region::Or(Region& r)
return res;
}
Region Region::Xor(Region& r)
Region Region::And(Region& r)
{
Region res;
RegionOp(*this, r, res, Region::OP::XOR);
RegionOp(*this, r, res, Region::OP::AND);
return res;
}
@ -311,12 +289,39 @@ Region Region::Sub(Region& r)
return res;
}
Region Region::Xor(Region& r)
{
Region res;
RegionOp(*this, r, res, Region::OP::XOR);
return res;
}
Region& Region::OrSelf(Region& r)
{
return OperationSelf(r, Region::OP::OR);
}
Region& Region::AndSelf(Region& r)
{
return OperationSelf(r, Region::OP::AND);
}
Region& Region::SubSelf(Region& r)
{
return OperationSelf(r, Region::OP::SUB);
}
Region& Region::XOrSelf(Region& r)
{
return OperationSelf(r, Region::OP::XOR);
}
std::ostream& operator<<(std::ostream& os, const Region& r)
{
os << "{";
os << r.GetSize() << ": ";
for (const Rect& rect : r.GetRegionRects()) {
os << rect;
for (const Rect& regionRect : r.GetRegionRects()) {
os << regionRect;
}
os << "}" << std::endl;
return os;

View File

@ -22,6 +22,7 @@
#include "session/host/include/session.h"
#include "session/host/include/system_session.h"
#include <ui/rs_surface_node.h>
#include "window_event_channel_base.h"
#include "window_helper.h"
#include "window_manager_hilog.h"
@ -30,109 +31,6 @@ using namespace testing::ext;
namespace OHOS {
namespace Rosen {
class TestWindowEventChannel : public IWindowEventChannel {
public:
WSError TransferKeyEvent(const std::shared_ptr<MMI::KeyEvent>& keyEvent) override;
WSError TransferPointerEvent(const std::shared_ptr<MMI::PointerEvent>& pointerEvent) override;
WSError TransferFocusActiveEvent(bool isFocusActive) override;
WSError TransferKeyEventForConsumed(const std::shared_ptr<MMI::KeyEvent>& keyEvent, bool& isConsumed,
bool isPreImeEvent = false) override;
WSError TransferKeyEventForConsumedAsync(const std::shared_ptr<MMI::KeyEvent>& keyEvent, bool isPreImeEvent,
const sptr<IRemoteObject>& listener) override;
WSError TransferFocusState(bool focusState) override;
WSError TransferBackpressedEventForConsumed(bool& isConsumed) override;
WSError TransferSearchElementInfo(int64_t elementId, int32_t mode, int64_t baseParent,
std::list<Accessibility::AccessibilityElementInfo>& infos) override;
WSError TransferSearchElementInfosByText(int64_t elementId, const std::string& text, int64_t baseParent,
std::list<Accessibility::AccessibilityElementInfo>& infos) override;
WSError TransferFindFocusedElementInfo(int64_t elementId, int32_t focusType, int64_t baseParent,
Accessibility::AccessibilityElementInfo& info) override;
WSError TransferFocusMoveSearch(int64_t elementId, int32_t direction, int64_t baseParent,
Accessibility::AccessibilityElementInfo& info) override;
WSError TransferExecuteAction(int64_t elementId, const std::map<std::string, std::string>& actionArguments,
int32_t action, int64_t baseParent) override;
WSError TransferAccessibilityHoverEvent(float pointX, float pointY, int32_t sourceType, int32_t eventType,
int64_t timeMs) override;
sptr<IRemoteObject> AsObject() override
{
return nullptr;
};
};
WSError TestWindowEventChannel::TransferKeyEvent(const std::shared_ptr<MMI::KeyEvent>& keyEvent)
{
return WSError::WS_OK;
}
WSError TestWindowEventChannel::TransferPointerEvent(const std::shared_ptr<MMI::PointerEvent>& pointerEvent)
{
return WSError::WS_OK;
}
WSError TestWindowEventChannel::TransferFocusActiveEvent(bool isFocusActive)
{
return WSError::WS_OK;
}
WSError TestWindowEventChannel::TransferKeyEventForConsumed(
const std::shared_ptr<MMI::KeyEvent>& keyEvent, bool& isConsumed, bool isPreImeEvent)
{
return WSError::WS_OK;
}
WSError TestWindowEventChannel::TransferKeyEventForConsumedAsync(const std::shared_ptr<MMI::KeyEvent>& keyEvent,
bool isPreImeEvent, const sptr<IRemoteObject>& listener)
{
return WSError::WS_OK;
}
WSError TestWindowEventChannel::TransferFocusState(bool foucsState)
{
return WSError::WS_OK;
}
WSError TestWindowEventChannel::TransferBackpressedEventForConsumed(bool& isConsumed)
{
return WSError::WS_OK;
}
WSError TestWindowEventChannel::TransferSearchElementInfo(int64_t elementId, int32_t mode, int64_t baseParent,
std::list<Accessibility::AccessibilityElementInfo>& infos)
{
return WSError::WS_OK;
}
WSError TestWindowEventChannel::TransferSearchElementInfosByText(int64_t elementId, const std::string& text,
int64_t baseParent, std::list<Accessibility::AccessibilityElementInfo>& infos)
{
return WSError::WS_OK;
}
WSError TestWindowEventChannel::TransferFindFocusedElementInfo(int64_t elementId, int32_t focusType, int64_t baseParent,
Accessibility::AccessibilityElementInfo& info)
{
return WSError::WS_OK;
}
WSError TestWindowEventChannel::TransferFocusMoveSearch(int64_t elementId, int32_t direction, int64_t baseParent,
Accessibility::AccessibilityElementInfo& info)
{
return WSError::WS_OK;
}
WSError TestWindowEventChannel::TransferExecuteAction(int64_t elementId,
const std::map<std::string, std::string>& actionArguments, int32_t action, int64_t baseParent)
{
return WSError::WS_OK;
}
WSError TestWindowEventChannel::TransferAccessibilityHoverEvent(float pointX, float pointY, int32_t sourceType,
int32_t eventType, int64_t timeMs)
{
return WSError::WS_OK;
}
class MainSessionTest : public testing::Test {
public:
static void SetUpTestCase();

View File

@ -29,6 +29,7 @@
#include "session_info.h"
#include "key_event.h"
#include "wm_common.h"
#include "window_event_channel_base.h"
#include "window_manager_hilog.h"
using namespace testing;
@ -41,109 +42,6 @@ const std::string UNDEFINED = "undefined";
constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_WINDOW, "WindowSessionTest"};
}
class TestWindowEventChannel : public IWindowEventChannel {
public:
WSError TransferKeyEvent(const std::shared_ptr<MMI::KeyEvent>& keyEvent) override;
WSError TransferPointerEvent(const std::shared_ptr<MMI::PointerEvent>& pointerEvent) override;
WSError TransferFocusActiveEvent(bool isFocusActive) override;
WSError TransferKeyEventForConsumed(const std::shared_ptr<MMI::KeyEvent>& keyEvent, bool& isConsumed,
bool isPreImeEvent = false) override;
WSError TransferKeyEventForConsumedAsync(const std::shared_ptr<MMI::KeyEvent>& keyEvent, bool isPreImeEvent,
const sptr<IRemoteObject>& listener) override;
WSError TransferFocusState(bool focusState) override;
WSError TransferBackpressedEventForConsumed(bool& isConsumed) override;
WSError TransferSearchElementInfo(int64_t elementId, int32_t mode, int64_t baseParent,
std::list<Accessibility::AccessibilityElementInfo>& infos) override;
WSError TransferSearchElementInfosByText(int64_t elementId, const std::string& text, int64_t baseParent,
std::list<Accessibility::AccessibilityElementInfo>& infos) override;
WSError TransferFindFocusedElementInfo(int64_t elementId, int32_t focusType, int64_t baseParent,
Accessibility::AccessibilityElementInfo& info) override;
WSError TransferFocusMoveSearch(int64_t elementId, int32_t direction, int64_t baseParent,
Accessibility::AccessibilityElementInfo& info) override;
WSError TransferExecuteAction(int64_t elementId, const std::map<std::string, std::string>& actionArguments,
int32_t action, int64_t baseParent) override;
WSError TransferAccessibilityHoverEvent(float pointX, float pointY, int32_t sourceType, int32_t eventType,
int64_t timeMs) override;
sptr<IRemoteObject> AsObject() override
{
return nullptr;
};
};
WSError TestWindowEventChannel::TransferKeyEvent(const std::shared_ptr<MMI::KeyEvent>& keyEvent)
{
return WSError::WS_OK;
}
WSError TestWindowEventChannel::TransferPointerEvent(const std::shared_ptr<MMI::PointerEvent>& pointerEvent)
{
return WSError::WS_OK;
}
WSError TestWindowEventChannel::TransferFocusActiveEvent(bool isFocusActive)
{
return WSError::WS_OK;
}
WSError TestWindowEventChannel::TransferKeyEventForConsumed(
const std::shared_ptr<MMI::KeyEvent>& keyEvent, bool& isConsumed, bool isPreImeEvent)
{
return WSError::WS_OK;
}
WSError TestWindowEventChannel::TransferKeyEventForConsumedAsync(const std::shared_ptr<MMI::KeyEvent>& keyEvent,
bool isPreImeEvent, const sptr<IRemoteObject>& listener)
{
return WSError::WS_OK;
}
WSError TestWindowEventChannel::TransferFocusState(bool foucsState)
{
return WSError::WS_OK;
}
WSError TestWindowEventChannel::TransferBackpressedEventForConsumed(bool& isConsumed)
{
return WSError::WS_OK;
}
WSError TestWindowEventChannel::TransferSearchElementInfo(int64_t elementId, int32_t mode, int64_t baseParent,
std::list<Accessibility::AccessibilityElementInfo>& infos)
{
return WSError::WS_OK;
}
WSError TestWindowEventChannel::TransferSearchElementInfosByText(int64_t elementId, const std::string& text,
int64_t baseParent, std::list<Accessibility::AccessibilityElementInfo>& infos)
{
return WSError::WS_OK;
}
WSError TestWindowEventChannel::TransferFindFocusedElementInfo(int64_t elementId, int32_t focusType, int64_t baseParent,
Accessibility::AccessibilityElementInfo& info)
{
return WSError::WS_OK;
}
WSError TestWindowEventChannel::TransferFocusMoveSearch(int64_t elementId, int32_t direction, int64_t baseParent,
Accessibility::AccessibilityElementInfo& info)
{
return WSError::WS_OK;
}
WSError TestWindowEventChannel::TransferExecuteAction(int64_t elementId,
const std::map<std::string, std::string>& actionArguments, int32_t action, int64_t baseParent)
{
return WSError::WS_OK;
}
WSError TestWindowEventChannel::TransferAccessibilityHoverEvent(float pointX, float pointY, int32_t sourceType,
int32_t eventType, int64_t timeMs)
{
return WSError::WS_OK;
}
class WindowSessionTest : public testing::Test {
public:
static void SetUpTestCase();

View File

@ -23,6 +23,7 @@
#include "session/host/include/main_session.h"
#include "session/host/include/system_session.h"
#include <ui/rs_surface_node.h>
#include "window_event_channel_base.h"
#include "window_helper.h"
#include "window_manager_hilog.h"
@ -31,109 +32,6 @@ using namespace testing::ext;
namespace OHOS {
namespace Rosen {
class TestWindowEventChannel : public IWindowEventChannel {
public:
WSError TransferKeyEvent(const std::shared_ptr<MMI::KeyEvent>& keyEvent) override;
WSError TransferPointerEvent(const std::shared_ptr<MMI::PointerEvent>& pointerEvent) override;
WSError TransferFocusActiveEvent(bool isFocusActive) override;
WSError TransferKeyEventForConsumed(const std::shared_ptr<MMI::KeyEvent>& keyEvent, bool& isConsumed,
bool isPreImeEvent = false) override;
WSError TransferKeyEventForConsumedAsync(const std::shared_ptr<MMI::KeyEvent>& keyEvent, bool isPreImeEvent,
const sptr<IRemoteObject>& listener) override;
WSError TransferFocusState(bool focusState) override;
WSError TransferBackpressedEventForConsumed(bool& isConsumed) override;
WSError TransferSearchElementInfo(int64_t elementId, int32_t mode, int64_t baseParent,
std::list<Accessibility::AccessibilityElementInfo>& infos) override;
WSError TransferSearchElementInfosByText(int64_t elementId, const std::string& text, int64_t baseParent,
std::list<Accessibility::AccessibilityElementInfo>& infos) override;
WSError TransferFindFocusedElementInfo(int64_t elementId, int32_t focusType, int64_t baseParent,
Accessibility::AccessibilityElementInfo& info) override;
WSError TransferFocusMoveSearch(int64_t elementId, int32_t direction, int64_t baseParent,
Accessibility::AccessibilityElementInfo& info) override;
WSError TransferExecuteAction(int64_t elementId, const std::map<std::string, std::string>& actionArguments,
int32_t action, int64_t baseParent) override;
WSError TransferAccessibilityHoverEvent(float pointX, float pointY, int32_t sourceType, int32_t eventType,
int64_t timeMs) override;
sptr<IRemoteObject> AsObject() override
{
return nullptr;
};
};
WSError TestWindowEventChannel::TransferKeyEvent(const std::shared_ptr<MMI::KeyEvent>& keyEvent)
{
return WSError::WS_OK;
}
WSError TestWindowEventChannel::TransferPointerEvent(const std::shared_ptr<MMI::PointerEvent>& pointerEvent)
{
return WSError::WS_OK;
}
WSError TestWindowEventChannel::TransferFocusActiveEvent(bool isFocusActive)
{
return WSError::WS_OK;
}
WSError TestWindowEventChannel::TransferKeyEventForConsumed(
const std::shared_ptr<MMI::KeyEvent>& keyEvent, bool& isConsumed, bool isPreImeEvent)
{
return WSError::WS_OK;
}
WSError TestWindowEventChannel::TransferKeyEventForConsumedAsync(const std::shared_ptr<MMI::KeyEvent>& keyEvent,
bool isPreImeEvent, const sptr<IRemoteObject>& listener)
{
return WSError::WS_OK;
}
WSError TestWindowEventChannel::TransferFocusState(bool foucsState)
{
return WSError::WS_OK;
}
WSError TestWindowEventChannel::TransferBackpressedEventForConsumed(bool& isConsumed)
{
return WSError::WS_OK;
}
WSError TestWindowEventChannel::TransferSearchElementInfo(int64_t elementId, int32_t mode, int64_t baseParent,
std::list<Accessibility::AccessibilityElementInfo>& infos)
{
return WSError::WS_OK;
}
WSError TestWindowEventChannel::TransferSearchElementInfosByText(int64_t elementId, const std::string& text,
int64_t baseParent, std::list<Accessibility::AccessibilityElementInfo>& infos)
{
return WSError::WS_OK;
}
WSError TestWindowEventChannel::TransferFindFocusedElementInfo(int64_t elementId, int32_t focusType, int64_t baseParent,
Accessibility::AccessibilityElementInfo& info)
{
return WSError::WS_OK;
}
WSError TestWindowEventChannel::TransferFocusMoveSearch(int64_t elementId, int32_t direction, int64_t baseParent,
Accessibility::AccessibilityElementInfo& info)
{
return WSError::WS_OK;
}
WSError TestWindowEventChannel::TransferExecuteAction(int64_t elementId,
const std::map<std::string, std::string>& actionArguments, int32_t action, int64_t baseParent)
{
return WSError::WS_OK;
}
WSError TestWindowEventChannel::TransferAccessibilityHoverEvent(float pointX, float pointY, int32_t sourceType,
int32_t eventType, int64_t timeMs)
{
return WSError::WS_OK;
}
class SubSessionTest : public testing::Test {
public:
static void SetUpTestCase();

View File

@ -21,6 +21,7 @@
#include "mock/mock_session_stage.h"
#include "session/host/include/session.h"
#include <ui/rs_surface_node.h>
#include "window_event_channel_base.h"
#include "window_helper.h"
#include "window_manager_hilog.h"
#include "pointer_event.h"
@ -30,109 +31,6 @@ using namespace testing::ext;
namespace OHOS {
namespace Rosen {
class TestWindowEventChannel : public IWindowEventChannel {
public:
WSError TransferKeyEvent(const std::shared_ptr<MMI::KeyEvent>& keyEvent) override;
WSError TransferPointerEvent(const std::shared_ptr<MMI::PointerEvent>& pointerEvent) override;
WSError TransferFocusActiveEvent(bool isFocusActive) override;
WSError TransferKeyEventForConsumed(const std::shared_ptr<MMI::KeyEvent>& keyEvent, bool& isConsumed,
bool isPreImeEvent = false) override;
WSError TransferKeyEventForConsumedAsync(const std::shared_ptr<MMI::KeyEvent>& keyEvent, bool isPreImeEvent,
const sptr<IRemoteObject>& listener) override;
WSError TransferFocusState(bool focusState) override;
WSError TransferBackpressedEventForConsumed(bool& isConsumed) override;
WSError TransferSearchElementInfo(int64_t elementId, int32_t mode, int64_t baseParent,
std::list<Accessibility::AccessibilityElementInfo>& infos) override;
WSError TransferSearchElementInfosByText(int64_t elementId, const std::string& text, int64_t baseParent,
std::list<Accessibility::AccessibilityElementInfo>& infos) override;
WSError TransferFindFocusedElementInfo(int64_t elementId, int32_t focusType, int64_t baseParent,
Accessibility::AccessibilityElementInfo& info) override;
WSError TransferFocusMoveSearch(int64_t elementId, int32_t direction, int64_t baseParent,
Accessibility::AccessibilityElementInfo& info) override;
WSError TransferExecuteAction(int64_t elementId, const std::map<std::string, std::string>& actionArguments,
int32_t action, int64_t baseParent) override;
WSError TransferAccessibilityHoverEvent(float pointX, float pointY, int32_t sourceType, int32_t eventType,
int64_t timeMs) override;
sptr<IRemoteObject> AsObject() override
{
return nullptr;
};
};
WSError TestWindowEventChannel::TransferKeyEvent(const std::shared_ptr<MMI::KeyEvent>& keyEvent)
{
return WSError::WS_OK;
}
WSError TestWindowEventChannel::TransferPointerEvent(const std::shared_ptr<MMI::PointerEvent>& pointerEvent)
{
return WSError::WS_OK;
}
WSError TestWindowEventChannel::TransferFocusActiveEvent(bool isFocusActive)
{
return WSError::WS_OK;
}
WSError TestWindowEventChannel::TransferKeyEventForConsumed(
const std::shared_ptr<MMI::KeyEvent>& keyEvent, bool& isConsumed, bool isPreImeEvent)
{
return WSError::WS_OK;
}
WSError TestWindowEventChannel::TransferKeyEventForConsumedAsync(const std::shared_ptr<MMI::KeyEvent>& keyEvent,
bool isPreImeEvent, const sptr<IRemoteObject>& listener)
{
return WSError::WS_OK;
}
WSError TestWindowEventChannel::TransferFocusState(bool foucsState)
{
return WSError::WS_OK;
}
WSError TestWindowEventChannel::TransferBackpressedEventForConsumed(bool& isConsumed)
{
return WSError::WS_OK;
}
WSError TestWindowEventChannel::TransferSearchElementInfo(int64_t elementId, int32_t mode, int64_t baseParent,
std::list<Accessibility::AccessibilityElementInfo>& infos)
{
return WSError::WS_OK;
}
WSError TestWindowEventChannel::TransferSearchElementInfosByText(int64_t elementId, const std::string& text,
int64_t baseParent, std::list<Accessibility::AccessibilityElementInfo>& infos)
{
return WSError::WS_OK;
}
WSError TestWindowEventChannel::TransferFindFocusedElementInfo(int64_t elementId, int32_t focusType, int64_t baseParent,
Accessibility::AccessibilityElementInfo& info)
{
return WSError::WS_OK;
}
WSError TestWindowEventChannel::TransferFocusMoveSearch(int64_t elementId, int32_t direction, int64_t baseParent,
Accessibility::AccessibilityElementInfo& info)
{
return WSError::WS_OK;
}
WSError TestWindowEventChannel::TransferExecuteAction(int64_t elementId,
const std::map<std::string, std::string>& actionArguments, int32_t action, int64_t baseParent)
{
return WSError::WS_OK;
}
WSError TestWindowEventChannel::TransferAccessibilityHoverEvent(float pointX, float pointY, int32_t sourceType,
int32_t eventType, int64_t timeMs)
{
return WSError::WS_OK;
}
class SystemSessionTest : public testing::Test {
public:
static void SetUpTestCase();

View File

@ -0,0 +1,133 @@
/*
* Copyright (c) 2024 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 OHOS_ROSEN_WINDOW_EVENT_CHANNEL_BASE_H
#define OHOS_ROSEN_WINDOW_EVENT_CHANNEL_BASE_H
#include "common/include/session_permission.h"
#include "key_event.h"
#include "session/host/include/session.h"
#include "session/host/include/system_session.h"
#include <ui/rs_surface_node.h>
#include "window_helper.h"
namespace OHOS {
namespace Rosen {
class TestWindowEventChannel : public IWindowEventChannel {
public:
WSError TransferKeyEvent(const std::shared_ptr<MMI::KeyEvent>& keyEvent) override;
WSError TransferPointerEvent(const std::shared_ptr<MMI::PointerEvent>& pointerEvent) override;
WSError TransferFocusActiveEvent(bool isFocusActive) override;
WSError TransferKeyEventForConsumed(const std::shared_ptr<MMI::KeyEvent>& keyEvent, bool& isConsumed,
bool isPreImeEvent = false) override;
WSError TransferKeyEventForConsumedAsync(const std::shared_ptr<MMI::KeyEvent>& keyEvent, bool isPreImeEvent,
const sptr<IRemoteObject>& listener) override;
WSError TransferFocusState(bool focusState) override;
WSError TransferBackpressedEventForConsumed(bool& isConsumed) override;
WSError TransferSearchElementInfo(int64_t elementId, int32_t mode, int64_t baseParent,
std::list<Accessibility::AccessibilityElementInfo>& infos) override;
WSError TransferSearchElementInfosByText(int64_t elementId, const std::string& text, int64_t baseParent,
std::list<Accessibility::AccessibilityElementInfo>& infos) override;
WSError TransferFindFocusedElementInfo(int64_t elementId, int32_t focusType, int64_t baseParent,
Accessibility::AccessibilityElementInfo& info) override;
WSError TransferFocusMoveSearch(int64_t elementId, int32_t direction, int64_t baseParent,
Accessibility::AccessibilityElementInfo& info) override;
WSError TransferExecuteAction(int64_t elementId, const std::map<std::string, std::string>& actionArguments,
int32_t action, int64_t baseParent) override;
WSError TransferAccessibilityHoverEvent(float pointX, float pointY, int32_t sourceType, int32_t eventType,
int64_t timeMs) override;
sptr<IRemoteObject> AsObject() override
{
return nullptr;
};
};
WSError TestWindowEventChannel::TransferKeyEvent(const std::shared_ptr<MMI::KeyEvent>& keyEvent)
{
return WSError::WS_OK;
}
WSError TestWindowEventChannel::TransferPointerEvent(const std::shared_ptr<MMI::PointerEvent>& pointerEvent)
{
return WSError::WS_OK;
}
WSError TestWindowEventChannel::TransferFocusActiveEvent(bool isFocusActive)
{
return WSError::WS_OK;
}
WSError TestWindowEventChannel::TransferKeyEventForConsumed(
const std::shared_ptr<MMI::KeyEvent>& keyEvent, bool& isConsumed, bool isPreImeEvent)
{
return WSError::WS_OK;
}
WSError TestWindowEventChannel::TransferKeyEventForConsumedAsync(const std::shared_ptr<MMI::KeyEvent>& keyEvent,
bool isPreImeEvent, const sptr<IRemoteObject>& listener)
{
return WSError::WS_OK;
}
WSError TestWindowEventChannel::TransferFocusState(bool foucsState)
{
return WSError::WS_OK;
}
WSError TestWindowEventChannel::TransferBackpressedEventForConsumed(bool& isConsumed)
{
return WSError::WS_OK;
}
WSError TestWindowEventChannel::TransferSearchElementInfo(int64_t elementId, int32_t mode, int64_t baseParent,
std::list<Accessibility::AccessibilityElementInfo>& infos)
{
return WSError::WS_OK;
}
WSError TestWindowEventChannel::TransferSearchElementInfosByText(int64_t elementId, const std::string& text,
int64_t baseParent, std::list<Accessibility::AccessibilityElementInfo>& infos)
{
return WSError::WS_OK;
}
WSError TestWindowEventChannel::TransferFindFocusedElementInfo(int64_t elementId, int32_t focusType, int64_t baseParent,
Accessibility::AccessibilityElementInfo& info)
{
return WSError::WS_OK;
}
WSError TestWindowEventChannel::TransferFocusMoveSearch(int64_t elementId, int32_t direction, int64_t baseParent,
Accessibility::AccessibilityElementInfo& info)
{
return WSError::WS_OK;
}
WSError TestWindowEventChannel::TransferExecuteAction(int64_t elementId,
const std::map<std::string, std::string>& actionArguments, int32_t action, int64_t baseParent)
{
return WSError::WS_OK;
}
WSError TestWindowEventChannel::TransferAccessibilityHoverEvent(float pointX, float pointY, int32_t sourceType,
int32_t eventType, int64_t timeMs)
{
return WSError::WS_OK;
}
} // namespace Rosen
} // namespace OHOS
#endif // OHOS_ROSEN_WINDOW_EVENT_CHANNEL_BASE_H

View File

@ -155,24 +155,24 @@ void WindowSceneConfigTest::TearDown()
ConfigItem WindowSceneConfigTest::ReadConfig(const std::string& xmlStr)
{
ConfigItem config;
ConfigItem cfgItem;
xmlDocPtr docPtr = xmlParseMemory(xmlStr.c_str(), xmlStr.length() + 1);
if (docPtr == nullptr) {
return config;
return cfgItem;
}
xmlNodePtr rootPtr = xmlDocGetRootElement(docPtr);
if (rootPtr == nullptr || rootPtr->name == nullptr ||
xmlStrcmp(rootPtr->name, reinterpret_cast<const xmlChar*>("Configs"))) {
xmlFreeDoc(docPtr);
return config;
return cfgItem;
}
std::map<std::string, ConfigItem> configMap;
config.SetValue(configMap);
WindowSceneConfig::ReadConfig(rootPtr, *config.mapValue_);
cfgItem.SetValue(configMap);
WindowSceneConfig::ReadConfig(rootPtr, *cfgItem.mapValue_);
xmlFreeDoc(docPtr);
return config;
return cfgItem;
}
namespace {
/**
@ -309,10 +309,10 @@ HWTEST_F(WindowSceneConfigTest, DecorConfig02, Function | SmallTest | Level2)
"</Configs>";
WindowSceneConfig::config_ = ReadConfig(xmlStr);
WindowSceneConfig::ConfigItem item = WindowSceneConfig::config_["decor"]["supportedMode"];
ASSERT_EQ(false, item.IsMap());
ASSERT_EQ(false, item.IsString());
ASSERT_EQ(true, item.IsStrings());
ASSERT_EQ(1, item.stringsValue_->size());
ASSERT_EQ(false, item.IsMap());
ASSERT_EQ(false, item.IsString());
std::vector<std::string> supportedModes;
supportedModes = *item.stringsValue_;
ASSERT_EQ("fullscreen", supportedModes[0]);

View File

@ -25,7 +25,7 @@ namespace OHOS {
namespace Rosen {
class WindowExtensionSessionImpl : public WindowSessionImpl {
public:
explicit WindowExtensionSessionImpl(const sptr<WindowOption>& option);
explicit WindowExtensionSessionImpl(const sptr<WindowOption> option);
~WindowExtensionSessionImpl();
WMError Create(const std::shared_ptr<AbilityRuntime::Context>& context,

View File

@ -105,7 +105,7 @@ class WindowImpl : public Window, AAFwk::PrepareTerminateCallbackStub {
} while (0)
public:
explicit WindowImpl(const sptr<WindowOption>& option);
explicit WindowImpl(const sptr<WindowOption> option);
~WindowImpl();
static sptr<Window> Find(const std::string& id);
@ -520,7 +520,7 @@ private:
reason == WindowSizeChangeReason::DRAG_START || reason == WindowSizeChangeReason::RECOVER ||
reason == WindowSizeChangeReason::MOVE || reason == WindowSizeChangeReason::UNDEFINED;
}
void InitWindowProperty(const sptr<WindowOption>& option);
void InitWindowProperty(const sptr<WindowOption> option);
void ClearListenersById(uint32_t winId);
void NotifySizeChange(Rect rect, WindowSizeChangeReason reason,
const std::shared_ptr<RSTransaction>& rsTransaction = nullptr);

View File

@ -43,7 +43,7 @@ const std::map<OHOS::AppExecFwk::DisplayOrientation, Orientation> ABILITY_TO_SES
class WindowSceneSessionImpl : public WindowSessionImpl {
public:
explicit WindowSceneSessionImpl(const sptr<WindowOption>& option);
explicit WindowSceneSessionImpl(const sptr<WindowOption> option);
~WindowSceneSessionImpl();
WMError Create(const std::shared_ptr<AbilityRuntime::Context>& context,
const sptr<Rosen::ISession>& iSession, const std::string& identityToken = "") override;

View File

@ -53,7 +53,7 @@ struct WindowTitleVisibleFlags {
class WindowSessionImpl : public Window, public virtual SessionStageStub {
public:
explicit WindowSessionImpl(const sptr<WindowOption>& option);
explicit WindowSessionImpl(const sptr<WindowOption> option);
~WindowSessionImpl();
void ConsumePointerEvent(const std::shared_ptr<MMI::PointerEvent>& pointerEvent) override;
void ConsumeKeyEvent(std::shared_ptr<MMI::KeyEvent>& inputEvent) override;

View File

@ -40,7 +40,7 @@ constexpr int64_t DISPATCH_KEY_EVENT_TIMEOUT_TIME_MS = 1000;
std::set<sptr<WindowSessionImpl>> WindowExtensionSessionImpl::windowExtensionSessionSet_;
std::shared_mutex WindowExtensionSessionImpl::windowExtensionSessionMutex_;
WindowExtensionSessionImpl::WindowExtensionSessionImpl(const sptr<WindowOption>& option) : WindowSessionImpl(option)
WindowExtensionSessionImpl::WindowExtensionSessionImpl(const sptr<WindowOption> option) : WindowSessionImpl(option)
{
}

View File

@ -75,7 +75,7 @@ std::recursive_mutex WindowImpl::globalMutex_;
int g_constructorCnt = 0;
int g_deConstructorCnt = 0;
bool WindowImpl::enableImmersiveMode_ = true;
WindowImpl::WindowImpl(const sptr<WindowOption>& option)
WindowImpl::WindowImpl(const sptr<WindowOption> option)
{
property_ = new (std::nothrow) WindowProperty();
if (property_ == nullptr) {
@ -114,8 +114,12 @@ WindowImpl::WindowImpl(const sptr<WindowOption>& option)
++g_constructorCnt, property_->GetWindowName().c_str());
}
void WindowImpl::InitWindowProperty(const sptr<WindowOption>& option)
void WindowImpl::InitWindowProperty(const sptr<WindowOption> option)
{
if (option == nullptr) {
TLOGE(WmsLogTag::WMS_MAIN, "Init window property failed, option is nullptr.");
return;
}
property_->SetWindowName(option->GetWindowName());
property_->SetRequestRect(option->GetWindowRect());
property_->SetWindowType(option->GetWindowType());

View File

@ -79,7 +79,7 @@ uint32_t WindowSceneSessionImpl::maxFloatingWindowSize_ = 1920;
std::mutex WindowSceneSessionImpl::keyboardPanelInfoChangeListenerMutex_;
bool WindowSceneSessionImpl::enableImmersiveMode_ = true;
WindowSceneSessionImpl::WindowSceneSessionImpl(const sptr<WindowOption>& option) : WindowSessionImpl(option)
WindowSceneSessionImpl::WindowSceneSessionImpl(const sptr<WindowOption> option) : WindowSessionImpl(option)
{
WLOGFI("[WMSCom] Constructor");
}

View File

@ -120,7 +120,7 @@ bool WindowSessionImpl::isUIExtensionAbilityProcess_ = false;
} \
} while (0)
WindowSessionImpl::WindowSessionImpl(const sptr<WindowOption>& option)
WindowSessionImpl::WindowSessionImpl(const sptr<WindowOption> option)
{
WLOGFD("[WMSCom]WindowSessionImpl");
property_ = new (std::nothrow) WindowSessionProperty();

View File

@ -111,9 +111,9 @@ void WindowManagerConfig::ReadConfig(const xmlNodePtr& rootPtr, std::map<std::st
}
std::string nodeName = reinterpret_cast<const char*>(curNodePtr->name);
if (configItemTypeMap_.count(nodeName)) {
std::map<std::string, ConfigItem> p = ReadProperty(curNodePtr);
if (p.size() > 0) {
mapValue[reinterpret_cast<const char*>(curNodePtr->name)].SetProperty(p);
std::map<std::string, ConfigItem> property = ReadProperty(curNodePtr);
if (property.size() > 0) {
mapValue[reinterpret_cast<const char*>(curNodePtr->name)].SetProperty(property);
}
switch (configItemTypeMap_.at(nodeName)) {
case ValueType::INTS: {
@ -121,19 +121,13 @@ void WindowManagerConfig::ReadConfig(const xmlNodePtr& rootPtr, std::map<std::st
mapValue[reinterpret_cast<const char*>(curNodePtr->name)].SetValue(v);
break;
}
case ValueType::POSITIVE_FLOATS: {
std::vector<float> v = ReadFloatNumbersConfigInfo(curNodePtr, false);
mapValue[reinterpret_cast<const char*>(curNodePtr->name)].SetValue(v);
break;
}
case ValueType::FLOATS: {
std::vector<float> v = ReadFloatNumbersConfigInfo(curNodePtr, true);
mapValue[reinterpret_cast<const char*>(curNodePtr->name)].SetValue(v);
break;
}
case ValueType::MAP: {
std::map<std::string, ConfigItem> v;
ReadConfig(curNodePtr, v);
case ValueType::POSITIVE_FLOATS: {
std::vector<float> v = ReadFloatNumbersConfigInfo(curNodePtr, false);
mapValue[reinterpret_cast<const char*>(curNodePtr->name)].SetValue(v);
break;
}
@ -147,6 +141,12 @@ void WindowManagerConfig::ReadConfig(const xmlNodePtr& rootPtr, std::map<std::st
mapValue[reinterpret_cast<const char*>(curNodePtr->name)].SetValue(v);
break;
}
case ValueType::MAP: {
std::map<std::string, ConfigItem> v;
ReadConfig(curNodePtr, v);
mapValue[reinterpret_cast<const char*>(curNodePtr->name)].SetValue(v);
break;
}
default:
break;
}
@ -195,20 +195,20 @@ bool WindowManagerConfig::IsValidNode(const xmlNode& currNode)
std::map<std::string, XmlConfigBase::ConfigItem> WindowManagerConfig::ReadProperty(const xmlNodePtr& currNode)
{
std::map<std::string, ConfigItem> property;
xmlChar* prop = xmlGetProp(currNode, reinterpret_cast<const xmlChar*>("enable"));
if (prop != nullptr) {
if (!xmlStrcmp(prop, reinterpret_cast<const xmlChar*>("true"))) {
xmlChar* propVal = xmlGetProp(currNode, reinterpret_cast<const xmlChar*>("enable"));
if (propVal != nullptr) {
if (!xmlStrcmp(propVal, reinterpret_cast<const xmlChar*>("true"))) {
property["enable"].SetValue(true);
} else if (!xmlStrcmp(prop, reinterpret_cast<const xmlChar*>("false"))) {
} else if (!xmlStrcmp(propVal, reinterpret_cast<const xmlChar*>("false"))) {
property["enable"].SetValue(false);
}
xmlFree(prop);
xmlFree(propVal);
}
prop = xmlGetProp(currNode, reinterpret_cast<const xmlChar*>("name"));
if (prop != nullptr) {
property["name"].SetValue(std::string(reinterpret_cast<const char*>(prop)));
xmlFree(prop);
propVal = xmlGetProp(currNode, reinterpret_cast<const xmlChar*>("name"));
if (propropValp != nullptr) {
property["name"].SetValue(std::string(reinterpret_cast<const char*>(propVal)));
xmlFree(propVal);
}
return property;
@ -283,25 +283,25 @@ void WindowManagerConfig::DumpConfig(const std::map<std::string, ConfigItem>& co
}
}
switch (conf.second.type_) {
case ValueType::INTS:
for (auto& num : *conf.second.intsValue_) {
TLOGI(WmsLogTag::DEFAULT, "[WmConfig] Num: %{public}d", num);
}
break;
case ValueType::MAP:
if (conf.second.mapValue_) {
DumpConfig(*conf.second.mapValue_);
}
break;
case ValueType::BOOL:
WLOGI("[WmConfig] %{public}u", conf.second.boolValue_);
break;
case ValueType::STRING:
WLOGI("[WmConfig] %{public}s", conf.second.stringValue_.c_str());
TLOGI(WmsLogTag::DEFAULT, "[WmConfig] %{public}s", conf.second.stringValue_.c_str());
break;
case ValueType::INTS:
for (auto& num : *conf.second.intsValue_) {
WLOGI("[WmConfig] Num: %{public}d", num);
}
case ValueType::BOOL:
TLOGI(WmsLogTag::DEFAULT, "[WmConfig] %{public}u", conf.second.boolValue_);
break;
case ValueType::FLOATS:
for (auto& num : *conf.second.floatsValue_) {
WLOGI("[WmConfig] Num: %{public}f", num);
TLOGI(WmsLogTag::DEFAULT, "[WmConfig] Num: %{public}f", num);
}
break;
default: