去掉ShowInputWindow中对ShowPanel的等待,因为它对于输入法英语直接创建window的情况下,每次Attach都多100ms的等待时间,很耗时

Signed-off-by: Hollokin <taoyuxin2@huawei.com>
This commit is contained in:
Hollokin 2023-07-09 18:33:43 +08:00
parent d12e013ec5
commit bd6fc25da2
4 changed files with 17 additions and 28 deletions

View File

@ -491,20 +491,21 @@ bool JsGetInputMethodController::GetValue(napi_env env, napi_value in, TextConfi
napi_value cursorInfoResult = nullptr;
status = JsUtils::GetValue(env, in, "cursorInfo", cursorInfoResult);
bool result = false;
if (status == napi_ok) {
ret = JsGetInputMethodController::GetValue(env, cursorInfoResult, out.cursorInfo);
IMSA_HILOGE("get cursorInfo end, ret = %{public}d", ret);
result = JsGetInputMethodController::GetValue(env, cursorInfoResult, out.cursorInfo);
IMSA_HILOGE("get cursorInfo end, ret = %{public}d", result);
}
napi_value rangeResult = nullptr;
status = JsUtils::GetValue(env, in, "selection", rangeResult);
if (status == napi_ok) {
ret = JsGetInputMethodController::GetValue(env, rangeResult, out.range);
IMSA_HILOGE("get selectionRange end, ret = %{public}d", ret);
result = JsGetInputMethodController::GetValue(env, rangeResult, out.range);
IMSA_HILOGE("get selectionRange end, ret = %{public}d", result);
}
ret = JsUtil::Object::ReadProperty(env, in, "windowId", out.windowId);
IMSA_HILOGE("get windowId end, ret = %{public}d", ret);
result = JsUtil::Object::ReadProperty(env, in, "windowId", out.windowId);
IMSA_HILOGE("get windowId end, ret = %{public}d", result);
return ret;
}

View File

@ -123,7 +123,6 @@ private:
void OnConfigurationChange(Message *msg);
void ShowInputWindow(bool isShowKeyboard);
void DismissInputWindow();
void EnsureToShowPanel();
void OnTextConfigChange(const TextTotalConfig &textConfig);
bool isImeReady_{ false };
InputStartNotifier notifier_;

View File

@ -37,8 +37,6 @@ class MessageHandler;
using namespace MessageID;
sptr<InputMethodAbility> InputMethodAbility::instance_;
std::mutex InputMethodAbility::instanceLock_;
constexpr int32_t RETRY_COUNT = 10;
constexpr int32_t WAIT_GAP = 10;
constexpr double INVALID_CURSOR_VALUE = -1.0;
constexpr int32_t INVALID_SELECTION_VALUE = -1;
InputMethodAbility::InputMethodAbility() : stop_(false)
@ -388,23 +386,6 @@ void InputMethodAbility::OnConfigurationChange(Message *msg)
kdListener_->OnEditorAttributeChange(attribute);
}
void InputMethodAbility::EnsureToShowPanel()
{
for (int i = 0; i < RETRY_COUNT; ++i) {
auto result = panels_.Find(SOFT_KEYBOARD);
if (result.first) {
IMSA_HILOGI("find SOFT_KEYBOARD panel.");
auto ret = result.second->ShowPanel();
if (ret != ErrorCode::NO_ERROR) {
IMSA_HILOGE("Show panel failed, ret = %{public}d.", ret);
}
return;
}
IMSA_HILOGE("Not find SOFT_KEYBOARD panel, count = %{public}d", i);
std::this_thread::sleep_for(std::chrono::milliseconds(WAIT_GAP));
}
}
void InputMethodAbility::ShowInputWindow(bool isShowKeyboard)
{
IMSA_HILOGI("InputMethodAbility::ShowInputWindow");
@ -430,7 +411,15 @@ void InputMethodAbility::ShowInputWindow(bool isShowKeyboard)
return;
}
channel->SendKeyboardStatus(KEYBOARD_SHOW);
EnsureToShowPanel();
auto result = panels_.Find(SOFT_KEYBOARD);
if (result.first) {
IMSA_HILOGI("find SOFT_KEYBOARD panel.");
auto ret = result.second->ShowPanel();
if (ret != ErrorCode::NO_ERROR) {
IMSA_HILOGE("Show panel failed, ret = %{public}d.", ret);
}
return;
}
}
void InputMethodAbility::OnTextConfigChange(const TextTotalConfig &textConfig)

View File

@ -275,7 +275,7 @@ void InputMethodPanel::SetPanelStatusListener(
return;
}
panelStatusListener_ = std::move(statusListener);
if (IsShowing()) {
if (window_ != nullptr && IsShowing()) {
panelStatusListener_->OnPanelStatus(windowId_, true);
}
}