Skip to content

Instantly share code, notes, and snippets.

@mantognini
Last active August 29, 2015 14:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mantognini/1e3cc79ace4cfa93bd85 to your computer and use it in GitHub Desktop.
Save mantognini/1e3cc79ace4cfa93bd85 to your computer and use it in GitHub Desktop.
Fix OS X request focus
diff --git a/src/SFML/Window/OSX/SFViewController.mm b/src/SFML/Window/OSX/SFViewController.mm
index 56c1b89..ee7f7eb 100644
--- a/src/SFML/Window/OSX/SFViewController.mm
+++ b/src/SFML/Window/OSX/SFViewController.mm
@@ -192,6 +192,9 @@
// The user has to make sure events are forwarded to the view
// with the usual responder chain.
[[m_view window] makeKeyAndOrderFront:nil];
+
+ // In case the app is not active, make it's dock icon bounce for one sec
+ [NSApp requestUserAttention:NSInformationalRequest];
}
diff --git a/src/SFML/Window/OSX/SFWindowController.mm b/src/SFML/Window/OSX/SFWindowController.mm
index 3b8f4b2..a28282b 100644
--- a/src/SFML/Window/OSX/SFWindowController.mm
+++ b/src/SFML/Window/OSX/SFWindowController.mm
@@ -453,6 +453,9 @@
-(void)requestFocus
{
[m_window makeKeyAndOrderFront:nil];
+
+ // In case the app is not active, make it's dock icon bounce for one sec
+ [NSApp requestUserAttention:NSInformationalRequest];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment