From 683662edad2c781e8454242b8e0f093d019e2e8d Mon Sep 17 00:00:00 2001 From: kimci86 Date: Sat, 29 Jul 2023 20:08:11 +0200 Subject: [PATCH] Clamp window height on macOS --- src/SFML/Window/macOS/SFWindowController.mm | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/SFML/Window/macOS/SFWindowController.mm b/src/SFML/Window/macOS/SFWindowController.mm index ffb5e418..05e4ca43 100644 --- a/src/SFML/Window/macOS/SFWindowController.mm +++ b/src/SFML/Window/macOS/SFWindowController.mm @@ -457,8 +457,14 @@ // Add titlebar height. height += static_cast([self titlebarHeight]); - // Send resize event if size has changed - if (sf::Vector2u(width, height) != m_requester->getSize()) + // 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(maxVisibleHeight); + + if (m_requester != nil) m_requester->windowResized({width, height - static_cast([self titlebarHeight])}); NSRect frame = NSMakeRect([m_window frame].origin.x, [m_window frame].origin.y, width, height);