!821 悬浮态窗口resize防抖

Merge pull request !821 from Hollokin/master
This commit is contained in:
openharmony_ci 2023-07-29 12:16:45 +00:00 committed by Gitee
commit 451f77ff1e
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
3 changed files with 32 additions and 26 deletions

View File

@ -24,11 +24,8 @@
#include "js_runtime_utils.h"
#include "panel_status_listener.h"
#include "window.h"
#include "window_option.h"
#include "wm_common.h"
namespace OHOS {
using namespace OHOS::Rosen;
namespace MiscServices {
enum PanelType {
SOFT_KEYBOARD = 0,
@ -72,8 +69,8 @@ private:
bool MarkListener(const std::string &type, bool isRegister);
static uint32_t GenerateSequenceId();
sptr<Window> window_ = nullptr;
sptr<WindowOption> winOption_ = nullptr;
sptr<OHOS::Rosen::Window> window_ = nullptr;
sptr<OHOS::Rosen::WindowOption> winOption_ = nullptr;
PanelType panelType_ = PanelType::SOFT_KEYBOARD;
PanelFlag panelFlag_ = PanelFlag::FLG_FIXED;
bool showRegistered_ = false;

View File

@ -18,11 +18,12 @@
#include "display_manager.h"
#include "global.h"
#include "input_method_ability_utils.h"
#include "window.h"
#include "wm_common.h"
#include "transaction/rs_interfaces.h"
#include "ui/rs_surface_node.h"
namespace OHOS {
namespace MiscServices {
class RSTransaction;
using WMError = OHOS::Rosen::WMError;
using WindowGravity = OHOS::Rosen::WindowGravity;
using WindowState = OHOS::Rosen::WindowState;
@ -41,10 +42,6 @@ int32_t InputMethodPanel::CreatePanel(
}
winOption_->SetWindowType(OHOS::Rosen::WindowType::WINDOW_TYPE_INPUT_METHOD_FLOAT);
WMError wmError = WMError::WM_OK;
WindowGravity gravity = WindowGravity::WINDOW_GRAVITY_FLOAT;
if (panelType_ == SOFT_KEYBOARD && panelFlag_ == FLG_FIXED) {
gravity = WindowGravity::WINDOW_GRAVITY_BOTTOM;
}
uint32_t sequenceId = GenerateSequenceId();
std::string windowName = panelType_ == SOFT_KEYBOARD ? "softKeyboard" + std::to_string(sequenceId)
: "statusBar" + std::to_string(sequenceId);
@ -59,12 +56,21 @@ int32_t InputMethodPanel::CreatePanel(
}
windowId_ = window_->GetWindowId();
IMSA_HILOGD("GetWindowId, windowId = %{public}u", windowId_);
WindowGravity gravity = WindowGravity::WINDOW_GRAVITY_FLOAT;
if (panelType_ == SOFT_KEYBOARD && panelFlag_ == FLG_FIXED) {
gravity = WindowGravity::WINDOW_GRAVITY_BOTTOM;
} else if (panelFlag_ == FLG_FLOATING) {
window_->GetSurfaceNode()->SetFrameGravity(Rosen::Gravity::TOP_LEFT);
Rosen::RSTransactionProxy::GetInstance()->FlushImplicitTransaction();
}
wmError = window_->SetWindowGravity(gravity, invalidGravityPercent);
if (wmError == WMError::WM_OK) {
return ErrorCode::NO_ERROR;
}
IMSA_HILOGE("SetWindowGravity failed, wmError is %{public}d, start destroy window.", wmError);
wmError = window_->Destroy();
return wmError == WMError::WM_OK ? ErrorCode::NO_ERROR : ErrorCode::ERROR_OPERATE_PANEL;
IMSA_HILOGI("Destroy window end, wmError is %{public}d.", wmError);
return ErrorCode::ERROR_OPERATE_PANEL;
}
int32_t InputMethodPanel::DestroyPanel()
@ -140,6 +146,9 @@ int32_t InputMethodPanel::ChangePanelFlag(PanelFlag panelFlag)
WindowGravity gravity = WindowGravity::WINDOW_GRAVITY_FLOAT;
if (panelFlag == FLG_FIXED) {
gravity = WindowGravity::WINDOW_GRAVITY_BOTTOM;
} else {
window_->GetSurfaceNode()->SetFrameGravity(Rosen::Gravity::TOP_LEFT);
Rosen::RSTransactionProxy::GetInstance()->FlushImplicitTransaction();
}
auto ret = window_->SetWindowGravity(gravity, invalidGravityPercent);
IMSA_HILOGI("InputMethodPanel, ChangePanelFlag end, ret = %{public}d", ret);

View File

@ -535,13 +535,13 @@ HWTEST_F(InputMethodControllerTest, testIMCDispatchKeyEvent003, TestSize.Level0)
}
/**
* @tc.name: testIMCOnCursorUpdate01
* @tc.desc: Test update cursorInfo, call 'OnCursorUpdate' twice, if cursorInfo is the same,
* the second time will not get callback.
* @tc.type: FUNC
* @tc.require:
* @tc.author: Zhaolinglan
*/
* @tc.name: testIMCOnCursorUpdate01
* @tc.desc: Test update cursorInfo, call 'OnCursorUpdate' twice, if cursorInfo is the same,
* the second time will not get callback.
* @tc.type: FUNC
* @tc.require:
* @tc.author: Zhaolinglan
*/
HWTEST_F(InputMethodControllerTest, testIMCOnCursorUpdate01, TestSize.Level0)
{
IMSA_HILOGI("IMC testIMCOnCursorUpdate01 Test START");
@ -557,13 +557,13 @@ HWTEST_F(InputMethodControllerTest, testIMCOnCursorUpdate01, TestSize.Level0)
}
/**
* @tc.name: testIMCOnCursorUpdate02
* @tc.desc: Test update cursorInfo, 'Attach'->'OnCursorUpdate'->'Close'->'Attach'->'OnCursorUpdate',
* it will get callback two time.
* @tc.type: FUNC
* @tc.require:
* @tc.author: Zhaolinglan
*/
* @tc.name: testIMCOnCursorUpdate02
* @tc.desc: Test update cursorInfo, 'Attach'->'OnCursorUpdate'->'Close'->'Attach'->'OnCursorUpdate',
* it will get callback two time.
* @tc.type: FUNC
* @tc.require:
* @tc.author: Zhaolinglan
*/
HWTEST_F(InputMethodControllerTest, testIMCOnCursorUpdate02, TestSize.Level0)
{
IMSA_HILOGI("IMC testIMCOnCursorUpdate02 Test START");