Permalink
Browse files

[SDL2] Mouse position is adjusted using the size of the focused window.

SDL_GetVideoSurface() does not exist anymore. We get the active window with
SDL_GetMouseFocus() then we request its size with SDL_GetWindowSize().
  • Loading branch information...
Julien Jorge
Julien Jorge committed Aug 25, 2013
1 parent 6506302 commit 701d58906ac3b5ba451365073ebb49f81afc49e2
Showing with 9 additions and 3 deletions.
  1. +9 −3 bear-engine/core/src/input/code/mouse.cpp
@@ -159,10 +159,16 @@ void bear::input::mouse::update_position()
int x, y;
SDL_GetMouseState( &x, &y );
- SDL_Surface* s( SDL_GetVideoSurface() );
- if ( s!=NULL )
- y = s->h - y;
+ SDL_Window* const window( SDL_GetMouseFocus() );
+
+ if ( window != NULL )
+ {
+ int h;
+ SDL_GetWindowSize( window, NULL, &h );
+
+ y = h - y;
+ }
m_position.set(x, y);
} // mouse::update_position()

0 comments on commit 701d589

Please sign in to comment.