We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 3793 - macOS: fullscreen toggle does not maintain SDL_Renderer's logical size
Summary: macOS: fullscreen toggle does not maintain SDL_Renderer's logical size
Status: RESOLVED FIXED
Alias: None
Product: SDL
Classification: Unclassified
Component: render (show other bugs)
Version: HG 2.0
Hardware: x86_64 macOS 10.12
: P2 major
Assignee: Sam Lantinga
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-09-02 20:40 UTC by David Ludwig
Modified: 2017-09-04 18:31 UTC (History)
1 user (show)

See Also:


Attachments
code for sample application (to reproduce bug with) (1.77 KB, text/x-csrc)
2017-09-02 20:40 UTC, David Ludwig
Details
screenshot of expected result, using attached sample code (27.13 KB, image/png)
2017-09-02 20:41 UTC, David Ludwig
Details
screenshot of observed result, using attached sample code (26.92 KB, image/png)
2017-09-02 20:42 UTC, David Ludwig
Details
possible fix, #1 (1.10 KB, text/plain)
2017-09-03 21:41 UTC, David Ludwig
Details

Note You need to log in before you can comment on or make changes to this bug.
Description David Ludwig 2017-09-02 20:40:31 UTC
Created attachment 2906 [details]
code for sample application (to reproduce bug with)

On macOS/OSX, toggling between fullscreen and windowed mode via SDL_SetWindowFullscreen calls can cause an app that uses a 'logical screen size', as set via SDL_RenderSetLogicalSize, to not display content correctly.

This bug was -not- present in SDL 2.0.5, but is present in the latest from hg.libsdl.org as of this writing (https://hg.libsdl.org/SDL/rev/11413fa29401).  I am not sure which commit triggered this.

Steps to reproduce:

1. create an SDL_Window in windowed mode
2. create an SDL_Renderer, using SDL provided defaults
3. set the SDL_Renderer's logical size to that of the window's size
4. create and populate a texture, whose size equals that of the SDL_Window, and the SDL_Renderer's logical size
5. create a game loop, processing events, and displaying the texture in its entirety
6. add a means to toggle between fullscreen and windowed mode, via calls to SDL_SetWindowFullscreen
7. run the app
8. switch to fullscreen, via a call to SDL_SetWindowFullscreen.  If using the attached sample code, press 'F' to switch to fullscreen.
9. switch to windowed mode, via a call to SDL_SetWindowFullscreen.  If using the attached sample code, press 'W' to switch to windowed-mode.
10. observe the contents of the window

Expected result: the entire texture's contents are displayed

Observed result: only a portion of the texture is displayed

Side-observation: the window's position will change, when going back to windowed mode.  This was not expected, and may warrant a separate bugzilla case and/or fix

A sample program is attached, with keyboard input potentially leading to SDL_SetWindowFullscreen being called.  Specifically, pressing:
- 'F' will switch to fullscreen
- 'W' will switch to windowed mode
Comment 1 David Ludwig 2017-09-02 20:41:46 UTC
Created attachment 2907 [details]
screenshot of expected result, using attached sample code
Comment 2 David Ludwig 2017-09-02 20:42:52 UTC
Created attachment 2908 [details]
screenshot of observed result, using attached sample code
Comment 3 David Ludwig 2017-09-02 20:59:41 UTC
This bug started appearing in changeset 11421 : https://hg.libsdl.org/SDL/rev/f9d5845f2311
Comment 4 David Ludwig 2017-09-03 21:41:47 UTC
Created attachment 2910 [details]
possible fix, #1

Here is a possible fix for this bug.  In my own testing (on macOS 10.12), it does not reintroduce the bug (#3719, https://bugzilla.libsdl.org/show_bug.cgi?id=3719) that changeset 11421 fixed.  It also fixes the reopened bug 3719's issue, whereby the SDL window can unexpectedly move, after switching from fullscreen to windowed mode.

Changeset 11421 does not invoke the SDL_Renderer's viewport-updating routines, due in part to [Cocoa_WindowListener windowDidResize:] ceasing to be called (via change 11421).

This change re-introduces the manual call to [Cocoa_WindowListener windowDidResize:], which updates the renderer's viewport, and leaves the window in the expected position.
Comment 5 Sam Lantinga 2017-09-04 18:31:25 UTC
Patch added, thanks!
https://hg.libsdl.org/SDL/rev/f76299105635