mirror of
https://github.com/SFML/SFML.git
synced 2024-11-25 12:51:05 +08:00
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:
parent
1ce8a42954
commit
efe4354bc5
@ -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];
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user