# HG changeset patch # User Alex Baines # Date 1406475230 -3600 # Node ID 62dff5bc51c84a42c5f29236827394493c48c4c9 # Parent ebc5144cfcabebf9b5749de6fec1fe5c57f5a517 Take the window border size into account when positioning the ibus candidate list. diff -r ebc5144cfcab -r 62dff5bc51c8 src/core/linux/SDL_ibus.c --- a/src/core/linux/SDL_ibus.c Wed Jul 16 21:18:03 2014 +0100 +++ b/src/core/linux/SDL_ibus.c Sun Jul 27 16:33:50 2014 +0100 @@ -22,10 +22,16 @@ #ifdef HAVE_IBUS_IBUS_H #include "SDL.h" +#include "SDL_syswm.h" #include "SDL_ibus.h" #include "SDL_dbus.h" #include "../../video/SDL_sysvideo.h" #include "../../events/SDL_keyboard_c.h" + +#ifdef SDL_VIDEO_DRIVER_X11 + #include "../../video/x11/SDL_x11video.h" +#endif + #include #include #include @@ -156,7 +162,6 @@ size_t chars = IBus_utf8_strlen(buf); SDL_SendEditingText(buf, cursor, chars); - i += sz; cursor += chars; } @@ -340,14 +345,14 @@ input_ctx_path, IBUS_INPUT_INTERFACE, "SetCapabilities"); - if(msg){ + if(msg2){ Uint32 caps = IBUS_CAP_FOCUS | IBUS_CAP_PREEDIT_TEXT; dbus->message_append_args(msg2, DBUS_TYPE_UINT32, &caps, DBUS_TYPE_INVALID); } - if(msg){ + if(msg2){ if(dbus->connection_send(ibus_conn, msg2, NULL)){ dbus->connection_flush(ibus_conn); } @@ -551,8 +556,26 @@ if(!focused_win) return; + SDL_SysWMinfo info; + SDL_VERSION(&info.version); + + if(!SDL_GetWindowWMInfo(focused_win, &info)) return; + int x = 0, y = 0; - SDL_GetWindowPosition(focused_win, &x, &y); + + if(info.subsystem == SDL_SYSWM_X11){ + SDL_DisplayData *displaydata = + (SDL_DisplayData *) SDL_GetDisplayForWindow(focused_win)->driverdata; + + Display *x_disp = info.info.x11.display; + Window x_win = info.info.x11.window; + int x_screen = displaydata->screen; + Window unused; + + X11_XTranslateCoordinates(x_disp, x_win, RootWindow(x_disp, x_screen), + 0, 0, &x, &y, &unused); + } + x += ibus_cursor_rect.x; y += ibus_cursor_rect.y;