New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix issue when window (on Mac) opens without focus #7949
Conversation
|
||
// Having the app in front of the terminal window is also generally | ||
// handy. There is an NSApplication API to do this, but... | ||
SetFrontProcess( &psn ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SetFrontProcess
- deprecated
// Eclipse does something similar: | ||
// https://bugs.eclipse.org/bugs/attachment.cgi?id=248969 | ||
[NSApp nextEventMatchingMask: NSAnyEventMask untilDate: nil | ||
inMode: NSDefaultRunLoopMode dequeue: NO ]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it seems like this hack doesn't work anymore. I moved part of it to didupdate
event
@@ -127,9 +127,17 @@ - (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sende | |||
return NSTerminateCancel; | |||
} | |||
|
|||
- (void)applicationDidFinishLaunching:(NSNotification *)notification | |||
{ | |||
[[NSRunningApplication currentApplication] activateWithOptions:(NSApplicationActivateAllWindows | NSApplicationActivateIgnoringOtherApps)]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this event never called
if( !_glfwLibrary.Unbundled ) { | ||
ProcessSerialNumber psn = { 0, kCurrentProcess }; | ||
TransformProcessType( &psn, kProcessTransformToForegroundApplication ); | ||
[[NSApplication sharedApplication] activateIgnoringOtherApps: YES]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Recommended function instead of SetFrontProcess()
even though it's deprecated as well 🤷♂️
// Wait for the first update to make window active | ||
// It helps to avoid issue when the window opens inactive | ||
// https://github.com/defold/defold/issues/6709 | ||
if( !_glfwLibrary.Unbundled ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just to make sure we call it once
@@ -810,7 +817,6 @@ int _glfwPlatformOpenWindow( int width, int height, | |||
} | |||
_glfwWin.aux_context = [[NSOpenGLContext alloc] initWithFormat:_glfwWin.pixelFormat shareContext:_glfwWin.context]; | |||
|
|||
[_glfwWin.window makeKeyAndOrderFront:nil]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there is no reason to call it twice
Fixed an issue when a window on Mac opens without focus. In such cases, the window doesn't react to most input events, and only double-click works.
Fix #6709
PR checklist