Skip to content

Commit

Permalink
Fix zombie windows in Mac OS when switching to/from fullscreen
Browse files Browse the repository at this point in the history
  • Loading branch information
jqdg committed Aug 9, 2021
1 parent fb4241c commit 4fff470
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
12 changes: 12 additions & 0 deletions src/SFML/Window/OSX/SFWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,18 @@
////////////////////////////////////////////////////////////
-(BOOL)canBecomeKeyWindow;

////////////////////////////////////////////////////////////
/// \brief Allow fullscreen windows to become the main window
///
/// By default, fullscreen windows (using NSBorderlessWindowMask)
/// cannot become the main window, so this method is changed to
/// always return YES.
///
/// \return YES
///
////////////////////////////////////////////////////////////
-(BOOL)canBecomeMainWindow;

////////////////////////////////////////////////////////////
/// \brief Prevent system alert
///
Expand Down
7 changes: 7 additions & 0 deletions src/SFML/Window/OSX/SFWindow.m
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,13 @@ -(BOOL)canBecomeKeyWindow
}


////////////////////////////////////////////////////////
-(BOOL)canBecomeMainWindow
{
return YES;
}


////////////////////////////////////////////////////////
-(void)keyDown:(NSEvent*)theEvent
{
Expand Down
6 changes: 5 additions & 1 deletion src/SFML/Window/OSX/WindowImplCocoa.mm
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,11 @@ void showMouseCursor()
// Put the next window in front, if any.
NSArray* windows = [NSApp orderedWindows];
if ([windows count] > 0)
[[windows objectAtIndex:0] makeKeyAndOrderFront:nil];
{
NSWindow *nextWindow = [windows objectAtIndex:0];
if ([nextWindow isVisible])
[nextWindow makeKeyAndOrderFront:nil];
}

drainThreadPool(); // Make sure everything was freed
// This solve some issue when sf::Window::Create is called for the
Expand Down

0 comments on commit 4fff470

Please sign in to comment.