From b1540898ac9a8c9a437b567c26fd364fb91e381d Mon Sep 17 00:00:00 2001 From: l00574490 Date: Sun, 21 Apr 2024 17:58:49 +0800 Subject: [PATCH] add create panel Signed-off-by: l00574490 Change-Id: I11c37580a459c588fadf1f4c54d1174b41d9c6db --- .../js_scene_session.cpp | 2 + .../js_scene_session_manager.cpp | 58 ++++++++++++++++++- .../js_scene_session_manager.h | 2 + .../session/host/include/keyboard_session.h | 3 + .../session/host/include/scb_system_session.h | 2 + .../session/host/include/scene_session.h | 11 +++- window_scene/session/host/include/session.h | 2 +- .../session/host/src/keyboard_session.cpp | 28 ++++++++- .../session/host/src/scb_system_session.cpp | 16 +++++ .../session/host/src/scene_session.cpp | 52 +++++++++++++++++ .../include/scene_session_manager.h | 6 ++ .../src/scene_session_manager.cpp | 58 ++++++++++++++++++- 12 files changed, 233 insertions(+), 7 deletions(-) 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 f6220b3ec9..45173befd4 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 @@ -110,6 +110,8 @@ napi_value JsSceneSession::Create(napi_env env, const sptr& sessio CreateJsValue(env, static_cast(GetApiType(session->GetWindowType())))); napi_set_named_property(env, objValue, "isAppType", CreateJsValue(env, session->IsFloatingWindowAppType())); napi_set_named_property(env, objValue, "pipTemplateInfo", CreatePipTemplateInfo(env, session)); + napi_set_named_property(env, objValue, "keyboardGravity", + CreateJsValue(env, static_cast(session->GetKeyboardGravity()))); const char* moduleName = "JsSceneSession"; BindNativeFunction(env, objValue, "on", moduleName, JsSceneSession::RegisterCallback); diff --git a/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session_manager.cpp b/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session_manager.cpp index f873f37404..1cf26d1234 100644 --- a/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session_manager.cpp +++ b/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session_manager.cpp @@ -53,6 +53,7 @@ constexpr int ARG_INDEX_3 = 3; constexpr int32_t RESTYPE_RECLAIM = 100001; const std::string RES_PARAM_RECLAIM_TAG = "reclaimTag"; const std::string CREATE_SYSTEM_SESSION_CB = "createSpecificSession"; +const std::string CREATE_KEYBOARD_SESSION_CB = "createKeyboardSession"; const std::string RECOVER_SCENE_SESSION_CB = "recoverSceneSession"; const std::string STATUS_BAR_ENABLED_CHANGE_CB = "statusBarEnabledChange"; const std::string GESTURE_NAVIGATION_ENABLED_CHANGE_CB = "gestureNavigationEnabledChange"; @@ -156,7 +157,8 @@ JsSceneSessionManager::JsSceneSessionManager(napi_env env) : env_(env) { listenerFunc_ = { { CREATE_SYSTEM_SESSION_CB, &JsSceneSessionManager::ProcessCreateSystemSessionRegister }, - { RECOVER_SCENE_SESSION_CB, &JsSceneSessionManager::ProcessRecoverSceneSessionRegister }, + { CREATE_KEYBOARD_SESSION_CB, &JsSceneSessionManager::ProcessCreateKeyboardSessionRegister }, + { RECOVER_SCENE_SESSION_CB, &JsSceneSessionManager::ProcessRecoverSceneSessionRegister }, { STATUS_BAR_ENABLED_CHANGE_CB, &JsSceneSessionManager::ProcessStatusBarEnabledChangeListener}, { OUTSIDE_DOWN_EVENT_CB, &JsSceneSessionManager::ProcessOutsideDownEvent }, { SHIFT_FOCUS_CB, &JsSceneSessionManager::ProcessShiftFocus }, @@ -200,6 +202,51 @@ void JsSceneSessionManager::OnCreateSystemSession(const sptr& scen taskScheduler_->PostMainThreadTask(task, "OnCreateSystemSession"); } +void JsSceneSessionManager::OnCreateKeyboardSession(const sptr& keyboardSession, + const sptr& panelSession) +{ + if (keyboardSession == nullptr || panelSession == nullptr) { + TLOGE(WmsLogTag::WMS_KEYBOARD, "[NAPI]keyboard or panel session is nullptr"); + return; + } + auto iter = jsCbMap_.find(CREATE_KEYBOARD_SESSION_CB); + if (iter == jsCbMap_.end()) { + TLOGE(WmsLogTag::WMS_KEYBOARD, "[NAPI]Can't find callback, id: %{public}d", keyboardSession->GetPersistentId()); + return; + } + + TLOGI(WmsLogTag::WMS_KEYBOARD, "[NAPI]keyboardId: %{public}d, panelId: %{public}d", + keyboardSession->GetPersistentId(), panelSession->GetPersistentId()); + auto jsCallBack = iter->second; + wptr weakKeyboardSession(keyboardSession); + wptr weakPanelSession(panelSession); + auto task = [this, weakKeyboardSession, weakPanelSession, jsCallBack, env = env_]() { + if (!jsCallBack) { + TLOGE(WmsLogTag::WMS_KEYBOARD, "[NAPI]jsCallBack is nullptr"); + return; + } + auto keyboardSession = weakKeyboardSession.promote(); + auto panelSession = weakPanelSession.promote(); + if (keyboardSession == nullptr || panelSession == nullptr) { + TLOGE(WmsLogTag::WMS_KEYBOARD, "[NAPI]keyboard or panel session is nullptr"); + return; + } + napi_value keyboardSessionObj = JsSceneSession::Create(env, keyboardSession); + if (keyboardSessionObj == nullptr) { + TLOGE(WmsLogTag::WMS_KEYBOARD, "[NAPI]keyboardSessionObj is nullptr"); + return; + } + napi_value panelSessionObj = JsSceneSession::Create(env, panelSession); + if (panelSessionObj == nullptr) { + TLOGE(WmsLogTag::WMS_KEYBOARD, "[NAPI]panelSessionObj is nullptr"); + return; + } + napi_value argv[] = { keyboardSessionObj, panelSessionObj }; + napi_call_function(env, NapiGetUndefined(env), jsCallBack->GetNapiValue(), ArraySize(argv), argv, nullptr); + }; + taskScheduler_->PostMainThreadTask(task, "OnCreateKeyboardSession"); +} + void JsSceneSessionManager::OnRecoverSceneSession(const sptr& sceneSession, const SessionInfo& info) { if (sceneSession == nullptr) { @@ -362,6 +409,15 @@ void JsSceneSessionManager::ProcessCreateSystemSessionRegister() SceneSessionManager::GetInstance().SetCreateSystemSessionListener(func); } +void JsSceneSessionManager::ProcessCreateKeyboardSessionRegister() +{ + NotifyCreateKeyboardSessionFunc func = [this](const sptr& keyboardSession, + const sptr& panelSession) { + this->OnCreateKeyboardSession(keyboardSession, panelSession); + }; + SceneSessionManager::GetInstance().SetCreateKeyboardSessionListener(func); +} + void JsSceneSessionManager::ProcessStartUIAbilityErrorRegister() { ProcessStartUIAbilityErrorFunc func = [this](uint32_t startUIAbilityError) { diff --git a/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session_manager.h b/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session_manager.h index 4da6fbeda2..b1ae5702d8 100644 --- a/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session_manager.h +++ b/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session_manager.h @@ -131,12 +131,14 @@ private: void OnStatusBarEnabledUpdate(bool enable); void OnGestureNavigationEnabledUpdate(bool enable); void OnCreateSystemSession(const sptr& sceneSession); + void OnCreateKeyboardSession(const sptr& keyboardSession, const sptr& panelSession); void OnRecoverSceneSession(const sptr& sceneSession, const SessionInfo& sessionInfo); void OnOutsideDownEvent(int32_t x, int32_t y); void OnStartUIAbilityError(const uint32_t errorCode); void OnShiftFocus(int32_t persistentId); void OnCallingSessionIdChange(uint32_t callingSessionId); void ProcessCreateSystemSessionRegister(); + void ProcessCreateKeyboardSessionRegister(); void ProcessRecoverSceneSessionRegister(); void ProcessStatusBarEnabledChangeListener(); void ProcessGestureNavigationEnabledChangeListener(); diff --git a/window_scene/session/host/include/keyboard_session.h b/window_scene/session/host/include/keyboard_session.h index 4a138b1a13..9c79fd626d 100644 --- a/window_scene/session/host/include/keyboard_session.h +++ b/window_scene/session/host/include/keyboard_session.h @@ -39,6 +39,9 @@ public: WSError Hide() override; WSError Disconnect(bool isFromClient = false) override; WSError NotifyClientToUpdateRect(std::shared_ptr rsTransaction) override; + void BindKeyboardPanelSession(sptr panelSession) override; + sptr GetKeyboardPanelSession() const override; + SessionGravity GetKeyboardGravity() const override; private: sptr GetSceneSession(uint32_t persistentId); diff --git a/window_scene/session/host/include/scb_system_session.h b/window_scene/session/host/include/scb_system_session.h index 6bce13cf00..614f08ceac 100644 --- a/window_scene/session/host/include/scb_system_session.h +++ b/window_scene/session/host/include/scb_system_session.h @@ -32,6 +32,8 @@ public: WSError UpdateFocus(bool isFocused) override; WSError UpdateWindowMode(WindowMode mode) override; WSError SetSystemSceneBlockingFocus(bool blocking) override; + void BindKeyboardSession(sptr session) override; + sptr GetKeyboardSession() const override; protected: void UpdatePointerArea(const WSRect& rect) override; diff --git a/window_scene/session/host/include/scene_session.h b/window_scene/session/host/include/scene_session.h index da9a055117..e0166aa655 100644 --- a/window_scene/session/host/include/scene_session.h +++ b/window_scene/session/host/include/scene_session.h @@ -125,6 +125,11 @@ public: WSError Foreground(sptr property) override; WSError Background() override; WSError Disconnect(bool isFromClient = false) override; + virtual void BindKeyboardPanelSession(sptr panelSession) {}; + virtual sptr GetKeyboardPanelSession() const { return nullptr; }; + virtual void BindKeyboardSession(sptr session) {}; + virtual sptr GetKeyboardSession() const { return nullptr; }; + virtual SessionGravity GetKeyboardGravity() const { return SessionGravity::SESSION_GRAVITY_DEFAULT; }; WSError UpdateActiveStatus(bool isActive) override; WSError OnSessionEvent(SessionEvent event) override; @@ -253,6 +258,7 @@ public: void SetForceHideState(bool hideFlag); bool GetForceHideState() const; + protected: void NotifyIsCustomAnimationPlaying(bool isPlaying); void SetMoveDragCallback(); @@ -271,6 +277,8 @@ protected: sptr sessionChangeCallback_ = nullptr; mutable std::shared_mutex moveDragControllerMutex_; sptr moveDragController_ = nullptr; + sptr keyboardPanelSession_ = nullptr; + sptr keyboardSession_ = nullptr; private: void NotifyAccessibilityVisibilityChange(); @@ -294,7 +302,8 @@ private: void UpdateWinRectForSystemBar(WSRect& rect); bool UpdateInputMethodSessionRect(const WSRect& rect, WSRect& newWinRect, WSRect& newRequestRect); void HandleCastScreenConnection(SessionInfo& info, sptr session); - + void FixKeyboardPositionByKeyboardPanel(sptr panelSession, sptr keyboardSession); + NotifySessionRectChangeFunc sessionRectChangeFunc_; static wptr enterSession_; static std::mutex enterSessionMutex_; diff --git a/window_scene/session/host/include/session.h b/window_scene/session/host/include/session.h index 4e735e1886..ff58458331 100644 --- a/window_scene/session/host/include/session.h +++ b/window_scene/session/host/include/session.h @@ -101,7 +101,7 @@ public: using Task = std::function; explicit Session(const SessionInfo& info); virtual ~Session() = default; - + bool isKeyboardPanelEnabled_ = false; void SetEventHandler(const std::shared_ptr& handler, const std::shared_ptr& exportHandler = nullptr); diff --git a/window_scene/session/host/src/keyboard_session.cpp b/window_scene/session/host/src/keyboard_session.cpp index bf57d13476..760ebbc852 100644 --- a/window_scene/session/host/src/keyboard_session.cpp +++ b/window_scene/session/host/src/keyboard_session.cpp @@ -38,6 +38,32 @@ KeyboardSession::~KeyboardSession() TLOGI(WmsLogTag::WMS_KEYBOARD, "~KeyboardSession"); } +void KeyboardSession::BindKeyboardPanelSession(sptr panelSession) +{ + if (panelSession == nullptr) { + TLOGE(WmsLogTag::WMS_KEYBOARD, "panelSession is nullptr"); + return; + } + keyboardPanelSession_ = panelSession; + TLOGI(WmsLogTag::WMS_KEYBOARD, "Success, panelId: %{public}d", panelSession->GetPersistentId()); +} + +sptr KeyboardSession::GetKeyboardPanelSession() const +{ + return keyboardPanelSession_; +} + +SessionGravity KeyboardSession::GetKeyboardGravity() const +{ + SessionGravity gravity = SessionGravity::SESSION_GRAVITY_DEFAULT; + uint32_t percent = 0; + if (GetSessionProperty()) { + GetSessionProperty()->GetSessionGravity(gravity, percent); + } + TLOGI(WmsLogTag::WMS_KEYBOARD, "gravity: %{public}d", gravity); + return gravity; +} + WSError KeyboardSession::Show(sptr property) { auto task = [weakThis = wptr(this), property]() { @@ -288,7 +314,7 @@ void KeyboardSession::RaiseCallingSession(bool isKeyboardUpdated) system::GetParameter("const.product.devicetype", "unknown") == "tablet")) { return; } - + if (isKeyboardUpdated && isCallingSessionFloating) { callingSessionRect = callingSessionRestoringRect_; } diff --git a/window_scene/session/host/src/scb_system_session.cpp b/window_scene/session/host/src/scb_system_session.cpp index d53fa0c24f..d2384ed251 100644 --- a/window_scene/session/host/src/scb_system_session.cpp +++ b/window_scene/session/host/src/scb_system_session.cpp @@ -73,6 +73,22 @@ WSError SCBSystemSession::NotifyClientToUpdateRect(std::shared_ptr session) +{ + if (session == nullptr) { + TLOGE(WmsLogTag::WMS_KEYBOARD, "session is nullptr"); + return; + } + keyboardSession_ = session; + TLOGI(WmsLogTag::WMS_KEYBOARD, "Success, id: %{public}d", keyboardSession_->GetPersistentId()); +} + +sptr SCBSystemSession::GetKeyboardSession() const +{ + return keyboardSession_; +} + void SCBSystemSession::PresentFocusIfPointDown() { WLOGFI("PresentFocusIfPointDown, id: %{public}d, type: %{public}d", GetPersistentId(), GetWindowType()); diff --git a/window_scene/session/host/src/scene_session.cpp b/window_scene/session/host/src/scene_session.cpp index 398e730ed9..01cd2e11bf 100644 --- a/window_scene/session/host/src/scene_session.cpp +++ b/window_scene/session/host/src/scene_session.cpp @@ -449,6 +449,46 @@ WSError SceneSession::UpdateRect(const WSRect& rect, SizeChangeReason reason, return WSError::WS_OK; } +void SceneSession::FixKeyboardPositionByKeyboardPanel(sptr panelSession, + sptr keyboardSession) +{ + if (panelSession == nullptr || keyboardSession == nullptr) { + TLOGE(WmsLogTag::WMS_LAYOUT, "keyboard or panel session is null"); + return; + } + + SessionGravity gravity = keyboardSession->GetKeyboardGravity(); + if (gravity == SessionGravity::SESSION_GRAVITY_FLOAT) { + keyboardSession->winRect_.posX_ = panelSession->winRect_.posX_; + } else { + if (keyboardSession->GetSessionProperty() == nullptr) { + TLOGE(WmsLogTag::WMS_LAYOUT, "keyboard property is null"); + return; + } + static bool isPhone = system::GetParameter("const.product.devicetype", "unknown") == "phone"; + static bool isFoldable = ScreenSessionManagerClient::GetInstance().IsFoldable(); + bool isFolded = ScreenSessionManagerClient::GetInstance().GetFoldStatus() == OHOS::Rosen::FoldStatus::FOLDED; + const auto& screenSession = ScreenSessionManagerClient::GetInstance().GetScreenSession( + keyboardSession->GetSessionProperty()->GetDisplayId()); + Rotation rotation = (screenSession != nullptr) ? screenSession->GetRotation() : Rotation::ROTATION_0; + bool isKeyboardNeedLeftOffset = (isPhone && (!isFoldable || (isFoldable && isFolded)) && + (rotation == Rotation::ROTATION_90 || rotation == Rotation::ROTATION_270)); + if (isKeyboardNeedLeftOffset) { + keyboardSession->winRect_.posX_ += panelSession->winRect_.posX_; + } else { + keyboardSession->winRect_.posX_ = panelSession->winRect_.posX_; + } + TLOGI(WmsLogTag::WMS_LAYOUT, "isPhone:%{public}d, isFoldable:%{public}d, isFolded:%{public}d, " + "rotation:%{public}d, isKeyboardNeedLeftOffset:%{public}d", isPhone, isFoldable, + isFolded, rotation, isKeyboardNeedLeftOffset); + } + keyboardSession->winRect_.posY_ = panelSession->winRect_.posY_; + TLOGI(WmsLogTag::WMS_LAYOUT, "panelId:%{public}d, keyboardId:%{public}d, panelRect:%{public}s, " + "keyboardRect:%{public}s, gravity:%{public}d", panelSession->GetPersistentId(), + keyboardSession->GetPersistentId(), panelSession->winRect_.ToString().c_str(), + keyboardSession->winRect_.ToString().c_str(), gravity); +} + WSError SceneSession::NotifyClientToUpdateRectTask( wptr weakThis, std::shared_ptr rsTransaction) { @@ -470,6 +510,18 @@ WSError SceneSession::NotifyClientToUpdateRectTask( "SceneSession::NotifyClientToUpdateRect%d [%d, %d, %u, %u] reason:%u", session->GetPersistentId(), session->winRect_.posX_, session->winRect_.posY_, session->winRect_.width_, session->winRect_.height_, session->reason_); + + if (isKeyboardPanelEnabled_) { + if (session->GetWindowType() == WindowType::WINDOW_TYPE_KEYBOARD_PANEL) { + const auto& keyboardSession = session->GetKeyboardSession(); + FixKeyboardPositionByKeyboardPanel(session, keyboardSession); + ret = keyboardSession->Session::UpdateRect(keyboardSession->winRect_, session->reason_, rsTransaction); + } + if (session->GetWindowType() == WindowType::WINDOW_TYPE_INPUT_METHOD_FLOAT) { + FixKeyboardPositionByKeyboardPanel(session->GetKeyboardPanelSession(), session); + } + } + // once reason is undefined, not use rsTransaction // when rotation, sync cnt++ in marshalling. Although reason is undefined caused by resize if (session->reason_ == SizeChangeReason::UNDEFINED || session->reason_ == SizeChangeReason::MOVE || diff --git a/window_scene/session_manager/include/scene_session_manager.h b/window_scene/session_manager/include/scene_session_manager.h index 1b7984ae19..6373097f4b 100644 --- a/window_scene/session_manager/include/scene_session_manager.h +++ b/window_scene/session_manager/include/scene_session_manager.h @@ -64,6 +64,8 @@ namespace AncoConsts { class SceneSession; class AccessibilityWindowInfo; using NotifyCreateSystemSessionFunc = std::function& session)>; +using NotifyCreateKeyboardSessionFunc = std::function& keyboardSession, + const sptr& panelSession)>; using NotifyCreateSubSessionFunc = std::function& session)>; using NotifyRecoverSceneSessionFunc = std::function& session, const SessionInfo& sessionInfo)>; @@ -143,6 +145,7 @@ public: const sptr& callback) override; WMError UpdateSessionProperty(const sptr& property, WSPropertyChangeAction action) override; void SetCreateSystemSessionListener(const NotifyCreateSystemSessionFunc& func); + void SetCreateKeyboardSessionListener(const NotifyCreateKeyboardSessionFunc& func); void SetStatusBarEnabledChangeListener(const ProcessStatusBarEnabledChangeFunc& func); void SetStartUIAbilityErrorListener(const ProcessStartUIAbilityErrorFunc& func); void SetRecoverSceneSessionListener(const NotifyRecoverSceneSessionFunc& func); @@ -315,6 +318,7 @@ protected: virtual ~SceneSessionManager() = default; private: + bool isKeyboardPanelEnabled_ = false; void Init(); void InitScheduleUtils(); void RegisterAppListener(); @@ -474,6 +478,7 @@ private: std::map> lastUpdatedAvoidArea_; NotifyCreateSystemSessionFunc createSystemSessionFunc_; + NotifyCreateKeyboardSessionFunc createKeyboardSessionFunc_; std::map createSubSessionFuncMap_; std::map>> recoverSubSessionCacheMap_; bool recoveringFinished_ = false; @@ -582,6 +587,7 @@ private: void NotifyCreateSpecificSession(sptr session, sptr property, const WindowType& type); sptr CreateSceneSession(const SessionInfo& sessionInfo, sptr property); + void CreateKeyboardPanelSession(sptr keyboardSession); bool GetPreWindowDrawingState(uint64_t windowId, int32_t& pid, bool currentDrawingContentState); bool GetProcessDrawingState(uint64_t windowId, int32_t pid, bool currentDrawingContentState); WSError GetAppMainSceneSession(sptr& sceneSession, int32_t persistentId); diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index 1bba804a52..29b380422f 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -257,6 +257,7 @@ void SceneSessionManager::Init() WLOGI("SceneSessionManager init success."); RegisterAppListener(); openDebugTrace = std::atoi((system::GetParameter("persist.sys.graphic.openDebugTrace", "0")).c_str()) != 0; + isKeyboardPanelEnabled_ = system::GetParameter("persist.sceneboard.keyboardPanel.enabled", "0") == "1"; } void SceneSessionManager::InitScheduleUtils() @@ -1089,6 +1090,47 @@ WMError SceneSessionManager::CheckWindowId(int32_t windowId, int32_t &pid) return taskScheduler_->PostSyncTask(task, "CheckWindowId:" + std::to_string(windowId)); } +void SceneSessionManager::CreateKeyboardPanelSession(sptr keyboardSession) +{ + if (!isKeyboardPanelEnabled_) { + TLOGI(WmsLogTag::WMS_KEYBOARD, "KeyboardPanel is not enabled"); + return; + } + if (keyboardSession == nullptr || keyboardSession->GetSessionProperty() == nullptr) { + TLOGE(WmsLogTag::WMS_KEYBOARD, "KeyboardSession or property is nullptr"); + return; + } + DisplayId displayId = keyboardSession->GetSessionProperty()->GetDisplayId(); + const auto& panelVec = GetSceneSessionVectorByType(WindowType::WINDOW_TYPE_KEYBOARD_PANEL, displayId); + sptr panelSession; + if (panelVec.size() > 1) { + TLOGE(WmsLogTag::WMS_KEYBOARD, "Error size of keyboardPanel, size: %{public}zu", panelVec.size()); + return; + } else if (panelVec.size() == 1) { + panelSession = panelVec.front(); + TLOGI(WmsLogTag::WMS_KEYBOARD, "KeyboardPanel is created, panelId:%{public}d", panelSession->GetPersistentId()); + } else { + SessionInfo panelInfo = { + .bundleName_ = "SCBKeyboardPanel", + .moduleName_ = "SCBKeyboardPanel", + .abilityName_ = "SCBKeyboardPanel", + .isSystem_ = true, + .windowType_ = static_cast(WindowType::WINDOW_TYPE_KEYBOARD_PANEL), + .isSystemInput_ = true, + .screenId_ = static_cast(displayId) + }; + panelSession = RequestSceneSession(panelInfo, nullptr); + if (panelSession == nullptr) { + TLOGE(WmsLogTag::WMS_KEYBOARD, "PanelSession is nullptr"); + return; + } + } + keyboardSession->BindKeyboardPanelSession(panelSession); + panelSession->BindKeyboardSession(keyboardSession); + TLOGI(WmsLogTag::WMS_KEYBOARD, "success, panelId:%{public}d, keyboardId:%{public}d", + panelSession->GetPersistentId(), keyboardSession->GetPersistentId()); +} + sptr SceneSessionManager::CreateSceneSession(const SessionInfo& sessionInfo, sptr property) { @@ -1106,6 +1148,7 @@ sptr SceneSessionManager::CreateSceneSession(const SessionInfo& se } else if (property != nullptr && property->GetWindowType() == WindowType::WINDOW_TYPE_INPUT_METHOD_FLOAT) { sptr keyboardCb = CreateKeyboardSessionCallback(); sceneSession = new (std::nothrow) KeyboardSession(sessionInfo, specificCb, keyboardCb); + CreateKeyboardPanelSession(sceneSession); TLOGI(WmsLogTag::WMS_KEYBOARD, "Create KeyboardSession, type: %{public}d", property->GetWindowType()); } else if (property != nullptr && SessionHelper::IsSystemWindow(property->GetWindowType())) { sceneSession = new (std::nothrow) SystemSession(sessionInfo, specificCb); @@ -1115,6 +1158,7 @@ sptr SceneSessionManager::CreateSceneSession(const SessionInfo& se } if (sceneSession != nullptr) { sceneSession->SetSessionInfoPersistentId(sceneSession->GetPersistentId()); + sceneSession->isKeyboardPanelEnabled_ = isKeyboardPanelEnabled_; } return sceneSession; } @@ -1911,7 +1955,7 @@ WSError SceneSessionManager::CreateAndConnectSpecificSession(const sptrGetSessionInfo().bundleName_; info.abilityName_ = property->GetSessionInfo().abilityName_; info.moduleName_ = property->GetSessionInfo().moduleName_; - + ClosePipWindowIfExist(type); sptr newSession = RequestSceneSession(info, property); if (newSession == nullptr) { @@ -2210,6 +2254,11 @@ void SceneSessionManager::SetCreateSystemSessionListener(const NotifyCreateSyste createSystemSessionFunc_ = func; } +void SceneSessionManager::SetCreateKeyboardSessionListener(const NotifyCreateKeyboardSessionFunc& func) +{ + createKeyboardSessionFunc_ = func; +} + void SceneSessionManager::RegisterCreateSubSessionListener(int32_t persistentId, const NotifyCreateSubSessionFunc& func) { @@ -2245,10 +2294,13 @@ void SceneSessionManager::NotifyCreateSpecificSession(sptr newSess newSession->SetParentSession(parentSession); } } - if (createSystemSessionFunc_ && type != WindowType::WINDOW_TYPE_DIALOG) { + if (type != WindowType::WINDOW_TYPE_DIALOG) { if (WindowHelper::IsSystemSubWindow(type)) { NotifyCreateSubSession(property->GetParentPersistentId(), newSession); - } else { + } else if (isKeyboardPanelEnabled_ && type == WindowType::WINDOW_TYPE_INPUT_METHOD_FLOAT + && createKeyboardSessionFunc_) { + createKeyboardSessionFunc_(newSession, newSession->GetKeyboardPanelSession()); + } else if (createSystemSessionFunc_) { createSystemSessionFunc_(newSession); } TLOGD(WmsLogTag::WMS_LIFE, "Create system session, id:%{public}d, type: %{public}d", -- Gitee