2
0
Эх сурвалжийг харах

Fix set_window_size not setting the correct size on OSX

(cherry picked from commit 38de4d24efb51e70302fd08c819241db5ec545ad)
marcelofg55 9 жил өмнө
parent
commit
fd6f62fd9a
1 өөрчлөгдсөн 10 нэмэгдсэн , 0 устгасан
  1. 10 0
      platform/osx/os_osx.mm

+ 10 - 0
platform/osx/os_osx.mm

@@ -1494,9 +1494,19 @@ Size2 OS_OSX::get_window_size() const {
 
 };
 
+const int menuHeight = [[NSStatusBar systemStatusBar] thickness];
+
 void OS_OSX::set_window_size(const Size2 p_size) {
 
 	Size2 size=p_size;
+
+	// NSRect used by setFrame includes the title bar, so add it to our size.y
+	CGFloat menuBarHeight = [[[NSApplication sharedApplication] mainMenu] menuBarHeight];
+	if (menuBarHeight != 0.f) {
+		size.y+= menuBarHeight;
+	} else {
+		size.y+= menuHeight;
+	}
 	NSRect frame = [window_object frame];
 	[window_object setFrame:NSMakeRect(frame.origin.x, frame.origin.y, size.x, size.y) display:YES];
 };