Skip to content

Commit

Permalink
more SDL fullscreen state tracking fixes, don't update fullscreen fla…
Browse files Browse the repository at this point in the history
…gs on failure to change fullscreen state
  • Loading branch information
slouken committed Nov 9, 2015
1 parent 792354d commit eeddb7c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/video/SDL_video.c
Expand Up @@ -1980,6 +1980,7 @@ SDL_RestoreWindow(SDL_Window * window)
int
SDL_SetWindowFullscreen(SDL_Window * window, Uint32 flags)
{
Uint32 oldflags;
CHECK_WINDOW_MAGIC(window, -1);

flags &= FULLSCREEN_MASK;
Expand All @@ -1989,10 +1990,17 @@ SDL_SetWindowFullscreen(SDL_Window * window, Uint32 flags)
}

/* clear the previous flags and OR in the new ones */
oldflags = window->flags & FULLSCREEN_MASK;
window->flags &= ~FULLSCREEN_MASK;
window->flags |= flags;

return SDL_UpdateFullscreenMode(window, FULLSCREEN_VISIBLE(window));
if (SDL_UpdateFullscreenMode(window, FULLSCREEN_VISIBLE(window)) == 0) {
return 0;
}

window->flags &= ~FULLSCREEN_MASK;
window->flags |= oldflags;
return -1;
}

static SDL_Surface *
Expand Down
4 changes: 4 additions & 0 deletions src/video/cocoa/SDL_cocoawindow.m
Expand Up @@ -646,6 +646,8 @@ - (void)windowDidFailToEnterFullScreen:(NSNotification *)aNotification

isFullscreenSpace = NO;
inFullscreenTransition = NO;

[self windowDidExitFullScreen:nil];
}

- (void)windowDidEnterFullScreen:(NSNotification *)aNotification
Expand Down Expand Up @@ -690,6 +692,8 @@ - (void)windowDidFailToExitFullScreen:(NSNotification *)aNotification

isFullscreenSpace = YES;
inFullscreenTransition = NO;

[self windowDidEnterFullScreen:nil];
}

- (void)windowDidExitFullScreen:(NSNotification *)aNotification
Expand Down

0 comments on commit eeddb7c

Please sign in to comment.