diff --git a/interfaces/innerkits/wm/window.h b/interfaces/innerkits/wm/window.h index 1d2c9ab4..34cfaf43 100644 --- a/interfaces/innerkits/wm/window.h +++ b/interfaces/innerkits/wm/window.h @@ -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 { diff --git a/interfaces/kits/napi/window_runtime/window_napi/js_window_listener.cpp b/interfaces/kits/napi/window_runtime/window_napi/js_window_listener.cpp index 27b8cd5a..e58755e8 100644 --- a/interfaces/kits/napi/window_runtime/window_napi/js_window_listener.cpp +++ b/interfaces/kits/napi/window_runtime/window_napi/js_window_listener.cpp @@ -248,10 +248,10 @@ void JsWindowListener::OnScreenshot() *engine_, std::make_unique(callback, std::move(execute), std::move(complete))); } -void JsWindowListener::OnDialogTargetTouch() +void JsWindowListener::OnDialogTargetTouch() const { std::unique_ptr complete = std::make_unique ( - [self = wptr(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(callback, std::move(execute), std::move(complete))); } -void JsWindowListener::OnDialogDeathRecipient() +void JsWindowListener::OnDialogDeathRecipient() const { std::unique_ptr complete = std::make_unique ( - [self = wptr(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"); diff --git a/interfaces/kits/napi/window_runtime/window_napi/js_window_listener.h b/interfaces/kits/napi/window_runtime/window_napi/js_window_listener.h index ff8a4eb4..07b6246e 100644 --- a/interfaces/kits/napi/window_runtime/window_napi/js_window_listener.h +++ b/interfaces/kits/napi/window_runtime/window_napi/js_window_listener.h @@ -66,8 +66,8 @@ public: void OnSizeChange(const sptr& 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); diff --git a/wm/src/window_impl.cpp b/wm/src/window_impl.cpp index 4b4588cc..8b9e38e1 100755 --- a/wm/src/window_impl.cpp +++ b/wm/src/window_impl.cpp @@ -2519,6 +2519,7 @@ void WindowImpl::NotifyTouchOutside() void WindowImpl::NotifyTouchDialogTarget() { std::vector> dialogTargetTouchListeners; + SingletonContainer::Get().ProcessPointDown(property_->GetWindowId(), property_, moveDragProperty_); { std::lock_guard lock(mutex_); dialogTargetTouchListeners = dialogTargetTouchListeners_; diff --git a/wm/src/window_input_channel.cpp b/wm/src/window_input_channel.cpp index 7371f164..2877fe1a 100644 --- a/wm/src/window_input_channel.cpp +++ b/wm/src/window_input_channel.cpp @@ -68,8 +68,8 @@ void WindowInputChannel::HandlePointerEvent(std::shared_ptr& } 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(); diff --git a/wmserver/include/window_zorder_policy.h b/wmserver/include/window_zorder_policy.h index 10e2826e..643c035e 100644 --- a/wmserver/include/window_zorder_policy.h +++ b/wmserver/include/window_zorder_policy.h @@ -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 }, diff --git a/wmserver/src/window_node_container.cpp b/wmserver/src/window_node_container.cpp index 012d2eac..c2b5ff9d 100644 --- a/wmserver/src/window_node_container.cpp +++ b/wmserver/src/window_node_container.cpp @@ -1210,7 +1210,8 @@ WMError WindowNodeContainer::RaiseZOrderForAppWindow(sptr& 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& 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()) { diff --git a/wmserver/src/window_root.cpp b/wmserver/src/window_root.cpp index 85a03bab..4f69b26c 100644 --- a/wmserver/src/window_root.cpp +++ b/wmserver/src/window_root.cpp @@ -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& 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 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");