Emit resize event any time size changes

Fixes bug where resize events only got triggered upon manual window
resizing OR if one called setSize with a height that was too large.
This commit is contained in:
Chris Thrasher 2023-04-27 16:53:54 -06:00
parent c2e065b9bc
commit 839ad6cf70

View File

@ -457,18 +457,9 @@
// Add titlebar height. // Add titlebar height.
height += static_cast<unsigned int>([self titlebarHeight]); height += static_cast<unsigned int>([self titlebarHeight]);
// Corner case: don't set the window height bigger than the screen height // Send resize event if size has changed
// or the view will be resized _later_ without generating a resize event. if (sf::Vector2u(width, height) != m_requester->getSize())
NSRect screenFrame = [[NSScreen mainScreen] visibleFrame]; m_requester->windowResized({width, height - static_cast<unsigned int>([self titlebarHeight])});
CGFloat maxVisibleHeight = screenFrame.size.height;
if (height > maxVisibleHeight)
{
height = static_cast<unsigned int>(maxVisibleHeight);
// The size is not the requested one, we fire an event
if (m_requester != nil)
m_requester->windowResized({width, height - static_cast<unsigned int>([self titlebarHeight])});
}
NSRect frame = NSMakeRect([m_window frame].origin.x, [m_window frame].origin.y, width, height); NSRect frame = NSMakeRect([m_window frame].origin.x, [m_window frame].origin.y, width, height);