Skip to content

Commit

Permalink
Emit resize event any time size changes
Browse files Browse the repository at this point in the history
Fixes bug where resize events only got triggered upon manual window
resizing OR if one called setSize with a height that was too large.
  • Loading branch information
ChrisThrasher committed Apr 30, 2023
1 parent c2e065b commit 839ad6c
Showing 1 changed file with 3 additions and 12 deletions.
15 changes: 3 additions & 12 deletions src/SFML/Window/OSX/SFWindowController.mm
Original file line number Diff line number Diff line change
Expand Up @@ -457,18 +457,9 @@ - (void)resizeTo:(unsigned int)width by:(unsigned int)height
// Add titlebar height.
height += static_cast<unsigned int>([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 = 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])});
}
// Send resize event if size has changed
if (sf::Vector2u(width, height) != m_requester->getSize())
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);

Expand Down

0 comments on commit 839ad6c

Please sign in to comment.