An InputContext represents a client of Fcitx, such as a window or a specific text field within an application. It serves as the primary interface for communication between the Fcitx core (and input methods) and the application frontend.
Key responsibilities include:
- Managing focus: Tracking whether the client has input focus via
focusIn() and focusOut(). - Handling text: Committing strings to the client via
commitString() or commitStringWithCursor(), and managing surrounding text via surroundingText(). - Event forwarding: Sending key events to the client using
forwardKey(). - UI Coordination: Notifying the client of preedit changes via
updatePreedit() and coordinating with the InputPanel and StatusArea.
Developers implementing a new frontend should inherit from InputContext (or InputContextV2 if cursor-based commits are required) and implement the protected virtual methods like commitStringImpl, deleteSurroundingTextImpl, and forwardKeyImpl to bridge Fcitx commands to the application's actual text handling logic.