diff -r 7d667b53ca2c sdl.c --- a/sdl.c Wed Mar 1 12:44:52 2006 -0500 +++ b/sdl.c Wed Mar 1 13:17:26 2006 -0500 @@ -39,6 +39,8 @@ static int gui_fullscreen_initial_grab; static int gui_grab_code = KMOD_LALT | KMOD_LCTRL; static uint8_t modifiers_state[256]; +static SDL_Cursor *sdl_cursor_normal; +static SDL_Cursor *sdl_cursor_hidden; static void sdl_update(DisplayState *ds, int x, int y, int w, int h) { @@ -273,7 +275,8 @@ static void sdl_grab_start(void) { - SDL_ShowCursor(0); + sdl_cursor_normal = SDL_GetCursor(); + SDL_SetCursor(sdl_cursor_hidden); SDL_WM_GrabInput(SDL_GRAB_ON); /* dummy read to avoid moving the mouse */ SDL_GetRelativeMouseState(NULL, NULL); @@ -284,7 +287,7 @@ static void sdl_grab_end(void) { SDL_WM_GrabInput(SDL_GRAB_OFF); - SDL_ShowCursor(1); + SDL_SetCursor(sdl_cursor_normal); gui_grab = 0; sdl_update_caption(); } @@ -475,6 +478,7 @@ void sdl_display_init(DisplayState *ds, int full_screen) { int flags; + uint8_t data = 0; #if defined(__APPLE__) /* always use generic keymaps */ @@ -508,6 +512,12 @@ SDL_EnableUNICODE(1); gui_grab = 0; + /* work around a bug in libsdl that causes mouse position to be reported + relative to the upper left corner of the screen instead of the window + after SDL_ShowCursor(0) by using a custom invisible cursor. + */ + sdl_cursor_hidden = SDL_CreateCursor(&data, &data, 8, 1, 0, 0); + atexit(sdl_cleanup); if (full_screen) { gui_fullscreen = 1;