Improved resizing windows on OS X (close #474)

sf::Window::setSize will fire a resize event if the view could not be created at the requested size.
This commit is contained in:
Marco Antognini 2014-04-23 13:14:42 +02:00
parent 1ce8a42954
commit efe4354bc5

View File

@ -391,10 +391,25 @@
[m_window setStyleMask:styleMask ^ NSResizableWindowMask]; [m_window setStyleMask:styleMask ^ NSResizableWindowMask];
// Add titlebar height. // Add titlebar height.
height += [self titlebarHeight];
// Corner case: don't set the window height bigger than the screen height
// or the view will be resized _later_ without generating a resize event.
NSRect screenFrame = [[NSScreen mainScreen] visibleFrame];
CGFloat maxVisibleHeight = screenFrame.size.height;
if (height > maxVisibleHeight)
{
height = maxVisibleHeight;
// The size is not the requested one, we fire an event
if (m_requester != 0)
m_requester->windowResized(width, height - [self titlebarHeight]);
}
NSRect frame = NSMakeRect([m_window frame].origin.x, NSRect frame = NSMakeRect([m_window frame].origin.x,
[m_window frame].origin.y, [m_window frame].origin.y,
width, width,
height + [self titlebarHeight]); height);
[m_window setFrame:frame display:YES]; [m_window setFrame:frame display:YES];