WinRT: enabled the Win10-Store Cert Kit bug-workaround, for Windows 8.1 apps
authorDavid Ludwig <dludwig@pobox.com>
Sun, 06 Dec 2015 18:33:43 -0500
changeset 9950 6cc7e0682758
parent 9949 67cc0111da82
child 9951 839a45509496
WinRT: enabled the Win10-Store Cert Kit bug-workaround, for Windows 8.1 apps
src/video/winrt/SDL_winrtvideo.cpp
--- a/src/video/winrt/SDL_winrtvideo.cpp	Sun Dec 06 17:32:33 2015 -0500
+++ b/src/video/winrt/SDL_winrtvideo.cpp	Sun Dec 06 18:33:43 2015 -0500
@@ -330,11 +330,12 @@
                happens, and use a hackish means to create a reasonable-as-possible
                'display mode'.  -- DavidL
             */
-#if (NTDDI_VERSION >= NTDDI_WIN10) && SDL_WINRT_USE_APPLICATIONVIEW
+#if SDL_WINRT_USE_APPLICATIONVIEW
             if (adapterIndex == 0 && outputIndex == 0) {
                 SDL_VideoDisplay display;
                 SDL_DisplayMode mode;
                 ApplicationView ^ appView = ApplicationView::GetForCurrentView();
+                CoreWindow ^ coreWin = CoreWindow::GetForCurrentThread();
                 SDL_zero(display);
                 SDL_zero(mode);
                 display.name = "DXGI Display-detection Workaround";
@@ -343,10 +344,19 @@
                    give a better approximation of display-size, than did CoreWindow's
                    Bounds property, insofar that ApplicationView::VisibleBounds seems like
                    it will, at least some of the time, give the full display size (during the
-                   failing test), whereas CoreWindow will not.  -- DavidL
+                   failing test), whereas CoreWindow might not.  -- DavidL
                 */
+
+#if (NTDDI_VERSION >= NTDDI_WIN10) || (WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP)
                 mode.w = WINRT_DIPS_TO_PHYSICAL_PIXELS(appView->VisibleBounds.Width);
                 mode.h = WINRT_DIPS_TO_PHYSICAL_PIXELS(appView->VisibleBounds.Height);
+#else
+                /* On platform(s) that do not support VisibleBounds, such as Windows 8.1,
+                   fall back to CoreWindow's Bounds property.
+                */
+                mode.w = WINRT_DIPS_TO_PHYSICAL_PIXELS(coreWin->Bounds.Width);
+                mode.h = WINRT_DIPS_TO_PHYSICAL_PIXELS(coreWin->Bounds.Height);
+#endif
 
                 mode.format = DXGI_FORMAT_B8G8R8A8_UNORM;
                 mode.refresh_rate = 0;  /* Display mode is unknown, so just fill in zero, as specified by SDL's header files */
@@ -358,7 +368,7 @@
                     return SDL_SetError("Failed to apply DXGI Display-detection workaround");
                 }
             }
-#endif  // (NTDDI_VERSION >= NTDDI_WIN10) && SDL_WINRT_USE_APPLICATIONVIEW
+#endif  // SDL_WINRT_USE_APPLICATIONVIEW
 
             break;
         }