!270 新增onModeChange回调接口

Merge pull request !270 from leafly2021/0111
This commit is contained in:
openharmony_ci
2022-02-14 13:27:28 +00:00
committed by Gitee
4 changed files with 18 additions and 1 deletions
+1
View File
@@ -44,6 +44,7 @@ class RSSurfaceNode;
class IWindowChangeListener : virtual public RefBase {
public:
virtual void OnSizeChange(Rect rect, WindowSizeChangeReason reason) = 0;
virtual void OnModeChange(WindowMode mode) = 0;
};
class IAvoidAreaChangedListener : virtual public RefBase {
@@ -105,6 +105,11 @@ void JsWindowListener::OnSizeChange(Rect rect, WindowSizeChangeReason reason)
AsyncTask::Schedule(*engine_, std::make_unique<AsyncTask>(callback, std::move(execute), std::move(complete)));
}
void JsWindowListener::OnModeChange(WindowMode mode)
{
WLOGFI("JsWindowListener::OnModeChange is called");
}
void JsWindowListener::OnSystemBarPropertyChange(DisplayId displayId, const SystemBarRegionTints& tints)
{
std::lock_guard<std::mutex> lock(mtx_);
@@ -43,6 +43,7 @@ public:
void RemoveCallback(NativeValue* jsListenerObject);
void OnSystemBarPropertyChange(DisplayId displayId, const SystemBarRegionTints& tints) override;
void OnSizeChange(Rect rect, WindowSizeChangeReason reason) override;
void OnModeChange(WindowMode mode) override;
void OnAvoidAreaChanged(std::vector<Rect> avoidAreas) override;
private:
+11 -1
View File
@@ -262,7 +262,12 @@ WMError WindowImpl::SetWindowMode(WindowMode mode)
property_->SetWindowMode(mode);
} else if (state_ == WindowState::STATE_SHOWN) {
property_->SetWindowMode(mode);
return SingletonContainer::Get<WindowAdapter>().SetWindowMode(property_->GetWindowId(), mode);
WMError ret = SingletonContainer::Get<WindowAdapter>().SetWindowMode(property_->GetWindowId(), mode);
if (ret == WMError::WM_OK && windowChangeListener_ != nullptr) {
WLOGFE("notify window mode changed");
windowChangeListener_->OnModeChange(mode);
}
return ret;
}
if (property_->GetWindowMode() != mode) {
WLOGFE("set window mode filed! id: %{public}d", property_->GetWindowId());
@@ -730,6 +735,7 @@ void WindowImpl::RegisterLifeCycleListener(sptr<IWindowLifeCycle>& listener)
void WindowImpl::RegisterWindowChangeListener(sptr<IWindowChangeListener>& listener)
{
WLOGFE("RegisterWindowChangeListener, windowId %{public}u", GetWindowId());
windowChangeListener_ = listener;
}
@@ -797,7 +803,11 @@ void WindowImpl::UpdateRect(const struct Rect& rect, WindowSizeChangeReason reas
void WindowImpl::UpdateMode(WindowMode mode)
{
WLOGI("UpdateMode %{public}d", mode);
property_->SetWindowMode(mode);
if (windowChangeListener_ != nullptr) {
windowChangeListener_->OnModeChange(mode);
}
}
void WindowImpl::ConsumeKeyEvent(std::shared_ptr<MMI::KeyEvent>& keyEvent)