7 #ifndef _FCITX_EVENT_H_ 8 #define _FCITX_EVENT_H_ 14 #include "fcitxcore_export.h" 26 enum class ResetReason {
27 ChangeByInactivate FCITXCORE_DEPRECATED,
28 LostFocus FCITXCORE_DEPRECATED,
29 SwitchIM FCITXCORE_DEPRECATED,
55 enum class InputMethodMode { PhysicalKeyboard, OnScreenKeyboard };
61 EventTypeFlag = 0xfffff000,
62 UserTypeFlag = 0xffff0000,
64 InputContextEventFlag = 0x0001000,
66 InputMethodEventFlag = 0x0002000,
72 InputContextCreated = InputContextEventFlag | 0x1,
73 InputContextDestroyed = InputContextEventFlag | 0x2,
110 InputContextSurroundingTextUpdated = InputContextEventFlag | 0x7,
111 InputContextCapabilityChanged = InputContextEventFlag | 0x8,
112 InputContextCursorRectChanged = InputContextEventFlag | 0x9,
113 InputContextCapabilityAboutToChange = InputContextEventFlag | 0xD,
125 InputContextInputMethodActivated = InputContextEventFlag | 0xB,
126 InputContextInputMethodDeactivated = InputContextEventFlag | 0xC,
136 InputContextVirtualKeyboardEvent = InputContextEventFlag | 0xF,
138 InputContextForwardKey = InputMethodEventFlag | 0x1,
139 InputContextCommitString = InputMethodEventFlag | 0x2,
140 InputContextDeleteSurroundingText = InputMethodEventFlag | 0x3,
141 InputContextUpdatePreedit = InputMethodEventFlag | 0x4,
142 InputContextUpdateUI = InputMethodEventFlag | 0x5,
143 InputContextCommitStringWithCursor = InputMethodEventFlag | 0x6,
144 InputContextFlushUI = InputMethodEventFlag | 0x7,
219 void accept() { accepted_ =
true; }
244 auto flag =
static_cast<uint32_t
>(EventType::InputContextEventFlag);
245 auto mask =
static_cast<uint32_t
>(EventType::EventTypeFlag);
246 return (static_cast<uint32_t>(type_) & mask) == flag;
251 bool accepted_ =
false;
257 :
Event(type), ic_(context) {}
268 bool isRelease =
false,
int time = 0);
325 bool isRelease()
const {
return isRelease_; }
326 int time()
const {
return time_; }
346 Key key_, origKey_, rawKey_;
349 bool forward_ =
false;
359 void filter() { filtered_ =
true; }
360 bool filtered()
const override {
return filtered_; }
361 void filterAndAccept() {
367 bool filtered_ =
false;
379 void setKey(
Key key);
380 const Key &key()
const;
382 void setPosition(
float x,
float y);
386 void setLongPress(
bool longPress);
387 bool isLongPress()
const;
389 void setUserAction(uint64_t actionId);
390 uint64_t userAction()
const;
392 void setText(std::string text);
393 const std::string &text()
const;
395 std::unique_ptr<KeyEvent> toKeyEvent()
const;
399 std::unique_ptr<VirtualKeyboardEventPrivate> d_ptr;
406 :
KeyEventBase(EventType::InputContextForwardKey, context, rawKey,
416 const std::string &text()
const {
return text_; }
433 EventType::InputContextCommitStringWithCursor),
434 text_(std::move(text)), cursor_(cursor) {}
436 const std::string &text()
const {
return text_; }
437 size_t cursor()
const {
return cursor_; }
446 enum class Action { LeftClick, RightClick };
449 action_(action), cursor_(cursor) {}
451 Action action()
const {
return action_; }
452 int cursor()
const {
return cursor_; }
458 bool filtered()
const override {
return filtered_; }
463 bool filtered_ =
false;
470 const std::string &oldIM,
473 reason_(reason), oldInputMethod_(oldIM) {}
476 const std::string &oldInputMethod()
const {
return oldInputMethod_; }
480 std::string oldInputMethod_;
490 reason_(ResetReason::Client) {}
492 FCITXCORE_DEPRECATED ResetReason reason()
const {
return reason_; }
503 component_(component), immediate_(immediate) {}
506 bool immediate()
const {
return immediate_; }
523 component_(component) {}
543 const std::string &name()
const {
return name_; }
554 EventType::InputContextInputMethodActivated, name, context) {}
562 EventType::InputContextInputMethodDeactivated, name, context) {}
565 #define FCITX_DEFINE_SIMPLE_EVENT(NAME, TYPE, ARGS...) \ 566 struct FCITXCORE_EXPORT NAME##Event : public InputContextEvent { \ 567 NAME##Event(InputContext *ic) \ 568 : InputContextEvent(ic, EventType::TYPE) {} \ 571 FCITX_DEFINE_SIMPLE_EVENT(InputContextCreated, InputContextCreated);
572 FCITX_DEFINE_SIMPLE_EVENT(InputContextDestroyed, InputContextDestroyed);
575 FCITX_DEFINE_SIMPLE_EVENT(SurroundingTextUpdated,
576 InputContextSurroundingTextUpdated);
577 FCITX_DEFINE_SIMPLE_EVENT(CursorRectChanged, InputContextCursorRectChanged);
578 FCITX_DEFINE_SIMPLE_EVENT(UpdatePreedit, InputContextUpdatePreedit);
607 bool filtered()
const override {
return filtered_; }
610 bool filtered_ =
false;
623 oldFocus_(oldFocus), newFocus_(newFocus) {}
662 newFlags_(newFlags) {}
664 auto oldFlags()
const {
return oldFlags_; }
665 auto newFlags()
const {
return newFlags_; }
677 oldFlags, newFlags) {}
685 oldFlags, newFlags) {}
690 #endif // _FCITX_EVENT_H_ InputMethodGroupAboutToChangeEvent is generated when input method group is about to be changed...
bool accepted() const
Return value used by Instance::postEvent.
EventType
Type of input method events.
Switched by alternative trigger key.
void setHasUpdate()
Make checking update short circuit.
FocusInEvent is generated when client gets focused.
Notify a focus change for focus group.
Switched by activate key.
This is generated when input method group changed.
when user switch to a different input method by hand such as ctrl+shift by default, or by ui, default behavior is reset IM.
InputMethodSwitchedReason
The reason why input method is switched to another.
void setKey(const Key &key)
It will automatically be called if input method layout does not match the system keyboard layout...
Key key() const
Normalized key event.
bool isVirtual() const
Whether this key event is derived from a virtual keyboard.
virtual bool filtered() const
Whether a event is filtered by handler.
Switched by group change.
bool filtered() const override
Whether a event is filtered by handler.
Base class for fcitx event.
Virtual keyboard visibility changed.
Enum type for input context capability.
Switched by capability change (e.g. password field)
Base class for User Interface addon.
Global config is reloaded.
Events triggered that user interface manager that flush the UI update.
InvokeAction event is generated when client click on the preedit.
bool filtered() const override
Whether a event is filtered by handler.
FocusGroupFocusChanged is posted when a focus group changed its focused input context.
Key rawKey() const
Key event after layout conversion.
CheckUpdateEvent is posted when the Instance is requested to check for newly installed addons and inp...
Input method mode changed.
bool filtered() const override
Whether a event is filtered by handler.
bool isInputContextEvent() const
A helper function to check if a event is input context event.
UIChangedEvent is posted when the UI implementation is changed.
Key origKey() const
Key event regardless of keyboard layout conversion.
Class provides bit flag support for Enum.
Event for commit string with cursor.
EventType type() const
Type of event, can be used to decide event class.
An input context represents a client of Fcitx.
Key event is generated when client press or release a key.
Class to represent a key.
void setRawKey(const Key &key)
It is designed for faking the key event.
Switched by deactivate key.
bool forward() const
If true, the key that produce character will commit a string.
void setForward(bool forward)
It is designed for overriding the key forward option.
Notify the global config is reloaded.
when using lost focus this might be variance case to case.
Switched by enumerate key.
Key normalize() const
Normalize a key, usually used when key is from frontend.