mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-11 23:32:04 +00:00
- SDL backend could use the new ScaleCoordsFromWindow since it does similarly for fullscreen.
This commit is contained in:
parent
9b6756114b
commit
1fa1e26cf9
2 changed files with 33 additions and 29 deletions
|
@ -18,8 +18,6 @@
|
||||||
#include "templates.h"
|
#include "templates.h"
|
||||||
#include "s_sound.h"
|
#include "s_sound.h"
|
||||||
|
|
||||||
void ScaleWithAspect (int &w, int &h, int Width, int Height);
|
|
||||||
|
|
||||||
static void I_CheckGUICapture ();
|
static void I_CheckGUICapture ();
|
||||||
static void I_CheckNativeMouse ();
|
static void I_CheckNativeMouse ();
|
||||||
|
|
||||||
|
@ -320,35 +318,11 @@ void MessagePump (const SDL_Event &sev)
|
||||||
int x, y;
|
int x, y;
|
||||||
SDL_GetMouseState (&x, &y);
|
SDL_GetMouseState (&x, &y);
|
||||||
|
|
||||||
// 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.
|
|
||||||
SDL_Window *focus;
|
|
||||||
if (screen->IsFullscreen() && (focus = SDL_GetMouseFocus ()))
|
|
||||||
{
|
|
||||||
int w, h;
|
|
||||||
SDL_GetWindowSize (focus, &w, &h);
|
|
||||||
int realw = w, realh = h;
|
|
||||||
ScaleWithAspect (realw, realh, SCREENWIDTH, SCREENHEIGHT);
|
|
||||||
if (realw != SCREENWIDTH || realh != SCREENHEIGHT)
|
|
||||||
{
|
|
||||||
double xratio = (double)SCREENWIDTH/realw;
|
|
||||||
double yratio = (double)SCREENHEIGHT/realh;
|
|
||||||
if (realw < w)
|
|
||||||
{
|
|
||||||
x = (x - (w - realw)/2)*xratio;
|
|
||||||
y *= yratio;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
y = (y - (h - realh)/2)*yratio;
|
|
||||||
x *= xratio;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
event.data1 = x;
|
event.data1 = x;
|
||||||
event.data2 = y;
|
event.data2 = y;
|
||||||
|
|
||||||
|
screen->ScaleCoordsFromWindow(event.data1, event.data2);
|
||||||
|
|
||||||
event.type = EV_GUI_Event;
|
event.type = EV_GUI_Event;
|
||||||
if(sev.type == SDL_MOUSEMOTION)
|
if(sev.type == SDL_MOUSEMOTION)
|
||||||
event.subtype = EV_GUI_MouseMove;
|
event.subtype = EV_GUI_MouseMove;
|
||||||
|
|
|
@ -50,6 +50,7 @@ public:
|
||||||
friend class SDLVideo;
|
friend class SDLVideo;
|
||||||
|
|
||||||
virtual void SetVSync (bool vsync);
|
virtual void SetVSync (bool vsync);
|
||||||
|
virtual void ScaleCoordsFromWindow(SWORD &x, SWORD &y);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
PalEntry SourcePalette[256];
|
PalEntry SourcePalette[256];
|
||||||
|
@ -723,6 +724,35 @@ void SDLFB::SetVSync (bool vsync)
|
||||||
#endif // __APPLE__
|
#endif // __APPLE__
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SDLFB::ScaleCoordsFromWindow(SWORD &x, SWORD &y)
|
||||||
|
{
|
||||||
|
// 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)
|
||||||
|
{
|
||||||
|
double xratio = (double)SCREENWIDTH/realw;
|
||||||
|
double yratio = (double)SCREENHEIGHT/realh;
|
||||||
|
if (realw < w)
|
||||||
|
{
|
||||||
|
x = (x - (w - realw)/2)*xratio;
|
||||||
|
y *= yratio;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
y = (y - (h - realh)/2)*yratio;
|
||||||
|
x *= xratio;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ADD_STAT (blit)
|
ADD_STAT (blit)
|
||||||
{
|
{
|
||||||
FString out;
|
FString out;
|
||||||
|
|
Loading…
Reference in a new issue