fix: keep IME preedit text visible on transparent backgrounds#381
Conversation
IME preedit selection used the window background color as the selected text color and the text color as the selection background. This inverse-color approach breaks for layer-shell windows using a transparent background, because selected preedit text becomes transparent and invisible. Render preedit text with the normal text color and use a translucent selection background instead, so IME composition remains readable on transparent surfaces.
|
can we take this as reference? I think we may still need to keep the background color, because it is also did in this way in iced |
Thanks, yes, I agree iced_layershell should probably follow iced upstream here. After checking iced-rs/iced#2819, it looks like this behavior is intentional upstream: iced forces the preedit background alpha to 1.0 to avoid invisible IME preedit text when the application background is transparent. However, this also means there is currently no way to have a transparent layer-shell window while keeping the IME preedit overlay transparent/readable, because preedit colors are derived from the application-level background/text colors instead of a dedicated preedit style. It looks like I should open an Issue for iced first. |
|
I see, you have already tried the upstream behavior, and that was bad.. I see. then I will accept this pr |
Thanks for accepting it! Emmm... One clarification: I don’t think this is an upstream iced issue. I tested normal iced with This looks specific to So I think fixing it in |
This changes IME preedit rendering so that the preedit text always uses the application text color.
Previously, the selected preedit span used the window background color as its text color, while the selection background used the text color. This inverse-color approach breaks when the layer-shell background is transparent: selected preedit text becomes transparent and invisible.
The new behavior keeps the preedit background transparent when the window background is transparent, renders preedit text with
text_color, and uses a subtle translucenttext_colorfill for the selected preedit range.This makes IME preedit readable in transparent layer-shell windows while preserving visible selection feedback.
test code
before


now
I think the current approach is more reasonable.