Improves fullscreen support on OS X by adding proper display mode … switching. #301

Closed
wants to merge 5 commits into
from

Conversation

Projects
None yet
2 participants
Contributor

ryanfields commented Oct 9, 2012

The existing fullscreen implementation simply opens a window to the size
of the desktop (while creating a context of the requested mode size).
This change tests the requested fullscreen mode for validity and, if the
mode is a valid hardware mode, switches the main display to the
requested mode. The original mode is retained so that when the window
is deallocated, the desktop can be restored to the user's normal display
mode.

This could be further improved by offering the option to fullscreen onto
another display, but that requires multi-display support higher up in
SFML as a prerequisite.

RELOCATION OF RESPONSIBILITY
This change introduces a DisplayImpl object that takes on responsibility of managing a specific display. Video mode lists are acquired via a DisplayImpl instance instead of from a static method in VideoModeImpl. This affords the DisplayImpl the chance to map native mode references to SFML video mode objects, making it simple to perform a proper mode switch on OS X.

IMPORTANT
The one caveat to this change is that Xcode 4 requires a setting change in the sfml-window target in order to avoid a link error. Changing the "Symbols Hidden by Default" build setting to "Yes" resolves the link error. I'm having trouble determining whether Cmake is able to set this during project creation. If not, then I might have to do some extra wrapping around DisplayImpl to keep it's usage of std::vector<VideoMode> from clashing with usage elsewhere. (I haven't quite figured out why it's doing that in the first place...)

This is the solution I referenced in LaurentGomila/SFML#300

ryanfields added some commits Oct 8, 2012

@ryanfields ryanfields Improves fullscreen support on OS X by adding proper display mode
switching.

The existing fullscreen implementation simply opens a window to the size
of the desktop (while creating a context of the requested mode size).
This change tests the requested fullscreen mode for validity and, if the
mode is a valid hardware mode, switches the main display to the
requested mode.  The original mode is retained so that when the window
is deallocated, the desktop can be restored to the user's normal display
mode.

This could be further improved by offering the option to fullscreen onto
another display, but that requires multi-display support higher up in
SFML as a prerequisite.
8b99119
@ryanfields ryanfields Removes code duplication leftover from previous commit.
Video mode listing has become a responsibility of the DisplayImpl
object, which makes sense because the display itself is the source of
the video mode list.
429bace
@ryanfields ryanfields Switches video mode back to desktop resolution when a fullscreen
application window loses focus.

As a consequence of performing a true mode switch on fullscreen window
creation, the desktop will no longer be at the user's normal operating
resolution while the SFML application is running.  This change resolves
that issue by performing a mode switch back to the original mode
whenever the application window loses key focus.
9854ab9
@ryanfields ryanfields Removes unneeded method declarations that were added by mistake when
working on the previous change.
b40adf2
@ryanfields ryanfields Adds DisplayImpl to the Xcode project in CMake.
This feature branch added a couple files that need to be part of the
Xcode project or it fails to link.
3af5958

mantognini closed this Jan 23, 2013

mantognini was assigned Jan 25, 2013

mantognini removed this from the 2.0 milestone Apr 13, 2014

mantognini was unassigned by ryanfields Apr 30, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment