7 #ifndef _FCITX_EVENT_H_ 8 #define _FCITX_EVENT_H_ 17 #include <fcitx-utils/macros.h> 18 #include <fcitx/fcitxcore_export.h> 31 enum class ResetReason {
32 ChangeByInactivate FCITXCORE_DEPRECATED,
33 LostFocus FCITXCORE_DEPRECATED,
34 SwitchIM FCITXCORE_DEPRECATED,
60 enum class InputMethodMode { PhysicalKeyboard, OnScreenKeyboard };
66 EventTypeFlag = 0xfffff000,
67 UserTypeFlag = 0xffff0000,
69 InputContextEventFlag = 0x0001000,
71 InputMethodEventFlag = 0x0002000,
77 InputContextCreated = InputContextEventFlag | 0x1,
78 InputContextDestroyed = InputContextEventFlag | 0x2,
115 InputContextSurroundingTextUpdated = InputContextEventFlag | 0x7,
116 InputContextCapabilityChanged = InputContextEventFlag | 0x8,
117 InputContextCursorRectChanged = InputContextEventFlag | 0x9,
118 InputContextCapabilityAboutToChange = InputContextEventFlag | 0xD,
130 InputContextInputMethodActivated = InputContextEventFlag | 0xB,
131 InputContextInputMethodDeactivated = InputContextEventFlag | 0xC,
141 InputContextVirtualKeyboardEvent = InputContextEventFlag | 0xF,
143 InputContextForwardKey = InputMethodEventFlag | 0x1,
144 InputContextCommitString = InputMethodEventFlag | 0x2,
145 InputContextDeleteSurroundingText = InputMethodEventFlag | 0x3,
146 InputContextUpdatePreedit = InputMethodEventFlag | 0x4,
147 InputContextUpdateUI = InputMethodEventFlag | 0x5,
148 InputContextCommitStringWithCursor = InputMethodEventFlag | 0x6,
149 InputContextFlushUI = InputMethodEventFlag | 0x7,
224 void accept() { accepted_ =
true; }
249 auto flag =
static_cast<uint32_t
>(EventType::InputContextEventFlag);
250 auto mask =
static_cast<uint32_t
>(EventType::EventTypeFlag);
251 return (static_cast<uint32_t>(type_) & mask) == flag;
256 bool accepted_ =
false;
262 :
Event(type), ic_(context) {}
273 bool isRelease =
false,
int time = 0);
330 bool isRelease()
const {
return isRelease_; }
331 int time()
const {
return time_; }
351 Key key_, origKey_, rawKey_;
354 bool forward_ =
false;
364 void filter() { filtered_ =
true; }
365 bool filtered()
const override {
return filtered_; }
366 void filterAndAccept() {
372 bool filtered_ =
false;
384 void setKey(
Key key);
385 const Key &key()
const;
387 void setPosition(
float x,
float y);
391 void setLongPress(
bool longPress);
392 bool isLongPress()
const;
394 void setUserAction(uint64_t actionId);
395 uint64_t userAction()
const;
397 void setText(std::string text);
398 const std::string &text()
const;
400 std::unique_ptr<KeyEvent> toKeyEvent()
const;
404 std::unique_ptr<VirtualKeyboardEventPrivate> d_ptr;
411 :
KeyEventBase(EventType::InputContextForwardKey, context, rawKey,
421 const std::string &text()
const {
return text_; }
438 EventType::InputContextCommitStringWithCursor),
439 text_(std::move(text)), cursor_(cursor) {}
441 const std::string &text()
const {
return text_; }
442 size_t cursor()
const {
return cursor_; }
451 enum class Action { LeftClick, RightClick };
454 action_(action), cursor_(cursor) {}
456 Action action()
const {
return action_; }
457 int cursor()
const {
return cursor_; }
463 bool filtered()
const override {
return filtered_; }
468 bool filtered_ =
false;
475 const std::string &oldIM,
478 reason_(reason), oldInputMethod_(oldIM) {}
481 const std::string &oldInputMethod()
const {
return oldInputMethod_; }
485 std::string oldInputMethod_;
495 reason_(ResetReason::Client) {}
497 FCITXCORE_DEPRECATED ResetReason reason()
const {
return reason_; }
508 component_(component), immediate_(immediate) {}
511 bool immediate()
const {
return immediate_; }
528 component_(component) {}
548 const std::string &name()
const {
return name_; }
559 EventType::InputContextInputMethodActivated, name, context) {}
567 EventType::InputContextInputMethodDeactivated, name, context) {}
570 #define FCITX_DEFINE_SIMPLE_EVENT(NAME, TYPE, ARGS...) \ 571 struct FCITXCORE_EXPORT NAME##Event : public InputContextEvent { \ 572 NAME##Event(InputContext *ic) \ 573 : InputContextEvent(ic, EventType::TYPE) {} \ 576 FCITX_DEFINE_SIMPLE_EVENT(InputContextCreated, InputContextCreated);
577 FCITX_DEFINE_SIMPLE_EVENT(InputContextDestroyed, InputContextDestroyed);
580 FCITX_DEFINE_SIMPLE_EVENT(SurroundingTextUpdated,
581 InputContextSurroundingTextUpdated);
582 FCITX_DEFINE_SIMPLE_EVENT(CursorRectChanged, InputContextCursorRectChanged);
583 FCITX_DEFINE_SIMPLE_EVENT(UpdatePreedit, InputContextUpdatePreedit);
612 bool filtered()
const override {
return filtered_; }
615 bool filtered_ =
false;
628 oldFocus_(oldFocus), newFocus_(newFocus) {}
667 newFlags_(newFlags) {}
669 auto oldFlags()
const {
return oldFlags_; }
670 auto newFlags()
const {
return newFlags_; }
682 oldFlags, newFlags) {}
690 oldFlags, newFlags) {}
695 #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.