Development and application of fcitx function plug-in

Add plug-ins to Fcitx framework

Fcitx plug-ins can be divided into four categories:


2.Input Method


4.User Interface

Frontend plug-in is responsible for interface key messages and passing them to Fcitx framework,

InputMethod plug-in is responsible for converting keyboard input into their language information, which is the core module of input method

Module is a general module, which realizes various functions through registration hooks

The User interface module is responsible for displaying various UI elements through the screen

If the plug-in needs a configuration file, the plug-in should first provide a configuration description file, and the name of the file should be the same as that of the plug-in. If the plug-in needs a series of sub configuration files or text files, the description file of the plug-in should contain the SubConfig field to match various file names.

The format of the plug-in description file is as follows:

_Comment=Table Input Method for Fcitx

The fcitx table plug-in has multiple configuration files, and the sub configuration format is as follows:


The definition format of each sub configuration is as follows:


The current configuration types can be: configfile, native,domain

The configuration file in native format defines a simple text file name in the description. The file name does not support fuzzy matching characters

The configuration file name described in the description of the configuration file in configfile format supports fuzzy matching symbols

The configuration file in domian format defines the text translation of the module

The names of configfile and natvie can be translated, and the corresponding translation content should be configured in the sub configuration of domain.

How to implement the user interface module of fcitx

If there are no special requirements, in fact, fcitx does not recommend implementing a new user interface module, because there are already three user interface modules in the existing fcitx framework. namely:


2. Fcitx kimpanel UI based on DBus


In order to implement the new user interface module, it is better to use the protocol compatible with kimpanel, and do not modify the protocol of fcitx.

In the customized User Interface plug-in, we first need to define each interface of the plug-in:

//Define the name, domain, and type of the plug-in
//The name is feifei_ui, which belongs to the ui domain, and the type is FcitxUI
FCITX_DEFINE_PLUGIN(feifei_ui, ui, FcitxUI) = {
    FeifeiUICreate,             //Callback function of UI construction
    FeifeiUICloseInputWindow,   //Close callback of input window
    FeifeiUIShowInputWindow,    //Displays the callback of the input window
    FeifeiUIMoveInputWindow,    //Move callback of input window
    FeifeiUIUpdateStatus,       //Callback to update UI status
    FeifeiUIRegisterStatus,     //Register callback for UI status
   FeifeiUIRegisterMenu,       //Register callback of UI menu
   FeifeiUIOnInputFocus,       //Callback to get focus
   FeifeiUIOnInputUnFocus,     //Callback without focus
   FeifeiUIOnTriggerOn,        //Active callback 
   FeifeiUIOnTriggerOff,       //Closed callback
   NULL,                       //Callback for presentation message (disabled)
   FeifeiUIMainWindowSizeHint, //Callback to get the size of the main window
   ReloadConfigFeifeiUI,       //Reload configured callback 
   FeifeiUISuspend,            //Pause switching callback
   FeifeiUIResume,              //Callback to resume from pause
   NULL,                        //Destroy callback of user interface
   FeifeiUIRegisterComplexStatus,  //Registration complex status
   FeifeiUIUpdateComplexStatus,    //Update complex state
   FeifeiUIUnRegisterMenu,        //Registration menu

At cmakelists Txt file through fcitx_addon_full interface to declare the information of the plug-in

fcitx_add_addon_full(feifei-ui DESC SCAN SCAN_PRIV ${kimpanel_noinstall}
  HEADER_DIR feifeiui
  FXADDON_SRC fcitx-feifeiui.fxaddon
  FXADDON_GEN fcitx-feifeiui.h
  HEADERS feifeiinterface.h
  EXTRA_DESC skin.desc
//The desc parameter determines the desc file for installing the plug-in, and the path of the configuration file with desc as the suffix,
//By DESC_SRC to determine

//The SCAN parameter generates the header file of the API, and the name of the generated header file is through FXADDON_GEN parameter
//The path of the input file is via FXADDON_SRC parameters,

//SCAN_PRIV generates the added function header file, and the path of the input file is through FXADDON_SRC parameters,
//The resulting header file is generated through ADDFUNCTIONS_GEN parameter determination

//NO_INSTALL does not install any files or compile any resources when the module is disabled, but it needs to generate
//Header file    

//SCAN_IN passed In file to generate api header file, fxaddon The path of the in file is via FXADDON_SRC parameters
//To determine The name of the generated header file is passed through the parameter FXADDON_GEN to determine

//HEADR_ The subdirectory of dir fcitx / module directory where the header files of plug-ins will be installed

//LIB_NAME: the binary name of the plug-in is (fcitx ${short_name}) by default
//CONF_SRC: the path of the plug-in conf file (without. In suffix). The default is fxitx - ${short_name} desc
//DESC_SRC: path of plug-in desc configuration file
//UNIQUE_NAME: the unique name of the plug-in. The default is fcitx-${short_name}

/********The following are multivalued parameters******/
//SOURCES: the source file that the plug-in needs to compile
//HEADER: the HEADER file that the plug-in needs to install (excluding the generated parameters)
//EXTRA_DESC: additional DESC parameters that need to be installed
//EXTRA_PO: additional files for browsing string translation
//EXTRA_LIBS needs to rely on additional library files
//Demands: some other files that the plug-in needs to rely on
//IM_CONFIG: input method configuration file

Keywords: C++ Linux

Added by jwhite68 on Sat, 12 Feb 2022 08:41:06 +0200