Hi David,
I found that modifying SDL as described fixes the issue. FYI the (pretty
ugly) patch is below. Modifying the behaviour in SDL_video.c’s “update
fullscreen” depending on the result of the TryEnterFullscreen() mode fixes
all screen size issues for me.
Regards,
Daniel
— SDL_snapshot/src/video/SDL_sysvideo.h??? 2016-10-02 08:22:
14.323265900 +0200
+++ SDL_merged/src/video/SDL_sysvideo.h 2016-10-22 16:08:43.340540400 +0200
@@ -220,7 +220,11 @@
??? void (*RestoreWindow) (_THIS, SDL_Window * window);
??? void (*SetWindowBordered) (_THIS, SDL_Window * window, SDL_bool
bordered);
??? void (*SetWindowResizable) (_THIS, SDL_Window * window, SDL_bool
resizable);
+#ifdef WINRT
+??? int (*SetWindowFullscreen) (THIS, SDL_Window * window, SDL
VideoDisplay * display, SDL_bool fullscreen);
+#else
??? void (*SetWindowFullscreen) (THIS, SDL_Window * window, SDL
VideoDisplay * display, SDL_bool fullscreen);
+#endif
??? int (*SetWindowGammaRamp) (_THIS, SDL_Window * window, const Uint16 *
ramp);
??? int (*GetWindowGammaRamp) (_THIS, SDL_Window * window, Uint16 * ramp);
??? void (*SetWindowGrab) (THIS, SDL_Window * window, SDL_bool grabbed);
diff -bBur SDL_snapshot/src/video/SDL_video.c SDL_merged/src/video/SDL
video.c
— SDL_snapshot/src/video/SDL_video.c? 2016-10-08 10:16:43.377628700 +0200
+++ SDL_merged/src/video/SDL_video.c??? 2016-10-22 17:26:58.402858000 +0200
@@ -1265,7 +1265,14 @@
??? }
??? if (_this->SetWindowFullscreen) {
+#ifdef WINRT
+??? if (_this->SetWindowFullscreen(_this, other,
display, SDL_TRUE) != 0)
+??? {
+??? resized = SDL_FALSE;
+??? }
+#else
??? _this->SetWindowFullscreen(this, other, display, SDL
TRUE);
+#endif
??? }
??? display->fullscreen_window = other;
diff -bBur 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 08:22:
18.423455500 +0200
+++ SDL_merged/src/video/winrt/SDL_winrtvideo.cpp??? 2016-10-22 17:27:
36.208419200 +0200
@@ -80,9 +81,10 @@
?/* Window functions */
?static int WINRT_CreateWindow(_THIS, SDL_Window * window);
?static void WINRT_SetWindowSize(_THIS, SDL_Window * window);
-static void WINRT_SetWindowFullscreen(THIS, SDL_Window * window, SDL
VideoDisplay * display, SDL_bool fullscreen);
+static int 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 */
@@ -723,23 +726,49 @@
?#endif
?}
-void
+int
?WINRT_SetWindowFullscreen(THIS, SDL_Window * window, SDL_VideoDisplay *
display, SDL_bool fullscreen)
?{
?#if NTDDI_VERSION >= NTDDI_WIN10
??? SDL_WindowData * data = (SDL_WindowData *)window->driverdata;
??? bool isWindowActive = WINRT_IsCoreWindowActive(data->coreWindow.Get());
+??? bool rememberMode = false;
+??? int successVal = 0;+
+??? 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->TryEnterFullScreenMode()
== true) {
+??? if (rememberMode == true) {
+??? data->appView->
PreferredLaunchWindowingMode = ApplicationViewWindowingMode::FullScreen;
+??? }
+??? } else {
+??? successVal = -1;
+??? }
??? }
??? } else {
??? if (data->appView->IsFullScreenMode) {
??? data->appView->ExitFullScreenMode();
+
+??? if (rememberMode == true) {
+??? data->appView->
PreferredLaunchWindowingMode = ApplicationViewWindowingMode::Auto;
+??? }
??? }
??? }
??? }
+??? else {
+??? successVal = -1;
+??? }
+??? return successVal;
+#else
+??? return 0;
?#endif
?}
---------- P?vodn? zpr?va ----------
Od: hardcoredaniel <@hardcoredaniel>
Komu: sdl at lists.libsdl.org
Datum: 18. 10. 2016 17:15:17
P?edm?t: Re: [SDL] Some WinRT strangeness with reported window size
"
Hi David,
I’m sorry for having you bothered with an issue that you could not have
reproduced due to missing information. After thinking about your
observations it occurred to me that some time ago I tried to implement some
workaround for the issue that the SDL app will not reliably start (resp
change to) fullscreen mode on PCs.
What I did was to add some code in my app to react on the window event “SDL_
WINDOWEVENT_SHOWN” and to call “SDL_SetWindowFullscreen” with SDL_TRUE as 2
nd parameter.
This worked well at app start, so that I forgot about this trick.
However, when restoring a minimized app that I changed to windowed mode
before, the system is not going to fullscreen despite that call (I’m not
sure whether or whom to blame, because I intentionally left fullscreen mode
before minimizing the window).
As the call to “SetWindowFullscreen” cannot return success/failure, SDL
doesn’t know about this and so probably assumes fullscreen was ok and sends
the SDL_WINDOWEVENT_RESIZED with the fullscreen coords.
So maybe I will have to modify the SDL sources myself to add a return code
to SetWindowFullscreen, return hard-coded success for all other platforms,
and success/failure for WinRT only. I remember your comment about such a
change not suiting all platforms where the success/failure of such operation
is reported asynchronously. Yet I have no other idea how to handle it.
BTW: Can you reproduce the width/height parameter inconsistency on the
mobile platform? Or is there a relation to my workaround as well?
Regards,
Daniel
---------- P?vodn? zpr?va ----------
Od: DLudwig
Komu: sdl at lists.libsdl.org
Datum: 15. 10. 2016 20:07:53
P?edm?t: Re: [SDL] Some WinRT strangeness with reported window size
"
hardcoredaniel wrote:
It will launch in fullscreen. When you resize it to windowed mode, change it
to say 50% of its fullscreen size, minimize it, and then restore, it will
display in invalid size. If you start resizing the window again, it’ll
immediately use the proper size.
I see the bug reproduce in that app, but not in my own code. I’ve tried
checking various SDL outputs as well (window size, renderer output size,
viewport, and a few other things), and am not yet seeing any discrepencies.
Do you have sample code that I could try building + testing against,
preferably something dependency-free and single-file?
– David L.
SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org"
SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org"