WinRT: bug-fix, fullscreen window flags weren't set if device was rotated 90 degrees
authorDavid Ludwig
Thu, 26 Nov 2015 01:36:36 -0500
changeset 99252be74843315c
parent 9924 355cccccc7dc
child 9926 277db103ed10
WinRT: bug-fix, fullscreen window flags weren't set if device was rotated 90 degrees
src/video/winrt/SDL_winrtvideo.cpp
     1.1 --- a/src/video/winrt/SDL_winrtvideo.cpp	Thu Nov 26 00:41:39 2015 -0500
     1.2 +++ b/src/video/winrt/SDL_winrtvideo.cpp	Thu Nov 26 01:36:36 2015 -0500
     1.3 @@ -35,6 +35,7 @@
     1.4  #include <dxgi1_2.h>
     1.5  using namespace Windows::ApplicationModel::Core;
     1.6  using namespace Windows::Foundation;
     1.7 +using namespace Windows::Graphics::Display;
     1.8  using namespace Windows::UI::Core;
     1.9  using namespace Windows::UI::ViewManagement;
    1.10  
    1.11 @@ -376,9 +377,31 @@
    1.12      if (data->coreWindow.Get()) {
    1.13          if (is_fullscreen) {
    1.14              SDL_VideoDisplay * display = SDL_GetDisplayForWindow(window);
    1.15 -            if (display->desktop_mode.w != WINRT_DIPS_TO_PHYSICAL_PIXELS(data->coreWindow->Bounds.Width) ||
    1.16 -                display->desktop_mode.h != WINRT_DIPS_TO_PHYSICAL_PIXELS(data->coreWindow->Bounds.Height))
    1.17 -            {
    1.18 +            int w = WINRT_DIPS_TO_PHYSICAL_PIXELS(data->coreWindow->Bounds.Width);
    1.19 +            int h = WINRT_DIPS_TO_PHYSICAL_PIXELS(data->coreWindow->Bounds.Height);
    1.20 +
    1.21 +#if (WINAPI_FAMILY != WINAPI_FAMILY_PHONE_APP) || (NTDDI_VERSION > NTDDI_WIN8)
    1.22 +            // On all WinRT platforms, except for WinPhone 8.0, rotate the
    1.23 +            // window size.  This is needed to properly calculate
    1.24 +            // fullscreen vs. maximized.
    1.25 +            const DisplayOrientations currentOrientation = WINRT_DISPLAY_PROPERTY(CurrentOrientation);
    1.26 +            switch (currentOrientation) {
    1.27 +#if (WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP)
    1.28 +                case DisplayOrientations::Landscape:
    1.29 +                case DisplayOrientations::LandscapeFlipped:
    1.30 +#else
    1.31 +                case DisplayOrientations::Portrait:
    1.32 +                case DisplayOrientations::PortraitFlipped:
    1.33 +#endif
    1.34 +                {
    1.35 +                    int tmp = w;
    1.36 +                    w = h;
    1.37 +                    h = tmp;
    1.38 +                } break;
    1.39 +            }
    1.40 +#endif
    1.41 +
    1.42 +            if (display->desktop_mode.w != w || display->desktop_mode.h != h) {
    1.43                  latestFlags |= SDL_WINDOW_MAXIMIZED;
    1.44              } else {
    1.45                  latestFlags |= SDL_WINDOW_FULLSCREEN_DESKTOP;