SDL: Move code to handle cursor coordinate HiDPI scale to SdlWindow
SDL handles HiDPI scaling differently depending on the system. On macOS for example the SDL window size and SDL drawable area have a different size (factor 2 usually) while on Windows they are the same. When HiDPI is disabled (for the SDL Surface mode for example) they are always the same. We need to appl this scaling when converting cursor position between the drawable area and the SDL window.
This commit is contained in:
parent
9d4ba30060
commit
feac996b50
3 changed files with 26 additions and 9 deletions
|
@ -87,7 +87,17 @@ public:
|
|||
*/
|
||||
Common::Rect getDesktopResolution();
|
||||
|
||||
void getDisplayDpi(float *dpi, float *defaultDpi) const;
|
||||
/*
|
||||
* Get the scaling between the SDL Window size and the SDL
|
||||
* drawable area size. On some system, when HiDPI support is
|
||||
* enabled, those two sizes are different.
|
||||
*
|
||||
* To convert from window coordinate to drawable area coordinate,
|
||||
* multiple the coordinate by this scaling factor. To convert
|
||||
* from drawable area coordinate to window coordinate, divide the
|
||||
* coordinate by this scaling factor.
|
||||
*/
|
||||
float getSdlDpiScalingFactor() const;
|
||||
|
||||
/**
|
||||
* Returns the scaling mode based on the display DPI
|
||||
|
@ -115,6 +125,9 @@ private:
|
|||
Common::Rect _desktopRes;
|
||||
bool _inputGrabState, _inputLockState;
|
||||
|
||||
protected:
|
||||
void getDisplayDpi(float *dpi, float *defaultDpi) const;
|
||||
|
||||
#if SDL_VERSION_ATLEAST(2, 0, 0)
|
||||
public:
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue