From 6f84f37c0ace37402570a304208af4432bd1ceb7 Mon Sep 17 00:00:00 2001 From: Alex Baines Date: Tue, 19 Aug 2014 22:28:53 +0100 Subject: [PATCH] Take the window border size into account when positioning the IBus candidate list. --- src/core/linux/SDL_ibus.c | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/src/core/linux/SDL_ibus.c b/src/core/linux/SDL_ibus.c index 9583b098c..3c4ff5c6f 100644 --- a/src/core/linux/SDL_ibus.c +++ b/src/core/linux/SDL_ibus.c @@ -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" + +#if SDL_VIDEO_DRIVER_X11 + #include "../../video/x11/SDL_x11video.h" +#endif + #include #include #include @@ -545,9 +551,31 @@ SDL_IBus_UpdateTextRect(SDL_Rect *rect) SDL_Window *focused_win = SDL_GetFocusWindow(); 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 SDL_VIDEO_DRIVER_X11 + 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); + } +#endif + x += ibus_cursor_rect.x; y += ibus_cursor_rect.y;