diff --git a/interfaces/innerkits/wm/window.h b/interfaces/innerkits/wm/window.h index b2774cd5..2ad9d407 100644 --- a/interfaces/innerkits/wm/window.h +++ b/interfaces/innerkits/wm/window.h @@ -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; diff --git a/utils/include/window_property.h b/utils/include/window_property.h index 3e635685..a26ae157 100644 --- a/utils/include/window_property.h +++ b/utils/include/window_property.h @@ -27,8 +27,11 @@ namespace Rosen { class WindowProperty : public Parcelable { public: WindowProperty() = default; + WindowProperty(const sptr& property); ~WindowProperty() = default; + void CopyFrom(const sptr& 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 Unmarshalling(Parcel& parcel); private: + bool MapMarshalling(Parcel& parcel) const; + static void MapUnmarshalling(Parcel& parcel, sptr& 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(WindowAnimation::DEFAULT) }; - + WindowSizeChangeReason windowSizeChangeReason_ = WindowSizeChangeReason::UNDEFINED; std::unordered_map 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& property); }; } } diff --git a/utils/include/wm_common_inner.h b/utils/include/wm_common_inner.h index 7a14d10b..9b8d87a8 100644 --- a/utils/include/wm_common_inner.h +++ b/utils/include/wm_common_inner.h @@ -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; diff --git a/utils/src/window_property.cpp b/utils/src/window_property.cpp index 72cdfa55..94d3aa3c 100644 --- a/utils/src/window_property.cpp +++ b/utils/src/window_property.cpp @@ -19,6 +19,11 @@ namespace OHOS { namespace Rosen { +WindowProperty::WindowProperty(const sptr& 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(windowSizeChangeReason_))) { + return false; + } return true; } @@ -380,7 +400,34 @@ sptr WindowProperty::Unmarshalling(Parcel& parcel) PointInfo offset = {parcel.ReadInt32(), parcel.ReadInt32()}; property->SetHitOffset(offset); property->SetAnimationFlag(parcel.ReadUint32()); + property->SetWindowSizeChangeReason(static_cast(parcel.ReadUint32())); return property; } + +void WindowProperty::CopyFrom(const sptr& 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_; +} } } diff --git a/wm/include/window_adapter.h b/wm/include/window_adapter.h index 31e47eb9..1b209449 100644 --- a/wm/include/window_adapter.h +++ b/wm/include/window_adapter.h @@ -41,12 +41,8 @@ public: virtual WMError RemoveWindow(uint32_t windowId); virtual WMError DestroyWindow(uint32_t windowId); virtual WMError SaveAbilityToken(const sptr& 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& 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, PropertyChangeAction action); virtual void RegisterWindowManagerAgent(WindowManagerAgentType type, const sptr& windowManagerAgent); diff --git a/wm/include/window_impl.h b/wm/include/window_impl.h index 92dce62c..43efff3a 100644 --- a/wm/include/window_impl.h +++ b/wm/include/window_impl.h @@ -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; diff --git a/wm/src/window_adapter.cpp b/wm/src/window_adapter.cpp index c0ece3e3..05ff8cb5 100644 --- a/wm/src/window_adapter.cpp +++ b/wm/src/window_adapter.cpp @@ -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& 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, PropertyChangeAction action) +{ + INIT_PROXY_CHECK_RETURN(WMError::WM_ERROR_SAMGR); + return windowManagerServiceProxy_->UpdateProperty(windowProperty, action); +} + WMError WindowAdapter::DumpWindowTree(std::vector &windowTreeInfos, WindowDumpType type) { INIT_PROXY_CHECK_RETURN(WMError::WM_ERROR_SAMGR); diff --git a/wm/src/window_impl.cpp b/wm/src/window_impl.cpp index 73d6f4a6..5f4f2e8a 100644 --- a/wm/src/window_impl.cpp +++ b/wm/src/window_impl.cpp @@ -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().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().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(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().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(ret), property_->GetWindowId()); @@ -522,6 +534,11 @@ void WindowImpl::MapFloatingWindowToAppIfNeeded() } } +WMError WindowImpl::UpdateProperty(PropertyChangeAction action) +{ + return SingletonContainer::Get().UpdateProperty(property_, action); +} + WMError WindowImpl::Create(const std::string& parentName, const std::shared_ptr& 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().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().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().ResizeRect(property_->GetWindowId(), - rect, WindowSizeChangeReason::DRAG); + property_->SetWindowRect(rect); + property_->SetWindowSizeChangeReason(WindowSizeChangeReason::DRAG); + return UpdateProperty(PropertyChangeAction::ACTION_UPDATE_RECT); } bool WindowImpl::IsDecorEnable() const diff --git a/wm/test/unittest/mock_window_adapter.h b/wm/test/unittest/mock_window_adapter.h index 2ce37163..945ad939 100644 --- a/wm/test/unittest/mock_window_adapter.h +++ b/wm/test/unittest/mock_window_adapter.h @@ -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& 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, PropertyChangeAction action)); MOCK_METHOD1(MaxmizeWindow, WMError(uint32_t windowId)); }; } diff --git a/wm/test/unittest/window_impl_test.cpp b/wm/test/unittest/window_impl_test.cpp index a0771a74..d04d47fe 100644 --- a/wm/test/unittest/window_impl_test.cpp +++ b/wm/test/unittest/window_impl_test.cpp @@ -454,7 +454,7 @@ HWTEST_F(WindowImplTest, SetSystemBarProperty02, Function | SmallTest | Level3) std::unique_ptr m = std::make_unique(); 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 m = std::make_unique(); 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 m = std::make_unique(); 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 m = std::make_unique(); 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 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 window = new WindowImpl(option); - std::unique_ptr m = std::make_unique(); - - 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 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 window = new WindowImpl(option); - std::unique_ptr m = std::make_unique(); - - 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 diff --git a/wmserver/include/window_controller.h b/wmserver/include/window_controller.h index 6dd16cc2..3132573e 100644 --- a/wmserver/include/window_controller.h +++ b/wmserver/include/window_controller.h @@ -35,15 +35,10 @@ public: WMError AddWindowNode(sptr& 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& 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 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& property, PropertyChangeAction action); void NotifySystemBarTints(); WMError DumpWindowTree(std::vector &windowTreeInfos, WindowDumpType type); @@ -61,6 +57,11 @@ private: void UpdateWindowAnimation(const sptr& 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_; sptr inputWindowMonitor_; diff --git a/wmserver/include/window_manager_interface.h b/wmserver/include/window_manager_interface.h index 9f2db875..4fb1dd5c 100644 --- a/wmserver/include/window_manager_interface.h +++ b/wmserver/include/window_manager_interface.h @@ -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& window, sptr& property, const std::shared_ptr& surfaceNode, uint32_t& windowId) = 0; virtual WMError AddWindow(sptr& 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& abilityToken, uint32_t windowId) = 0; virtual std::vector 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, PropertyChangeAction action) = 0; virtual void RegisterWindowManagerAgent(WindowManagerAgentType type, const sptr& windowManagerAgent) = 0; virtual void UnregisterWindowManagerAgent(WindowManagerAgentType type, diff --git a/wmserver/include/window_manager_proxy.h b/wmserver/include/window_manager_proxy.h index f9fb8472..3b9a2676 100644 --- a/wmserver/include/window_manager_proxy.h +++ b/wmserver/include/window_manager_proxy.h @@ -32,23 +32,17 @@ public: WMError AddWindow(sptr& 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& 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 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, PropertyChangeAction action) override; void RegisterWindowManagerAgent(WindowManagerAgentType type, const sptr& windowManagerAgent) override; diff --git a/wmserver/include/window_manager_service.h b/wmserver/include/window_manager_service.h index 8a043494..21a9310b 100644 --- a/wmserver/include/window_manager_service.h +++ b/wmserver/include/window_manager_service.h @@ -52,23 +52,17 @@ public: WMError AddWindow(sptr& 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& 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 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, PropertyChangeAction action) override; void RegisterWindowManagerAgent(WindowManagerAgentType type, const sptr& windowManagerAgent) override; diff --git a/wmserver/include/window_node.h b/wmserver/include/window_node.h index 9cf63641..4e94f46e 100644 --- a/wmserver/include/window_node.h +++ b/wmserver/include/window_node.h @@ -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& GetWindowToken() const; uint32_t GetWindowId() const; diff --git a/wmserver/src/window_controller.cpp b/wmserver/src/window_controller.cpp index bf07926c..42b905ba 100644 --- a/wmserver/src/window_controller.cpp +++ b/wmserver/src/window_controller.cpp @@ -40,8 +40,9 @@ WMError WindowController::CreateWindow(sptr& window, sptrSetWindowId(windowId); - sptr node = new WindowNode(property, window, surfaceNode); + sptr windowProperty = new WindowProperty(property); + windowProperty->SetWindowId(windowId); + sptr node = new WindowNode(windowProperty, window, surfaceNode); UpdateWindowAnimation(node); return windowRoot_->SaveWindow(node); } @@ -64,7 +65,7 @@ WMError WindowController::AddWindowNode(sptr& 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& 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 &windowTreeInfos, WindowDumpType type) { return windowRoot_->DumpWindowTree(windowTreeInfos, type); diff --git a/wmserver/src/window_manager_proxy.cpp b/wmserver/src/window_manager_proxy.cpp index 982543b3..7d1bd697 100644 --- a/wmserver/src/window_manager_proxy.cpp +++ b/wmserver/src/window_manager_proxy.cpp @@ -128,40 +128,6 @@ WMError WindowManagerProxy::DestroyWindow(uint32_t windowId, bool /* onlySelf */ return static_cast(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(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(ret); -} - WMError WindowManagerProxy::RequestFocus(uint32_t windowId) { MessageParcel data; @@ -184,31 +150,6 @@ WMError WindowManagerProxy::RequestFocus(uint32_t windowId) return static_cast(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(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(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(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(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(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(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(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(ret); -} - WMError WindowManagerProxy::SaveAbilityToken(const sptr& abilityToken, uint32_t windowId) { MessageParcel data; @@ -539,6 +400,34 @@ WMError WindowManagerProxy::SetWindowLayoutMode(DisplayId displayId, WindowLayou return static_cast(ret); } +WMError WindowManagerProxy::UpdateProperty(sptr& 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(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(ret); +} + WMError WindowManagerProxy::GetTopWindowId(uint32_t mainWinId, uint32_t& topWinId) { MessageParcel data; diff --git a/wmserver/src/window_manager_service.cpp b/wmserver/src/window_manager_service.cpp index b176df9b..fb5f0042 100644 --- a/wmserver/src/window_manager_service.cpp +++ b/wmserver/src/window_manager_service.cpp @@ -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 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 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 lock(mutex_); - return windowController_->SetWindowType(windowId, type); -} - -WMError WindowManagerService::SetWindowFlags(uint32_t windowId, uint32_t flags) -{ - WM_SCOPED_TRACE("wms:SetWindowFlags"); - std::lock_guard 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 lock(mutex_); - return windowController_->SetSystemBarProperty(windowId, type, prop); -} - WMError WindowManagerService::SaveAbilityToken(const sptr& 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, PropertyChangeAction action) +{ + if (windowProperty == nullptr) { + WLOGFE("property is invalid"); + return WMError::WM_ERROR_NULLPTR; + } + WM_SCOPED_TRACE("wms:UpdateProperty"); + std::lock_guard 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 &windowTreeInfo, WindowDumpType type) { WM_SCOPED_TRACE("wms:DumpWindowTree"); diff --git a/wmserver/src/window_manager_stub.cpp b/wmserver/src/window_manager_stub.cpp index 69d903cb..c510782d 100644 --- a/wmserver/src/window_manager_stub.cpp +++ b/wmserver/src/window_manager_stub.cpp @@ -62,27 +62,12 @@ int32_t WindowManagerStub::OnRemoteRequest(uint32_t code, MessageParcel &data, M reply.WriteInt32(static_cast(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(data.ReadUint32()); - WMError errCode = ResizeRect(windowId, rect, reason); - reply.WriteInt32(static_cast(errCode)); - break; - } case TRANS_ID_REQUEST_FOCUS: { uint32_t windowId = data.ReadUint32(); WMError errCode = RequestFocus(windowId); reply.WriteInt32(static_cast(errCode)); break; } - case TRANS_ID_UPDATE_MODE: { - uint32_t windowId = data.ReadUint32(); - WindowMode mode = static_cast(data.ReadUint32()); - WMError errCode = SetWindowMode(windowId, mode); - reply.WriteInt32(static_cast(errCode)); - break; - } case TRANS_ID_SET_BACKGROUND_BLUR: { uint32_t windowId = data.ReadUint32(); WindowBlurLevel level = static_cast(data.ReadUint32()); @@ -97,28 +82,6 @@ int32_t WindowManagerStub::OnRemoteRequest(uint32_t code, MessageParcel &data, M reply.WriteInt32(static_cast(errCode)); break; } - case TRANS_ID_UPDATE_TYPE: { - uint32_t windowId = data.ReadUint32(); - WindowType type = static_cast(data.ReadUint32()); - WMError errCode = SetWindowType(windowId, type); - reply.WriteInt32(static_cast(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(errCode)); - break; - } - case TRANS_ID_UPDATE_SYSTEM_BAR_PROPERTY: { - uint32_t windowId = data.ReadUint32(); - WindowType type = static_cast(data.ReadUint32()); - SystemBarProperty property = { data.ReadBool(), data.ReadUint32(), data.ReadUint32() }; - WMError errCode = SetSystemBarProperty(windowId, type, property); - reply.WriteInt32(static_cast(errCode)); - break; - } case TRANS_ID_SEND_ABILITY_TOKEN: { sptr 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(errCode)); break; } + case TRANS_ID_UPDATE_PROPERTY: { + sptr windowProperty = data.ReadStrongParcelable(); + PropertyChangeAction action = static_cast(data.ReadUint32()); + WMError errCode = UpdateProperty(windowProperty, action); + reply.WriteInt32(static_cast(errCode)); + break; + } case TRANS_ID_DUMP_WINDOW_TREE: { std::vector windowTreeInfos; WindowDumpType type = static_cast(data.ReadUint32()); diff --git a/wmserver/src/window_node.cpp b/wmserver/src/window_node.cpp index 7819610f..34e32918 100644 --- a/wmserver/src/window_node.cpp +++ b/wmserver/src/window_node.cpp @@ -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;