Fcitx
tempmode.cpp
1 /*
2  * SPDX-FileCopyrightText: 2026-2026 CSSlayer <wengxt@gmail.com>
3  *
4  * SPDX-License-Identifier: LGPL-2.1-or-later
5  *
6  */
7 
8 #include "tempmode.h"
9 #include <memory>
10 #include "fcitx-utils/macros.h"
11 #include "event.h"
12 #include "inputcontext.h"
13 #include "inputcontextmanager.h"
14 #include "tempmode_p.h"
15 
16 namespace fcitx {
17 
18 TempMode::TempMode() : d_ptr(std::make_unique<TempModePrivate>(this)) {}
19 TempMode::~TempMode() { unregister(); }
20 
21 bool TempMode::isRegistered() const {
22  FCITX_D();
23  return d->handle_ != nullptr;
24 }
25 
27  FCITX_UNUSED(event);
28  return true;
29 }
30 
32  FCITX_D();
33  d->stateFactory_.unregister();
34  d->handle_.reset();
35 }
36 
39  FCITX_D();
40  return inputContext->propertyFor(&d->stateFactory_);
41 }
42 
43 } // namespace fcitx
bool isRegistered() const
Return whether this temp mode is registered with a manager.
Definition: tempmode.cpp:21
Temporary input modes for Fcitx.
void unregister()
Unregister this temp mode from its manager.
Definition: tempmode.cpp:31
T::PropertyType * propertyFor(const T *factory)
Helper function to return the input context property in specific type by given factory.
Definition: inputcontext.h:288
InputContextProperty * genericProperty(InputContext *inputContext) const
Return the registered temp mode state for an input context.
Definition: tempmode.cpp:38
Definition: action.cpp:17
Definition: matchrule.h:78
virtual bool invokeAction(InvokeActionEvent &event)
Handle an action invoked while the temp mode is active.
Definition: tempmode.cpp:26
Input Context for Fcitx.
An input context represents a client of Fcitx.
Definition: inputcontext.h:50
This is a class that designed to store state that is specific to certain input context.