Skip to content

Commit

Permalink
Merge topic 'bug2025'
Browse files Browse the repository at this point in the history
5234e0b Fixed bug #2025 by forcing NSApplicationActivationPolicyRegular

Acked-by: David Gobbi <david.gobbi@gmail.com>
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !909
  • Loading branch information
seanm authored and kwrobot committed Nov 20, 2015
2 parents 2592e61 + 5234e0b commit 7d4bccc
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
8 changes: 6 additions & 2 deletions Rendering/OpenGL/vtkCocoaRenderWindow.mm
Original file line number Diff line number Diff line change
Expand Up @@ -721,18 +721,22 @@ - (void)viewFrameDidChange:(NSNotification *)aNotification
//
// So here we call +sharedApplication which will create the NSApplication
// if it does not exist. If it does exist, this does nothing.
// We are not actually interested in the return value.
// This call is intentionally delayed until this CreateAWindow call
// to prevent Cocoa-window related stuff from happening in scenarios
// where vtkRenderWindows are created but never shown.
(void)[NSApplication sharedApplication];
NSApplication* app = [NSApplication sharedApplication];

// create an NSWindow only if neither an NSView nor an NSWindow have
// been specified already. This is the case for a 'pure vtk application'.
// If you are using vtk in a 'regular Mac application' you should call
// SetRootWindow() and SetWindowId() so that a window is not created here.
if (!this->GetRootWindow() && !this->GetWindowId() && !this->GetParentId())
{
// Ordinarily, only .app bundles get proper mouse and keyboard interaction,
// but here we change the 'activation policy' to behave as if we were a
// .app bundle (which we may or may not be).
(void)[app setActivationPolicy:NSApplicationActivationPolicyRegular];

NSWindow* theWindow = nil;

#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
Expand Down
8 changes: 6 additions & 2 deletions Rendering/OpenGL2/vtkCocoaRenderWindow.mm
Original file line number Diff line number Diff line change
Expand Up @@ -716,18 +716,22 @@ - (void)viewFrameDidChange:(NSNotification *)aNotification
//
// So here we call +sharedApplication which will create the NSApplication
// if it does not exist. If it does exist, this does nothing.
// We are not actually interested in the return value.
// This call is intentionally delayed until this CreateAWindow call
// to prevent Cocoa-window related stuff from happening in scenarios
// where vtkRenderWindows are created but never shown.
(void)[NSApplication sharedApplication];
NSApplication* app = [NSApplication sharedApplication];

// create an NSWindow only if neither an NSView nor an NSWindow have
// been specified already. This is the case for a 'pure vtk application'.
// If you are using vtk in a 'regular Mac application' you should call
// SetRootWindow() and SetWindowId() so that a window is not created here.
if (!this->GetRootWindow() && !this->GetWindowId() && !this->GetParentId())
{
// Ordinarily, only .app bundles get proper mouse and keyboard interaction,
// but here we change the 'activation policy' to behave as if we were a
// .app bundle (which we may or may not be).
(void)[app setActivationPolicy:NSApplicationActivationPolicyRegular];

NSWindow* theWindow = nil;

#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
Expand Down

0 comments on commit 7d4bccc

Please sign in to comment.