WinRT: code cleanup wrt. display mode(s)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97
diff --git a/src/core/winrt/SDL_winrtapp.cpp b/src/core/winrt/SDL_winrtapp.cpp
index 28bd8e0..70937e3 100644
--- a/src/core/winrt/SDL_winrtapp.cpp
+++ b/src/core/winrt/SDL_winrtapp.cpp
@@ -41,6 +41,7 @@ extern "C" {
extern SDL_Window * WINRT_GlobalSDLWindow;
extern SDL_VideoDevice * WINRT_GlobalSDLVideoDevice;
+extern SDL_DisplayMode WINRT_CalcDisplayModeUsingNativeWindow();
// Compile-time debugging options:
@@ -305,7 +306,7 @@ void SDL_WinRTApp::OnWindowSizeChanged(CoreWindow^ sender, WindowSizeChangedEven
// window-resize event as it appeared the SDL window didn't change
// size, and the Direct3D 11.1 renderer wouldn't resize its swap
// chain.
- SDL_DisplayMode resizedDisplayMode = CalcCurrentDisplayMode();
+ SDL_DisplayMode resizedDisplayMode = WINRT_CalcDisplayModeUsingNativeWindow();
WINRT_GlobalSDLVideoDevice->displays[0].current_mode = resizedDisplayMode;
WINRT_GlobalSDLVideoDevice->displays[0].desktop_mode = resizedDisplayMode;
WINRT_GlobalSDLVideoDevice->displays[0].display_modes[0] = resizedDisplayMode;
@@ -466,24 +467,3 @@ void SDL_WinRTApp::OnResuming(Platform::Object^ sender, Platform::Object^ args)
SDL_FilterEvents(RemoveAppSuspendAndResumeEvents, 0);
}
}
-
-SDL_DisplayMode SDL_WinRTApp::CalcCurrentDisplayMode()
-{
- // Create an empty, zeroed-out display mode:
- SDL_DisplayMode mode;
- SDL_zero(mode);
-
- // Fill in most fields:
- mode.format = SDL_PIXELFORMAT_RGB888;
- mode.refresh_rate = 0; // TODO, WinRT: see if refresh rate data is available, or relevant (for WinRT apps)
- mode.driverdata = NULL;
-
- // Calculate the display size given the window size, taking into account
- // the current display's DPI:
- const float currentDPI = Windows::Graphics::Display::DisplayProperties::LogicalDpi;
- const float dipsPerInch = 96.0f;
- mode.w = (int) ((CoreWindow::GetForCurrentThread()->Bounds.Width * currentDPI) / dipsPerInch);
- mode.h = (int) ((CoreWindow::GetForCurrentThread()->Bounds.Height * currentDPI) / dipsPerInch);
-
- return mode;
-}
diff --git a/src/core/winrt/SDL_winrtapp.h b/src/core/winrt/SDL_winrtapp.h
index 0b76621..5136643 100644
--- a/src/core/winrt/SDL_winrtapp.h
+++ b/src/core/winrt/SDL_winrtapp.h
@@ -14,7 +14,6 @@ public:
internal:
// SDL-specific methods
- SDL_DisplayMode CalcCurrentDisplayMode();
void PumpEvents();
Windows::Foundation::Point TransformCursor(Windows::Foundation::Point rawPosition);
diff --git a/src/video/winrt/SDL_winrtvideo.cpp b/src/video/winrt/SDL_winrtvideo.cpp
index 756162e..fcaca6a 100644
--- a/src/video/winrt/SDL_winrtvideo.cpp
+++ b/src/video/winrt/SDL_winrtvideo.cpp
@@ -147,10 +147,33 @@ WINRT_VideoInit(_THIS)
return 0;
}
+SDL_DisplayMode
+WINRT_CalcDisplayModeUsingNativeWindow()
+{
+ // Create an empty, zeroed-out display mode:
+ SDL_DisplayMode mode;
+ SDL_zero(mode);
+
+ // Fill in most fields:
+ mode.format = SDL_PIXELFORMAT_RGB888;
+ mode.refresh_rate = 0; // TODO, WinRT: see if refresh rate data is available, or relevant (for WinRT apps)
+ mode.driverdata = NULL;
+
+ // Calculate the display size given the window size, taking into account
+ // the current display's DPI:
+ const float currentDPI = Windows::Graphics::Display::DisplayProperties::LogicalDpi;
+ const float dipsPerInch = 96.0f;
+ mode.w = (int) ((CoreWindow::GetForCurrentThread()->Bounds.Width * currentDPI) / dipsPerInch);
+ mode.h = (int) ((CoreWindow::GetForCurrentThread()->Bounds.Height * currentDPI) / dipsPerInch);
+
+ return mode;
+}
+
+
static int
WINRT_InitModes(_THIS)
{
- SDL_DisplayMode mode = SDL_WinRTGlobalApp->CalcCurrentDisplayMode();
+ SDL_DisplayMode mode = WINRT_CalcDisplayModeUsingNativeWindow();
if (SDL_AddBasicVideoDisplay(&mode) < 0) {
return -1;
}