Take the window border size into account when positioning the IBus candidate list.

This commit is contained in:
Alex Baines 2014-08-19 22:28:53 +01:00
parent eba65c66a3
commit 6f84f37c0a

View file

@ -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 <sys/inotify.h>
#include <unistd.h>
#include <fcntl.h>
@ -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;