Candidate list appearing at the wrong coordinates |
Sik
|
Having problems implementing IME support in my game. While I know
support for it in Linux is already flaky (candidate list will get hidden in fullscreen mode), I thought I should still work on the parts that do work (i.e. windowed mode). So this happened: http://i.imgur.com/N5ubxjC.png The code responsible for this mess: ------------------------------------------------------------ int list_x = x; int list_y = FILE_NAME_Y2; virtual_to_real_coord(&list_x, &list_y); SDL_Rect list_rect; list_rect.x = list_x; list_rect.y = list_y; list_rect.w = 1; list_rect.h = 1; SDL_SetTextInputRect(&list_rect); ------------------------------------------------------------ Yes, I did think that maybe coordinates are being calculated wrong, so I checked where the list ended up in the screenshot to make sure. It seems like the calculations are correct, but the list position is relative to the window frame, not the inside (so the main reason it appears higher than it should is that the titlebar is heavily skewing the position - if the frame was thicker it would also appear noticeably shifted to the left). So the solution seems obvious: offset the coordinates so they're relative to the window contents and not the frame. Should SDL be doing it itself or should I be doing it on my own? (probably the former) If the latter, how do I get the window frame size? (in a platform-independent way, that is) _______________________________________________ SDL mailing list http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org |
|||||||||||
|
Candidate list appearing at the wrong coordinates |
Sik
|
Random thought that just came up on Twitter: this may be actually
ibus' fault again (since window coordinates in X should not include the frame, as the frame is added by window managers). Not sure how much can SDL do about this. Between that and the list not working in fullscreen because it's not topmost, I'm seriously starting to think that SDL should allow being able to take control over the list (either that or handle the list itself). How feasible is that? (aware that this wouldn't make it to 2.0.4) _______________________________________________ SDL mailing list http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org |
|||||||||||
|
Candidate list appearing at the wrong coordinates |
Sik
|
OK, looking at the ibus code (spent hours trying to look at the SDL
code for possible workarounds) I found this: ------------------------------------------------------------ int x = 0, y = 0; SDL_GetWindowPosition(focused_win, &x, &y); x += ibus_cursor_rect.x; y += ibus_cursor_rect.y; ------------------------------------------------------------ So it looks like ibus takes absolute screen coordinates (in other words, not ibus' fault after all). This means SDL_GetWindowPosition is returning the position of the window with frame included, but the code is ignoring that there's a frame to deal with. This probably needs to be changed. 2014-07-27 1:03 GMT-03:00, Sik the hedgehog:
SDL mailing list http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org |
|||||||||||||
|
Candidate list appearing at the wrong coordinates |
Alex Baines
Guest
|
I will look into this.
On 27/07/14 09:08, Sik the hedgehog wrote:
SDL mailing list http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org |
|||||||||||||||
|
Candidate list appearing at the wrong coordinates |
Alex Baines
Guest
|
Ok, I have fixed this here: https://bugzilla.libsdl.org/show_bug.cgi?id=2662
I've also fixed the variable shadowing and another separate bug where you wouldn't get an editing event when the user presses backspace enough times to close the list. On 27/07/14 15:40, Alex Baines wrote:
SDL mailing list http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org |
|||||||||||||||||
|
Candidate list appearing at the wrong coordinates |
Sik
|
Just tested it, I can confirm it works (ignore the lack of placeholder
text, that's because I didn't add code to draw it yet): http://i.imgur.com/N48UKpA.png 2014-07-27 12:51 GMT-03:00, Alex Baines:
SDL mailing list http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org |
|||||||||||||||||||
|