From efe4354bc5ebc2c58bb86bd3780e80199ff75f5b Mon Sep 17 00:00:00 2001 From: Marco Antognini Date: Wed, 23 Apr 2014 13:14:42 +0200 Subject: [PATCH] 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. --- src/SFML/Window/OSX/SFWindowController.mm | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/SFML/Window/OSX/SFWindowController.mm b/src/SFML/Window/OSX/SFWindowController.mm index e045d087b..25e8ab13a 100644 --- a/src/SFML/Window/OSX/SFWindowController.mm +++ b/src/SFML/Window/OSX/SFWindowController.mm @@ -391,10 +391,25 @@ [m_window setStyleMask:styleMask ^ NSResizableWindowMask]; // 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, [m_window frame].origin.y, width, - height + [self titlebarHeight]); + height); [m_window setFrame:frame display:YES];