Repository navigation
[GTK4] Enable input methods in Canvas based controls - #3756
Merged
Merged
Conversation
The input method context of a Composite had no client widget and was never focused when the control got the keyboard focus, so IBus and the Wayland text-input protocol were never enabled and a StyledText got the raw keys instead of the composed text. Set the control as the client widget, focus the context from the GTK4 focus controller like the GTK3 focus signals do, and clear the client widget on release. Skip the preedit window, it uses GTK3 only API and threw an UnsatisfiedLinkError once an input method was active. Assisted-by: Anthropic Claude Code (claude-opus-5-5)
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Parent–child keyboard-focus transitions leave input-context focus unsynchronized.
1 open issue
What changed in this PR
Enables GTK4 input methods for Canvas-based controls, including StyledText.
Changes:
- Associates input contexts with client widgets and clears them on release.
- Adds input-context focus handling.
- Skips the GTK3-only preedit popup on GTK4.
| File | Description |
|---|---|
| bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Display.java | Skips the preedit popup on GTK4. |
| bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java | Shares IM focus handling and clears client associations. |
| bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Composite.java | Sets the input context’s client widget. |
| bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk4/GTK4.java | Declares the client-widget native binding. |
| bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/gtk4.c | Adds the generated native wrapper. |
| bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/gtk4_stats.h | Registers the new native function identifier. |
Review effort: Balanced
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

The input method context of a Composite had no client widget and was never focused when the control got the keyboard focus, so IBus and the Wayland text-input protocol were never enabled and a StyledText got the raw keys instead of the composed text.
Set the control as the client widget, focus the context from the GTK4 focus controller like the GTK3 focus signals do, and clear the client widget on release. Skip the preedit window, it uses GTK3 only API and threw an UnsatisfiedLinkError once an input method was active.
Assisted-by: Anthropic Claude Code (claude-opus-5-5)