diff --git a/interfaces/innerkits/wm/window.h b/interfaces/innerkits/wm/window.h index 8ed30ff621484f0083c8d9ef15d1ab26ad931518..d1ec230cdeef8f9b2ed23421580f65fd138a6854 100644 --- a/interfaces/innerkits/wm/window.h +++ b/interfaces/innerkits/wm/window.h @@ -4041,9 +4041,10 @@ public: * @brief Show keyboard window * * @param effectOption Keyboard will show with special effect option. + * @param displayId Keyboard will show on the screen with this displayId. * @return WM_OK means window show success, others means failed. */ - virtual WMError ShowKeyboard(KeyboardEffectOption effectOption) + virtual WMError ShowKeyboard(KeyboardEffectOption effectOption, uint64_t displayId = 0) { return WMError::WM_OK; } diff --git a/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session.cpp b/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session.cpp index af238015367bbde8348c4c62871e8dad9b800fef..7ae0d69f4168ab5d022215c2f24b3071f5437192 100644 --- a/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session.cpp +++ b/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session.cpp @@ -7388,25 +7388,27 @@ void JsSceneSession::ProcessKeyboardStateChangeRegister() return; } session->SetKeyboardStateChangeListener( - [weakThis = wptr(this), where = __func__](SessionState state, const KeyboardEffectOption& effectOption) { + [weakThis = wptr(this), where = __func__](SessionState state, const KeyboardEffectOption& effectOption, + uint64_t displayId) { auto jsSceneSession = weakThis.promote(); if (!jsSceneSession) { TLOGNE(WmsLogTag::WMS_KEYBOARD, "%{public}s: jsSceneSession is null", where); return; } - jsSceneSession->OnKeyboardStateChange(state, effectOption); + jsSceneSession->OnKeyboardStateChange(state, effectOption, displayId); }); TLOGD(WmsLogTag::WMS_KEYBOARD, "success"); } -void JsSceneSession::OnKeyboardStateChange(SessionState state, const KeyboardEffectOption& effectOption) +void JsSceneSession::OnKeyboardStateChange(SessionState state, const KeyboardEffectOption& effectOption, + uint64_t displayId) { auto session = weakSession_.promote(); if (session == nullptr) { TLOGW(WmsLogTag::WMS_KEYBOARD, "session is nullptr, id:%{public}d", persistentId_); return; } - auto task = [weakThis = wptr(this), persistentId = persistentId_, state, env = env_, effectOption, + auto task = [weakThis = wptr(this), persistentId = persistentId_, state, env = env_, effectOption, displayId, where = __func__] { auto jsSceneSession = weakThis.promote(); if (!jsSceneSession || jsSceneSessionMap_.find(persistentId) == jsSceneSessionMap_.end()) { @@ -7421,7 +7423,8 @@ void JsSceneSession::OnKeyboardStateChange(SessionState state, const KeyboardEff } napi_value jsKeyboardStateObj = CreateJsValue(env, state); napi_value jsKeyboardEffectOptionObj = ConvertKeyboardEffectOptionToJsValue(env, effectOption); - napi_value argv[] = { jsKeyboardStateObj, jsKeyboardEffectOptionObj }; + napi_value jsKeyboardDisplayIdObj = CreateJsValue(env, static_cast(displayId)); + napi_value argv[] = { jsKeyboardStateObj, jsKeyboardEffectOptionObj, jsKeyboardDisplayIdObj }; napi_call_function(env, NapiGetUndefined(env), jsCallBack->GetNapiValue(), ArraySize(argv), argv, nullptr); TLOGNI(WmsLogTag::WMS_KEYBOARD, "%{public}s: id: %{public}d, state: %{public}d", where, persistentId, state); }; diff --git a/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session.h b/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session.h index d29f92ad27edf8fcd8e0fdc0213a1a50fad67473..131bd0309b03785b980c74e32cf3c8f1e1a682b0 100644 --- a/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session.h +++ b/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session.h @@ -495,7 +495,7 @@ private: void OnUpdateAppUseControl(ControlAppType type, bool isNeedControl, bool isControlRecentOnly); void OnWindowMoving(DisplayId displayId, int32_t pointerX, int32_t pointerY); void UpdateSessionLabelAndIcon(const std::string& label, const std::shared_ptr& icon); - void OnKeyboardStateChange(SessionState state, const KeyboardEffectOption& effectOption); + void OnKeyboardStateChange(SessionState state, const KeyboardEffectOption& effectOption, uint64_t displayId); void OnKeyboardEffectOptionChange(const KeyboardEffectOption& effectOption); void NotifyHighlightChange(bool isHighlight); void NotifyWindowAnchorInfoChange(const WindowAnchorInfo& windowAnchorInfo); diff --git a/window_scene/session/host/include/session.h b/window_scene/session/host/include/session.h index ce30e298902b43fe3448dbfff7a4aedc5bcf804f..8e92fc8c097b8e311e0a743b7e0e74203953b50f 100644 --- a/window_scene/session/host/include/session.h +++ b/window_scene/session/host/include/session.h @@ -109,7 +109,8 @@ using UpdateTransitionAnimationFunc = std::function& icon)>; using NotifySessionGetTargetOrientationConfigInfoFunc = std::function; -using NotifyKeyboardStateChangeFunc = std::function; +using NotifyKeyboardStateChangeFunc = + std::function; using NotifyHighlightChangeFunc = std::function; using NotifySurfaceBoundsChangeFunc = std::function; using HasRequestedVsyncFunc = std::function; diff --git a/window_scene/session/host/src/session.cpp b/window_scene/session/host/src/session.cpp index 328e19761e4d22562213270bdbd25e59365c99bb..2d837dcb5f0bd73d0382b5039a40c50029427222 100644 --- a/window_scene/session/host/src/session.cpp +++ b/window_scene/session/host/src/session.cpp @@ -3109,7 +3109,8 @@ void Session::NotifySessionStateChange(const SessionState& state) static_cast(state), session->GetPersistentId()); if (session->GetWindowType() == WindowType::WINDOW_TYPE_INPUT_METHOD_FLOAT && session->keyboardStateChangeFunc_) { - session->keyboardStateChangeFunc_(state, session->GetSessionProperty()->GetKeyboardEffectOption()); + session->keyboardStateChangeFunc_(state, session->GetSessionProperty()->GetKeyboardEffectOption(), + session->GetSessionProperty()->GetDisplayId()); } else if (session->sessionStateChangeFunc_) { session->sessionStateChangeFunc_(state); } else { diff --git a/wm/include/window_impl.h b/wm/include/window_impl.h index f9a3295f69a8137b63569fad4e2243899c257704..484a2f41d2d55893abefd27c60e14bfc193e2bca 100644 --- a/wm/include/window_impl.h +++ b/wm/include/window_impl.h @@ -373,7 +373,7 @@ public: /* * Keyboard */ - WMError ShowKeyboard(KeyboardEffectOption effectOption) override; + WMError ShowKeyboard(KeyboardEffectOption effectOption, uint64_t displayId = 0) override; /* * RS Client Multi Instance diff --git a/wm/include/window_scene_session_impl.h b/wm/include/window_scene_session_impl.h index 2ce0ea1aafc9ff31aca218de6c873084ddd3f8a5..785d3dfb6cb991676b14814217fa939bfb5fc3a6 100644 --- a/wm/include/window_scene_session_impl.h +++ b/wm/include/window_scene_session_impl.h @@ -34,7 +34,7 @@ public: bool isModuleAbilityHookEnd = false) override; WMError Show(uint32_t reason = 0, bool withAnimation = false, bool withFocus = true) override; WMError Show(uint32_t reason, bool withAnimation, bool withFocus, bool waitAttach) override; - WMError ShowKeyboard(KeyboardEffectOption effectOption) override; + WMError ShowKeyboard(KeyboardEffectOption effectOption, uint64_t displayId = 0) override; WMError Hide(uint32_t reason, bool withAnimation, bool isFromInnerkits) override; WMError Hide(uint32_t reason, bool withAnimation, bool isFromInnerkits, bool waitDetach) override; WMError Destroy(bool needNotifyServer, bool needClearListener = true, uint32_t reason = 0) override; diff --git a/wm/src/window_impl.cpp b/wm/src/window_impl.cpp index 72ed14ee176f49548a473a884c74ef84f7bd1822..5fc8c125f8d4d8d4f799e09f980dc534c2187634 100644 --- a/wm/src/window_impl.cpp +++ b/wm/src/window_impl.cpp @@ -1931,7 +1931,7 @@ WMError WindowImpl::Show(uint32_t reason, bool withAnimation, bool withFocus, bo return ret; } -WMError WindowImpl::ShowKeyboard(KeyboardEffectOption effectOption) +WMError WindowImpl::ShowKeyboard(KeyboardEffectOption effectOption, uint64_t displayId) { return Show(); } diff --git a/wm/src/window_scene_session_impl.cpp b/wm/src/window_scene_session_impl.cpp index 7790ddb8cfee226bd897e8e60a8974816b1ec78f..c5a165e2eb0fe4ead475acdd5bcc05b57006f582 100644 --- a/wm/src/window_scene_session_impl.cpp +++ b/wm/src/window_scene_session_impl.cpp @@ -1655,7 +1655,7 @@ sptr WindowSceneSessionImpl::GetDisplayInfo() const return display->GetDisplayInfo(); } -WMError WindowSceneSessionImpl::ShowKeyboard(KeyboardEffectOption effectOption) +WMError WindowSceneSessionImpl::ShowKeyboard(KeyboardEffectOption effectOption, uint64_t displayId) { TLOGI(WmsLogTag::WMS_KEYBOARD, "Effect option: %{public}s", effectOption.ToString().c_str()); if (effectOption.viewMode_ >= KeyboardViewMode::VIEW_MODE_END) { @@ -1674,6 +1674,7 @@ WMError WindowSceneSessionImpl::ShowKeyboard(KeyboardEffectOption effectOption) effectOption.gradientMode_ = KeyboardGradientMode::NONE; } property_->SetKeyboardEffectOption(effectOption); + property_->SetDisplayId(displayId); return Show(); }