KWin::InputMethod Class

Provides integration for input methods. More...

Header: #include <inputmethod.h>
CMake: find_package(KWin REQUIRED)
target_link_libraries(mytarget PRIVATE KWin::kwin)

Public Types

enum class VirtualKeyboardVisibility { Never, NonMouseInput, AnyInput }

Public Functions

bool activeClientSupportsTextInput() const
KWin::Window *activeWindow() const
void commitPendingText()
KWin::RectF cursorRectangle() const
void forceActivate()
void forwardModifiers(KWin::InputMethod::ForwardModifiersForce force)
void hide()
bool isActive() const
bool isAvailable() const
bool isEnabled() const
bool isVisible() const
KWin::InputMethodGrabV1 *keyboardGrab()
KWin::InputPanelV1Window *panel() const
void setActive(bool active)
void setInputMethodCommand(const QString &path)
void setPanel(KWin::InputPanelV1Window *panel)
bool shouldShowOnActive() const
void show()

Signals

void activeChanged(bool active)
void activeClientSupportsTextInputChanged()
void activeWindowChanged()
void availableChanged()
void cursorRectangleChanged()
void modeChanged(KWin::InputMethod::VirtualKeyboardVisibility mode)
void panelChanged()
void visibleChanged()

Private Slots

void contentTypeChanged()
void handleFocusedSurfaceChanged()
void key(quint32 serial, quint32 time, quint32 key, KWin::KeyboardKeyState state)
void modifiers(quint32 serial, quint32 mods_depressed, quint32 mods_latched, quint32 mods_locked, quint32 group)
void setPreeditCursor(qint32 index)
void setPreeditString(uint32_t serial, const QString &text, const QString &commit)
void setPreeditStyling(quint32 index, quint32 length, quint32 style)
void stateCommitted(uint32_t serial)
void surroundingTextChanged()
void textInputInterfaceV2EnabledChanged()
void textInputInterfaceV2StateUpdated(quint32 serial, KWin::TextInputV2Interface::UpdateReason reason)
void textInputInterfaceV3EnableRequested()
void textInputInterfaceV3EnabledChanged()

Detailed Description

Manages the compositor-side integration for zwp_input_method_unstable_v1, enabling an input method to be used for text input in KWin, as well as the ability to display an on-screen keyboard and overlay panels.

Member Type Documentation

enum class InputMethod::VirtualKeyboardVisibility

The visibility mode of the on-screen keyboard.

ConstantValueDescription
KWin::InputMethod::VirtualKeyboardVisibility::Never0The on-screen keyboard is never shown automatically.
KWin::InputMethod::VirtualKeyboardVisibility::NonMouseInput1The on-screen keyboard is shown automatically for non-mouse input devices (e.g., touch, stylus) when a text input field is focused.
KWin::InputMethod::VirtualKeyboardVisibility::AnyInput2The on-screen keyboard is shown automatically when any input device (e.g., mouse, touch, stylus) focuses a text input field.

Member Function Documentation

[signal] void InputMethod::activeChanged(bool active)

Emitted when the input method becomes active or inactive.

bool InputMethod::activeClientSupportsTextInput() const

Whether the currently focused client supports Wayland's text-input protocol (v2 or v3) and can receive text input from the input method.

[signal] void InputMethod::activeClientSupportsTextInputChanged()

Emitted when the state of whether the currently focused client supports text input changes.

KWin::Window *InputMethod::activeWindow() const

The window that is currently receiving input from the input method.

Returns nullptr if no window is currently connected to the input method.

[signal] void InputMethod::activeWindowChanged()

Emitted when the active window (which supports text input) changes.

[signal] void InputMethod::availableChanged()

Emitted when the configured input method changes.

void InputMethod::commitPendingText()

Commits any pending preedit text to the focused text input.

[private slot] void InputMethod::contentTypeChanged()

KWin::RectF InputMethod::cursorRectangle() const

The location of the text input cursor, in global coordinates.

[signal] void InputMethod::cursorRectangleChanged()

Emitted when the location of the text input cursor changes.

void InputMethod::forceActivate()

Request the input method to activate itself, even if the currently focused client does not support text input.

Does not guarantee that the input method will actually show itself.

void InputMethod::forwardModifiers(KWin::InputMethod::ForwardModifiersForce force)

Sync the keyboard modifiers state to the active input method keyboard grab, if any.

[private slot] void InputMethod::handleFocusedSurfaceChanged()

void InputMethod::hide()

Hides the on-screen keyboard and any overlay panels, if they are currently visible.

bool InputMethod::isActive() const

Considered active if the focused client has a Wayland text-input enabled and the input method is currently connected to it.

This does not necessarily mean that the on-screen keyboard is visible.

bool InputMethod::isAvailable() const

Whether an input method has been configured and is available for use.

bool InputMethod::isEnabled() const

The input method is considered enabled if the on-screen keyboard is configured to show automatically.

bool InputMethod::isVisible() const

Whether the on-screen keyboard is currently visible.

[private slot] void InputMethod::key(quint32 serial, quint32 time, quint32 key, KWin::KeyboardKeyState state)

KWin::InputMethodGrabV1 *InputMethod::keyboardGrab()

Returns the currently installed keyboard grab, if any.

[signal] void InputMethod::modeChanged(KWin::InputMethod::VirtualKeyboardVisibility mode)

Emitted when the visibility InputMethod::mode of the on-screen keyboard changes.

[private slot] void InputMethod::modifiers(quint32 serial, quint32 mods_depressed, quint32 mods_latched, quint32 mods_locked, quint32 group)

KWin::InputPanelV1Window *InputMethod::panel() const

The window for the on-screen keyboard and overlay panels.

See also setPanel().

[signal] void InputMethod::panelChanged()

Emitted when the input method panel window has been added or replaced.

void InputMethod::setActive(bool active)

Instruct the input method to (de)activate itself for the currently focused client.

See also isActive().

void InputMethod::setInputMethodCommand(const QString &path)

Sets the command to launch the input method process.

If an input method process is already running, it will be terminated and the new command will be used to launch a new process.

void InputMethod::setPanel(KWin::InputPanelV1Window *panel)

Installs a new input method panel window, replacing any existing one.

See also panel().

[private slot] void InputMethod::setPreeditCursor(qint32 index)

[private slot] void InputMethod::setPreeditString(uint32_t serial, const QString &text, const QString &commit)

[private slot] void InputMethod::setPreeditStyling(quint32 index, quint32 length, quint32 style)

bool InputMethod::shouldShowOnActive() const

Whether the on-screen keyboard should be shown automatically when a text input field is focused, based on the current visibility mode and the last input device used.

void InputMethod::show()

Show the on-screen keyboard (but only if the input method has something to display).

This method is more of a "you are allowed to show yourself" than a "please show yourself" request.

[private slot] void InputMethod::stateCommitted(uint32_t serial)

[private slot] void InputMethod::surroundingTextChanged()

[private slot] void InputMethod::textInputInterfaceV2EnabledChanged()

[private slot] void InputMethod::textInputInterfaceV2StateUpdated(quint32 serial, KWin::TextInputV2Interface::UpdateReason reason)

[private slot] void InputMethod::textInputInterfaceV3EnableRequested()

[private slot] void InputMethod::textInputInterfaceV3EnabledChanged()

[signal] void InputMethod::visibleChanged()

Emitted when the on-screen keyboard is shown or hidden.