diff --git a/service/libinput_adapter/include/libinput_adapter.h b/service/libinput_adapter/include/libinput_adapter.h index 81066554a6cd434f97c312eaecbea33a30f77822..c3f94e07fa5013067a034ccbe4d273f5041ba746 100644 --- a/service/libinput_adapter/include/libinput_adapter.h +++ b/service/libinput_adapter/include/libinput_adapter.h @@ -37,6 +37,7 @@ typedef std::function ClearKeyMessage; typedef std::function HardwareKeyEventDetected; typedef std::function GetKeyboardActivationState; typedef std::function IsFloatingKeyboard; +typedef std::function IsVKeyboardShown; #ifdef OHOS_BUILD_ENABLE_VKEYBOARD enum VTPSwipeStateType { @@ -117,7 +118,8 @@ public: ClearKeyMessage clearKeyMessage, HardwareKeyEventDetected hardwareKeyEventDetected, GetKeyboardActivationState getKeyboardActivationState, - IsFloatingKeyboard isFloatingKeyboard + IsFloatingKeyboard isFloatingKeyboard, + IsVKeyboardShown isVKeyboardShown ); private: @@ -131,6 +133,7 @@ private: #ifdef OHOS_BUILD_ENABLE_VKEYBOARD void HandleVFullKeyboardMessages( libinput_event *event, int64_t frameTime, libinput_event_type eventType, libinput_event_touch *touch); + bool IsVKeyboardActivationDropEvent(libinput_event_touch* touch, libinput_event_type eventType); void HandleVKeyTouchpadMessages(libinput_event_touch* touch); void OnVKeyTrackPadMessage(libinput_event_touch* touch, const std::vector>& msgList); @@ -202,6 +205,7 @@ private: bool CreateVKeyboardDelayTimer(libinput_event *event, int32_t delayMs, int32_t keyCode); void StartVKeyboardDelayTimer(int32_t delayMs); bool GetIsCaptureMode(); + void UpdateBootFlag(); VTPSwipeStateType vtpSwipeState_ = VTPSwipeStateType::SWIPE_END; libinput_event *vkbDelayedEvent_ = nullptr; @@ -223,11 +227,11 @@ private: HardwareKeyEventDetected hardwareKeyEventDetected_ { nullptr }; GetKeyboardActivationState getKeyboardActivationState_ { nullptr }; IsFloatingKeyboard isFloatingKeyboard_ { nullptr }; + IsVKeyboardShown isVKeyboardShown_ { nullptr }; int32_t deviceId; std::unordered_map> touchPoints_; static std::unordered_map keyCodes_; std::unordered_map touchPointPressureCache_; - std::unordered_map skipTouchMoveCache_; HotplugDetector hotplugDetector_; std::unordered_map devices_; diff --git a/service/libinput_adapter/src/libinput_adapter.cpp b/service/libinput_adapter/src/libinput_adapter.cpp index 8a3d72dd8e502099b8b3686869586874d95550db..58ac3802a20edc4ea8e7350728e538edca5e3c7b 100644 --- a/service/libinput_adapter/src/libinput_adapter.cpp +++ b/service/libinput_adapter/src/libinput_adapter.cpp @@ -296,7 +296,8 @@ void LibinputAdapter::InitVKeyboard(HandleTouchPoint handleTouchPoint, ClearKeyMessage clearKeyMessage, HardwareKeyEventDetected hardwareKeyEventDetected, GetKeyboardActivationState getKeyboardActivationState, - IsFloatingKeyboard isFloatingKeyboard) + IsFloatingKeyboard isFloatingKeyboard, + IsVKeyboardShown isVKeyboardShown) { handleTouchPoint_ = handleTouchPoint; getMessage_ = getMessage; @@ -307,6 +308,7 @@ void LibinputAdapter::InitVKeyboard(HandleTouchPoint handleTouchPoint, hardwareKeyEventDetected_ = hardwareKeyEventDetected; getKeyboardActivationState_ = getKeyboardActivationState; isFloatingKeyboard_ = isFloatingKeyboard; + isVKeyboardShown_ = isVKeyboardShown; // init touch device Id. deviceId = -1; @@ -1603,27 +1605,58 @@ double LibinputAdapter::GetAccumulatedPressure(int touchId, int32_t eventType, d return accumulatedPressure; } -bool LibinputAdapter::SkipTouchMove(int touchId, int32_t eventType) +bool LibinputAdapter::IsVKeyboardActivationDropEvent(libinput_event_touch* touch, libinput_event_type eventType) { - if (eventType == LIBINPUT_EVENT_TOUCH_DOWN) { - skipTouchMoveCache_[touchId] = true; - } else if (eventType == LIBINPUT_EVENT_TOUCH_UP) { - auto pos = skipTouchMoveCache_.find(touchId); - if (pos != skipTouchMoveCache_.end()) { - skipTouchMoveCache_.erase(pos); - } - } else if (eventType == LIBINPUT_EVENT_TOUCH_MOTION) { - auto pos = skipTouchMoveCache_.find(touchId); - if (pos != skipTouchMoveCache_.end()) { - return pos->second; + bool bDropEventFlag = false; + if (getKeyboardActivationState_ != nullptr) { + VKeyboardActivation activateState = (VKeyboardActivation)getKeyboardActivationState_(); + switch (activateState) { + case VKeyboardActivation::INACTIVE: { + break; + } + case VKeyboardActivation::ACTIVATED: { + MMI_HILOGI("activation state: %{public}d", static_cast(activateState)); + break; + } + case VKeyboardActivation::TOUCH_CANCEL: { + MMI_HILOGI( + "activation state: %{public}d, sending touch cancel event", static_cast(activateState)); + if (eventType == LIBINPUT_EVENT_TOUCH_MOTION) { + libinput_set_touch_event_type(touch, LIBINPUT_EVENT_TOUCH_CANCEL); + } + if (eventType == LIBINPUT_EVENT_TOUCH_DOWN) { + bDropEventFlag = true; + } + break; + } + case VKeyboardActivation::TOUCH_DROP: { + MMI_HILOGI("activation state: %{public}d, dropping event", static_cast(activateState)); + if (eventType != LIBINPUT_EVENT_TOUCH_UP) { + bDropEventFlag = true; + } + break; + } + case VKeyboardActivation::EIGHT_FINGERS_UP: { + MMI_HILOGI("activation state: %{public}d", static_cast(activateState)); + break; + } + default: + break; } - } else if (eventType == LIBINPUT_EVENT_TOUCH_FRAME) { - auto pos = skipTouchMoveCache_.find(touchId); - if (pos != skipTouchMoveCache_.end()) { - skipTouchMoveCache_[touchId] = !pos->second; + } + return bDropEventFlag; +} + +void LibinputAdapter::UpdateBootFlag() +{ + if (!isBootCompleted_ && isVKeyboardShown_ != nullptr) { + isBootCompleted_ = isVKeyboardShown_(); + if (isBootCompleted_) { + MMI_HILOGI("backend booted from outside (mainly due to process restart)=%{public}d", + static_cast(isBootCompleted_)); } } - return false; + // could also check SA status here. } #endif // OHOS_BUILD_ENABLE_VKEYBOARD @@ -1669,6 +1702,9 @@ void LibinputAdapter::OnEventHandler() libinput_event_touch* touch = nullptr; static int32_t downCount = 0; + // confirm boot completed msg in case of mmi restart. + UpdateBootFlag(); + // add the logic of screen capture window conuming touch point in high priority bool isCaptureMode = GetIsCaptureMode(); if (((eventType == LIBINPUT_EVENT_TOUCH_DOWN && !isCaptureMode) @@ -1733,46 +1769,7 @@ type:%{private}d, accPressure:%{private}f, longAxis:%{private}d, shortAxis:%{pri MMI_HILOGD("Inside vkeyboard area"); HandleVFullKeyboardMessages(event, frameTime, eventType, touch); } else { - bool bDropEventFlag = false; - - if (getKeyboardActivationState_ != nullptr) { - VKeyboardActivation activateState = (VKeyboardActivation)getKeyboardActivationState_(); - switch (activateState) { - case VKeyboardActivation::INACTIVE : { - break; - } - case VKeyboardActivation::ACTIVATED : { - MMI_HILOGI("activation state: %{public}d", static_cast(activateState)); - break; - } - case VKeyboardActivation::TOUCH_CANCEL : { - MMI_HILOGI("activation state: %{public}d, sending touch cancel event", - static_cast(activateState)); - if (eventType == LIBINPUT_EVENT_TOUCH_MOTION) { - libinput_set_touch_event_type(touch, LIBINPUT_EVENT_TOUCH_CANCEL); - } - if (eventType == LIBINPUT_EVENT_TOUCH_DOWN) { - bDropEventFlag = true; - } - break; - } - case VKeyboardActivation::TOUCH_DROP : { - MMI_HILOGI("activation state: %{public}d, dropping event", - static_cast(activateState)); - if (eventType != LIBINPUT_EVENT_TOUCH_UP) { - bDropEventFlag = true; - } - break; - } - case VKeyboardActivation::EIGHT_FINGERS_UP : { - MMI_HILOGI("activation state: %{public}d", static_cast(activateState)); - break; - } - default: - break; - } - } - + bool bDropEventFlag = IsVKeyboardActivationDropEvent(touch, eventType); if (!bDropEventFlag) { funInputEvent_(event, frameTime); } diff --git a/service/message_handle/src/server_msg_handler.cpp b/service/message_handle/src/server_msg_handler.cpp index bd13852b4230f7f88317cda2fec5cd79663f0894..0f092e665b77b767e609c7a43624511a6695e508 100644 --- a/service/message_handle/src/server_msg_handler.cpp +++ b/service/message_handle/src/server_msg_handler.cpp @@ -206,7 +206,7 @@ int32_t ServerMsgHandler::OnSetFunctionKeyState(int32_t pid, int32_t funcKey, bo return RET_OK; } #ifdef OHOS_BUILD_ENABLE_VKEYBOARD - if (hasVirtualKeyboard && funcKey == KeyEvent::CAPS_LOCK_FUNCTION_KEY) { + if (funcKey == KeyEvent::CAPS_LOCK_FUNCTION_KEY) { // set vkeyboard caps state with separate API. MMI_HILOGD("Set vkb func state old=%{private}d, new=%{private}d", checkState, enable); libinput_toggle_caps_key(); diff --git a/service/module_loader/src/mmi_service.cpp b/service/module_loader/src/mmi_service.cpp index b55c976c283ee9f52ec2a7a37018650aa097aa08..fa59185f0d78732882a73f671583d2ee2aea7db0 100644 --- a/service/module_loader/src/mmi_service.cpp +++ b/service/module_loader/src/mmi_service.cpp @@ -162,6 +162,8 @@ typedef int32_t (*VKEYBOARD_GETKEYBOARDACTIVATIONSTATE_TYPE)(); VKEYBOARD_GETKEYBOARDACTIVATIONSTATE_TYPE vkeyboard_getKeyboardActivationState_ = nullptr; typedef bool (*GAUSSIANKEYBOARD_ISFLOATINGKEYBOARD_TYPE)(); GAUSSIANKEYBOARD_ISFLOATINGKEYBOARD_TYPE gaussiankeyboard_isFloatingKeyboard_ = nullptr; +typedef bool (*VKEYBOARD_ISSHOWN)(); +VKEYBOARD_ISSHOWN vkeyboard_isShown_ = nullptr; #endif // OHOS_BUILD_ENABLE_VKEYBOARD #ifdef OHOS_BUILD_PC_PRIORITY @@ -3240,6 +3242,7 @@ void MMIService::InitVKeyboardFuncHandler() g_VKeyboardHandle, "GetKeyboardActivationState"); gaussiankeyboard_isFloatingKeyboard_ = (GAUSSIANKEYBOARD_ISFLOATINGKEYBOARD_TYPE)dlsym( g_VKeyboardHandle, "IsFloatingKeyboard"); + vkeyboard_isShown_ = (VKEYBOARD_ISSHOWN)dlsym(g_VKeyboardHandle, "IsVKeyboardShown"); libinputAdapter_.InitVKeyboard(handleTouchPoint_, statemachineMessageQueue_getLibinputMessage_, @@ -3249,7 +3252,8 @@ void MMIService::InitVKeyboardFuncHandler() trackPadEngine_clearKeyMessage_, vkeyboard_hardwareKeyEventDetected_, vkeyboard_getKeyboardActivationState_, - gaussiankeyboard_isFloatingKeyboard_); + gaussiankeyboard_isFloatingKeyboard_, + vkeyboard_isShown_); } } }