mirror of https://gitee.com/openkylin/fcitx5.git
Virtual keyboard Event should also support key press event and key release event
1. There are two kinds of virtual keyboard at least. 2. First, the virtual keyboard is the same as the physical keyboard except that the virtual keyboard is displayed on the screen while the physical keyboard not. So, the virtual keyboard and the physical keyboard should use the same logic of input method engine. 3. Second, the virtual keyboard use a different logic of input method engine which is dedicated to the virtual keyboard. In this case, the press event and the release event may not be so important.
This commit is contained in:
parent
f20de9fe15
commit
bbae9fc7f6
|
@ -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<VirtualKeyboardEventPrivate>(time)) {}
|
||||
d_ptr(std::make_unique<VirtualKeyboardEventPrivate>(isRelease, time)) {}
|
||||
|
||||
FCITX_DEFINE_DEFAULT_DTOR(VirtualKeyboardEvent);
|
||||
|
||||
|
@ -58,7 +61,8 @@ std::unique_ptr<KeyEvent> fcitx::VirtualKeyboardEvent::toKeyEvent() const {
|
|||
|
||||
Key key{d->key_.sym(), d->key_.states() | KeyState::Virtual,
|
||||
d->key_.code()};
|
||||
return std::make_unique<KeyEvent>(inputContext(), key, false, time());
|
||||
return std::make_unique<KeyEvent>(inputContext(), key, d->isRelease_,
|
||||
time());
|
||||
}
|
||||
|
||||
} // namespace fcitx
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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<KeySym>(keyval), KeyStates(state), keycode));
|
||||
|
||||
auto eventConsumed = inputContext->virtualKeyboardEvent(event);
|
||||
|
|
Loading…
Reference in New Issue