From 354ec022b313af7c6c5266e1d70eebabf7dcf4af Mon Sep 17 00:00:00 2001 From: Braden Obrzut Date: Wed, 20 May 2015 12:32:17 -0400 Subject: [PATCH] - On Windows resizing a window just renders the image to the size of the window, so lets do the same for SDL (makes mouse coordinate scaling easier). --- src/posix/sdl/sdlvideo.cpp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/posix/sdl/sdlvideo.cpp b/src/posix/sdl/sdlvideo.cpp index dbaf182398..76191e1a92 100644 --- a/src/posix/sdl/sdlvideo.cpp +++ b/src/posix/sdl/sdlvideo.cpp @@ -705,7 +705,7 @@ void SDLFB::ResetSDLRenderer () } // In fullscreen, set logical size according to animorphic ratio. - // Windowed modes are always rendered 1:1. + // Windowed modes are rendered to fill the window (usually 1:1) if (IsFullscreen ()) { int w, h; @@ -713,10 +713,6 @@ void SDLFB::ResetSDLRenderer () ScaleWithAspect (w, h, Width, Height); SDL_RenderSetLogicalSize (Renderer, w, h); } - else - { - SDL_RenderSetLogicalSize (Renderer, Width, Height); - } } void SDLFB::SetVSync (bool vsync) @@ -743,13 +739,14 @@ void SDLFB::SetVSync (bool vsync) void SDLFB::ScaleCoordsFromWindow(SWORD &x, SWORD &y) { + int w, h; + SDL_GetWindowSize (Screen, &w, &h); + // Detect if we're doing scaling in the Window and adjust the mouse // coordinates accordingly. This could be more efficent, but I // don't think performance is an issue in the menus. if(IsFullscreen()) { - int w, h; - SDL_GetWindowSize (Screen, &w, &h); int realw = w, realh = h; ScaleWithAspect (realw, realh, SCREENWIDTH, SCREENHEIGHT); if (realw != SCREENWIDTH || realh != SCREENHEIGHT) @@ -768,6 +765,11 @@ void SDLFB::ScaleCoordsFromWindow(SWORD &x, SWORD &y) } } } + else + { + x = (SWORD)(x*Width/w); + y = (SWORD)(y*Height/h); + } } ADD_STAT (blit)