Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix macOS Window Resizing Bug #2538

Merged
merged 1 commit into from
Apr 30, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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