模态窗口Z序及死亡回调策略调整

Change-Id: I872ca31d54d14311bf372929e00ea9185fdbeb95
Signed-off-by: zhengjiangliang <zhengjiangliang@huawei.com>
This commit is contained in:
zhengjiangliang
2022-07-28 19:52:27 +08:00
parent f675b4e506
commit 7ac3270fc3
8 changed files with 32 additions and 13 deletions
+2 -2
View File
@@ -144,12 +144,12 @@ public:
class IDialogTargetTouchListener : virtual public RefBase {
public:
virtual void OnDialogTargetTouch() = 0;
virtual void OnDialogTargetTouch() const = 0;
};
class IDialogDeathRecipientListener : virtual public RefBase {
public:
virtual void OnDialogDeathRecipient() = 0;
virtual void OnDialogDeathRecipient() const = 0;
};
class Window : public RefBase {
@@ -248,10 +248,10 @@ void JsWindowListener::OnScreenshot()
*engine_, std::make_unique<AsyncTask>(callback, std::move(execute), std::move(complete)));
}
void JsWindowListener::OnDialogTargetTouch()
void JsWindowListener::OnDialogTargetTouch() const
{
std::unique_ptr<AsyncTask::CompleteCallback> complete = std::make_unique<AsyncTask::CompleteCallback> (
[self = wptr<JsWindowListener>(this)] (NativeEngine &engine, AsyncTask &task, int32_t status) {
[self = weakRef_] (NativeEngine &engine, AsyncTask &task, int32_t status) {
auto thisListener = self.promote();
if (thisListener == nullptr) {
WLOGFE("[NAPI]this listener is nullptr");
@@ -267,10 +267,10 @@ void JsWindowListener::OnDialogTargetTouch()
*engine_, std::make_unique<AsyncTask>(callback, std::move(execute), std::move(complete)));
}
void JsWindowListener::OnDialogDeathRecipient()
void JsWindowListener::OnDialogDeathRecipient() const
{
std::unique_ptr<AsyncTask::CompleteCallback> complete = std::make_unique<AsyncTask::CompleteCallback> (
[self = wptr<JsWindowListener>(this)] (NativeEngine &engine, AsyncTask &task, int32_t status) {
[self = weakRef_] (NativeEngine &engine, AsyncTask &task, int32_t status) {
auto thisListener = self.promote();
if (thisListener == nullptr) {
WLOGFE("[NAPI]this listener is nullptr");
@@ -66,8 +66,8 @@ public:
void OnSizeChange(const sptr<OccupiedAreaChangeInfo>& info) override;
void OnTouchOutside() const override;
void OnScreenshot() override;
void OnDialogTargetTouch() override;
void OnDialogDeathRecipient() override;
void OnDialogTargetTouch() const override;
void OnDialogDeathRecipient() const override;
void CallJsMethod(const char* methodName, NativeValue* const* argv = nullptr, size_t argc = 0);
private:
void LifeCycleCallBack(LifeCycleEventType eventType);
+1
View File
@@ -2519,6 +2519,7 @@ void WindowImpl::NotifyTouchOutside()
void WindowImpl::NotifyTouchDialogTarget()
{
std::vector<sptr<IDialogTargetTouchListener>> dialogTargetTouchListeners;
SingletonContainer::Get<WindowAdapter>().ProcessPointDown(property_->GetWindowId(), property_, moveDragProperty_);
{
std::lock_guard<std::recursive_mutex> lock(mutex_);
dialogTargetTouchListeners = dialogTargetTouchListeners_;
+2 -2
View File
@@ -68,8 +68,8 @@ void WindowInputChannel::HandlePointerEvent(std::shared_ptr<MMI::PointerEvent>&
}
if ((window_->GetType() == WindowType::WINDOW_TYPE_DIALOG) &&
(pointerEvent->GetAgentWindowId() != pointerEvent->GetTargetWindowId())) {
if (pointerEvent->GetPointerAction() == MMI::PointerEvent::POINTER_ACTION_UP ||
pointerEvent->GetPointerAction() == MMI::PointerEvent::POINTER_ACTION_BUTTON_UP) {
if (pointerEvent->GetPointerAction() == MMI::PointerEvent::POINTER_ACTION_DOWN ||
pointerEvent->GetPointerAction() == MMI::PointerEvent::POINTER_ACTION_BUTTON_DOWN) {
window_->NotifyTouchDialogTarget();
}
pointerEvent->MarkProcessed();
+1 -1
View File
@@ -43,7 +43,7 @@ private:
{ WindowType::WINDOW_TYPE_WALLPAPER, 0 },
{ WindowType::WINDOW_TYPE_DESKTOP, 1 },
{ WindowType::WINDOW_TYPE_APP_COMPONENT, 2 },
{ WindowType::WINDOW_TYPE_DIALOG, 2 },
{ WindowType::WINDOW_TYPE_DIALOG, 1 },
{ WindowType::WINDOW_TYPE_APP_LAUNCHING, 101 },
{ WindowType::WINDOW_TYPE_DOCK_SLICE, 0 },
{ WindowType::WINDOW_TYPE_PLACEHOLDER, 0 },
+3 -2
View File
@@ -1210,7 +1210,8 @@ WMError WindowNodeContainer::RaiseZOrderForAppWindow(sptr<WindowNode>& node, spt
return WMError::WM_ERROR_INVALID_TYPE;
}
if (WindowHelper::IsSubWindow(node->GetWindowType())) {
if (WindowHelper::IsSubWindow(node->GetWindowType()) ||
(node->GetWindowType() == WindowType::WINDOW_TYPE_DIALOG)) {
if (parentNode == nullptr) {
WLOGFE("window type is invalid");
return WMError::WM_ERROR_NULLPTR;
@@ -1219,7 +1220,7 @@ WMError WindowNodeContainer::RaiseZOrderForAppWindow(sptr<WindowNode>& node, spt
if (parentNode->IsSplitMode()) {
RaiseSplitRelatedWindowToTop(parentNode);
} else {
RaiseWindowToTop(node->GetParentId(), parentNode->parent_->children_); // raise parent window
RaiseWindowToTop(parentNode->GetWindowId(), parentNode->parent_->children_); // raise parent window
}
} else if (WindowHelper::IsMainWindow(node->GetWindowType())) {
if (node->IsSplitMode()) {
+17
View File
@@ -707,6 +707,11 @@ WMError WindowRoot::DestroyWindow(uint32_t windowId, bool onlySelf)
if (onlySelf) {
for (auto& child : node->children_) {
child->parent_ = nullptr;
if ((child != nullptr) && (child->GetWindowToken() != nullptr) &&
(child->abilityToken_ != token) &&
(child->GetWindowType() == WindowType::WINDOW_TYPE_DIALOG)) {
child->GetWindowToken()->NotifyDestroy();
}
}
res = container->RemoveWindowNode(node);
if (res != WMError::WM_OK) {
@@ -978,6 +983,18 @@ WMError WindowRoot::RaiseZOrderForAppWindow(sptr<WindowNode>& node)
container->RaiseSplitRelatedWindowToTop(node);
return WMError::WM_OK;
}
if (node->GetWindowType() == WindowType::WINDOW_TYPE_DIALOG) {
auto container = GetOrCreateWindowNodeContainer(node->GetDisplayId());
if (container == nullptr) {
WLOGFW("window container could not be found");
return WMError::WM_ERROR_NULLPTR;
}
sptr<WindowNode> parentNode = FindDialogCallerNode(node->GetWindowType(), node->dialogTargetToken_);
if (parentNode != nullptr) {
container->RaiseZOrderForAppWindow(node, parentNode);
}
return WMError::WM_OK;
}
if (!WindowHelper::IsAppWindow(node->GetWindowType())) {
WLOGFW("window is not app window");