From e786200b8ea79cedc5f4549d980566d263970858 Mon Sep 17 00:00:00 2001 From: liaoqingxing Date: Fri, 28 Feb 2025 16:49:14 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E9=A1=B5=E9=9D=A2=E7=BA=A7=E6=97=8B?= =?UTF-8?q?=E8=BD=AC-=E8=8E=B7=E5=8F=96=E9=94=AE=E7=9B=98=E9=81=BF?= =?UTF-8?q?=E8=AE=A9=E5=8C=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: liaoqingxing --- .../session/host/include/scene_session.h | 4 ++++ window_scene/session/host/src/scene_session.cpp | 5 +++++ .../include/scene_session_manager.h | 2 ++ .../src/scene_session_manager.cpp | 16 ++++++++++++++++ 4 files changed, 27 insertions(+) diff --git a/window_scene/session/host/include/scene_session.h b/window_scene/session/host/include/scene_session.h index e7b5d262b0..389092e7d2 100644 --- a/window_scene/session/host/include/scene_session.h +++ b/window_scene/session/host/include/scene_session.h @@ -115,6 +115,8 @@ using NotifySetSupportedWindowModesFunc = std::function&& supportedWindowModes)>; using GetStatusBarAvoidHeightFunc = std::function; using NotifySetWindowCornerRadiusFunc = std::function; +using GetKeyboardOccupiedAreaWithRotationCallback = + std::function>& avoidAreas)>; struct UIExtensionTokenInfo { bool canShowOnLockScreen { false }; @@ -148,6 +150,7 @@ public: PiPStateChangeCallback onPiPStateChange_; UpdateGestureBackEnabledCallback onUpdateGestureBackEnabled_; NotifyAvoidAreaChangeCallback onNotifyAvoidAreaChange_; + GetKeyboardOccupiedAreaWithRotationCallback onKeyboardRotationChange_; }; // func for change window scene pattern property @@ -642,6 +645,7 @@ public: void ActivateKeyboardAvoidArea(bool active, bool recalculateAvoid); bool IsKeyboardAvoidAreaActive() const; virtual void SetKeyboardViewModeChangeListener(const NotifyKeyboarViewModeChangeFunc& func) {}; + void GetKeyboardOccupiedAreaWithRotation(int32_t persistentId, uint32_t rotation, std::vector>& avoidAreas); /* * Window Focus diff --git a/window_scene/session/host/src/scene_session.cpp b/window_scene/session/host/src/scene_session.cpp index 4c747993e7..c4c8c80c92 100644 --- a/window_scene/session/host/src/scene_session.cpp +++ b/window_scene/session/host/src/scene_session.cpp @@ -2135,6 +2135,11 @@ void SceneSession::GetKeyboardAvoidArea(WSRect& rect, AvoidArea& avoidArea) return; } +void GetKeyboardOccupiedAreaWithRotation(vector>) +{ + +} + void SceneSession::GetCutoutAvoidArea(WSRect& rect, AvoidArea& avoidArea) { auto display = DisplayManager::GetInstance().GetDisplayById(GetSessionProperty()->GetDisplayId()); diff --git a/window_scene/session_manager/include/scene_session_manager.h b/window_scene/session_manager/include/scene_session_manager.h index df718ec7f6..b8a445e916 100644 --- a/window_scene/session_manager/include/scene_session_manager.h +++ b/window_scene/session_manager/include/scene_session_manager.h @@ -432,6 +432,7 @@ public: */ void RequestInputMethodCloseKeyboard(int32_t persistentId); void RegisterNotifyRootSceneOccupiedAreaChangeFunc(NotifyRootSceneOccupiedAreaChangeFunc&& func); + void GetKeyboardOccupiedAreaWithRotation(int32_t persistentId, uint32_t rotation, std::vector>& avoidAreas); /* * UIExtension @@ -1128,6 +1129,7 @@ private: void UpdateKeyboardAvoidAreaActive(bool systemKeyboardAvoidAreaActive); NotifyRootSceneOccupiedAreaChangeFunc onNotifyOccupiedAreaChangeForRootFunc_; + /* * Specific Window */ diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index c667744be6..fe819d092b 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -1576,6 +1576,10 @@ sptr SceneSessionManager::CreateSpecificS specificCb->onUpdateGestureBackEnabled_ = [this](int32_t persistentId) { this->UpdateGestureBackEnabled(persistentId); }; + specificCb->onKeyboardRotationChange_ = [this](int32_t persistentId, uint32_t rotation, + std::vector>& avoidAreas) { + this->GetKeyboardOccupiedAreaWithRotation(persistentId, rotation, avoidAreas); + } return specificCb; } @@ -9431,6 +9435,18 @@ void SceneSessionManager::UpdateAvoidArea(int32_t persistentId) }, "UpdateAvoidArea:PID:" + std::to_string(persistentId)); } +void SceneSessionManager::GetKeyboardOccupiedAreaWithRotation(int32_t persistentId, uint32_t rotation, std::vector>& avoidAreas) +{ + auto sceneSession = GetSceneSession(persistentId); + if (sceneSession == nullptr) { + TLOGE(WmsLogTag::WMS_KEYBOARD, "sceneSession is nullptr"); + return; + } + // auto keyboardSession = GetKeyboardSession(sceneSession->GetSessionProperty()->GetDisplayId(), false); + std::pair keyboardOccupiedArea = {true, {10, 900, 1200, 900}}; + avoidAreas.push_back(keyboardOccupiedArea); +} + void SceneSessionManager::UpdateGestureBackEnabled(int32_t persistentId) { auto task = [this, persistentId, where = __func__] { -- Gitee From 8d9de1702a8a5bd0c65f8ac682891ecca6429884 Mon Sep 17 00:00:00 2001 From: liaoqingxing Date: Fri, 28 Feb 2025 16:49:14 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E9=A1=B5=E9=9D=A2=E7=BA=A7=E6=97=8B?= =?UTF-8?q?=E8=BD=AC-=E8=8E=B7=E5=8F=96=E9=94=AE=E7=9B=98=E9=81=BF?= =?UTF-8?q?=E8=AE=A9=E5=8C=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: liaoqingxing --- .../session/host/include/scene_session.h | 4 ++++ window_scene/session/host/src/scene_session.cpp | 10 ++++++++++ .../include/scene_session_manager.h | 2 ++ .../src/scene_session_manager.cpp | 16 ++++++++++++++++ 4 files changed, 32 insertions(+) diff --git a/window_scene/session/host/include/scene_session.h b/window_scene/session/host/include/scene_session.h index e7b5d262b0..389092e7d2 100644 --- a/window_scene/session/host/include/scene_session.h +++ b/window_scene/session/host/include/scene_session.h @@ -115,6 +115,8 @@ using NotifySetSupportedWindowModesFunc = std::function&& supportedWindowModes)>; using GetStatusBarAvoidHeightFunc = std::function; using NotifySetWindowCornerRadiusFunc = std::function; +using GetKeyboardOccupiedAreaWithRotationCallback = + std::function>& avoidAreas)>; struct UIExtensionTokenInfo { bool canShowOnLockScreen { false }; @@ -148,6 +150,7 @@ public: PiPStateChangeCallback onPiPStateChange_; UpdateGestureBackEnabledCallback onUpdateGestureBackEnabled_; NotifyAvoidAreaChangeCallback onNotifyAvoidAreaChange_; + GetKeyboardOccupiedAreaWithRotationCallback onKeyboardRotationChange_; }; // func for change window scene pattern property @@ -642,6 +645,7 @@ public: void ActivateKeyboardAvoidArea(bool active, bool recalculateAvoid); bool IsKeyboardAvoidAreaActive() const; virtual void SetKeyboardViewModeChangeListener(const NotifyKeyboarViewModeChangeFunc& func) {}; + void GetKeyboardOccupiedAreaWithRotation(int32_t persistentId, uint32_t rotation, std::vector>& avoidAreas); /* * Window Focus diff --git a/window_scene/session/host/src/scene_session.cpp b/window_scene/session/host/src/scene_session.cpp index 4c747993e7..8f40789bda 100644 --- a/window_scene/session/host/src/scene_session.cpp +++ b/window_scene/session/host/src/scene_session.cpp @@ -2135,6 +2135,16 @@ void SceneSession::GetKeyboardAvoidArea(WSRect& rect, AvoidArea& avoidArea) return; } +void GetKeyboardOccupiedAreaWithRotation(int32_t persistentId, uint32_t rotation, std::vector>& avoidAreas) +{ + TLOGE(WmsLogTag::WMS_KEYBOARD, "GetKeyboardOccupiedAreaWithRotation begin"); + if (specificCallback_ != nullptr && specificCallback_->onKeyboardRotationChange_) { + specificCallback_->onKeyboardRotationChange_(persistentId, rotation, avoidAreas); + } else { + TLOGE(WmsLogTag::WMS_KEYBOARD, "Fail to GetKeyboardOccupiedAreaWithRotation, specificCallback_ is nullptr"); + } +} + void SceneSession::GetCutoutAvoidArea(WSRect& rect, AvoidArea& avoidArea) { auto display = DisplayManager::GetInstance().GetDisplayById(GetSessionProperty()->GetDisplayId()); diff --git a/window_scene/session_manager/include/scene_session_manager.h b/window_scene/session_manager/include/scene_session_manager.h index df718ec7f6..b8a445e916 100644 --- a/window_scene/session_manager/include/scene_session_manager.h +++ b/window_scene/session_manager/include/scene_session_manager.h @@ -432,6 +432,7 @@ public: */ void RequestInputMethodCloseKeyboard(int32_t persistentId); void RegisterNotifyRootSceneOccupiedAreaChangeFunc(NotifyRootSceneOccupiedAreaChangeFunc&& func); + void GetKeyboardOccupiedAreaWithRotation(int32_t persistentId, uint32_t rotation, std::vector>& avoidAreas); /* * UIExtension @@ -1128,6 +1129,7 @@ private: void UpdateKeyboardAvoidAreaActive(bool systemKeyboardAvoidAreaActive); NotifyRootSceneOccupiedAreaChangeFunc onNotifyOccupiedAreaChangeForRootFunc_; + /* * Specific Window */ diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index c667744be6..fe819d092b 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -1576,6 +1576,10 @@ sptr SceneSessionManager::CreateSpecificS specificCb->onUpdateGestureBackEnabled_ = [this](int32_t persistentId) { this->UpdateGestureBackEnabled(persistentId); }; + specificCb->onKeyboardRotationChange_ = [this](int32_t persistentId, uint32_t rotation, + std::vector>& avoidAreas) { + this->GetKeyboardOccupiedAreaWithRotation(persistentId, rotation, avoidAreas); + } return specificCb; } @@ -9431,6 +9435,18 @@ void SceneSessionManager::UpdateAvoidArea(int32_t persistentId) }, "UpdateAvoidArea:PID:" + std::to_string(persistentId)); } +void SceneSessionManager::GetKeyboardOccupiedAreaWithRotation(int32_t persistentId, uint32_t rotation, std::vector>& avoidAreas) +{ + auto sceneSession = GetSceneSession(persistentId); + if (sceneSession == nullptr) { + TLOGE(WmsLogTag::WMS_KEYBOARD, "sceneSession is nullptr"); + return; + } + // auto keyboardSession = GetKeyboardSession(sceneSession->GetSessionProperty()->GetDisplayId(), false); + std::pair keyboardOccupiedArea = {true, {10, 900, 1200, 900}}; + avoidAreas.push_back(keyboardOccupiedArea); +} + void SceneSessionManager::UpdateGestureBackEnabled(int32_t persistentId) { auto task = [this, persistentId, where = __func__] { -- Gitee