WinRT: fixed bug whereby SDL would override an app's default orientation
authorDavid Ludwig <dludwig@pobox.com>
Wed, 03 Dec 2014 10:55:23 -0500
changeset 9256 9c45fc8605d9
parent 9255 c2ef0d8d6da0
child 9257 6f41196c2d6b
WinRT: fixed bug whereby SDL would override an app's default orientation WinRT apps can set a default, preferred orientation via a .appxmanifest file. SDL was overriding this on app startup, and making the app use all possible orientations (landscape and portrait). Thanks to Eric Wing for the heads up on this!
src/core/winrt/SDL_winrtapp_direct3d.cpp
--- a/src/core/winrt/SDL_winrtapp_direct3d.cpp	Tue Dec 02 21:18:50 2014 -0500
+++ b/src/core/winrt/SDL_winrtapp_direct3d.cpp	Wed Dec 03 10:55:23 2014 -0500
@@ -126,6 +126,16 @@
 {
     SDL_assert(SDL_strcmp(name, SDL_HINT_ORIENTATIONS) == 0);
 
+    /* HACK: prevent SDL from altering an app's .appxmanifest-set orientation
+     * from being changed on startup, by detecting when SDL_HINT_ORIENTATIONS
+     * is getting registered.
+     *
+     * TODO, WinRT: consider reading in an app's .appxmanifest file, and apply its orientation when 'newValue == NULL'.
+     */
+    if ((oldValue == NULL) && (newValue == NULL)) {
+        return;
+    }
+
     // Start with no orientation flags, then add each in as they're parsed
     // from newValue.
     unsigned int orientationFlags = 0;