From 020dd4604988d7db62ba8cd7c716c64c4413ae2a Mon Sep 17 00:00:00 2001 From: FangWuxing Date: Sat, 23 Aug 2025 08:44:08 +0000 Subject: [PATCH 1/2] =?UTF-8?q?=E8=BE=93=E5=85=A5=E6=B3=95=E6=8C=87?= =?UTF-8?q?=E5=AE=9A=E6=98=BE=E7=A4=BA=E5=B1=8F=E5=B9=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: FangWuxing --- interfaces/innerkits/wm/window.h | 3 ++- .../napi/scene_session_manager/js_scene_session.cpp | 12 +++++++----- .../napi/scene_session_manager/js_scene_session.h | 2 +- window_scene/session/host/include/session.h | 3 ++- window_scene/session/host/src/session.cpp | 3 ++- wm/include/window_impl.h | 2 +- wm/include/window_scene_session_impl.h | 2 +- wm/src/window_impl.cpp | 2 +- wm/src/window_scene_session_impl.cpp | 3 ++- 9 files changed, 19 insertions(+), 13 deletions(-) diff --git a/interfaces/innerkits/wm/window.h b/interfaces/innerkits/wm/window.h index 8ed30ff621..d1ec230cde 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 af23801536..588929a32a 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,26 @@ 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 +7422,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 d29f92ad27..131bd0309b 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 ce30e29890..8e92fc8c09 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 328e19761e..2d837dcb5f 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 f9a3295f69..484a2f41d2 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 2ce0ea1aaf..785d3dfb6c 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 72ed14ee17..5fc8c125f8 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 7790ddb8cf..c5a165e2eb 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(); } -- Gitee From b8412c252c1e421d7dab3bbef14b722346d275dd Mon Sep 17 00:00:00 2001 From: FangWuxing Date: Sat, 23 Aug 2025 08:46:49 +0000 Subject: [PATCH 2/2] =?UTF-8?q?=E8=BE=93=E5=85=A5=E6=B3=95=E6=8C=87?= =?UTF-8?q?=E5=AE=9A=E6=98=BE=E7=A4=BA=E5=B1=8F=E5=B9=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: FangWuxing --- .../kits/napi/scene_session_manager/js_scene_session.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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 588929a32a..7ae0d69f41 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 @@ -7400,7 +7400,8 @@ void JsSceneSession::ProcessKeyboardStateChangeRegister() TLOGD(WmsLogTag::WMS_KEYBOARD, "success"); } -void JsSceneSession::OnKeyboardStateChange(SessionState state, const KeyboardEffectOption& effectOption, uint64_t displayId) +void JsSceneSession::OnKeyboardStateChange(SessionState state, const KeyboardEffectOption& effectOption, + uint64_t displayId) { auto session = weakSession_.promote(); if (session == nullptr) { -- Gitee