src/core/linux/SDL_ibus.c
changeset 9095 ed277c1c9e7f
parent 9009 ddbca09f8f9d
child 9096 6454f71d6f15
     1.1 --- a/src/core/linux/SDL_ibus.c	Tue Aug 19 21:17:21 2014 -0700
     1.2 +++ b/src/core/linux/SDL_ibus.c	Tue Aug 19 22:28:53 2014 +0100
     1.3 @@ -22,10 +22,16 @@
     1.4  
     1.5  #ifdef HAVE_IBUS_IBUS_H
     1.6  #include "SDL.h"
     1.7 +#include "SDL_syswm.h"
     1.8  #include "SDL_ibus.h"
     1.9  #include "SDL_dbus.h"
    1.10  #include "../../video/SDL_sysvideo.h"
    1.11  #include "../../events/SDL_keyboard_c.h"
    1.12 +
    1.13 +#if SDL_VIDEO_DRIVER_X11
    1.14 +    #include "../../video/x11/SDL_x11video.h"
    1.15 +#endif
    1.16 +
    1.17  #include <sys/inotify.h>
    1.18  #include <unistd.h>
    1.19  #include <fcntl.h>
    1.20 @@ -545,9 +551,31 @@
    1.21      SDL_Window *focused_win = SDL_GetFocusWindow();
    1.22  
    1.23      if(!focused_win) return;
    1.24 +    
    1.25 +    SDL_SysWMinfo info;
    1.26 +    SDL_VERSION(&info.version);
    1.27 +    
    1.28 +    if(!SDL_GetWindowWMInfo(focused_win, &info)) return;
    1.29 +    
    1.30 +    int x = 0, y = 0;
    1.31 +    
    1.32 +    SDL_GetWindowPosition(focused_win, &x, &y);
    1.33 +   
    1.34 +#if SDL_VIDEO_DRIVER_X11    
    1.35 +    if(info.subsystem == SDL_SYSWM_X11){
    1.36 +        SDL_DisplayData *displaydata =
    1.37 +            (SDL_DisplayData *) SDL_GetDisplayForWindow(focused_win)->driverdata;
    1.38 +            
    1.39 +        Display *x_disp = info.info.x11.display;
    1.40 +        Window x_win = info.info.x11.window;
    1.41 +        int x_screen = displaydata->screen;
    1.42 +        Window unused;
    1.43 +            
    1.44 +        X11_XTranslateCoordinates(x_disp, x_win, RootWindow(x_disp, x_screen),
    1.45 +            0, 0, &x, &y, &unused);
    1.46 +    }
    1.47 +#endif
    1.48  
    1.49 -    int x = 0, y = 0;
    1.50 -    SDL_GetWindowPosition(focused_win, &x, &y);
    1.51      x += ibus_cursor_rect.x;
    1.52      y += ibus_cursor_rect.y;
    1.53