Commit 25d16026 authored by George Zagaris's avatar George Zagaris
Browse files

Merge remote-tracking branch 'origin/master' into AMR-Refactoring

parents 11cce57d a6edd1ab
......@@ -69,15 +69,19 @@ public:
virtual void Initialize();
// Description:
// Change the window to fill the entire screen.
// Change the window to fill the entire screen. This is only partially
// implemented for the vtkCocoaRenderWindow. It can only be called
// before the window has been created, and it might not work on all
// versions of OS X.
virtual void SetFullScreen(int);
// Description:
// Remap the window.
// Remap the window. This is not implemented for the vtkCocoaRenderWindow.
virtual void WindowRemap();
// Description:
// Set the preferred window size to full screen.
// Set the preferred window size to full screen. This is not implemented
// for the vtkCocoaRenderWindow.
virtual void PrefFullScreen();
// Description:
......
......@@ -27,6 +27,20 @@ PURPOSE. See the above copyright notice for more information.
vtkStandardNewMacro(vtkCocoaRenderWindow);
//----------------------------------------------------------------------------
// For fullscreen, an NSWindow that captures key events even when borderless
@interface vtkCocoaFullScreenWindow : NSWindow
{
}
- (BOOL)canBecomeKeyWindow;
@end
@implementation vtkCocoaFullScreenWindow
- (BOOL)canBecomeKeyWindow
{
return YES;
}
@end
//----------------------------------------------------------------------------
vtkCocoaRenderWindow::vtkCocoaRenderWindow()
......@@ -518,7 +532,11 @@ void vtkCocoaRenderWindow::CreateAWindow()
// Get the screen's scale factor.
// It will be used to create the window if not created yet.
#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1040
this->ScaleFactor = [[NSScreen mainScreen] userSpaceScaleFactor];
NSScreen *screen = [NSScreen mainScreen];
if (screen)
{
this->ScaleFactor = [screen userSpaceScaleFactor];
}
#endif
// As vtk is both crossplatform and a library, we don't know if it is being
......@@ -543,31 +561,56 @@ void vtkCocoaRenderWindow::CreateAWindow()
// SetRootWindow() and SetWindowId() so that a window is not created here.
if (!this->GetRootWindow() && !this->GetWindowId() && !this->GetParentId())
{
if ((this->Size[0]+this->Size[1]) == 0)
NSWindow* theWindow = NULL;
#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
if (this->FullScreen && screen)
{
this->Size[0] = 300;
this->Size[1] = 300;
NSRect ctRect = [screen frame];
this->Size[0] = (int)round(NSWidth(ctRect) * this->ScaleFactor);
this->Size[1] = (int)round(NSHeight(ctRect) * this->ScaleFactor);
theWindow = [[[vtkCocoaFullScreenWindow alloc]
initWithContentRect:ctRect
styleMask:NSBorderlessWindowMask
backing:NSBackingStoreBuffered
defer:NO] autorelease];
// This will hide the menu and the dock
[theWindow setLevel:NSMainMenuWindowLevel+1];
// This will show the menu and the dock
//[theWindow setLevel:NSFloatingWindowLevel];
}
if ((this->Position[0]+this->Position[1]) == 0)
else
#endif
{
this->Position[0] = 50;
this->Position[1] = 50;
if ((this->Size[0]+this->Size[1]) == 0)
{
this->Size[0] = 300;
this->Size[1] = 300;
}
if ((this->Position[0]+this->Position[1]) == 0)
{
this->Position[0] = 50;
this->Position[1] = 50;
}
// VTK measures in pixels, but NSWindow/NSView measure in points
NSRect ctRect = NSMakeRect((CGFloat)this->Position[0],
(CGFloat)this->Position[1],
(CGFloat)this->Size[0] / this->ScaleFactor,
(CGFloat)this->Size[1] / this->ScaleFactor);
theWindow = [[[NSWindow alloc]
initWithContentRect:ctRect
styleMask:NSTitledWindowMask |
NSClosableWindowMask |
NSMiniaturizableWindowMask |
NSResizableWindowMask
backing:NSBackingStoreBuffered
defer:NO] autorelease];
}
// VTK measures in pixels, but NSWindow/NSView measure in points; convert.
NSRect ctRect = NSMakeRect((CGFloat)this->Position[0],
(CGFloat)this->Position[1],
(CGFloat)this->Size[0] / this->ScaleFactor,
(CGFloat)this->Size[1] / this->ScaleFactor);
NSWindow* theWindow = [[[NSWindow alloc]
initWithContentRect:ctRect
styleMask:NSTitledWindowMask |
NSClosableWindowMask |
NSMiniaturizableWindowMask |
NSResizableWindowMask
backing:NSBackingStoreBuffered
defer:NO] autorelease];
if (!theWindow)
{
vtkErrorMacro("Could not create window, serious error!");
......@@ -579,7 +622,7 @@ void vtkCocoaRenderWindow::CreateAWindow()
[theWindow makeKeyAndOrderFront:nil];
[theWindow setAcceptsMouseMovedEvents:YES];
}
}
// Always use the scaling factor from the window once it is created.
// The screen and the window might possibly have different scaling factors, though unlikely.
......@@ -878,7 +921,7 @@ void vtkCocoaRenderWindow::SetFullScreen(int arg)
if (!this->Mapped)
{
this->PrefFullScreen();
this->FullScreen = arg;
return;
}
......@@ -935,7 +978,7 @@ void vtkCocoaRenderWindow::SetStereoCapableWindow(int capable)
void vtkCocoaRenderWindow::PrefFullScreen()
{
int *size = this->GetScreenSize();
vtkWarningMacro(<< "Can't get full screen window of size "
vtkWarningMacro(<< "Can only set FullScreen before showing window: "
<< size[0] << 'x' << size[1] << ".");
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment