Fcitx
event.h
Go to the documentation of this file.
1 /*
2  * SPDX-FileCopyrightText: 2016-2016 CSSlayer <wengxt@gmail.com>
3  *
4  * SPDX-License-Identifier: LGPL-2.1-or-later
5  *
6  */
7 #ifndef _FCITX_EVENT_H_
8 #define _FCITX_EVENT_H_
9 
10 #include <cstddef>
11 #include <cstdint>
12 #include <memory>
13 #include <string>
14 #include <utility>
16 #include <fcitx-utils/flags.h>
17 #include <fcitx-utils/key.h>
18 #include <fcitx-utils/macros.h>
19 #include <fcitx/fcitxcore_export.h>
20 #include <fcitx/userinterface.h>
21 #include <span>
22 
23 /// \addtogroup FcitxCore
24 /// \{
25 /// \file
26 /// \brief Input Method event for Fcitx.
27 
28 namespace fcitx {
29 
30 class InputContext;
31 class FocusGroup;
32 
33 enum class ResetReason {
34  ChangeByInactivate FCITXCORE_DEPRECATED,
35  LostFocus FCITXCORE_DEPRECATED,
36  SwitchIM FCITXCORE_DEPRECATED,
37  Client
38 };
39 
40 /**
41  * The reason why input method is switched to another.
42  */
44  /// Switched by trigger key
45  Trigger,
46  /// Switched by deactivate key
47  Deactivate,
48  /// Switched by alternative trigger key
49  AltTrigger,
50  /// Switched by activate key
51  Activate,
52  /// Switched by enumerate key
53  Enumerate,
54  /// Switched by group change
56  /// Switched by capability change (e.g. password field)
58  /// miscellaneous reason
59  Other,
60 };
61 
62 enum class InputMethodMode { PhysicalKeyboard, OnScreenKeyboard };
63 
64 /**
65  * Type of input method events.
66  */
67 enum class EventType : uint32_t {
68  EventTypeFlag = 0xfffff000,
69  UserTypeFlag = 0xffff0000,
70  // send by frontend, captured by core, input method, or module
71  InputContextEventFlag = 0x0001000,
72  // send by im, captured by frontend, or module
73  InputMethodEventFlag = 0x0002000,
74 
75  /**
76  * captured by everything
77  */
78  InstanceEventFlag = 0x0003000,
79  InputContextCreated = InputContextEventFlag | 0x1,
80  InputContextDestroyed = InputContextEventFlag | 0x2,
81  /**
82  * FocusInEvent is generated when client gets focused.
83  *
84  * @see FocusInEvent
85  */
86  InputContextFocusIn = InputContextEventFlag | 0x3,
87  /**
88  * when using lost focus
89  * this might be variance case to case. the default behavior is to commit
90  * the preedit, and resetIM.
91  *
92  * Controlled by [Output/DontCommitPreeditWhenUnfocus], this option will not
93  * work for application switch doesn't support async commit.
94  *
95  * So OnClose is called when preedit IS committed (not like
96  * CChangeByInactivate,
97  * this behavior cannot be overridden), it give im a chance to choose
98  * remember this
99  * word or not.
100  *
101  * Input method need to notice, that the commit is already DONE, do not do
102  * extra commit.
103  *
104  * @see FocusOutEvent
105  */
106  InputContextFocusOut = InputContextEventFlag | 0x4,
107  /**
108  * Key event is generated when client press or release a key.
109  * @see KeyEvent
110  */
111  InputContextKeyEvent = InputContextEventFlag | 0x5,
112  /**
113  * ResetEvent is generated
114  *
115  */
116  InputContextReset = InputContextEventFlag | 0x6,
117  InputContextSurroundingTextUpdated = InputContextEventFlag | 0x7,
118  InputContextCapabilityChanged = InputContextEventFlag | 0x8,
119  InputContextCursorRectChanged = InputContextEventFlag | 0x9,
120  InputContextCapabilityAboutToChange = InputContextEventFlag | 0xD,
121  /**
122  * when user switch to a different input method by hand
123  * such as ctrl+shift by default, or by ui,
124  * default behavior is reset IM.
125  */
126  InputContextSwitchInputMethod = InputContextEventFlag | 0xA,
127 
128  // Two convenient event after input method is actually activate and
129  // deactivated. Useful for UI to update after specific input method get
130  // activated and deactivated. Will not be emitted if the input method is not
131  // a valid one.
132  InputContextInputMethodActivated = InputContextEventFlag | 0xB,
133  InputContextInputMethodDeactivated = InputContextEventFlag | 0xC,
134  /**
135  * InvokeAction event is generated when client click on the preedit.
136  *
137  * Not all client support this feature.
138  *
139  * @since 5.0.11
140  */
141  InputContextInvokeAction = InputContextEventFlag | 0xE,
142 
143  InputContextVirtualKeyboardEvent = InputContextEventFlag | 0xF,
144 
145  InputContextForwardKey = InputMethodEventFlag | 0x1,
146  InputContextCommitString = InputMethodEventFlag | 0x2,
147  InputContextDeleteSurroundingText = InputMethodEventFlag | 0x3,
148  InputContextUpdatePreedit = InputMethodEventFlag | 0x4,
149  InputContextUpdateUI = InputMethodEventFlag | 0x5,
150  InputContextCommitStringWithCursor = InputMethodEventFlag | 0x6,
151  InputContextFlushUI = InputMethodEventFlag | 0x7,
152 
153  /**
154  * This is generated when input method group changed.
155  * This would also trigger InputContextSwitchInputMethod afterwards.
156  */
158  /**
159  * InputMethodGroupAboutToChangeEvent is generated when input method group
160  * is about to be changed.
161  *
162  * @see InputMethodGroupAboutToChange
163  */
165  /**
166  * UIChangedEvent is posted when the UI implementation is changed.
167  */
169  /**
170  * CheckUpdateEvent is posted when the Instance is requested to check for
171  * newly installed addons and input methods.
172  *
173  * This can be used for addons to pick up new input methods if it provides
174  * input method at runtime.
175  */
177  /**
178  * FocusGroupFocusChanged is posted when a focus group changed its focused
179  * input context.
180  *
181  * This is a more fine grained control over focus in and focus out event.
182  * This is more useful for UI to keep track of what input context is being
183  * focused.
184  *
185  * @see FocusInEvent
186  * @see FocusOutEvent
187  */
189  /**
190  * Input method mode changed
191  */
193  /**
194  * Global config is reloaded
195  *
196  * This only fires after fcitx has entered running state.
197  * The initial load will not trigger this event.
198  * @see GlobalConfig
199  * @since 5.1.0
200  */
202  /**
203  * Virtual keyboard visibility changed
204  *
205  * @see UserInterfaceManager
206  * @since 5.1.0
207  */
209 };
210 
211 template <EventType T>
213 
214 template <EventType T>
215 using EventFor = typename EventForType<T>::type;
216 
217 #define FCITX_DEFINE_EVENT_TYPE(KLASS, TYPE) \
218  template <> \
219  struct EventForType<EventType::TYPE> { \
220  using type = KLASS; \
221  }
222 
223 /**
224  * Base class for fcitx event.
225  */
226 class FCITXCORE_EXPORT Event {
227 public:
228  Event(EventType type) : type_(type) {}
229  virtual ~Event();
230 
231  /**
232  * Type of event, can be used to decide event class.
233  *
234  * @return fcitx::EventType
235  */
236  EventType type() const { return type_; }
237 
238  void accept() { accepted_ = true; }
239  /**
240  * Return value used by Instance::postEvent.
241  *
242  * @see Instance::postEvent
243  * @return bool
244  */
245  bool accepted() const { return accepted_; }
246 
247  /**
248  * Whether a event is filtered by handler.
249  *
250  * If event is filtered, it will not send to another handler.
251  * For now only keyevent from input context can be filtered.
252  *
253  * @return bool
254  */
255  virtual bool filtered() const { return false; }
256 
257  /**
258  * A helper function to check if a event is input context event.
259  *
260  * @return bool
261  */
262  bool isInputContextEvent() const {
263  auto flag = static_cast<uint32_t>(EventType::InputContextEventFlag);
264  auto mask = static_cast<uint32_t>(EventType::EventTypeFlag);
265  return (static_cast<uint32_t>(type_) & mask) == flag;
266  }
267 
268 protected:
269  EventType type_;
270  bool accepted_ = false;
271 };
272 
273 class FCITXCORE_EXPORT InputContextEvent : public Event {
274 public:
276  : Event(type), ic_(context) {}
277 
278  InputContext *inputContext() const { return ic_; }
279 
280 protected:
281  InputContext *ic_;
282 };
283 
284 /**
285  * Key event matching mode.
286  * @since 5.1.23
287  */
289  /**
290  * Match the normalized key event.
291  *
292  * This is the default matching mode.
293  * If the matching key using key code, the raw key will be used to avoid
294  * missing the key states.
295  */
296  MatchNormalizedKey = (1 << 0),
297  /**
298  * Match the original key event.
299  *
300  * This is the key event before any layout conversion.
301  */
302  MatchOrigKey = (1 << 1),
303  /**
304  * Match the original key event before layout conversion, after
305  * normalization.
306  *
307  * This can be used to match key with system layout.
308  * Similar to MatchNormalizedKey, the key code mode matching will be using
309  * the unnormalized orig key.
310  */
311  MatchNormalizedOrigKey = (1 << 2),
312  /**
313  * Match the raw key event.
314  *
315  * This is the key event after layout conversion before normalization.
316  */
317  MatchRawKey = (1 << 3),
318  MatchAllNormalizedKeys = MatchNormalizedKey | MatchNormalizedOrigKey,
319 };
320 
322 
323 class FCITXCORE_EXPORT KeyEventBase : public InputContextEvent {
324 public:
325  KeyEventBase(EventType type, InputContext *context, Key rawKey,
326  bool isRelease = false, int time = 0);
327  KeyEventBase(const KeyEventBase &) = default;
328 
329  /**
330  * Normalized key event.
331  *
332  * @return fcitx::Key
333  */
334  Key key() const { return key_; }
335 
336  /**
337  * It will automatically be called if input method layout does not match the
338  * system keyboard layout.
339  *
340  * @param key p_key:...
341  */
342  void setKey(const Key &key) {
343  key_ = key;
344  forward_ = true;
345  }
346 
347  /**
348  * It is designed for faking the key event. Normally should not be used.
349  *
350  * @param key key event to override.
351  * @since 5.0.4
352  */
353  void setRawKey(const Key &key) {
354  rawKey_ = key;
355  key_ = key.normalize();
356  forward_ = true;
357  }
358 
359  /**
360  * It is designed for overriding the key forward option. Normally should not
361  * be used.
362  *
363  * @param forward
364  * @since 5.0.4
365  */
366  void setForward(bool forward) { forward_ = forward; }
367 
368  /**
369  * Key event regardless of keyboard layout conversion.
370  *
371  * @return fcitx::Key
372  */
373  Key origKey() const { return origKey_; }
374 
375  /**
376  * Key event after layout conversion.
377  *
378  * Basically it is the "unnormalized" key event.
379  *
380  * @return fcitx::Key
381  */
382  Key rawKey() const { return rawKey_; }
383  bool isRelease() const { return isRelease_; }
384  int time() const { return time_; }
385 
386  /**
387  * If true, the key that produce character will commit a string.
388  *
389  * This is currently used by internal keyboard layout translation.
390  *
391  * @return bool
392  */
393  bool forward() const { return forward_; }
394 
395  /**
396  * Whether this key event is derived from a virtual keyboard
397  *
398  * @return bool
399  * @since 5.1.2
400  */
401  bool isVirtual() const { return origKey_.isVirtual(); }
402 
403  /**
404  * Check if the key event matches the given key according to the specified
405  * mode.
406  *
407  * @param key The key to check against.
408  * @param mode The matching mode.
409  * @return bool True if the key event matches, false otherwise.
410  * @since 5.1.23
411  */
412  bool check(const Key &key,
413  KeyEventMatchingModes mode =
415 
416  /**
417  * Check if the key event matches any key in the given list according to the
418  * specified mode.
419  *
420  * @param keys The list of keys to check against.
421  * @param mode The matching mode.
422  * @return bool True if the key event matches any key in the list, false
423  * otherwise.
424  * @since 5.1.23
425  */
426  bool checkKeyList(std::span<const Key> keys,
427  KeyEventMatchingModes mode =
429 
430 protected:
431  Key key_, origKey_, rawKey_;
432  bool isRelease_;
433  int time_;
434  bool forward_ = false;
435 };
436 
437 class FCITXCORE_EXPORT KeyEvent : public KeyEventBase {
438 public:
439  KeyEvent(InputContext *context, Key rawKey, bool isRelease = false,
440  int time = 0)
442  isRelease, time) {}
443 
444  void filter() { filtered_ = true; }
445  bool filtered() const override { return filtered_; }
446  void filterAndAccept() {
447  filter();
448  accept();
449  }
450 
451 private:
452  bool filtered_ = false;
453 };
454 
456 
457 class FCITXCORE_EXPORT VirtualKeyboardEvent : public InputContextEvent {
458 public:
459  VirtualKeyboardEvent(InputContext *context, bool isRelease, int time = 0);
461 
462  int time() const;
463 
464  void setKey(Key key);
465  const Key &key() const;
466 
467  void setPosition(float x, float y);
468  float x() const;
469  float y() const;
470 
471  void setLongPress(bool longPress);
472  bool isLongPress() const;
473 
474  void setUserAction(uint64_t actionId);
475  uint64_t userAction() const;
476 
477  void setText(std::string text);
478  const std::string &text() const;
479 
480  std::unique_ptr<KeyEvent> toKeyEvent() const;
481 
482 protected:
483  FCITX_DECLARE_PRIVATE(VirtualKeyboardEvent);
484  std::unique_ptr<VirtualKeyboardEventPrivate> d_ptr;
485 };
486 
487 class FCITXCORE_EXPORT ForwardKeyEvent : public KeyEventBase {
488 public:
489  ForwardKeyEvent(InputContext *context, Key rawKey, bool isRelease = false,
490  int time = 0)
491  : KeyEventBase(EventType::InputContextForwardKey, context, rawKey,
492  isRelease, time) {}
493 };
494 
495 class FCITXCORE_EXPORT CommitStringEvent : public InputContextEvent {
496 public:
497  CommitStringEvent(const std::string &text, InputContext *context)
498  : InputContextEvent(context, EventType::InputContextCommitString),
499  text_(text) {}
500 
501  const std::string &text() const { return text_; }
502 
503 protected:
504  std::string text_;
505 };
506 
507 /**
508  * Event for commit string with cursor
509  *
510  * @see InputContext::commitStringWithCursor
511  * @since 5.1.2
512  */
513 class FCITXCORE_EXPORT CommitStringWithCursorEvent : public InputContextEvent {
514 public:
515  CommitStringWithCursorEvent(std::string text, size_t cursor,
516  InputContext *context)
517  : InputContextEvent(context,
518  EventType::InputContextCommitStringWithCursor),
519  text_(std::move(text)), cursor_(cursor) {}
520 
521  const std::string &text() const { return text_; }
522  size_t cursor() const { return cursor_; }
523 
524 protected:
525  std::string text_;
526  size_t cursor_;
527 };
528 
529 class FCITXCORE_EXPORT InvokeActionEvent : public InputContextEvent {
530 public:
531  enum class Action { LeftClick, RightClick };
532  InvokeActionEvent(Action action, int cursor, InputContext *context)
534  action_(action), cursor_(cursor) {}
535 
536  Action action() const { return action_; }
537  int cursor() const { return cursor_; }
538 
539  void filter() {
540  filtered_ = true;
541  accept();
542  }
543  bool filtered() const override { return filtered_; }
544 
545 protected:
546  Action action_;
547  int cursor_;
548  bool filtered_ = false;
549 };
550 
552  : public InputContextEvent {
553 public:
555  const std::string &oldIM,
556  InputContext *context)
558  reason_(reason), oldInputMethod_(oldIM) {}
559 
560  InputMethodSwitchedReason reason() const { return reason_; }
561  const std::string &oldInputMethod() const { return oldInputMethod_; }
562 
563 protected:
565  std::string oldInputMethod_;
566 };
567 
568 class FCITXCORE_EXPORT ResetEvent : public InputContextEvent {
569 public:
570  FCITXCORE_DEPRECATED ResetEvent(ResetReason reason, InputContext *context)
572  reason_(reason) {}
573  ResetEvent(InputContext *context)
575  reason_(ResetReason::Client) {}
576 
577  FCITXCORE_DEPRECATED ResetReason reason() const { return reason_; }
578 
579 protected:
580  ResetReason reason_;
581 };
582 
583 class FCITXCORE_EXPORT InputContextUpdateUIEvent : public InputContextEvent {
584 public:
586  InputContext *context, bool immediate = false)
587  : InputContextEvent(context, EventType::InputContextUpdateUI),
588  component_(component), immediate_(immediate) {}
589 
590  UserInterfaceComponent component() const { return component_; }
591  bool immediate() const { return immediate_; }
592 
593 protected:
594  UserInterfaceComponent component_;
595  bool immediate_;
596 };
597 
598 /**
599  * Events triggered that user interface manager that flush the UI update.
600  *
601  * @since 5.1.2
602  */
603 class FCITXCORE_EXPORT InputContextFlushUIEvent : public InputContextEvent {
604 public:
606  InputContext *context)
607  : InputContextEvent(context, EventType::InputContextFlushUI),
608  component_(component) {}
609 
610  UserInterfaceComponent component() const { return component_; }
611 
612 protected:
613  UserInterfaceComponent component_;
614 };
615 
616 class FCITXCORE_EXPORT VirtualKeyboardVisibilityChangedEvent : public Event {
617 public:
620 };
621 
622 class FCITXCORE_EXPORT InputMethodNotificationEvent : public InputContextEvent {
623 public:
624  InputMethodNotificationEvent(EventType type, const std::string &name,
625  InputContext *context)
626  : InputContextEvent(context, type), name_(name) {}
627 
628  const std::string &name() const { return name_; }
629 
630 protected:
631  std::string name_;
632 };
633 
634 class FCITXCORE_EXPORT InputMethodActivatedEvent
636 public:
637  InputMethodActivatedEvent(const std::string &name, InputContext *context)
639  EventType::InputContextInputMethodActivated, name, context) {}
640 };
641 
642 class FCITXCORE_EXPORT InputMethodDeactivatedEvent
644 public:
645  InputMethodDeactivatedEvent(const std::string &name, InputContext *context)
647  EventType::InputContextInputMethodDeactivated, name, context) {}
648 };
649 
650 #define FCITX_DEFINE_SIMPLE_EVENT(NAME, TYPE, ARGS...) \
651  struct FCITXCORE_EXPORT NAME##Event : public InputContextEvent { \
652  NAME##Event(InputContext *ic) \
653  : InputContextEvent(ic, EventType::TYPE) {} \
654  }
655 
656 FCITX_DEFINE_SIMPLE_EVENT(InputContextCreated, InputContextCreated);
657 FCITX_DEFINE_SIMPLE_EVENT(InputContextDestroyed, InputContextDestroyed);
658 FCITX_DEFINE_SIMPLE_EVENT(FocusIn, InputContextFocusIn);
659 FCITX_DEFINE_SIMPLE_EVENT(FocusOut, InputContextFocusOut);
660 FCITX_DEFINE_SIMPLE_EVENT(SurroundingTextUpdated,
661  InputContextSurroundingTextUpdated);
662 FCITX_DEFINE_SIMPLE_EVENT(CursorRectChanged, InputContextCursorRectChanged);
663 FCITX_DEFINE_SIMPLE_EVENT(UpdatePreedit, InputContextUpdatePreedit);
664 
665 class FCITXCORE_EXPORT InputMethodGroupChangedEvent : public Event {
666 public:
669 };
670 
671 class FCITXCORE_EXPORT InputMethodGroupAboutToChangeEvent : public Event {
672 public:
675 };
676 
677 class FCITXCORE_EXPORT UIChangedEvent : public Event {
678 public:
680 };
681 
682 class FCITXCORE_EXPORT CheckUpdateEvent : public Event {
683 public:
685 
686  /// Make checking update short circuit. If anything need a refresh, just
687  /// simply break.
688  void setHasUpdate() {
689  filtered_ = true;
690  accept();
691  }
692  bool filtered() const override { return filtered_; }
693 
694 private:
695  bool filtered_ = false;
696 };
697 
698 /**
699  * Notify a focus change for focus group.
700  *
701  * @since 5.0.11
702  */
703 class FCITXCORE_EXPORT FocusGroupFocusChangedEvent : public Event {
704 public:
706  InputContext *newFocus)
707  : Event(EventType::FocusGroupFocusChanged), group_(group),
708  oldFocus_(oldFocus), newFocus_(newFocus) {}
709 
710  FocusGroup *group() const { return group_; }
711  InputContext *oldFocus() const { return oldFocus_; };
712  InputContext *newFocus() const { return newFocus_; };
713 
714 private:
715  FocusGroup *group_;
716  InputContext *oldFocus_;
717  InputContext *newFocus_;
718 };
719 
720 /**
721  * Notify the input method mode is changed.
722  *
723  * @see Instance::InputMethodMode
724  * @since 5.1.0
725  */
726 class FCITXCORE_EXPORT InputMethodModeChangedEvent : public Event {
727 public:
729 };
730 
731 /**
732  * Notify the global config is reloaded.
733  *
734  * @see GlobalConfig
735  * @since 5.1.0
736  */
737 class FCITXCORE_EXPORT GlobalConfigReloadedEvent : public Event {
738 public:
740 };
741 
742 class FCITXCORE_EXPORT CapabilityEvent : public InputContextEvent {
743 public:
745  CapabilityFlags newFlags)
746  : InputContextEvent(ic, type), oldFlags_(oldFlags),
747  newFlags_(newFlags) {}
748 
749  auto oldFlags() const { return oldFlags_; }
750  auto newFlags() const { return newFlags_; }
751 
752 protected:
753  const CapabilityFlags oldFlags_;
754  const CapabilityFlags newFlags_;
755 };
756 
757 class FCITXCORE_EXPORT CapabilityChangedEvent : public CapabilityEvent {
758 public:
760  CapabilityFlags newFlags)
761  : CapabilityEvent(ic, EventType::InputContextCapabilityChanged,
762  oldFlags, newFlags) {}
763 };
764 
765 class FCITXCORE_EXPORT CapabilityAboutToChangeEvent : public CapabilityEvent {
766 public:
768  CapabilityFlags newFlags)
769  : CapabilityEvent(ic, EventType::InputContextCapabilityAboutToChange,
770  oldFlags, newFlags) {}
771 };
772 
773 FCITX_DEFINE_EVENT_TYPE(InputContextCreatedEvent, InputContextCreated);
774 FCITX_DEFINE_EVENT_TYPE(InputContextDestroyedEvent, InputContextDestroyed);
775 FCITX_DEFINE_EVENT_TYPE(FocusInEvent, InputContextFocusIn);
776 FCITX_DEFINE_EVENT_TYPE(FocusOutEvent, InputContextFocusOut);
777 FCITX_DEFINE_EVENT_TYPE(KeyEvent, InputContextKeyEvent);
778 FCITX_DEFINE_EVENT_TYPE(ResetEvent, InputContextReset);
779 FCITX_DEFINE_EVENT_TYPE(SurroundingTextUpdatedEvent,
780  InputContextSurroundingTextUpdated);
781 FCITX_DEFINE_EVENT_TYPE(CursorRectChangedEvent, InputContextCursorRectChanged);
782 FCITX_DEFINE_EVENT_TYPE(CapabilityChangedEvent, InputContextCapabilityChanged);
783 FCITX_DEFINE_EVENT_TYPE(CapabilityAboutToChangeEvent,
784  InputContextCapabilityAboutToChange);
785 FCITX_DEFINE_EVENT_TYPE(InputContextSwitchInputMethodEvent,
787 FCITX_DEFINE_EVENT_TYPE(InputMethodActivatedEvent,
788  InputContextInputMethodActivated);
789 FCITX_DEFINE_EVENT_TYPE(InputMethodDeactivatedEvent,
790  InputContextInputMethodDeactivated);
791 FCITX_DEFINE_EVENT_TYPE(InvokeActionEvent, InputContextInvokeAction);
792 FCITX_DEFINE_EVENT_TYPE(VirtualKeyboardEvent, InputContextVirtualKeyboardEvent);
793 FCITX_DEFINE_EVENT_TYPE(ForwardKeyEvent, InputContextForwardKey);
794 FCITX_DEFINE_EVENT_TYPE(CommitStringEvent, InputContextCommitString);
795 FCITX_DEFINE_EVENT_TYPE(UpdatePreeditEvent, InputContextUpdatePreedit);
796 FCITX_DEFINE_EVENT_TYPE(InputContextUpdateUIEvent, InputContextUpdateUI);
797 FCITX_DEFINE_EVENT_TYPE(CommitStringWithCursorEvent,
798  InputContextCommitStringWithCursor);
799 FCITX_DEFINE_EVENT_TYPE(InputContextFlushUIEvent, InputContextFlushUI);
801 FCITX_DEFINE_EVENT_TYPE(InputMethodGroupAboutToChangeEvent,
803 FCITX_DEFINE_EVENT_TYPE(UIChangedEvent, UIChanged);
804 FCITX_DEFINE_EVENT_TYPE(CheckUpdateEvent, CheckUpdate);
808 FCITX_DEFINE_EVENT_TYPE(VirtualKeyboardVisibilityChangedEvent,
810 
811 } // namespace fcitx
812 
813 #endif // _FCITX_EVENT_H_
InputMethodGroupAboutToChangeEvent is generated when input method group is about to be changed...
Describe a Key in fcitx.
Definition: key.h:42
bool accepted() const
Return value used by Instance::postEvent.
Definition: event.h:245
Match the original key event.
EventType
Type of input method events.
Definition: event.h:67
Switched by alternative trigger key.
void setHasUpdate()
Make checking update short circuit.
Definition: event.h:688
ResetEvent is generated.
FocusInEvent is generated when client gets focused.
Notify a focus change for focus group.
Definition: event.h:703
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.
Definition: event.h:43
Definition: action.cpp:17
void setKey(const Key &key)
It will automatically be called if input method layout does not match the system keyboard layout...
Definition: event.h:342
Key key() const
Normalized key event.
Definition: event.h:334
Match the original key event before layout conversion, after normalization.
bool isVirtual() const
Whether this key event is derived from a virtual keyboard.
Definition: event.h:401
virtual bool filtered() const
Whether a event is filtered by handler.
Definition: event.h:255
bool filtered() const override
Whether a event is filtered by handler.
Definition: event.h:445
Base class for fcitx event.
Definition: event.h:226
Virtual keyboard visibility changed.
Enum type for input context capability.
Switched by capability change (e.g. password field)
Base class for User Interface addon.
KeyEventMatchingMode
Key event matching mode.
Definition: event.h:288
Global config is reloaded.
Events triggered that user interface manager that flush the UI update.
Definition: event.h:603
InvokeAction event is generated when client click on the preedit.
bool filtered() const override
Whether a event is filtered by handler.
Definition: event.h:692
FocusGroupFocusChanged is posted when a focus group changed its focused input context.
UserInterfaceComponent
Definition: userinterface.h:21
Match the normalized key event.
Key rawKey() const
Key event after layout conversion.
Definition: event.h:382
Notify the input method mode is changed.
Definition: event.h:726
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.
Definition: event.h:543
bool isInputContextEvent() const
A helper function to check if a event is input context event.
Definition: event.h:262
UIChangedEvent is posted when the UI implementation is changed.
Key origKey() const
Key event regardless of keyboard layout conversion.
Definition: event.h:373
Class provides bit flag support for Enum.
Definition: flags.h:33
Event for commit string with cursor.
Definition: event.h:513
Helper template class to make easier to use type safe enum flags.
EventType type() const
Type of event, can be used to decide event class.
Definition: event.h:236
An input context represents a client of Fcitx.
Definition: inputcontext.h:50
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.
Definition: event.h:353
bool forward() const
If true, the key that produce character will commit a string.
Definition: event.h:393
void setForward(bool forward)
It is designed for overriding the key forward option.
Definition: event.h:366
Notify the global config is reloaded.
Definition: event.h:737
when using lost focus this might be variance case to case.
Key normalize() const
Normalize a key, usually used when key is from frontend.
Definition: key.cpp:493