Skip to content

uim: keep the focused context when another client sends focus_in - #183

Closed
shitamo wants to merge 1 commit into
arakiken:masterfrom
shitamo:uim-keep-focus-on-foreign-focus-in
Closed

shitamo wants to merge 1 commit into
arakiken:masterfrom
shitamo:uim-keep-focus-on-foreign-focus-in

Conversation

@shitamo

@shitamo shitamo commented Oct 18, 2026

Copy link
Copy Markdown
Contributor

Problem

With the uim input method, actions sent from the uim toolbar or the
IM switcher (e.g. "About this program" in the property menu, mode
changes, commit_string) are sometimes silently ignored while mlterm
has input focus.

Cause

uim-helper-server relays every client's messages to all other clients.
helper_read_handler() resets focused_uim to NULL on any "focus_in"
message, assuming another application has taken the focus. But a
background uim client (for example a GTK/Electron application) can
also send "focus_in" while mlterm still has the input focus. In that
case focused_uim stays NULL until the next focused() call, and
"prop_activate", "commit_string" and "im_list_get" are dropped.

Fix

Track whether the terminal itself currently has input focus
(active_uim, set in focused(), cleared in unfocused() and destroy()),
and only clear focused_uim on a foreign "focus_in" when the terminal
does not have the focus. Behaviour when switching to another
application is unchanged.

Testing

Built against mlterm with uim 1.9.9. With another
uim client (Electron app) running, selecting "About this program" from
the uim toolbar while mlterm is focused used to work only
intermittently; it now works every time. Switching focus between
mlterm and other uim clients still behaves as before.

Generated with Claude Code

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@arakiken

arakiken commented Nov 1, 2026

Copy link
Copy Markdown
Owner

@shitamo

shitamo commented Nov 1, 2026

Copy link
Copy Markdown
Contributor Author

Thank you.

@shitamo shitamo closed this Nov 1, 2026
@shitamo
shitamo deleted the uim-keep-focus-on-foreign-focus-in branch November 1, 2026 03:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants