The SDL forums have moved to discourse.libsdl.org.
This is just a read-only archive of the previous forums, to keep old links working.


SDL Forum Index
SDL
Simple Directmedia Layer Forums
WinRT changes for review
hardcoredaniel
Guest

Hi,

I have experimented with WinRT a little and want to publish my changes. Below is the diff.

These are the changes:

1) Added a hint to enable saving the fullscreen preference of an app. Default is disabled.
2) Use triple-buffering instead of double-buffering. We discussed this before, not sure whether and how to apply it.
3) Experimental code to query display densities. Because I have no idea what to do with the "diagonal DPI" value, I tried to put the scaling factor in.

Any feedback is welcome!

Regards,

Daniel

-------------------------

diff -Naur SDL_snapshot/include/SDL_hints.h SDL_merged/include/SDL_hints.h
--- SDL_snapshot/include/SDL_hints.h 2016-10-02 09:27:31.000000000 +0200
+++ SDL_merged/include/SDL_hints.h 2016-10-02 09:41:18.000000000 +0200
@@ -689,6 +689,20 @@
#define SDL_HINT_BMP_SAVE_LEGACY_FORMAT "SDL_BMP_SAVE_LEGACY_FORMAT"

/**
+ * \brief A hint to control whether the system shall remember the preferred fullscreen mode.
+ *
+ * This hint will work for WinRT only.
+ *
+ * The variable can be set to the following values:
+ * "0" - No action. System does not remember whether the app wants to run in fullscreen.
+ * "1" - Remember preferred app setting (fullscreen or windowed).
+ *
+ * The default is "0".
+ *
+ */
+#define SDL_HINT_WINRT_REMEMBER_WINDOW_FULLSCREEN_PREFERENCE "SDL_WINRT_REMEMBER_WINDOW_FULLSCREEN_PREFERENCE"
+
+/**
* \brief An enumeration of hint priorities
*/
typedef enum
diff -Naur SDL_snapshot/src/render/direct3d11/SDL_render_d3d11.c SDL_merged/src/render/direct3d11/SDL_render_d3d11.c
--- SDL_snapshot/src/render/direct3d11/SDL_render_d3d11.c 2016-10-02 09:27:31.000000000 +0200
+++ SDL_merged/src/render/direct3d11/SDL_render_d3d11.c 2016-10-02 09:58:08.000000000 +0200
@@ -1437,7 +1437,7 @@
swapChainDesc.SampleDesc.Count = 1; /* Don't use multi-sampling. */
swapChainDesc.SampleDesc.Quality = 0;
swapChainDesc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
- swapChainDesc.BufferCount = 2; /* Use double-buffering to minimize latency. */
+ swapChainDesc.BufferCount = 3; /* Use triple-buffering to minimize latency. */
#if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP
swapChainDesc.Scaling = DXGI_SCALING_STRETCH; /* On phone, only stretch and aspect-ratio stretch scaling are allowed. */
swapChainDesc.SwapEffect = DXGI_SWAP_EFFECT_DISCARD; /* On phone, no swap effects are supported. */
diff -Naur SDL_snapshot/src/video/winrt/SDL_winrtvideo.cpp SDL_merged/src/video/winrt/SDL_winrtvideo.cpp
--- SDL_snapshot/src/video/winrt/SDL_winrtvideo.cpp 2016-10-02 09:27:31.000000000 +0200
+++ SDL_merged/src/video/winrt/SDL_winrtvideo.cpp 2016-10-02 10:10:31.000000000 +0200
@@ -67,7 +67,8 @@
#include "SDL_winrtmouse_c.h"
#include "SDL_main.h"
#include "SDL_system.h"
-//#include "SDL_log.h"
+#include "SDL_hints.h"
+#include "SDL_log.h"


/* Initialization/Query functions */
@@ -83,6 +84,7 @@
static void WINRT_SetWindowFullscreen(_THIS, SDL_Window * window, SDL_VideoDisplay * display, SDL_bool fullscreen);
static void WINRT_DestroyWindow(_THIS, SDL_Window * window);
static SDL_bool WINRT_GetWindowWMInfo(_THIS, SDL_Window * window, SDL_SysWMinfo * info);
+static int WINRT_GetDisplayDPI(_THIS, SDL_VideoDisplay * sdl_display, float * ddpi, float * hdpi, float * vdpi);


/* Misc functions */
@@ -148,6 +150,7 @@
device->PumpEvents = WINRT_PumpEvents;
device->GetWindowWMInfo = WINRT_GetWindowWMInfo;
device->SuspendScreenSaver = WINRT_SuspendScreenSaver;
+ device->GetDisplayDPI = WINRT_GetDisplayDPI;

#if NTDDI_VERSION >= NTDDI_WIN10
device->HasScreenKeyboardSupport = WINRT_HasScreenKeyboardSupport;
@@ -729,14 +732,33 @@
#if NTDDI_VERSION >= NTDDI_WIN10
SDL_WindowData * data = (SDL_WindowData *)window->driverdata;
bool isWindowActive = WINRT_IsCoreWindowActive(data->coreWindow.Get());
+ bool rememberMode = false;
+
+ const char *hint = SDL_GetHint(SDL_HINT_WINRT_REMEMBER_WINDOW_FULLSCREEN_PREFERENCE);
+ if (hint) {
+ if (*hint == '1') {
+ rememberMode = true;
+ }
+ }
+
if (isWindowActive) {
if (fullscreen) {
- if (!data->appView->IsFullScreenMode) {
- data->appView->TryEnterFullScreenMode(); // TODO, WinRT: return failure (to caller?) from TryEnterFullScreenMode()
- }
+ if (!data->appView->IsFullScreenMode) {
+ if (data->appView->TryEnterFullScreenMode() == true) {
+ if (rememberMode == true) {
+ data->appView->PreferredLaunchWindowingMode = ApplicationViewWindowingMode::FullScreen;
+ }
+ } else {
+ // TODO, WinRT: return failure (to caller?) from TryEnterFullScreenMode()
+ }
+ }
} else {
if (data->appView->IsFullScreenMode) {
data->appView->ExitFullScreenMode();
+
+ if (rememberMode == true) {
+ data->appView->PreferredLaunchWindowingMode = ApplicationViewWindowingMode::Auto;
+ }
}
}
}
@@ -837,6 +859,90 @@
}
}

+int
+WINRT_GetDisplayDPI(_THIS, SDL_VideoDisplay * sdl_display, float * ddpi, float * hdpi, float * vdpi)
+{
+ DisplayInformation ^ inf = DisplayInformation::GetForCurrentView();
+
+ *hdpi = inf->RawDpiX;
+ *vdpi = inf->RawDpiY;
+ switch (inf->ResolutionScale)
+ {
+ case ResolutionScale::Scale100Percent:
+ *ddpi = 100;
+ break;
+
+ case ResolutionScale::Scale120Percent:
+ *ddpi = 120;
+ break;
+
+ case ResolutionScale::Scale125Percent:
+ *ddpi = 125;
+ break;
+
+ case ResolutionScale::Scale140Percent:
+ *ddpi = 140;
+ break;
+
+ case ResolutionScale::Scale150Percent:
+ *ddpi = 150;
+ break;
+
+ case ResolutionScale::Scale160Percent:
+ *ddpi = 160;
+ break;
+
+ case ResolutionScale::Scale175Percent:
+ *ddpi = 175;
+ break;
+
+ case ResolutionScale::Scale180Percent:
+ *ddpi = 180;
+ break;
+
+ case ResolutionScale::Scale200Percent:
+ *ddpi = 200;
+ break;
+
+ case ResolutionScale::Scale225Percent:
+ *ddpi = 225;
+ break;
+
+ case ResolutionScale::Scale250Percent:
+ *ddpi = 250;
+ break;
+
+ case ResolutionScale::Scale300Percent:
+ *ddpi = 300;
+ break;
+
+ case ResolutionScale::Scale350Percent:
+ *ddpi = 350;
+ break;
+
+ case ResolutionScale::Scale400Percent:
+ *ddpi = 400;
+ break;
+
+ case ResolutionScale::Scale450Percent:
+ *ddpi = 450;
+ break;
+
+ case ResolutionScale::Scale500Percent:
+ *ddpi = 500;
+ break;
+
+ case ResolutionScale::Invalid:
+ default:
+ *ddpi = 0;
+ }
+ // *ddpi = inf->ResolutionScale;
+
+ SDL_Log("Densities: H=%.1f V=%.1f D=%.1f\n", *hdpi, *vdpi, *ddpi);
+
+ return 0;
+}
+
#endif /* SDL_VIDEO_DRIVER_WINRT */

/* vi: set ts=4 sw=4 expandtab: */
WinRT changes for review
DLudwig


Joined: 09 Feb 2012
Posts: 179
Thanks for the patch.  I have a few questions and comments about it:

1. regarding DPI, the diagonal-DPI computation looks odd to me.  Is this returning the same values that the SDL's Win32 backend would return?


2. regarding buffer-count: any thoughts on if that were moved into a hint?


3. for remembering window-fullscreen, does SDL need to be modified in order to support that?  Could that be handled via app code, or via an extension library?




Cheers,
-- David L.




On Sun, Oct 2, 2016 at 5:20 AM, hardcoredaniel wrote:
Quote:
Hi,

I have experimented with WinRT a little and want to publish my changes. Below is the diff.

These are the changes:

1) Added a hint to enable saving the fullscreen preference of an app. Default is disabled.
2) Use triple-buffering instead of double-buffering. We discussed this before, not sure whether and how to apply it.
3) Experimental code to query display densities. Because I have no idea what to do with the "diagonal DPI" value, I tried to put the scaling factor in.

Any feedback is welcome!

Regards,

Daniel

-------------------------

diff -Naur SDL_snapshot/include/SDL_hints.h SDL_merged/include/SDL_hints.h
--- SDL_snapshot/include/SDL_hints.h    2016-10-02 09:27:31.000000000 +0200
+++ SDL_merged/include/SDL_hints.h    2016-10-02 09:41:18.000000000 +0200
@@ -689,6 +689,20 @@
 #define SDL_HINT_BMP_SAVE_LEGACY_FORMAT "SDL_BMP_SAVE_LEGACY_FORMAT"
 
 /**
+ * \brief A hint to control whether the system shall remember the preferred fullscreen mode.
+ *
+ * This hint will work for WinRT only.
+ *
+ * The variable can be set to the following values:
+ *    "0"       - No action. System does not remember whether the app wants to run in fullscreen.
+ *    "1"       - Remember preferred app setting (fullscreen or windowed).
+ *
+ * The default is "0".
+ *
+ */
+#define SDL_HINT_WINRT_REMEMBER_WINDOW_FULLSCREEN_PREFERENCE "SDL_WINRT_REMEMBER_WINDOW_FULLSCREEN_PREFERENCE"
+
+/**
  *  \brief  An enumeration of hint priorities
  */
 typedef enum
diff -Naur SDL_snapshot/src/render/direct3d11/SDL_render_d3d11.c SDL_merged/src/render/direct3d11/SDL_render_d3d11.c
--- SDL_snapshot/src/render/direct3d11/SDL_render_d3d11.c    2016-10-02 09:27:31.000000000 +0200
+++ SDL_merged/src/render/direct3d11/SDL_render_d3d11.c    2016-10-02 09:58:08.000000000 +0200
@@ -1437,7 +1437,7 @@
     swapChainDesc.SampleDesc.Count = 1; /* Don't use multi-sampling. */
     swapChainDesc.SampleDesc.Quality = 0;
     swapChainDesc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
-    swapChainDesc.BufferCount = 2; /* Use double-buffering to minimize latency. */
+    swapChainDesc.BufferCount = 3; /* Use triple-buffering to minimize latency. */
 #if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP
     swapChainDesc.Scaling = DXGI_SCALING_STRETCH; /* On phone, only stretch and aspect-ratio stretch scaling are allowed. */
     swapChainDesc.SwapEffect = DXGI_SWAP_EFFECT_DISCARD; /* On phone, no swap effects are supported. */
diff -Naur SDL_snapshot/src/video/winrt/SDL_winrtvideo.cpp SDL_merged/src/video/winrt/SDL_winrtvideo.cpp
--- SDL_snapshot/src/video/winrt/SDL_winrtvideo.cpp    2016-10-02 09:27:31.000000000 +0200
+++ SDL_merged/src/video/winrt/SDL_winrtvideo.cpp    2016-10-02 10:10:31.000000000 +0200
@@ -67,7 +67,8 @@
 #include "SDL_winrtmouse_c.h"
 #include "SDL_main.h"
 #include "SDL_system.h"
-//#include "SDL_log.h"
+#include "SDL_hints.h"
+#include "SDL_log.h"
 
 
 /* Initialization/Query functions */
@@ -83,6 +84,7 @@
 static void WINRT_SetWindowFullscreen(_THIS, SDL_Window * window, SDL_VideoDisplay * display, SDL_bool fullscreen);
 static void WINRT_DestroyWindow(_THIS, SDL_Window * window);
 static SDL_bool WINRT_GetWindowWMInfo(_THIS, SDL_Window * window, SDL_SysWMinfo * info);
+static int WINRT_GetDisplayDPI(_THIS, SDL_VideoDisplay * sdl_display, float * ddpi, float * hdpi, float * vdpi);
 
 
 /* Misc functions */
@@ -148,6 +150,7 @@
     device->PumpEvents = WINRT_PumpEvents;
     device->GetWindowWMInfo = WINRT_GetWindowWMInfo;
     device->SuspendScreenSaver = WINRT_SuspendScreenSaver;
+    device->GetDisplayDPI = WINRT_GetDisplayDPI;
 
 #if NTDDI_VERSION >= NTDDI_WIN10
     device->HasScreenKeyboardSupport = WINRT_HasScreenKeyboardSupport;
@@ -729,14 +732,33 @@
 #if NTDDI_VERSION >= NTDDI_WIN10
     SDL_WindowData * data = (SDL_WindowData *)window->driverdata;
     bool isWindowActive = WINRT_IsCoreWindowActive(data->coreWindow.Get());
+    bool rememberMode = false;
+
+    const char *hint = SDL_GetHint(SDL_HINT_WINRT_REMEMBER_WINDOW_FULLSCREEN_PREFERENCE);
+    if (hint) {
+        if (*hint == '1') {
+            rememberMode = true;
+        }
+    }
+
     if (isWindowActive) {
         if (fullscreen) {
-            if (!data->appView->IsFullScreenMode) {
-                data->appView->TryEnterFullScreenMode();    // TODO, WinRT: return failure (to caller?) from TryEnterFullScreenMode()
-            }
+            if (!data->appView->IsFullScreenMode) {
+                if (data->appView->TryEnterFullScreenMode() == true) {
+                    if (rememberMode == true) {
+                        data->appView->PreferredLaunchWindowingMode = ApplicationViewWindowingMode::FullScreen;
+                    }
+                } else {
+                    // TODO, WinRT: return failure (to caller?) from TryEnterFullScreenMode()
+                }
+            }
         } else {
             if (data->appView->IsFullScreenMode) {
                 data->appView->ExitFullScreenMode();
+
+                if (rememberMode == true) {
+                    data->appView->PreferredLaunchWindowingMode = ApplicationViewWindowingMode::Auto;
+                }
             }
         }
     }
@@ -837,6 +859,90 @@
     }
 }
 
+int
+WINRT_GetDisplayDPI(_THIS, SDL_VideoDisplay * sdl_display, float * ddpi, float * hdpi, float * vdpi)
+{
+    DisplayInformation ^ inf = DisplayInformation::GetForCurrentView();
+
+    *hdpi = inf->RawDpiX;
+    *vdpi = inf->RawDpiY;
+    switch (inf->ResolutionScale)
+    {
+    case ResolutionScale::Scale100Percent:
+        *ddpi = 100;
+        break;
+
+    case ResolutionScale::Scale120Percent:
+        *ddpi = 120;
+        break;
+
+    case ResolutionScale::Scale125Percent:
+        *ddpi = 125;
+        break;
+
+    case ResolutionScale::Scale140Percent:
+        *ddpi = 140;
+        break;
+
+    case ResolutionScale::Scale150Percent:
+        *ddpi = 150;
+        break;
+
+    case ResolutionScale::Scale160Percent:
+        *ddpi = 160;
+        break;
+
+    case ResolutionScale::Scale175Percent:
+        *ddpi = 175;
+        break;
+
+    case ResolutionScale::Scale180Percent:
+        *ddpi = 180;
+        break;
+
+    case ResolutionScale::Scale200Percent:
+        *ddpi = 200;
+        break;
+
+    case ResolutionScale::Scale225Percent:
+        *ddpi = 225;
+        break;
+
+    case ResolutionScale::Scale250Percent:
+        *ddpi = 250;
+        break;
+
+    case ResolutionScale::Scale300Percent:
+        *ddpi = 300;
+        break;
+
+    case ResolutionScale::Scale350Percent:
+        *ddpi = 350;
+        break;
+
+    case ResolutionScale::Scale400Percent:
+        *ddpi = 400;
+        break;
+
+    case ResolutionScale::Scale450Percent:
+        *ddpi = 450;
+        break;
+
+    case ResolutionScale::Scale500Percent:
+        *ddpi = 500;
+        break;
+
+    case ResolutionScale::Invalid:
+    default:
+        *ddpi = 0;
+    }
+    //    *ddpi = inf->ResolutionScale;
+
+    SDL_Log("Densities: H=%.1f V=%.1f D=%.1f\n", *hdpi, *vdpi, *ddpi);
+
+    return 0;
+}
+
 #endif /* SDL_VIDEO_DRIVER_WINRT */
 
 /* vi: set ts=4 sw=4 expandtab: */



_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

WinRT changes for review
hardcoredaniel
Guest

Hi,

let me put my answers here:

1. I have not found anything useful to put into ddpi. I filled in the value for "ResolutionScale", but I do not know whether the raw DPI values need to be scaled anyway - so this was experimental only. I can also put in the mean of rawdpix and rawdpiy instead.

2. I would be fine with a hint, one reason less to maintain an out-of-tree SDL :-) Last time we discussed it we did not conclude whether the hint is necessary, or triple-buffering should be enabled by default, because the additional memory consumption is not relevant nowadays.

3. The implementation from the patch will only try to set the "PreferredLaunchWindowingMode" property if the switch to windowed/fullscreen worked. An implementation outside SDL would have to query the fullscreen state first (to check whether the call worked) and then set the property accordingly.
However, if the property should be set independently of the result of the function call, it can be set externally.
Too bad that "SetWindowFullscreen" cannot return success or failure...

Regards,

Daniel



---------- Původní zpráva ----------
Od: David Ludwig
Komu: SDL Development List
Datum: 2. 10. 2016 17:09:45
Předmět: Re: [SDL] WinRT changes for review
Quote:
Thanks for the patch. I have a few questions and comments about it:

1. regarding DPI, the diagonal-DPI computation looks odd to me. Is this returning the same values that the SDL's Win32 backend would return?


2. regarding buffer-count: any thoughts on if that were moved into a hint?


3. for remembering window-fullscreen, does SDL need to be modified in order to support that? Could that be handled via app code, or via an extension library?




Cheers,
-- David L.




On Sun, Oct 2, 2016 at 5:20 AM, hardcoredaniel wrote:
Quote:
Hi,

I have experimented with WinRT a little and want to publish my changes. Below is the diff.

These are the changes:

1) Added a hint to enable saving the fullscreen preference of an app. Default is disabled.
2) Use triple-buffering instead of double-buffering. We discussed this before, not sure whether and how to apply it.
3) Experimental code to query display densities. Because I have no idea what to do with the "diagonal DPI" value, I tried to put the scaling factor in.

Any feedback is welcome!

Regards,

Daniel

-------------------------

diff -Naur SDL_snapshot/include/SDL_ hints.h SDL_merged/include/SDL_hints.h
--- SDL_snapshot/include/SDL_ hints.h 2016-10-02 09:27:31.000000000 +0200
+++ SDL_merged/include/SDL_hints. h 2016-10-02 09:41:18.000000000 +0200
@@ -689,6 +689,20 @@
#define SDL_HINT_BMP_SAVE_LEGACY_ FORMAT "SDL_BMP_SAVE_LEGACY_FORMAT"

/**
+ * \brief A hint to control whether the system shall remember the preferred fullscreen mode.
+ *
+ * This hint will work for WinRT only.
+ *
+ * The variable can be set to the following values:
+ * "0" - No action. System does not remember whether the app wants to run in fullscreen.
+ * "1" - Remember preferred app setting (fullscreen or windowed).
+ *
+ * The default is "0".
+ *
+ */
+#define SDL_HINT_WINRT_REMEMBER_ WINDOW_FULLSCREEN_PREFERENCE "SDL_WINRT_REMEMBER_WINDOW_ FULLSCREEN_PREFERENCE"
+
+/**
* \brief An enumeration of hint priorities
*/
typedef enum
diff -Naur SDL_snapshot/src/render/ direct3d11/SDL_render_d3d11.c SDL_merged/src/render/ direct3d11/SDL_render_d3d11.c
--- SDL_snapshot/src/render/ direct3d11/SDL_render_d3d11.c 2016-10-02 09:27:31.000000000 +0200
+++ SDL_merged/src/render/ direct3d11/SDL_render_d3d11.c 2016-10-02 09:58:08.000000000 +0200
@@ -1437,7 +1437,7 @@
swapChainDesc.SampleDesc.Count = 1; /* Don't use multi-sampling. */
swapChainDesc.SampleDesc. Quality = 0;
swapChainDesc.BufferUsage = DXGI_USAGE_RENDER_TARGET_ OUTPUT;
- swapChainDesc.BufferCount = 2; /* Use double-buffering to minimize latency. */
+ swapChainDesc.BufferCount = 3; /* Use triple-buffering to minimize latency. */
#if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP
swapChainDesc.Scaling = DXGI_SCALING_STRETCH; /* On phone, only stretch and aspect-ratio stretch scaling are allowed. */
swapChainDesc.SwapEffect = DXGI_SWAP_EFFECT_DISCARD; /* On phone, no swap effects are supported. */
diff -Naur SDL_snapshot/src/video/winrt/ SDL_winrtvideo.cpp SDL_merged/src/video/winrt/ SDL_winrtvideo.cpp
--- SDL_snapshot/src/video/winrt/ SDL_winrtvideo.cpp 2016-10-02 09:27:31.000000000 +0200
+++ SDL_merged/src/video/winrt/ SDL_winrtvideo.cpp 2016-10-02 10:10:31.000000000 +0200
@@ -67,7 +67,8 @@
#include "SDL_winrtmouse_c.h"
#include "SDL_main.h"
#include "SDL_system.h"
-//#include "SDL_log.h"
+#include "SDL_hints.h"
+#include "SDL_log.h"


/* Initialization/Query functions */
@@ -83,6 +84,7 @@
static void WINRT_SetWindowFullscreen(_ THIS, SDL_Window * window, SDL_VideoDisplay * display, SDL_bool fullscreen);
static void WINRT_DestroyWindow(_THIS, SDL_Window * window);
static SDL_bool WINRT_GetWindowWMInfo(_THIS, SDL_Window * window, SDL_SysWMinfo * info);
+static int WINRT_GetDisplayDPI(_THIS, SDL_VideoDisplay * sdl_display, float * ddpi, float * hdpi, float * vdpi);


/* Misc functions */
@@ -148,6 +150,7 @@
device->PumpEvents = WINRT_PumpEvents;
device->GetWindowWMInfo = WINRT_GetWindowWMInfo;
device->SuspendScreenSaver = WINRT_SuspendScreenSaver;
+ device->GetDisplayDPI = WINRT_GetDisplayDPI;

#if NTDDI_VERSION >= NTDDI_WIN10
device-> HasScreenKeyboardSupport = WINRT_ HasScreenKeyboardSupport;
@@ -729,14 +732,33 @@
#if NTDDI_VERSION >= NTDDI_WIN10
SDL_WindowData * data = (SDL_WindowData *)window->driverdata;
bool isWindowActive = WINRT_IsCoreWindowActive(data- >coreWindow.Get());
+ bool rememberMode = false;
+
+ const char *hint = SDL_GetHint(SDL_HINT_WINRT_ REMEMBER_WINDOW_FULLSCREEN_ PREFERENCE);
+ if (hint) {
+ if (*hint == '1') {
+ rememberMode = true;
+ }
+ }
+
if (isWindowActive) {
if (fullscreen) {
- if (!data->appView-> IsFullScreenMode) {
- data->appView-> TryEnterFullScreenMode(); // TODO, WinRT: return failure (to caller?) from TryEnterFullScreenMode()
- }
+ if (!data->appView-> IsFullScreenMode) {
+ if (data->appView-> TryEnterFullScreenMode() == true) {
+ if (rememberMode == true) {
+ data->appView-> PreferredLaunchWindowingMode = ApplicationViewWindowingMode:: FullScreen;
+ }
+ } else {
+ // TODO, WinRT: return failure (to caller?) from TryEnterFullScreenMode()
+ }
+ }
} else {
if (data->appView-> IsFullScreenMode) {
data->appView-> ExitFullScreenMode();
+
+ if (rememberMode == true) {
+ data->appView-> PreferredLaunchWindowingMode = ApplicationViewWindowingMode:: Auto;
+ }
}
}
}
@@ -837,6 +859,90 @@
}
}

+int
+WINRT_GetDisplayDPI(_THIS, SDL_VideoDisplay * sdl_display, float * ddpi, float * hdpi, float * vdpi)
+{
+ DisplayInformation ^ inf = DisplayInformation:: GetForCurrentView();
+
+ *hdpi = inf->RawDpiX;
+ *vdpi = inf->RawDpiY;
+ switch (inf->ResolutionScale)
+ {
+ case ResolutionScale:: Scale100Percent:
+ *ddpi = 100;
+ break;
+
+ case ResolutionScale:: Scale120Percent:
+ *ddpi = 120;
+ break;
+
+ case ResolutionScale:: Scale125Percent:
+ *ddpi = 125;
+ break;
+
+ case ResolutionScale:: Scale140Percent:
+ *ddpi = 140;
+ break;
+
+ case ResolutionScale:: Scale150Percent:
+ *ddpi = 150;
+ break;
+
+ case ResolutionScale:: Scale160Percent:
+ *ddpi = 160;
+ break;
+
+ case ResolutionScale:: Scale175Percent:
+ *ddpi = 175;
+ break;
+
+ case ResolutionScale:: Scale180Percent:
+ *ddpi = 180;
+ break;
+
+ case ResolutionScale:: Scale200Percent:
+ *ddpi = 200;
+ break;
+
+ case ResolutionScale:: Scale225Percent:
+ *ddpi = 225;
+ break;
+
+ case ResolutionScale:: Scale250Percent:
+ *ddpi = 250;
+ break;
+
+ case ResolutionScale:: Scale300Percent:
+ *ddpi = 300;
+ break;
+
+ case ResolutionScale:: Scale350Percent:
+ *ddpi = 350;
+ break;
+
+ case ResolutionScale:: Scale400Percent:
+ *ddpi = 400;
+ break;
+
+ case ResolutionScale:: Scale450Percent:
+ *ddpi = 450;
+ break;
+
+ case ResolutionScale:: Scale500Percent:
+ *ddpi = 500;
+ break;
+
+ case ResolutionScale::Invalid:
+ default:
+ *ddpi = 0;
+ }
+ // *ddpi = inf->ResolutionScale;
+
+ SDL_Log("Densities: H=%.1f V=%.1f D=%.1f\n", *hdpi, *vdpi, *ddpi);
+
+ return 0;
+}
+
#endif /* SDL_VIDEO_DRIVER_WINRT */

/* vi: set ts=4 sw=4 expandtab: */



______________________________ _________________
SDL mailing list

http://lists.libsdl.org/ listinfo.cgi/sdl-libsdl.org





_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
WinRT changes for review
DLudwig


Joined: 09 Feb 2012
Posts: 179
On Sun, Oct 2, 2016 at 3:04 PM, hardcoredaniel wrote:
Quote:
1. I have not found anything useful to put into ddpi. I filled in the value for "ResolutionScale", but I do not know whether the raw DPI values need to be scaled anyway - so this was experimental only. I can also put in the mean of rawdpix and rawdpiy instead.



If those values give return values that are equal to the values returned by the Win32 backend, I'd generally be fine with this.
 
Quote:

2. I would be fine with a hint, one reason less to maintain an out-of-tree SDL :-) Last time we discussed it we did not conclude whether the hint is necessary, or triple-buffering should be enabled by default, because the additional memory consumption is not relevant nowadays.



I've started work on a patch (for a hypothetical, SDL_HINT_RENDER_BUFFER_COUNT), and will try to post it to Bugzilla soon, for review.
 

Quote:

3. The implementation from the patch will only try to set the "PreferredLaunchWindowingMode" property if the switch to windowed/fullscreen worked. An implementation outside SDL would have to query the fullscreen state first (to check whether the call worked) and then set the property accordingly.
However, if the property should be set independently of the result of the function call, it can be set externally.
Too bad that "SetWindowFullscreen" cannot return success or failure...



Having internal SetWindowFullscreen functions be able to report errors sounds interesting.  I'm wondering if there are downsides here, such as quirky behavior on select platforms (I vaguely recall OSX-fullscreen'ing being async, for example), that would prevent this operation from making sense, in some cases.  :-/


-- David L.
WinRT changes for review
hardcoredaniel
Guest

On Sun, Oct 2, 2016 at 3:04 PM, hardcoredaniel wrote:
Quote:
Quote:
1. I have not found anything useful to put into ddpi. I filled in the value for "ResolutionScale", but I do not know whether the raw DPI values need to be scaled anyway - so this was experimental only. I can also put in the mean of rawdpix and rawdpiy instead.



If those values give return values that are equal to the values returned by the Win32 backend, I'd generally be fine with this.








No, currently they are not. I put in the numeric value of this enum instead:


https://msdn.microsoft.com/de-de/library/windows/apps/windows.graphics.display.displayinformation.resolutionscale.aspx


My impression was that the DPI values need to be scaled by this. (Like iOS physical DPI changes depending on whether you request a highDPI window or not). But maybe this is not true.


If these values


https://msdn.microsoft.com/de-de/library/windows/apps/windows.graphics.display.displayinformation.rawdpix.aspx
https://msdn.microsoft.com/de-de/library/windows/apps/windows.graphics.display.displayinformation.rawdpiy.aspx


are always correct, then I can simply copy&paste from the Win32 backend to compute ddpi.

Quote:

Quote:

2. I would be fine with a hint, one reason less to maintain an out-of-tree SDL :-) Last time we discussed it we did not conclude whether the hint is necessary, or triple-buffering should be enabled by default, because the additional memory consumption is not relevant nowadays.



I've started work on a patch (for a hypothetical, SDL_HINT_RENDER_BUFFER_COUNT), and will try to post it to Bugzilla soon, for review.







Cool :-) Please announce your patch on the list as well so I can take a look.

Quote:



Quote:

3. The implementation from the patch will only try to set the "PreferredLaunchWindowingMode" property if the switch to windowed/fullscreen worked. An implementation outside SDL would have to query the fullscreen state first (to check whether the call worked) and then set the property accordingly.
However, if the property should be set independently of the result of the function call, it can be set externally.
Too bad that "SetWindowFullscreen" cannot return success or failure...



Having internal SetWindowFullscreen functions be able to report errors sounds interesting. I'm wondering if there are downsides here, such as quirky behavior on select platforms (I vaguely recall OSX-fullscreen'ing being async, for example), that would prevent this operation from making sense, in some cases. :-/







Hm, in that case a "get()" function for the fullscreen state would probably be a better idea than a success/failure return value from the "set()" function.
Quote:



-- David L.






_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org