fix: make sure that we return to the same display mode that was set in windowed mode when toggling between fullscreen and windowed mode

This commit is contained in:
Brian Matzon 2007-08-15 20:14:29 +00:00
parent e76fd53950
commit e809c1f7f0
1 changed files with 6 additions and 0 deletions

View File

@ -82,6 +82,9 @@ public final class Display {
/** Cached window icons, for when Display is recreated */ /** Cached window icons, for when Display is recreated */
private static ByteBuffer[] cached_icons; private static ByteBuffer[] cached_icons;
/** Display mode used prior to entering fullscreen */
private static DisplayMode windowed_display_mode;
/** /**
* Y coordinate of the window. Y in window coordinates is from the top of the display down, * Y coordinate of the window. Y in window coordinates is from the top of the display down,
@ -298,6 +301,7 @@ public final class Display {
private static void switchDisplayMode() throws LWJGLException { private static void switchDisplayMode() throws LWJGLException {
if (!current_mode.isFullscreen()) { if (!current_mode.isFullscreen()) {
LWJGLUtil.log("Switching to "+initial_mode); LWJGLUtil.log("Switching to "+initial_mode);
windowed_display_mode = current_mode;
setDisplayMode(initial_mode); setDisplayMode(initial_mode);
} }
display_impl.switchDisplayMode(current_mode); display_impl.switchDisplayMode(current_mode);
@ -473,6 +477,7 @@ public final class Display {
switchDisplayMode(); switchDisplayMode();
} else { } else {
display_impl.resetDisplayMode(); display_impl.resetDisplayMode();
current_mode = windowed_display_mode;
} }
createWindow(); createWindow();
makeCurrentAndSetSwapInterval(); makeCurrentAndSetSwapInterval();
@ -844,6 +849,7 @@ public final class Display {
destroyPeerInfo(); destroyPeerInfo();
x = y = -1; x = y = -1;
cached_icons = null; cached_icons = null;
windowed_display_mode = null;
reset(); reset();
removeShutdownHook(); removeShutdownHook();
} }