Open xorgy opened 1 week ago
I think the docs mention that it's not implemented on X11? The issue is mostly that I don't think there's an API for that, winit could try to e.g. put the thing below what was submitted, but it could break.
The APIs you see on other platforms require you to pass a rectangle to not obscure an area, so they are just different and compositor positions the window in a way to not obscure it.
@kchibisov The problem is that if you use this API as documented, you will obscure your text 100% of the time with the most common X11 IME (iBus). If you ignore the documentation and send only a Position at the baseline with no size, you get usable behavior most of the time, but then you are misusing the API on every other platform.
The API being called in the X11 backend as far as I'm aware is meant to be given the equivalent of ptCurrentPos
on Windows, as most implementations rarely place the candidate window anywhere but below the given point, but I may be wrong about that.
Of course, you could also make a case for adding width
to x
in this case, because ibus on XIM will still obscure the line if it is near the bottom of the screen.
The thing is that none of that will happen with any of the other backend, though, it' x11 and i don't care that much.
Alright so I've talked with Fcitx @wengxt and he's willing to accept an attribute on the XIM IC, I'll see if I can confirm with Mr. Fujiwara about a name for the attribute for adding this to iBus as well.
Description
On X11, unlike other platforms (windows, macOS),
Window::set_ime_cursor_area
behaves differently from how it is described in the documentation. In particular, it ignores the height of the rectangle, and submits the top left corner as the composition/insertion point: https://github.com/rust-windowing/winit/blob/c913cdab0b0b1ddecc6b7896d85da187f44b2393/src/platform_impl/linux/x11/window.rs#L2034-L2042Whereas on Windows, the height is added to produce the equivalent: https://github.com/rust-windowing/winit/blob/c913cdab0b0b1ddecc6b7896d85da187f44b2393/src/platform_impl/windows/ime.rs#L123-L126
And on Mac, NSView gives a rectangle for this operation, which the system will avoid placing the candidate window over (still assuming the bottom left corner, typically)
https://github.com/rust-windowing/winit/blob/c913cdab0b0b1ddecc6b7896d85da187f44b2393/src/platform_impl/apple/appkit/view.rs#L370-L384
This results in the candidate window being reliably placed overtop the preedit text, without platform-specific workarounds.
OS and window mananger
Xorg 21
Winit version
0.30.5