8 #ifndef _FCITX_TEMPMODE_H_ 9 #define _FCITX_TEMPMODE_H_ 12 #include <string_view> 14 #include <fcitx-utils/macros.h> 16 #include <fcitx/fcitxcore_export.h> 26 class TempModePrivate;
28 template <
typename PropertyBaseType>
30 public PropertyBaseType {
32 bool isActive()
const {
return active_; }
33 void setActive(
bool active) { active_ = active; }
48 friend class TempModePrivate;
56 bool isRegistered()
const;
66 virtual bool isActive(
InputContext *inputContext)
const = 0;
77 virtual bool triggerTempMode(
const KeyEvent &keyEvent) = 0;
85 virtual bool keyEvent(
const KeyEvent &keyEvent) = 0;
105 virtual std::string_view name()
const = 0;
120 std::unique_ptr<TempModePrivate> d_ptr;
124 template <
typename PropertyBaseType>
130 return static_cast<PropertyType *
>(genericProperty(inputContext));
135 if (
auto *prop = property(inputContext)) {
136 return prop->isActive();
142 if (
auto *prop = property(inputContext)) {
143 prop->setActive(
false);
148 FCITX_UNUSED(inputContext);
157 #endif // _FCITX_TEMPMODE_H_ Manage registered TempMode objects for an Instance.
void reset(InputContext *inputContext) override
Reset the temp mode state for an input context.
A temporary mode that can take over key handling for a short period.
bool isActive(InputContext *inputContext) const override
Return whether this temp mode is currently active.
InputContextProperty * createProperty(InputContext &inputContext) override
Create the property object stored for each input context.
Input Method event for Fcitx.
Input Context Property for Fcitx.
An input context represents a client of Fcitx.
Class to represent a key.
This is a class that designed to store state that is specific to certain input context.