Fcitx
|
An instance represents a standalone Fcitx instance. More...
#include <fcitx/instance.h>
Public Member Functions | |
Instance (int argc, char *argv[]) | |
A main function like construct to be used to create Fcitx Instance. More... | |
bool | initialized () const |
void | setSignalPipe (int fd) |
Set the pipe forwarding unix signal information. More... | |
int | exec () |
Start the event loop of Fcitx. More... | |
bool | willTryReplace () const |
Check whether command line specify if it will replace an existing fcitx server. More... | |
bool | exitWhenMainDisplayDisconnected () const |
Check whether command line specify whether to keep fcitx running. More... | |
bool | exiting () const |
Check whether fcitx is in exiting process. More... | |
EventLoop & | eventLoop () |
Get the fcitx event loop. | |
EventDispatcher & | eventDispatcher () |
Return a shared event dispatcher that is already attached to instance's event loop. More... | |
AddonManager & | addonManager () |
Get the addon manager. | |
InputContextManager & | inputContextManager () |
Get the input context manager. | |
UserInterfaceManager & | userInterfaceManager () |
Get the user interface manager. | |
InputMethodManager & | inputMethodManager () |
Get the input method manager. | |
const InputMethodManager & | inputMethodManager () const |
Get the input method manager. | |
GlobalConfig & | globalConfig () |
Get the global config. | |
bool | postEvent (Event &event) |
bool | postEvent (Event &&event) |
bool | postEvent (Event &event) const |
Put a event to the event pipe line. More... | |
bool | postEvent (Event &&event) const |
FCITX_NODISCARD std::unique_ptr< HandlerTableEntry< EventHandler > > | watchEvent (EventType type, EventWatcherPhase phase, EventHandler callback) |
Add a callback to for certain event type. More... | |
std::string | inputMethod (InputContext *ic) |
Return the unique name of input method for given input context. | |
const InputMethodEntry * | inputMethodEntry (InputContext *ic) |
Return the input method entry for given input context. | |
InputMethodEngine * | inputMethodEngine (InputContext *ic) |
Return the input method engine object for given input context. | |
InputMethodEngine * | inputMethodEngine (const std::string &name) |
Return the input method engine object for given unique input method name. More... | |
std::string | inputMethodIcon (InputContext *ic) |
Return the input method icon for input context. More... | |
std::string | inputMethodLabel (InputContext *ic) |
Return the input method label for input context. More... | |
FCITXCORE_DEPRECATED uint32_t | processCompose (InputContext *ic, KeySym keysym) |
Handle current XCompose state. More... | |
std::optional< std::string > | processComposeString (InputContext *ic, KeySym keysym) |
Handle current XCompose state. More... | |
void | resetCompose (InputContext *inputContext) |
Reset the compose state. | |
bool | isComposing (InputContext *inputContext) |
Check whether input context is composing or not. | |
std::string | commitFilter (InputContext *inputContext, const std::string &orig) |
Update the commit string to frontend. More... | |
Text | outputFilter (InputContext *inputContext, const Text &orig) |
Update the string that will be displayed in user interface. More... | |
FCITX_DECLARE_SIGNAL (Instance, CommitFilter, void(InputContext *inputContext, std::string &orig)) | |
FCITX_DECLARE_SIGNAL (Instance, OutputFilter, void(InputContext *inputContext, Text &orig)) | |
FCITX_DECLARE_SIGNAL (Instance, KeyEventResult, void(const KeyEvent &keyEvent)) | |
FCITX_DECLARE_SIGNAL (Instance, CheckUpdate, bool()) | |
InputContext * | lastFocusedInputContext () |
Return a focused input context. | |
InputContext * | mostRecentInputContext () |
Return the most recent focused input context. More... | |
void | flushUI () |
All user interface update is batched internally. More... | |
void | exit () |
Exit the fcitx event loop. | |
void | exit (int exitCode) |
Exit the fcitx event loop with an exit code. | |
void | restart () |
Restart fcitx instance, this should only be used within a regular Fcitx server, not within embedded mode. More... | |
void | configure () |
Launch configtool. | |
FCITXCORE_DEPRECATED void | configureAddon (const std::string &addon) |
FCITXCORE_DEPRECATED void | configureInputMethod (const std::string &imName) |
std::string | currentUI () |
Return the name of current user interface addon. | |
std::string | addonForInputMethod (const std::string &imName) |
Return the addon name of given input method. | |
void | activate () |
Activate last focused input context. (Switch to the active input method) | |
void | deactivate () |
Deactivate last focused input context. More... | |
void | toggle () |
Toggle between the first input method and active input method. | |
void | resetInputMethodList () |
Reset the input method configuration and recreate based on system language. More... | |
int | state () |
Return a fcitx5-remote compatible value for the state. | |
void | reloadConfig () |
Reload global config. | |
void | reloadAddonConfig (const std::string &addonName) |
Reload certain addon config. | |
void | refresh () |
Load newly installed input methods and addons. | |
std::string | currentInputMethod () |
Return the current input method of last focused input context. | |
void | setCurrentInputMethod (const std::string &imName) |
Set the input method of last focused input context. | |
void | setCurrentInputMethod (InputContext *ic, const std::string &imName, bool local) |
Set the input method of given input context. More... | |
FCITXCORE_DEPRECATED bool | enumerateGroup (bool forward) |
void | enumerate (bool forward) |
Enumerate input method with in current group. | |
FocusGroup * | defaultFocusGroup (const std::string &displayHint={}) |
Get the default focus group with given display hint. More... | |
void | setXkbParameters (const std::string &display, const std::string &rule, const std::string &model, const std::string &options) |
Set xkb RLVMO tuple for given display. More... | |
void | updateXkbStateMask (const std::string &display, uint32_t depressed_mods, uint32_t latched_mods, uint32_t locked_mods) |
Update xkb state mask for given display. | |
void | clearXkbStateMask (const std::string &display) |
Clear xkb state mask for given display. | |
void | showInputMethodInformation (InputContext *ic) |
Show a small popup with input popup window with current input method information. More... | |
void | showCustomInputMethodInformation (InputContext *ic, const std::string &message) |
Show a small popup with input popup window with current input method information. More... | |
bool | checkUpdate () const |
Check if need to invoke Instance::refresh. More... | |
void | save () |
Save everything including input method profile and addon data. More... | |
void | initialize () |
Initialize fcitx. More... | |
void | setRunning (bool running) |
Let other know that event loop is already running. More... | |
bool | isRunning () const |
Whether event loop is started and still running. More... | |
InputMethodMode | inputMethodMode () const |
The current global input method mode. More... | |
void | setInputMethodMode (InputMethodMode mode) |
Set the current global input method mode. More... | |
bool | isRestartRequested () const |
Whether restart is requested. More... | |
bool | virtualKeyboardAutoShow () const |
void | setVirtualKeyboardAutoShow (bool autoShow) |
bool | virtualKeyboardAutoHide () const |
void | setVirtualKeyboardAutoHide (bool autoHide) |
VirtualKeyboardFunctionMode | virtualKeyboardFunctionMode () const |
void | setVirtualKeyboardFunctionMode (VirtualKeyboardFunctionMode mode) |
void | setBinaryMode () |
Set if this instance is running as fcitx5 binary. More... | |
bool | canRestart () const |
Check if fcitx 5 can safely restart by itself. More... | |
![]() | |
template<typename SignalType , typename F > | |
Connection | connect (F &&func) |
template<typename SignalType > | |
void | disconnectAll () |
Static Public Member Functions | |
static const char * | version () |
Return the version string of Fcitx. | |
Protected Member Functions | |
InstancePrivate * | privateData () |
![]() | |
void | destroy () |
Allow user to notify the destroy event earlier. More... | |
template<typename SignalType , typename... Args> | |
auto | emit (Args &&...args) |
template<typename SignalType , typename... Args> | |
auto | emit (Args &&...args) const |
template<typename SignalType , typename Combiner = LastValue<typename std::function< typename SignalType::signalType>::result_type>> | |
void | registerSignal () |
template<typename SignalType > | |
void | unregisterSignal () |
An instance represents a standalone Fcitx instance.
Usually there is only one of such object.
Fcitx Instance provides the access to all the addons and sub components. It also provides a event pipeline for handling input method related event.
Definition at line 88 of file instance.h.
fcitx::Instance::Instance | ( | int | argc, |
char * | argv[] | ||
) |
A main function like construct to be used to create Fcitx Instance.
For more details, see –help of fcitx5 command.
argc | number of argument |
argv | command line arguments |
Definition at line 660 of file instance.cpp.
bool fcitx::Instance::canRestart | ( | ) | const |
Check if fcitx 5 can safely restart by itself.
When the existing fcitx 5 instance returns false, fcitx5 -r, or Instance::restart will just be no-op.
Definition at line 1564 of file instance.cpp.
bool fcitx::Instance::checkUpdate | ( | ) | const |
Check if need to invoke Instance::refresh.
Definition at line 2540 of file instance.cpp.
std::string fcitx::Instance::commitFilter | ( | InputContext * | inputContext, |
const std::string & | orig | ||
) |
Update the commit string to frontend.
This function should be not be used directly since it is already used internally by InputContext::commitString.
inputContext | input context |
orig | original string |
Definition at line 2340 of file instance.cpp.
void fcitx::Instance::deactivate | ( | ) |
Deactivate last focused input context.
(Switch to the first input method)
Definition at line 1987 of file instance.cpp.
FocusGroup * fcitx::Instance::defaultFocusGroup | ( | const std::string & | displayHint = {} | ) |
Get the default focus group with given display hint.
This function is used by frontend to assign a focus group from an unknown display server.
displayHint | Display server hint, it can something like be x11: / wayland: |
Definition at line 2412 of file instance.cpp.
EventDispatcher & fcitx::Instance::eventDispatcher | ( | ) |
Return a shared event dispatcher that is already attached to instance's event loop.
Definition at line 1588 of file instance.cpp.
int fcitx::Instance::exec | ( | ) |
Start the event loop of Fcitx.
Definition at line 1481 of file instance.cpp.
bool fcitx::Instance::exiting | ( | ) | const |
bool fcitx::Instance::exitWhenMainDisplayDisconnected | ( | ) | const |
Check whether command line specify whether to keep fcitx running.
There could be multiple display server, such as X/Wayland/etc. Fcitx usually will exit when the connection is closed. Command line -k can override this behavior and keep Fcitx running.
Definition at line 1387 of file instance.cpp.
fcitx::Instance::FCITX_DECLARE_SIGNAL | ( | Instance | , |
CheckUpdate | , | ||
bool() | |||
) |
void fcitx::Instance::flushUI | ( | ) |
All user interface update is batched internally.
This function will flush all the batched UI update immediately.
Definition at line 2381 of file instance.cpp.
void fcitx::Instance::initialize | ( | ) |
Initialize fcitx.
This is only intended to be used if you want to handle event loop on your own. Otherwise you should use Instance::exec().
Definition at line 1415 of file instance.cpp.
InputMethodEngine * fcitx::Instance::inputMethodEngine | ( | const std::string & | name | ) |
Return the input method engine object for given unique input method name.
Definition at line 1766 of file instance.cpp.
std::string fcitx::Instance::inputMethodIcon | ( | InputContext * | ic | ) |
Return the input method icon for input context.
It will fallback to input-keyboard by default if no input method is available.
ic | input context |
Definition at line 1776 of file instance.cpp.
std::string fcitx::Instance::inputMethodLabel | ( | InputContext * | ic | ) |
Return the input method label for input context.
ic | input context |
Definition at line 1793 of file instance.cpp.
InputMethodMode fcitx::Instance::inputMethodMode | ( | ) | const |
The current global input method mode.
It may affect the user interface and behavior of certain key binding.
Definition at line 1509 of file instance.cpp.
bool fcitx::Instance::isRestartRequested | ( | ) | const |
bool fcitx::Instance::isRunning | ( | ) | const |
Whether event loop is started and still running.
Definition at line 1504 of file instance.cpp.
InputContext * fcitx::Instance::mostRecentInputContext | ( | ) |
Return the most recent focused input context.
If there isn't such ic, return the last unfocused input context.
Definition at line 2376 of file instance.cpp.
Text fcitx::Instance::outputFilter | ( | InputContext * | inputContext, |
const Text & | orig | ||
) |
Update the string that will be displayed in user interface.
This function should only be used by frontend for client preedit, or user interface, for the other field in input panel.
inputContext | input context |
orig | orig text |
Definition at line 2347 of file instance.cpp.
bool fcitx::Instance::postEvent | ( | Event & | event | ) | const |
Put a event to the event pipe line.
event | Input method event |
Definition at line 1627 of file instance.cpp.
uint32_t fcitx::Instance::processCompose | ( | InputContext * | ic, |
KeySym | keysym | ||
) |
Handle current XCompose state.
ic | input context. |
keysym | key symbol. |
Definition at line 1808 of file instance.cpp.
std::optional< std::string > fcitx::Instance::processComposeString | ( | InputContext * | ic, |
KeySym | keysym | ||
) |
Handle current XCompose state.
ic | input context. |
keysym | key symbol. |
Definition at line 1856 of file instance.cpp.
void fcitx::Instance::resetInputMethodList | ( | ) |
Reset the input method configuration and recreate based on system language.
Definition at line 2060 of file instance.cpp.
void fcitx::Instance::restart | ( | ) |
Restart fcitx instance, this should only be used within a regular Fcitx server, not within embedded mode.
Definition at line 2065 of file instance.cpp.
void fcitx::Instance::save | ( | ) |
Save everything including input method profile and addon data.
It also reset the idle save timer.
Definition at line 1940 of file instance.cpp.
void fcitx::Instance::setBinaryMode | ( | ) |
Set if this instance is running as fcitx5 binary.
This will affect return value of Instance::canRestart.
Definition at line 1559 of file instance.cpp.
void fcitx::Instance::setCurrentInputMethod | ( | InputContext * | ic, |
const std::string & | imName, | ||
bool | local | ||
) |
Set the input method of given input context.
The input method need to be within the current group. Local parameter can be used to set the input method only for this input context.
ic | input context |
imName | unique name of a input method |
local |
Definition at line 2078 of file instance.cpp.
void fcitx::Instance::setInputMethodMode | ( | InputMethodMode | mode | ) |
Set the current global input method mode.
Definition at line 1514 of file instance.cpp.
void fcitx::Instance::setRunning | ( | bool | running | ) |
Let other know that event loop is already running.
This should only be used if you run event loop on your own.
Definition at line 1499 of file instance.cpp.
void fcitx::Instance::setSignalPipe | ( | int | fd | ) |
Set the pipe forwarding unix signal information.
Fcitx Instance is running within its own thread, usually main thread. In order to make it handle signal correctly in a thread-safe way, it is possible to set a file descriptor that write the signal number received by the signal handler. Usually this is done through a self-pipe. This is already handled by Fcitx default server implementation, normal addon user should not touch this. The common usecase is when you want to embed Fcitx into your own program.
fd | file descriptor |
Definition at line 1368 of file instance.cpp.
void fcitx::Instance::setXkbParameters | ( | const std::string & | display, |
const std::string & | rule, | ||
const std::string & | model, | ||
const std::string & | options | ||
) |
Set xkb RLVMO tuple for given display.
display | display name |
rule | xkb rule name |
model | xkb model name |
options | xkb option |
Definition at line 2548 of file instance.cpp.
void fcitx::Instance::showCustomInputMethodInformation | ( | InputContext * | ic, |
const std::string & | message | ||
) |
Show a small popup with input popup window with current input method information.
The popup will be hidden after certain amount of time. The popup will always be displayed, regardless of the showInputMethodInformation in global config.
This is useful for input method that has internal switches.
ic | input context. |
message | message string to be displayed |
Definition at line 2532 of file instance.cpp.
void fcitx::Instance::showInputMethodInformation | ( | InputContext * | ic | ) |
Show a small popup with input popup window with current input method information.
The popup will be hidden after certain amount of time.
This is useful for input method that has multiple sub modes. It can be called with switching sub modes within the input method.
The behavior is controlled by global config.
ic | input context. |
Definition at line 2523 of file instance.cpp.
std::unique_ptr< HandlerTableEntry< EventHandler > > fcitx::Instance::watchEvent | ( | EventType | type, |
EventWatcherPhase | phase, | ||
EventHandler | callback | ||
) |
Add a callback to for certain event type.
type | event type |
phase | the stage that callback will be executed. |
callback | callback function. |
Definition at line 1692 of file instance.cpp.
bool fcitx::Instance::willTryReplace | ( | ) | const |
Check whether command line specify if it will replace an existing fcitx server.
This function is only useful if your addon provides a way to replace existing fcitx server. Basically it is checking whether -r is passed to fcitx command line.
Definition at line 1382 of file instance.cpp.