diff --git a/src/lib/fcitx/event.cpp b/src/lib/fcitx/event.cpp index c4686094..7e300f18 100644 --- a/src/lib/fcitx/event.cpp +++ b/src/lib/fcitx/event.cpp @@ -11,9 +11,11 @@ namespace fcitx { class VirtualKeyboardEventPrivate { public: - VirtualKeyboardEventPrivate(int time) : time_(time) {} + VirtualKeyboardEventPrivate(bool isRelease, int time) + : isRelease_(isRelease), time_(time) {} Key key_; + bool isRelease_ = false; int time_ = 0; uint64_t userAction_ = 0; std::string text_; @@ -28,9 +30,10 @@ KeyEventBase::KeyEventBase(EventType type, InputContext *context, Key rawKey, : InputContextEvent(context, type), key_(rawKey.normalize()), origKey_(rawKey), rawKey_(rawKey), isRelease_(isRelease), time_(time) {} -VirtualKeyboardEvent::VirtualKeyboardEvent(InputContext *context, int time) +VirtualKeyboardEvent::VirtualKeyboardEvent(InputContext *context, + bool isRelease, int time) : InputContextEvent(context, EventType::InputContextVirtualKeyboardEvent), - d_ptr(std::make_unique(time)) {} + d_ptr(std::make_unique(isRelease, time)) {} FCITX_DEFINE_DEFAULT_DTOR(VirtualKeyboardEvent); @@ -58,7 +61,8 @@ std::unique_ptr fcitx::VirtualKeyboardEvent::toKeyEvent() const { Key key{d->key_.sym(), d->key_.states() | KeyState::Virtual, d->key_.code()}; - return std::make_unique(inputContext(), key, false, time()); + return std::make_unique(inputContext(), key, d->isRelease_, + time()); } } // namespace fcitx diff --git a/src/lib/fcitx/event.h b/src/lib/fcitx/event.h index 70ee6476..c1da11cf 100644 --- a/src/lib/fcitx/event.h +++ b/src/lib/fcitx/event.h @@ -339,7 +339,7 @@ class VirtualKeyboardEventPrivate; class FCITXCORE_EXPORT VirtualKeyboardEvent : public InputContextEvent { public: - VirtualKeyboardEvent(InputContext *context, int time = 0); + VirtualKeyboardEvent(InputContext *context, bool isRelease, int time = 0); ~VirtualKeyboardEvent(); int time() const; diff --git a/src/ui/virtualkeyboard/virtualkeyboard.cpp b/src/ui/virtualkeyboard/virtualkeyboard.cpp index 60b4ee44..0f149e0c 100644 --- a/src/ui/virtualkeyboard/virtualkeyboard.cpp +++ b/src/ui/virtualkeyboard/virtualkeyboard.cpp @@ -153,7 +153,7 @@ void VirtualKeyboardBackend::processKeyEvent(uint32_t keyval, uint32_t keycode, return; } - VirtualKeyboardEvent event(inputContext, time); + VirtualKeyboardEvent event(inputContext, isRelease, time); event.setKey(Key(static_cast(keyval), KeyStates(state), keycode)); auto eventConsumed = inputContext->virtualKeyboardEvent(event);