mirror of
https://github.com/Relintai/sdl2_frt.git
synced 2024-12-16 11:06:49 +01:00
WinRT: display-information code cleanups
This commit is contained in:
parent
d4f1d2257e
commit
164e5b89d5
@ -170,11 +170,7 @@ static void WINRT_SetDisplayOrientationsPreference(void *userdata, const char *n
|
|||||||
// for details. Microsoft's "Display orientation sample" also gives an
|
// for details. Microsoft's "Display orientation sample" also gives an
|
||||||
// outline of how Windows treats device rotation
|
// outline of how Windows treats device rotation
|
||||||
// (http://code.msdn.microsoft.com/Display-Orientation-Sample-19a58e93).
|
// (http://code.msdn.microsoft.com/Display-Orientation-Sample-19a58e93).
|
||||||
#if NTDDI_VERSION > NTDDI_WIN8
|
WINRT_DISPLAY_PROPERTY(AutoRotationPreferences) = (DisplayOrientations) orientationFlags;
|
||||||
DisplayInformation::AutoRotationPreferences = (DisplayOrientations) orientationFlags;
|
|
||||||
#else
|
|
||||||
DisplayProperties::AutoRotationPreferences = (DisplayOrientations) orientationFlags;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
#if SDL_VIDEO_RENDER_D3D11 && !SDL_RENDER_DISABLED
|
#if SDL_VIDEO_RENDER_D3D11 && !SDL_RENDER_DISABLED
|
||||||
|
|
||||||
#include "SDL_syswm.h"
|
#include "SDL_syswm.h"
|
||||||
|
#include "../../video/winrt/SDL_winrtvideo_cpp.h"
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#include "../SDL_sysrender.h"
|
#include "../SDL_sysrender.h"
|
||||||
}
|
}
|
||||||
@ -79,11 +80,7 @@ D3D11_GetCoreWindowFromSDLRenderer(SDL_Renderer * renderer)
|
|||||||
extern "C" DXGI_MODE_ROTATION
|
extern "C" DXGI_MODE_ROTATION
|
||||||
D3D11_GetCurrentRotation()
|
D3D11_GetCurrentRotation()
|
||||||
{
|
{
|
||||||
#if NTDDI_VERSION > NTDDI_WIN8
|
const DisplayOrientations currentOrientation = WINRT_DISPLAY_PROPERTY(CurrentOrientation);
|
||||||
const DisplayOrientations currentOrientation = DisplayInformation::GetForCurrentView()->CurrentOrientation;
|
|
||||||
#else
|
|
||||||
const DisplayOrientations currentOrientation = DisplayProperties::CurrentOrientation;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
switch (currentOrientation) {
|
switch (currentOrientation) {
|
||||||
|
|
||||||
|
@ -87,7 +87,7 @@ WINRT_TransformCursorPosition(SDL_Window * window,
|
|||||||
outputPosition.X = rawPosition.X / nativeWindow->Bounds.Width;
|
outputPosition.X = rawPosition.X / nativeWindow->Bounds.Width;
|
||||||
outputPosition.Y = rawPosition.Y / nativeWindow->Bounds.Height;
|
outputPosition.Y = rawPosition.Y / nativeWindow->Bounds.Height;
|
||||||
#else
|
#else
|
||||||
switch (DisplayProperties::CurrentOrientation)
|
switch (WINRT_DISPLAY_PROPERTY(CurrentOrientation))
|
||||||
{
|
{
|
||||||
case DisplayOrientations::Portrait:
|
case DisplayOrientations::Portrait:
|
||||||
outputPosition.X = rawPosition.X / nativeWindow->Bounds.Width;
|
outputPosition.X = rawPosition.X / nativeWindow->Bounds.Width;
|
||||||
|
@ -185,11 +185,7 @@ WINRT_CalcDisplayModeUsingNativeWindow(SDL_DisplayMode * mode)
|
|||||||
|
|
||||||
// Calculate the display size given the window size, taking into account
|
// Calculate the display size given the window size, taking into account
|
||||||
// the current display's DPI:
|
// the current display's DPI:
|
||||||
#if NTDDI_VERSION > NTDDI_WIN8
|
const float currentDPI = WINRT_DISPLAY_PROPERTY(LogicalDpi);
|
||||||
const float currentDPI = DisplayInformation::GetForCurrentView()->LogicalDpi;
|
|
||||||
#else
|
|
||||||
const float currentDPI = Windows::Graphics::Display::DisplayProperties::LogicalDpi;
|
|
||||||
#endif
|
|
||||||
const float dipsPerInch = 96.0f;
|
const float dipsPerInch = 96.0f;
|
||||||
const int w = (int) ((CoreWindow::GetForCurrentThread()->Bounds.Width * currentDPI) / dipsPerInch);
|
const int w = (int) ((CoreWindow::GetForCurrentThread()->Bounds.Width * currentDPI) / dipsPerInch);
|
||||||
const int h = (int) ((CoreWindow::GetForCurrentThread()->Bounds.Height * currentDPI) / dipsPerInch);
|
const int h = (int) ((CoreWindow::GetForCurrentThread()->Bounds.Height * currentDPI) / dipsPerInch);
|
||||||
@ -211,11 +207,7 @@ WINRT_CalcDisplayModeUsingNativeWindow(SDL_DisplayMode * mode)
|
|||||||
mode->w = w;
|
mode->w = w;
|
||||||
mode->h = h;
|
mode->h = h;
|
||||||
mode->driverdata = driverdata;
|
mode->driverdata = driverdata;
|
||||||
#if NTDDI_VERSION > NTDDI_WIN8
|
driverdata->currentOrientation = WINRT_DISPLAY_PROPERTY(CurrentOrientation);
|
||||||
driverdata->currentOrientation = DisplayInformation::GetForCurrentView()->CurrentOrientation;
|
|
||||||
#else
|
|
||||||
driverdata->currentOrientation = DisplayProperties::CurrentOrientation;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if (WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP) && (NTDDI_VERSION == NTDDI_WIN8)
|
#if (WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP) && (NTDDI_VERSION == NTDDI_WIN8)
|
||||||
// On Windows Phone 8.0, the native window's size is always in portrait,
|
// On Windows Phone 8.0, the native window's size is always in portrait,
|
||||||
|
Loading…
Reference in New Issue
Block a user