Skip to content

Commit

Permalink
Take the window border size into account when positioning the IBus ca…
Browse files Browse the repository at this point in the history
…ndidate list.
  • Loading branch information
baines committed Aug 19, 2014
1 parent eba65c6 commit 6f84f37
Showing 1 changed file with 29 additions and 1 deletion.
30 changes: 29 additions & 1 deletion src/core/linux/SDL_ibus.c
Expand Up @@ -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>
Expand Down Expand Up @@ -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;

Expand Down

0 comments on commit 6f84f37

Please sign in to comment.