From eee7740a5749d73e6ff94d8e01a23c62ffe65882 Mon Sep 17 00:00:00 2001 From: lancer <591320480@qq.com> Date: Wed, 15 Mar 2023 16:14:07 +0800 Subject: [PATCH] Description: check zero count when dispatch rotate end event IssueNo: https://gitee.com/openharmony/graphic_ui/issues/I6NDKY Feature or Bugfix: Feature Binary Source:No Signed-off-by: lancer --- frameworks/dock/rotate_input_device.cpp | 16 ++++++++++++---- interfaces/innerkits/dock/rotate_input_device.h | 1 + 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/frameworks/dock/rotate_input_device.cpp b/frameworks/dock/rotate_input_device.cpp index d8e56b5..d836eb2 100644 --- a/frameworks/dock/rotate_input_device.cpp +++ b/frameworks/dock/rotate_input_device.cpp @@ -25,10 +25,14 @@ constexpr int16_t ROTATE_INPUT_THRESHOLD = 1; #else constexpr int16_t ROTATE_INPUT_THRESHOLD = 10; #endif +constexpr uint8_t ROTATE_END_ZERO_COUNT = 2; } namespace OHOS { -RotateInputDevice::RotateInputDevice() : rotateStart_(false), threshold_(ROTATE_INPUT_THRESHOLD), cachedRotation_(0) {} +RotateInputDevice::RotateInputDevice() + : rotateStart_(false), threshold_(ROTATE_INPUT_THRESHOLD), cachedRotation_(0), zeroCount_(0) +{ +} void RotateInputDevice::DispatchEvent(const DeviceData& data) { @@ -65,9 +69,13 @@ void RotateInputDevice::DispatchEvent(const DeviceData& data) } if (data.rotate == 0 && rotateStart_) { - view->OnRotateEndEvent(0); - rotateStart_ = false; - GRAPHIC_LOGW("RotateInputDevice dispatched 0-value event!\n"); + zeroCount_++; + if (zeroCount_ >= ROTATE_END_ZERO_COUNT) { + view->OnRotateEndEvent(0); + zeroCount_ = 0; + rotateStart_ = false; + GRAPHIC_LOGW("RotateInputDevice dispatched 0-value event!\n"); + } return; } if (!rotateStart_) { diff --git a/interfaces/innerkits/dock/rotate_input_device.h b/interfaces/innerkits/dock/rotate_input_device.h index 706e41e..496a318 100644 --- a/interfaces/innerkits/dock/rotate_input_device.h +++ b/interfaces/innerkits/dock/rotate_input_device.h @@ -39,6 +39,7 @@ protected: bool rotateStart_; int16_t threshold_; int16_t cachedRotation_; + uint8_t zeroCount_; }; } // namespace OHOS -- GitLab