Normalized updateproperty and add Setfocusable, Settouchable for window

Signed-off-by: xiahaiqin <xiahaiqin1@huawei.com>
Change-Id: Idd36300d9bf7bbf989202cd8d6e149b3f855ffb3
This commit is contained in:
xiahaiqin
2022-03-10 17:58:09 +08:00
parent 6d26791caa
commit edfdd27618
20 changed files with 236 additions and 364 deletions
+2
View File
@@ -87,7 +87,9 @@ public:
virtual uint32_t GetWindowId() const = 0;
virtual uint32_t GetWindowFlags() const = 0;
virtual bool GetShowState() const = 0;
virtual void SetFocusable(bool isFocusable) = 0;
virtual bool GetFocusable() const = 0;
virtual void SetTouchable(bool isTouchable) = 0;
virtual bool GetTouchable() const = 0;
virtual SystemBarProperty GetSystemBarPropertyByType(WindowType type) const = 0;
virtual bool IsFullScreen() const = 0;
+9 -3
View File
@@ -27,8 +27,11 @@ namespace Rosen {
class WindowProperty : public Parcelable {
public:
WindowProperty() = default;
WindowProperty(const sptr<WindowProperty>& property);
~WindowProperty() = default;
void CopyFrom(const sptr<WindowProperty>& property);
void SetWindowName(const std::string& name);
void SetWindowRect(const struct Rect& rect);
void SetWindowHotZoneRect(const struct Rect& rect);
@@ -50,6 +53,8 @@ public:
void SetDecorEnable(bool decorEnable);
void SetHitOffset(const PointInfo& offset);
void SetAnimationFlag(uint32_t animationFlag);
void SetWindowSizeChangeReason(WindowSizeChangeReason reason);
WindowSizeChangeReason GetWindowSizeChangeReason() const;
const std::string& GetWindowName() const;
Rect GetWindowRect() const;
@@ -75,6 +80,9 @@ public:
virtual bool Marshalling(Parcel& parcel) const override;
static sptr<WindowProperty> Unmarshalling(Parcel& parcel);
private:
bool MapMarshalling(Parcel& parcel) const;
static void MapUnmarshalling(Parcel& parcel, sptr<WindowProperty>& property);
std::string windowName_;
Rect windowRect_ { 0, 0, 0, 0 };
WindowType type_ { WindowType::WINDOW_TYPE_APP_MAIN_WINDOW };
@@ -93,14 +101,12 @@ private:
uint32_t parentId_ { 0 };
PointInfo hitOffset_ { 0, 0 };
uint32_t animationFlag_ { static_cast<uint32_t>(WindowAnimation::DEFAULT) };
WindowSizeChangeReason windowSizeChangeReason_ = WindowSizeChangeReason::UNDEFINED;
std::unordered_map<WindowType, SystemBarProperty> sysBarPropMap_ {
{ WindowType::WINDOW_TYPE_STATUS_BAR, SystemBarProperty() },
{ WindowType::WINDOW_TYPE_NAVIGATION_BAR, SystemBarProperty() },
};
bool isDecorEnable_ { false };
bool MapMarshalling(Parcel& parcel) const;
static void MapUnmarshalling(Parcel& parcel, sptr<WindowProperty>& property);
};
}
}
+9
View File
@@ -55,6 +55,15 @@ enum class AvoidPosType : uint32_t {
AVOID_POS_UNKNOWN
};
enum class PropertyChangeAction : uint32_t {
ACTION_UPDATE_RECT = 1,
ACTION_UPDATE_MODE = 1 << 1,
ACTION_UPDATE_FLAGS = 1 << 2,
ACTION_UPDATE_OTHER_PROPS = 1 << 3,
ACTION_UPDATE_FOCUSABLE = 1 << 4,
ACTION_UPDATE_TOUCHABLE = 1 << 5,
};
namespace {
constexpr float DEFAULT_SPLIT_RATIO = 0.5;
constexpr uint32_t DIVIDER_WIDTH = 8;
+47
View File
@@ -19,6 +19,11 @@
namespace OHOS {
namespace Rosen {
WindowProperty::WindowProperty(const sptr<WindowProperty>& property)
{
CopyFrom(property);
}
void WindowProperty::SetWindowName(const std::string& name)
{
windowName_ = name;
@@ -115,6 +120,16 @@ void WindowProperty::SetAnimationFlag(uint32_t animationFlag)
animationFlag_ = animationFlag;
}
void WindowProperty::SetWindowSizeChangeReason(WindowSizeChangeReason reason)
{
windowSizeChangeReason_ = reason;
}
WindowSizeChangeReason WindowProperty::GetWindowSizeChangeReason() const
{
return windowSizeChangeReason_;
}
void WindowProperty::ResumeLastWindowMode()
{
mode_ = lastMode_;
@@ -353,6 +368,11 @@ bool WindowProperty::Marshalling(Parcel& parcel) const
if (!parcel.WriteUint32(animationFlag_)) {
return false;
}
// write windowSizeChangeReason_
if (!parcel.WriteUint32(static_cast<uint32_t>(windowSizeChangeReason_))) {
return false;
}
return true;
}
@@ -380,7 +400,34 @@ sptr<WindowProperty> WindowProperty::Unmarshalling(Parcel& parcel)
PointInfo offset = {parcel.ReadInt32(), parcel.ReadInt32()};
property->SetHitOffset(offset);
property->SetAnimationFlag(parcel.ReadUint32());
property->SetWindowSizeChangeReason(static_cast<WindowSizeChangeReason>(parcel.ReadUint32()));
return property;
}
void WindowProperty::CopyFrom(const sptr<WindowProperty>& property)
{
windowName_ = property->windowName_;
windowRect_ = property->windowRect_;
type_ = property->type_;
mode_ = property->mode_;
level_ = property->level_;
lastMode_ = property->lastMode_;
flags_ = property->flags_;
isFullScreen_ = property->isFullScreen_;
focusable_ = property->focusable_;
touchable_ = property->touchable_;
isPrivacyMode_ = property->isPrivacyMode_;
isTransparent_ = property->isTransparent_;
alpha_ = property->alpha_;
displayId_ = property->displayId_;
windowId_ = property->windowId_;
parentId_ = property->parentId_;
hitOffset_ = property->hitOffset_;
animationFlag_ = property->animationFlag_;
windowSizeChangeReason_ = property->windowSizeChangeReason_;
sysBarPropMap_ = property->sysBarPropMap_;
isDecorEnable_ = property->isDecorEnable_;
isDecorEnable_ = property->isDecorEnable_;
}
}
}
+1 -4
View File
@@ -41,12 +41,8 @@ public:
virtual WMError RemoveWindow(uint32_t windowId);
virtual WMError DestroyWindow(uint32_t windowId);
virtual WMError SaveAbilityToken(const sptr<IRemoteObject>& abilityToken, uint32_t windowId);
virtual WMError ResizeRect(uint32_t windowId, const Rect& rect, WindowSizeChangeReason reason);
virtual WMError RequestFocus(uint32_t windowId);
virtual WMError SetWindowFlags(uint32_t windowId, uint32_t flags);
virtual WMError SetSystemBarProperty(uint32_t windowId, WindowType type, const SystemBarProperty& property);
virtual WMError GetAvoidAreaByType(uint32_t windowId, AvoidAreaType type, std::vector<Rect>& avoidRect);
virtual WMError SetWindowMode(uint32_t windowId, WindowMode mode);
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);
@@ -54,6 +50,7 @@ public:
virtual void MinimizeAllAppWindows(DisplayId displayId);
virtual WMError MaxmizeWindow(uint32_t windowId);
virtual WMError SetWindowLayoutMode(DisplayId displayId, WindowLayoutMode mode);
virtual WMError UpdateProperty(sptr<WindowProperty>& windowProperty, PropertyChangeAction action);
virtual void RegisterWindowManagerAgent(WindowManagerAgentType type,
const sptr<IWindowManagerAgent>& windowManagerAgent);
+3
View File
@@ -62,7 +62,9 @@ public:
virtual WindowBlurLevel GetWindowBackgroundBlur() const override;
virtual float GetAlpha() const override;
virtual bool GetShowState() const override;
virtual void SetFocusable(bool isFocusable) override;
virtual bool GetFocusable() const override;
virtual void SetTouchable(bool isTouchable) override;
virtual bool GetTouchable() const override;
virtual const std::string& GetWindowName() const override;
virtual uint32_t GetWindowId() const override;
@@ -194,6 +196,7 @@ private:
bool IsPointerEventConsumed();
void AdjustWindowAnimationFlag();
void MapFloatingWindowToAppIfNeeded();
WMError UpdateProperty(PropertyChangeAction action);
// colorspace, gamut
using ColorSpaceConvertMap = struct {
ColorSpace colorSpace;
+6 -28
View File
@@ -70,13 +70,6 @@ WMError WindowAdapter::DestroyWindow(uint32_t windowId)
return windowManagerServiceProxy_->DestroyWindow(windowId);
}
WMError WindowAdapter::ResizeRect(uint32_t windowId, const Rect& rect, WindowSizeChangeReason reason)
{
INIT_PROXY_CHECK_RETURN(WMError::WM_ERROR_SAMGR);
return windowManagerServiceProxy_->ResizeRect(windowId, rect, reason);
}
WMError WindowAdapter::RequestFocus(uint32_t windowId)
{
INIT_PROXY_CHECK_RETURN(WMError::WM_ERROR_SAMGR);
@@ -84,20 +77,6 @@ WMError WindowAdapter::RequestFocus(uint32_t windowId)
return windowManagerServiceProxy_->RequestFocus(windowId);
}
WMError WindowAdapter::SetWindowFlags(uint32_t windowId, uint32_t flags)
{
INIT_PROXY_CHECK_RETURN(WMError::WM_ERROR_SAMGR);
return windowManagerServiceProxy_->SetWindowFlags(windowId, flags);
}
WMError WindowAdapter::SetSystemBarProperty(uint32_t windowId, WindowType type, const SystemBarProperty& property)
{
INIT_PROXY_CHECK_RETURN(WMError::WM_ERROR_SAMGR);
return windowManagerServiceProxy_->SetSystemBarProperty(windowId, type, property);
}
void WindowAdapter::RegisterWindowManagerAgent(WindowManagerAgentType type,
const sptr<IWindowManagerAgent>& windowManagerAgent)
{
@@ -122,13 +101,6 @@ WMError WindowAdapter::GetAvoidAreaByType(uint32_t windowId, AvoidAreaType type,
return WMError::WM_OK;
}
WMError WindowAdapter::SetWindowMode(uint32_t windowId, WindowMode mode)
{
INIT_PROXY_CHECK_RETURN(WMError::WM_ERROR_SAMGR);
return windowManagerServiceProxy_->SetWindowMode(windowId, mode);
}
WMError WindowAdapter::SetWindowBackgroundBlur(uint32_t windowId, WindowBlurLevel level)
{
INIT_PROXY_CHECK_RETURN(WMError::WM_ERROR_SAMGR);
@@ -239,6 +211,12 @@ WMError WindowAdapter::SetWindowLayoutMode(DisplayId displayId, WindowLayoutMode
return windowManagerServiceProxy_->SetWindowLayoutMode(displayId, mode);
}
WMError WindowAdapter::UpdateProperty(sptr<WindowProperty>& windowProperty, PropertyChangeAction action)
{
INIT_PROXY_CHECK_RETURN(WMError::WM_ERROR_SAMGR);
return windowManagerServiceProxy_->UpdateProperty(windowProperty, action);
}
WMError WindowAdapter::DumpWindowTree(std::vector<std::string> &windowTreeInfos, WindowDumpType type)
{
INIT_PROXY_CHECK_RETURN(WMError::WM_ERROR_SAMGR);
+30 -10
View File
@@ -190,11 +190,23 @@ bool WindowImpl::GetShowState() const
return state_ == WindowState::STATE_SHOWN;
}
void WindowImpl::SetFocusable(bool isFocusable)
{
property_->SetFocusable(isFocusable);
UpdateProperty(PropertyChangeAction::ACTION_UPDATE_FOCUSABLE);
}
bool WindowImpl::GetFocusable() const
{
return property_->GetFocusable();
}
void WindowImpl::SetTouchable(bool isTouchable)
{
property_->SetTouchable(isTouchable);
UpdateProperty(PropertyChangeAction::ACTION_UPDATE_TOUCHABLE);
}
bool WindowImpl::GetTouchable() const
{
return property_->GetTouchable();
@@ -267,7 +279,8 @@ WMError WindowImpl::SetWindowMode(WindowMode mode)
if (state_ == WindowState::STATE_CREATED || state_ == WindowState::STATE_HIDDEN) {
UpdateMode(mode);
} else if (state_ == WindowState::STATE_SHOWN) {
WMError ret = SingletonContainer::Get<WindowAdapter>().SetWindowMode(property_->GetWindowId(), mode);
property_->SetWindowMode(mode);
WMError ret = UpdateProperty(PropertyChangeAction::ACTION_UPDATE_MODE);
if (ret != WMError::WM_OK) {
return ret;
}
@@ -326,7 +339,7 @@ WMError WindowImpl::SetWindowFlags(uint32_t flags)
if (state_ == WindowState::STATE_CREATED || state_ == WindowState::STATE_HIDDEN) {
return WMError::WM_OK;
}
WMError ret = SingletonContainer::Get<WindowAdapter>().SetWindowFlags(property_->GetWindowId(), flags);
WMError ret = UpdateProperty(PropertyChangeAction::ACTION_UPDATE_FLAGS);
if (ret != WMError::WM_OK) {
WLOGFE("SetWindowFlags errCode:%{public}d winId:%{public}d",
static_cast<int32_t>(ret), property_->GetWindowId());
@@ -432,8 +445,7 @@ WMError WindowImpl::SetSystemBarProperty(WindowType type, const SystemBarPropert
if (state_ == WindowState::STATE_CREATED || state_ == WindowState::STATE_HIDDEN) {
return WMError::WM_OK;
}
WMError ret = SingletonContainer::Get<WindowAdapter>().SetSystemBarProperty(property_->GetWindowId(),
type, property);
WMError ret = UpdateProperty(PropertyChangeAction::ACTION_UPDATE_OTHER_PROPS);
if (ret != WMError::WM_OK) {
WLOGFE("SetSystemBarProperty errCode:%{public}d winId:%{public}d",
static_cast<int32_t>(ret), property_->GetWindowId());
@@ -522,6 +534,11 @@ void WindowImpl::MapFloatingWindowToAppIfNeeded()
}
}
WMError WindowImpl::UpdateProperty(PropertyChangeAction action)
{
return SingletonContainer::Get<WindowAdapter>().UpdateProperty(property_, action);
}
WMError WindowImpl::Create(const std::string& parentName, const std::shared_ptr<AbilityRuntime::Context>& context)
{
WLOGFI("[Client] Window Create");
@@ -732,8 +749,9 @@ WMError WindowImpl::MoveTo(int32_t x, int32_t y)
property_->SetWindowRect(moveRect);
return WMError::WM_OK;
}
return SingletonContainer::Get<WindowAdapter>().ResizeRect(property_->GetWindowId(),
moveRect, WindowSizeChangeReason::MOVE);
property_->SetWindowRect(moveRect);
property_->SetWindowSizeChangeReason(WindowSizeChangeReason::MOVE);
return UpdateProperty(PropertyChangeAction::ACTION_UPDATE_RECT);
}
WMError WindowImpl::Resize(uint32_t width, uint32_t height)
@@ -751,8 +769,9 @@ WMError WindowImpl::Resize(uint32_t width, uint32_t height)
property_->SetWindowRect(resizeRect);
return WMError::WM_OK;
}
return SingletonContainer::Get<WindowAdapter>().ResizeRect(property_->GetWindowId(),
resizeRect, WindowSizeChangeReason::RESIZE);
property_->SetWindowRect(resizeRect);
property_->SetWindowSizeChangeReason(WindowSizeChangeReason::RESIZE);
return UpdateProperty(PropertyChangeAction::ACTION_UPDATE_RECT);
}
WMError WindowImpl::Drag(const Rect& rect)
@@ -760,8 +779,9 @@ WMError WindowImpl::Drag(const Rect& rect)
if (!IsWindowValid()) {
return WMError::WM_ERROR_INVALID_WINDOW;
}
return SingletonContainer::Get<WindowAdapter>().ResizeRect(property_->GetWindowId(),
rect, WindowSizeChangeReason::DRAG);
property_->SetWindowRect(rect);
property_->SetWindowSizeChangeReason(WindowSizeChangeReason::DRAG);
return UpdateProperty(PropertyChangeAction::ACTION_UPDATE_RECT);
}
bool WindowImpl::IsDecorEnable() const
+1 -3
View File
@@ -32,9 +32,7 @@ public:
MOCK_METHOD2(SetWindowBackgroundBlur, WMError(uint32_t windowId, WindowBlurLevel level));
MOCK_METHOD2(SetAlpha, WMError(uint32_t windowId, float alpha));
MOCK_METHOD2(SaveAbilityToken, WMError(const sptr<IRemoteObject>& abilityToken, uint32_t windowId));
MOCK_METHOD3(SetSystemBarProperty, WMError(uint32_t windowId, WindowType type, const SystemBarProperty& property));
MOCK_METHOD3(ResizeRect, WMError(uint32_t windowId, const Rect& rect, WindowSizeChangeReason reason));
MOCK_METHOD2(SetWindowMode, WMError(uint32_t windowId, WindowMode mode));
MOCK_METHOD2(UpdateProperty, WMError(sptr<WindowProperty>& windowProperty, PropertyChangeAction action));
MOCK_METHOD1(MaxmizeWindow, WMError(uint32_t windowId));
};
}
+5 -63
View File
@@ -454,7 +454,7 @@ HWTEST_F(WindowImplTest, SetSystemBarProperty02, Function | SmallTest | Level3)
std::unique_ptr<Mocker> m = std::make_unique<Mocker>();
EXPECT_CALL(m->Mock(), AddWindow(_)).Times(1).WillOnce(Return(WMError::WM_OK));
window_->Show();
EXPECT_CALL(m->Mock(), SetSystemBarProperty(_, _, _)).Times(1).WillOnce(Return(WMError::WM_ERROR_SAMGR));
EXPECT_CALL(m->Mock(), UpdateProperty(_, _)).Times(1).WillOnce(Return(WMError::WM_ERROR_SAMGR));
WindowType type = WindowType::WINDOW_TYPE_STATUS_BAR;
const SystemBarProperty SYS_BAR_PROP(false, 0xE5222222, 0xE5333333);
ASSERT_EQ(WMError::WM_ERROR_SAMGR, window_->SetSystemBarProperty(type, SYS_BAR_PROP));
@@ -487,7 +487,7 @@ HWTEST_F(WindowImplTest, GetSystemBarPropertyByType01, Function | SmallTest | Le
std::unique_ptr<Mocker> m = std::make_unique<Mocker>();
EXPECT_CALL(m->Mock(), AddWindow(_)).Times(1).WillOnce(Return(WMError::WM_OK));
ASSERT_EQ(WMError::WM_OK, window_->Show());
EXPECT_CALL(m->Mock(), SetSystemBarProperty(_, _, _)).Times(1).WillOnce(Return(WMError::WM_OK));
EXPECT_CALL(m->Mock(), UpdateProperty(_, _)).Times(1).WillOnce(Return(WMError::WM_OK));
WindowType type = WindowType::WINDOW_TYPE_STATUS_BAR;
const SystemBarProperty SYS_BAR_PROP(false, 0xE5222222, 0xE5333344);
ASSERT_EQ(WMError::WM_OK, window_->SetSystemBarProperty(type, SYS_BAR_PROP));
@@ -506,7 +506,7 @@ HWTEST_F(WindowImplTest, GetSystemBarPropertyByType02, Function | SmallTest | Le
std::unique_ptr<Mocker> m = std::make_unique<Mocker>();
EXPECT_CALL(m->Mock(), AddWindow(_)).Times(1).WillOnce(Return(WMError::WM_OK));
window_->Show();
EXPECT_CALL(m->Mock(), SetSystemBarProperty(_, _, _)).Times(1).WillOnce(Return(WMError::WM_OK));
EXPECT_CALL(m->Mock(), UpdateProperty(_, _)).Times(1).WillOnce(Return(WMError::WM_OK));
const SystemBarProperty SYS_BAR_PROP(false, 0xE5222222, 0xE5333333);
const SystemBarProperty DEFAULT_PROP;
ASSERT_EQ(WMError::WM_OK, window_->SetSystemBarProperty(WindowType::WINDOW_TYPE_STATUS_BAR, SYS_BAR_PROP));
@@ -525,7 +525,7 @@ HWTEST_F(WindowImplTest, GetSystemBarPropertyByType03, Function | SmallTest | Le
std::unique_ptr<Mocker> m = std::make_unique<Mocker>();
EXPECT_CALL(m->Mock(), AddWindow(_)).Times(1).WillOnce(Return(WMError::WM_OK));
window_->Show();
EXPECT_CALL(m->Mock(), SetSystemBarProperty(_, _, _)).Times(1).WillOnce(Return(WMError::WM_OK));
EXPECT_CALL(m->Mock(), UpdateProperty(_, _)).Times(1).WillOnce(Return(WMError::WM_OK));
const SystemBarProperty SYS_BAR_PROP(false, 0xE5222222, 0xE5333366);
const SystemBarProperty DEFAULT_PROP;
ASSERT_EQ(WMError::WM_OK, window_->SetSystemBarProperty(WindowType::WINDOW_TYPE_STATUS_BAR, SYS_BAR_PROP));
@@ -608,7 +608,7 @@ HWTEST_F(WindowImplTest, Recover01, Function | SmallTest | Level3)
window->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW);
window->SetWindowMode(WindowMode::WINDOW_MODE_FULLSCREEN);
window->Show();
EXPECT_CALL(m->Mock(), SetWindowMode(_, _)).Times(1).WillOnce(Return(WMError::WM_OK));
EXPECT_CALL(m->Mock(), UpdateProperty(_, _)).Times(1).WillOnce(Return(WMError::WM_OK));
window->Recover();
ASSERT_EQ(WindowMode::WINDOW_MODE_FLOATING, window->GetMode());
EXPECT_CALL(m->Mock(), RemoveWindow(_)).Times(1).WillOnce(Return(WMError::WM_OK));
@@ -767,35 +767,6 @@ HWTEST_F(WindowImplTest, MoveTo01, Function | SmallTest | Level3)
ASSERT_EQ(WMError::WM_OK, window->Destroy());
}
/**
* @tc.name: MoveTo02
* @tc.desc: create and show window, move mvoe window return WM_ERROR_SAMGR, test rect
* @tc.type: FUNC
*/
HWTEST_F(WindowImplTest, MoveTo02, Function | SmallTest | Level3)
{
sptr<WindowOption> option = new WindowOption();
option->SetWindowName("WindowImplTest_MoveTo02");
option->SetWindowMode(WindowMode::WINDOW_MODE_FLOATING);
Rect winRect = {10, 20, 30u, 40u}; // set window rect: 10, 20, 30, 40
option->SetWindowRect(winRect);
sptr<WindowImpl> window = new WindowImpl(option);
std::unique_ptr<Mocker> m = std::make_unique<Mocker>();
EXPECT_CALL(m->Mock(), CreateWindow(_, _, _, _)).Times(1).WillOnce(Return(WMError::WM_OK));
ASSERT_EQ(WMError::WM_OK, window->Create(""));
EXPECT_CALL(m->Mock(), AddWindow(_)).Times(1).WillOnce(Return(WMError::WM_OK));
window->Show();
ASSERT_TRUE(window->GetShowState());
EXPECT_CALL(m->Mock(), ResizeRect(_, _, _)).Times(1).WillOnce(Return(WMError::WM_ERROR_SAMGR));
const float moveRatio = 0.5;
Rect newRect = {winRect.posX_ * moveRatio, winRect.posY_ * moveRatio, winRect.width_, winRect.height_};
window->MoveTo(newRect.posX_, newRect.posY_);
ASSERT_EQ(winRect, window->GetRect());
EXPECT_CALL(m->Mock(), DestroyWindow(_)).Times(1).WillOnce(Return(WMError::WM_OK));
ASSERT_EQ(WMError::WM_OK, window->Destroy());
}
/**
* @tc.name: Resize01
* @tc.desc: create window but not show, resize window, test rect
@@ -823,35 +794,6 @@ HWTEST_F(WindowImplTest, Resize01, Function | SmallTest | Level3)
ASSERT_EQ(WMError::WM_OK, window->Destroy());
}
/**
* @tc.name: Resize02
* @tc.desc: create and show window, mock resize window return WM_ERROR_SAMGR, test rect
* @tc.type: FUNC
*/
HWTEST_F(WindowImplTest, Resize02, Function | SmallTest | Level3)
{
sptr<WindowOption> option = new WindowOption();
option->SetWindowName("WindowImplTest_Resize02");
option->SetWindowMode(WindowMode::WINDOW_MODE_FLOATING);
Rect winRect = {10, 20, 30u, 40u}; // set window rect: 10, 20, 30, 40
option->SetWindowRect(winRect);
sptr<WindowImpl> window = new WindowImpl(option);
std::unique_ptr<Mocker> m = std::make_unique<Mocker>();
EXPECT_CALL(m->Mock(), CreateWindow(_, _, _, _)).Times(1).WillOnce(Return(WMError::WM_OK));
ASSERT_EQ(WMError::WM_OK, window->Create(""));
EXPECT_CALL(m->Mock(), AddWindow(_)).Times(1).WillOnce(Return(WMError::WM_OK));
window->Show();
ASSERT_TRUE(window->GetShowState());
EXPECT_CALL(m->Mock(), ResizeRect(_, _, _)).Times(1).WillOnce(Return(WMError::WM_ERROR_SAMGR));
const float resizeRatio = 0.5;
Rect newRect = {winRect.posX_, winRect.posY_, winRect.width_ * resizeRatio, winRect.height_ * resizeRatio};
window->Resize(newRect.width_, newRect.height_);
ASSERT_EQ(winRect, window->GetRect());
EXPECT_CALL(m->Mock(), DestroyWindow(_)).Times(1).WillOnce(Return(WMError::WM_OK));
ASSERT_EQ(WMError::WM_OK, window->Destroy());
}
/**
* @tc.name: StartMove01
* @tc.desc: start move main fullscreen window, test startMoveFlag
+6 -5
View File
@@ -35,15 +35,10 @@ public:
WMError AddWindowNode(sptr<WindowProperty>& property);
WMError RemoveWindowNode(uint32_t windowId);
WMError DestroyWindow(uint32_t windowId, bool onlySelf);
WMError ResizeRect(uint32_t windowId, const Rect& rect, WindowSizeChangeReason reason);
WMError RequestFocus(uint32_t windowId);
WMError SaveAbilityToken(const sptr<IRemoteObject>& abilityToken, uint32_t windowId);
WMError SetWindowMode(uint32_t windowId, WindowMode dstMode);
WMError SetWindowBackgroundBlur(uint32_t windowId, WindowBlurLevel level);
WMError SetAlpha(uint32_t windowId, float alpha);
WMError SetWindowType(uint32_t windowId, WindowType type);
WMError SetWindowFlags(uint32_t windowId, uint32_t flags);
WMError SetSystemBarProperty(uint32_t windowId, WindowType type, const SystemBarProperty& property);
std::vector<Rect> GetAvoidAreaByType(uint32_t windowId, AvoidAreaType avoidAreaType);
WMError GetTopWindowId(uint32_t mainWinId, uint32_t& topWinId);
void NotifyDisplayStateChange(DisplayId id, DisplayStateChangeType type);
@@ -51,6 +46,7 @@ public:
void MinimizeAllAppWindows(DisplayId displayId);
WMError MaxmizeWindow(uint32_t windowId);
WMError SetWindowLayoutMode(DisplayId displayId, WindowLayoutMode mode);
WMError UpdateProperty(sptr<WindowProperty>& property, PropertyChangeAction action);
void NotifySystemBarTints();
WMError DumpWindowTree(std::vector<std::string> &windowTreeInfos, WindowDumpType type);
@@ -61,6 +57,11 @@ private:
void UpdateWindowAnimation(const sptr<WindowNode>& node);
void ProcessDisplayChange(DisplayId displayId, DisplayStateChangeType type);
void StopBootAnimationIfNeed(WindowType type) const;
WMError SetWindowType(uint32_t windowId, WindowType type);
WMError SetWindowFlags(uint32_t windowId, uint32_t flags);
WMError SetSystemBarProperty(uint32_t windowId, WindowType type, const SystemBarProperty& property);
WMError ResizeRect(uint32_t windowId, const Rect& rect, WindowSizeChangeReason reason);
WMError SetWindowMode(uint32_t windowId, WindowMode dstMode);
sptr<WindowRoot> windowRoot_;
sptr<InputWindowMonitor> inputWindowMonitor_;
+2 -13
View File
@@ -33,12 +33,7 @@ public:
TRANS_ID_ADD_WINDOW,
TRANS_ID_REMOVE_WINDOW,
TRANS_ID_DESTROY_WINDOW,
TRANS_ID_RESIZE_RECT,
TRANS_ID_REQUEST_FOCUS,
TRANS_ID_UPDATE_TYPE,
TRANS_ID_UPDATE_MODE,
TRANS_ID_UPDATE_FLAGS,
TRANS_ID_UPDATE_SYSTEM_BAR_PROPERTY,
TRANS_ID_SEND_ABILITY_TOKEN,
TRANS_ID_REGISTER_FOCUS_CHANGED_LISTENER,
TRANS_ID_UNREGISTER_FOCUS_CHANGED_LISTENER,
@@ -53,22 +48,16 @@ public:
TRANS_ID_UPDATE_LAYOUT_MODE,
TRANS_ID_MAXMIZE_WINDOW,
TRANS_ID_DUMP_WINDOW_TREE,
TRANS_ID_UPDATE_PROPERTY,
};
virtual WMError CreateWindow(sptr<IWindow>& window, sptr<WindowProperty>& property,
const std::shared_ptr<RSSurfaceNode>& surfaceNode, uint32_t& windowId) = 0;
virtual WMError AddWindow(sptr<WindowProperty>& property) = 0;
virtual WMError RemoveWindow(uint32_t windowId) = 0;
virtual WMError DestroyWindow(uint32_t windowId, bool onlySelf = false) = 0;
virtual WMError ResizeRect(uint32_t windowId, const Rect& rect, WindowSizeChangeReason reason) = 0;
virtual WMError RequestFocus(uint32_t windowId) = 0;
virtual WMError SetWindowMode(uint32_t windowId, WindowMode mode) = 0;
virtual WMError SetWindowBackgroundBlur(uint32_t windowId, WindowBlurLevel level) = 0;
virtual WMError SetAlpha(uint32_t windowId, float alpha) = 0;
virtual WMError SetWindowType(uint32_t windowId, WindowType type) = 0;
virtual WMError SetWindowFlags(uint32_t windowId, uint32_t flags) = 0;
virtual WMError SetSystemBarProperty(uint32_t windowId, WindowType type, const SystemBarProperty& prop) = 0;
virtual WMError SaveAbilityToken(const sptr<IRemoteObject>& abilityToken, uint32_t windowId) = 0;
virtual std::vector<Rect> GetAvoidAreaByType(uint32_t windowId, AvoidAreaType type) = 0;
virtual WMError GetTopWindowId(uint32_t mainWinId, uint32_t& topWinId) = 0;
@@ -76,7 +65,7 @@ public:
virtual void MinimizeAllAppWindows(DisplayId displayId) = 0;
virtual WMError MaxmizeWindow(uint32_t windowId) = 0;
virtual WMError SetWindowLayoutMode(DisplayId displayId, WindowLayoutMode mode) = 0;
virtual WMError UpdateProperty(sptr<WindowProperty>& windowProperty, PropertyChangeAction action) = 0;
virtual void RegisterWindowManagerAgent(WindowManagerAgentType type,
const sptr<IWindowManagerAgent>& windowManagerAgent) = 0;
virtual void UnregisterWindowManagerAgent(WindowManagerAgentType type,
+1 -7
View File
@@ -32,23 +32,17 @@ public:
WMError AddWindow(sptr<WindowProperty>& property) override;
WMError RemoveWindow(uint32_t windowId) override;
WMError DestroyWindow(uint32_t windowId, bool onlySelf = false) override;
WMError ResizeRect(uint32_t windowId, const Rect& rect, WindowSizeChangeReason reason) override;
WMError RequestFocus(uint32_t windowId) override;
WMError SaveAbilityToken(const sptr<IRemoteObject>& abilityToken, uint32_t windowId) override;
WMError SetWindowMode(uint32_t windowId, WindowMode mode) override;
WMError SetWindowBackgroundBlur(uint32_t windowId, WindowBlurLevel level) override;
WMError SetAlpha(uint32_t windowId, float alpha) override;
WMError SetWindowType(uint32_t windowId, WindowType type) override;
WMError SetWindowFlags(uint32_t windowId, uint32_t flags) override;
WMError SetSystemBarProperty(uint32_t windowId, WindowType type, const SystemBarProperty& prop) override;
std::vector<Rect> GetAvoidAreaByType(uint32_t windowId, AvoidAreaType type) override;
WMError GetTopWindowId(uint32_t mainWinId, uint32_t& topWinId) override;
void ProcessWindowTouchedEvent(uint32_t windowId) override;
void MinimizeAllAppWindows(DisplayId displayId) override;
WMError MaxmizeWindow(uint32_t windowId) override;
WMError SetWindowLayoutMode(DisplayId displayId, WindowLayoutMode mode) override;
WMError UpdateProperty(sptr<WindowProperty>& windowProperty, PropertyChangeAction action) override;
void RegisterWindowManagerAgent(WindowManagerAgentType type,
const sptr<IWindowManagerAgent>& windowManagerAgent) override;
+1 -7
View File
@@ -52,23 +52,17 @@ public:
WMError AddWindow(sptr<WindowProperty>& property) override;
WMError RemoveWindow(uint32_t windowId) override;
WMError DestroyWindow(uint32_t windowId, bool onlySelf = false) override;
WMError ResizeRect(uint32_t windowId, const Rect& rect, WindowSizeChangeReason reason) override;
WMError RequestFocus(uint32_t windowId) override;
WMError SaveAbilityToken(const sptr<IRemoteObject>& abilityToken, uint32_t windowId) override;
WMError SetWindowMode(uint32_t windowId, WindowMode mode) override;
WMError SetWindowBackgroundBlur(uint32_t windowId, WindowBlurLevel level) override;
WMError SetAlpha(uint32_t windowId, float alpha) override;
WMError SetWindowType(uint32_t windowId, WindowType type) override;
WMError SetWindowFlags(uint32_t windowId, uint32_t flags) override;
WMError SetSystemBarProperty(uint32_t windowId, WindowType type, const SystemBarProperty& prop) override;
std::vector<Rect> GetAvoidAreaByType(uint32_t windowId, AvoidAreaType avoidAreaType) override;
void ProcessWindowTouchedEvent(uint32_t windowId) override;
WMError GetTopWindowId(uint32_t mainWinId, uint32_t& topWinId) override;
void MinimizeAllAppWindows(DisplayId displayId) override;
WMError MaxmizeWindow(uint32_t windowId) override;
WMError SetWindowLayoutMode(DisplayId displayId, WindowLayoutMode mode) override;
WMError UpdateProperty(sptr<WindowProperty>& windowProperty, PropertyChangeAction action) override;
void RegisterWindowManagerAgent(WindowManagerAgentType type,
const sptr<IWindowManagerAgent>& windowManagerAgent) override;
+2
View File
@@ -49,6 +49,8 @@ public:
void SetWindowMode(WindowMode mode);
void SetWindowBackgroundBlur(WindowBlurLevel level);
void SetAlpha(float alpha);
void SetFocusable(bool focusable);
void SetTouchable(bool touchable);
void SetWindowSizeChangeReason(WindowSizeChangeReason reason);
const sptr<IWindow>& GetWindowToken() const;
uint32_t GetWindowId() const;
+50 -3
View File
@@ -40,8 +40,9 @@ WMError WindowController::CreateWindow(sptr<IWindow>& window, sptr<WindowPropert
return WMError::WM_ERROR_INVALID_TYPE;
}
windowId = GenWindowId();
property->SetWindowId(windowId);
sptr<WindowNode> node = new WindowNode(property, window, surfaceNode);
sptr<WindowProperty> windowProperty = new WindowProperty(property);
windowProperty->SetWindowId(windowId);
sptr<WindowNode> node = new WindowNode(windowProperty, window, surfaceNode);
UpdateWindowAnimation(node);
return windowRoot_->SaveWindow(node);
}
@@ -64,7 +65,7 @@ WMError WindowController::AddWindowNode(sptr<WindowProperty>& property)
WLOGFE("could not find window");
return WMError::WM_ERROR_NULLPTR;
}
node->SetWindowProperty(property);
node->GetWindowProperty()->CopyFrom(property);
// Need 'check permission'
// Need 'adjust property'
@@ -471,6 +472,52 @@ WMError WindowController::SetWindowLayoutMode(DisplayId displayId, WindowLayoutM
return res;
}
WMError WindowController::UpdateProperty(sptr<WindowProperty>& property, PropertyChangeAction action)
{
if (property == nullptr) {
WLOGFE("property is invalid");
return WMError::WM_ERROR_NULLPTR;
}
uint32_t windowId = property->GetWindowId();
auto node = windowRoot_->GetWindowNode(windowId);
if (node == nullptr) {
WLOGFE("window is invalid");
return WMError::WM_ERROR_NULLPTR;
}
switch (action) {
case PropertyChangeAction::ACTION_UPDATE_RECT: {
ResizeRect(windowId, property->GetWindowRect(), property->GetWindowSizeChangeReason());
break;
}
case PropertyChangeAction::ACTION_UPDATE_MODE: {
SetWindowMode(windowId, property->GetWindowMode());
break;
}
case PropertyChangeAction::ACTION_UPDATE_FLAGS: {
SetWindowFlags(windowId, property->GetWindowFlags());
break;
}
case PropertyChangeAction::ACTION_UPDATE_OTHER_PROPS: {
auto& props = property->GetSystemBarProperty();
for (auto& iter : props) {
SetSystemBarProperty(windowId, iter.first, iter.second);
}
break;
}
case PropertyChangeAction::ACTION_UPDATE_FOCUSABLE: {
node->SetFocusable(property->GetFocusable());
break;
}
case PropertyChangeAction::ACTION_UPDATE_TOUCHABLE: {
node->SetTouchable(property->GetTouchable());
break;
}
default:
break;
}
return WMError::WM_OK;
}
WMError WindowController::DumpWindowTree(std::vector<std::string> &windowTreeInfos, WindowDumpType type)
{
return windowRoot_->DumpWindowTree(windowTreeInfos, type);
+28 -139
View File
@@ -128,40 +128,6 @@ WMError WindowManagerProxy::DestroyWindow(uint32_t windowId, bool /* onlySelf */
return static_cast<WMError>(ret);
}
WMError WindowManagerProxy::ResizeRect(uint32_t windowId, const Rect& rect, WindowSizeChangeReason reason)
{
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.WriteInt32(rect.posX_) && data.WriteInt32(rect.posY_) &&
data.WriteUint32(rect.width_) && data.WriteUint32(rect.height_))) {
WLOGFE("Write rect failed");
return WMError::WM_ERROR_IPC_FAILED;
}
if (!data.WriteUint32(static_cast<uint32_t>(reason))) {
WLOGFE("Write WindowSizeChangeReason failed");
return WMError::WM_ERROR_IPC_FAILED;
}
if (Remote()->SendRequest(TRANS_ID_RESIZE_RECT, data, reply, option) != ERR_NONE) {
return WMError::WM_ERROR_IPC_FAILED;
}
int32_t ret = reply.ReadInt32();
return static_cast<WMError>(ret);
}
WMError WindowManagerProxy::RequestFocus(uint32_t windowId)
{
MessageParcel data;
@@ -184,31 +150,6 @@ WMError WindowManagerProxy::RequestFocus(uint32_t windowId)
return static_cast<WMError>(ret);
}
WMError WindowManagerProxy::SetWindowMode(uint32_t windowId, WindowMode mode)
{
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.WriteUint32(static_cast<uint32_t>(mode))) {
WLOGFE("Write type failed");
return WMError::WM_ERROR_IPC_FAILED;
}
if (Remote()->SendRequest(TRANS_ID_UPDATE_MODE, data, reply, option) != ERR_NONE) {
return WMError::WM_ERROR_IPC_FAILED;
}
int32_t ret = reply.ReadInt32();
return static_cast<WMError>(ret);
}
WMError WindowManagerProxy::SetWindowBackgroundBlur(uint32_t windowId, WindowBlurLevel level)
{
MessageParcel data;
@@ -259,86 +200,6 @@ WMError WindowManagerProxy::SetAlpha(uint32_t windowId, float alpha)
return static_cast<WMError>(ret);
}
WMError WindowManagerProxy::SetWindowType(uint32_t windowId, WindowType type)
{
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.WriteUint32(static_cast<uint32_t>(type))) {
WLOGFE("Write type failed");
return WMError::WM_ERROR_IPC_FAILED;
}
if (Remote()->SendRequest(TRANS_ID_UPDATE_TYPE, data, reply, option) != ERR_NONE) {
return WMError::WM_ERROR_IPC_FAILED;
}
int32_t ret = reply.ReadInt32();
return static_cast<WMError>(ret);
}
WMError WindowManagerProxy::SetWindowFlags(uint32_t windowId, uint32_t flags)
{
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.WriteUint32(flags)) {
WLOGFE("Write type failed");
return WMError::WM_ERROR_IPC_FAILED;
}
if (Remote()->SendRequest(TRANS_ID_UPDATE_FLAGS, data, reply, option) != ERR_NONE) {
return WMError::WM_ERROR_IPC_FAILED;
}
int32_t ret = reply.ReadInt32();
return static_cast<WMError>(ret);
}
WMError WindowManagerProxy::SetSystemBarProperty(uint32_t windowId, WindowType type, const SystemBarProperty& prop)
{
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.WriteUint32(static_cast<uint32_t>(type))) {
WLOGFE("Write type failed");
return WMError::WM_ERROR_IPC_FAILED;
}
if (!(data.WriteBool(prop.enable_) && data.WriteUint32(prop.backgroundColor_) &&
data.WriteUint32(prop.contentColor_))) {
WLOGFE("Write property failed");
return WMError::WM_ERROR_IPC_FAILED;
}
if (Remote()->SendRequest(TRANS_ID_UPDATE_SYSTEM_BAR_PROPERTY, data, reply, option) != ERR_NONE) {
return WMError::WM_ERROR_IPC_FAILED;
}
int32_t ret = reply.ReadInt32();
return static_cast<WMError>(ret);
}
WMError WindowManagerProxy::SaveAbilityToken(const sptr<IRemoteObject>& abilityToken, uint32_t windowId)
{
MessageParcel data;
@@ -539,6 +400,34 @@ WMError WindowManagerProxy::SetWindowLayoutMode(DisplayId displayId, WindowLayou
return static_cast<WMError>(ret);
}
WMError WindowManagerProxy::UpdateProperty(sptr<WindowProperty>& windowProperty, PropertyChangeAction action)
{
MessageParcel data;
MessageParcel reply;
MessageOption option;
if (!data.WriteInterfaceToken(GetDescriptor())) {
WLOGFE("WriteInterfaceToken failed");
return WMError::WM_ERROR_IPC_FAILED;
}
if (!data.WriteParcelable(windowProperty.GetRefPtr())) {
WLOGFE("Write windowProperty failed");
return WMError::WM_ERROR_IPC_FAILED;
}
if (!data.WriteUint32(static_cast<uint32_t>(action))) {
WLOGFE("Write PropertyChangeAction failed");
return WMError::WM_ERROR_IPC_FAILED;
}
if (Remote()->SendRequest(TRANS_ID_UPDATE_PROPERTY, data, reply, option) != ERR_NONE) {
return WMError::WM_ERROR_IPC_FAILED;
}
int32_t ret = reply.ReadInt32();
return static_cast<WMError>(ret);
}
WMError WindowManagerProxy::GetTopWindowId(uint32_t mainWinId, uint32_t& topWinId)
{
MessageParcel data;
+16 -42
View File
@@ -162,20 +162,6 @@ WMError WindowManagerService::DestroyWindow(uint32_t windowId, bool onlySelf)
return windowController_->DestroyWindow(windowId, onlySelf);
}
WMError WindowManagerService::ResizeRect(uint32_t windowId, const Rect& rect, WindowSizeChangeReason reason)
{
WLOGFI("[WMS] ResizeRect windowId: %{public}u, reason: %{public}u, resizeRect: "
"[%{public}d, %{public}d, %{public}u, %{public}u]",
windowId, reason, rect.posX_, rect.posY_, rect.width_, rect.height_);
WM_SCOPED_TRACE("wms:ResizeRect");
std::lock_guard<std::recursive_mutex> lock(mutex_);
WMError res = windowController_->ResizeRect(windowId, rect, reason);
if (res == WMError::WM_OK && reason == WindowSizeChangeReason::MOVE) {
dragController_->UpdateDragInfo(windowId);
}
return res;
}
WMError WindowManagerService::RequestFocus(uint32_t windowId)
{
WLOGFI("[WMS] RequestFocus: %{public}u", windowId);
@@ -184,13 +170,6 @@ WMError WindowManagerService::RequestFocus(uint32_t windowId)
return windowController_->RequestFocus(windowId);
}
WMError WindowManagerService::SetWindowMode(uint32_t windowId, WindowMode mode)
{
WM_SCOPED_TRACE("wms:SetWindowMode");
std::lock_guard<std::recursive_mutex> lock(mutex_);
return windowController_->SetWindowMode(windowId, mode);
}
WMError WindowManagerService::SetWindowBackgroundBlur(uint32_t windowId, WindowBlurLevel level)
{
WM_SCOPED_TRACE("wms:SetWindowBackgroundBlur");
@@ -205,27 +184,6 @@ WMError WindowManagerService::SetAlpha(uint32_t windowId, float alpha)
return windowController_->SetAlpha(windowId, alpha);
}
WMError WindowManagerService::SetWindowType(uint32_t windowId, WindowType type)
{
WM_SCOPED_TRACE("wms:SetWindowType");
std::lock_guard<std::recursive_mutex> lock(mutex_);
return windowController_->SetWindowType(windowId, type);
}
WMError WindowManagerService::SetWindowFlags(uint32_t windowId, uint32_t flags)
{
WM_SCOPED_TRACE("wms:SetWindowFlags");
std::lock_guard<std::recursive_mutex> lock(mutex_);
return windowController_->SetWindowFlags(windowId, flags);
}
WMError WindowManagerService::SetSystemBarProperty(uint32_t windowId, WindowType type, const SystemBarProperty& prop)
{
WM_SCOPED_TRACE("wms:SetSystemBarProperty");
std::lock_guard<std::recursive_mutex> lock(mutex_);
return windowController_->SetSystemBarProperty(windowId, type, prop);
}
WMError WindowManagerService::SaveAbilityToken(const sptr<IRemoteObject>& abilityToken, uint32_t windowId)
{
WLOGFI("[WMS] SaveAbilityToken: %{public}u", windowId);
@@ -324,6 +282,22 @@ WMError WindowManagerService::SetWindowLayoutMode(DisplayId displayId, WindowLay
return windowController_->SetWindowLayoutMode(displayId, mode);
}
WMError WindowManagerService::UpdateProperty(sptr<WindowProperty>& windowProperty, PropertyChangeAction action)
{
if (windowProperty == nullptr) {
WLOGFE("property is invalid");
return WMError::WM_ERROR_NULLPTR;
}
WM_SCOPED_TRACE("wms:UpdateProperty");
std::lock_guard<std::recursive_mutex> lock(mutex_);
WMError res = windowController_->UpdateProperty(windowProperty, action);
if (action == PropertyChangeAction::ACTION_UPDATE_RECT && res == WMError::WM_OK &&
windowProperty->GetWindowSizeChangeReason() == WindowSizeChangeReason::MOVE) {
dragController_->UpdateDragInfo(windowProperty->GetWindowId());
}
return res;
}
WMError WindowManagerService::DumpWindowTree(std::vector<std::string> &windowTreeInfo, WindowDumpType type)
{
WM_SCOPED_TRACE("wms:DumpWindowTree");
+7 -37
View File
@@ -62,27 +62,12 @@ int32_t WindowManagerStub::OnRemoteRequest(uint32_t code, MessageParcel &data, M
reply.WriteInt32(static_cast<int32_t>(errCode));
break;
}
case TRANS_ID_RESIZE_RECT: {
uint32_t windowId = data.ReadUint32();
Rect rect = { data.ReadInt32(), data.ReadInt32(), data.ReadUint32(), data.ReadUint32() };
WindowSizeChangeReason reason = static_cast<WindowSizeChangeReason>(data.ReadUint32());
WMError errCode = ResizeRect(windowId, rect, reason);
reply.WriteInt32(static_cast<int32_t>(errCode));
break;
}
case TRANS_ID_REQUEST_FOCUS: {
uint32_t windowId = data.ReadUint32();
WMError errCode = RequestFocus(windowId);
reply.WriteInt32(static_cast<int32_t>(errCode));
break;
}
case TRANS_ID_UPDATE_MODE: {
uint32_t windowId = data.ReadUint32();
WindowMode mode = static_cast<WindowMode>(data.ReadUint32());
WMError errCode = SetWindowMode(windowId, mode);
reply.WriteInt32(static_cast<int32_t>(errCode));
break;
}
case TRANS_ID_SET_BACKGROUND_BLUR: {
uint32_t windowId = data.ReadUint32();
WindowBlurLevel level = static_cast<WindowBlurLevel>(data.ReadUint32());
@@ -97,28 +82,6 @@ int32_t WindowManagerStub::OnRemoteRequest(uint32_t code, MessageParcel &data, M
reply.WriteInt32(static_cast<int32_t>(errCode));
break;
}
case TRANS_ID_UPDATE_TYPE: {
uint32_t windowId = data.ReadUint32();
WindowType type = static_cast<WindowType>(data.ReadUint32());
WMError errCode = SetWindowType(windowId, type);
reply.WriteInt32(static_cast<int32_t>(errCode));
break;
}
case TRANS_ID_UPDATE_FLAGS: {
uint32_t windowId = data.ReadUint32();
uint32_t flags = data.ReadUint32();
WMError errCode = SetWindowFlags(windowId, flags);
reply.WriteInt32(static_cast<int32_t>(errCode));
break;
}
case TRANS_ID_UPDATE_SYSTEM_BAR_PROPERTY: {
uint32_t windowId = data.ReadUint32();
WindowType type = static_cast<WindowType>(data.ReadUint32());
SystemBarProperty property = { data.ReadBool(), data.ReadUint32(), data.ReadUint32() };
WMError errCode = SetSystemBarProperty(windowId, type, property);
reply.WriteInt32(static_cast<int32_t>(errCode));
break;
}
case TRANS_ID_SEND_ABILITY_TOKEN: {
sptr<IRemoteObject> abilityToken = data.ReadRemoteObject();
uint32_t windowId = data.ReadUint32();
@@ -186,6 +149,13 @@ int32_t WindowManagerStub::OnRemoteRequest(uint32_t code, MessageParcel &data, M
reply.WriteInt32(static_cast<int32_t>(errCode));
break;
}
case TRANS_ID_UPDATE_PROPERTY: {
sptr<WindowProperty> windowProperty = data.ReadStrongParcelable<WindowProperty>();
PropertyChangeAction action = static_cast<PropertyChangeAction>(data.ReadUint32());
WMError errCode = UpdateProperty(windowProperty, action);
reply.WriteInt32(static_cast<int32_t>(errCode));
break;
}
case TRANS_ID_DUMP_WINDOW_TREE: {
std::vector<std::string> windowTreeInfos;
WindowDumpType type = static_cast<WindowDumpType>(data.ReadUint32());
+10
View File
@@ -97,6 +97,16 @@ void WindowNode::SetAlpha(float alpha)
surfaceNode_->SetAlpha(alpha);
}
void WindowNode::SetFocusable(bool focusable)
{
property_->SetFocusable(focusable);
}
void WindowNode::SetTouchable(bool touchable)
{
property_->SetTouchable(touchable);
}
void WindowNode::SetWindowSizeChangeReason(WindowSizeChangeReason reason)
{
windowSizeChangeReason_ = reason;