Browse Source

Merge pull request #23499 from bruvzg/fix_osx_app_crash_and_black_spash

[macOS] Fix .app bundle crash and blank initial window
Rémi Verschelde 6 năm trước cách đây
mục cha
commit
5d5227104e
1 tập tin đã thay đổi với 15 bổ sung5 xóa
  1. 15 5
      platform/osx/os_osx.mm

+ 15 - 5
platform/osx/os_osx.mm

@@ -328,14 +328,14 @@ static Vector2 get_mouse_pos(NSPoint locationInWindow, CGFloat backingScaleFacto
 	//_GodotPlatformSetCursorMode(window, window->cursorMode);
 	//_GodotPlatformSetCursorMode(window, window->cursorMode);
 	[OS_OSX::singleton->context update];
 	[OS_OSX::singleton->context update];
 
 
-	get_mouse_pos(
-			[OS_OSX::singleton->window_object mouseLocationOutsideOfEventStream],
-			[OS_OSX::singleton->window_view backingScaleFactor]);
-	if (OS_OSX::singleton->input)
+	if (OS_OSX::singleton->get_main_loop()) {
+		get_mouse_pos(
+				[OS_OSX::singleton->window_object mouseLocationOutsideOfEventStream],
+				[OS_OSX::singleton->window_view backingScaleFactor]);
 		OS_OSX::singleton->input->set_mouse_position(Point2(mouse_x, mouse_y));
 		OS_OSX::singleton->input->set_mouse_position(Point2(mouse_x, mouse_y));
 
 
-	if (OS_OSX::singleton->get_main_loop())
 		OS_OSX::singleton->get_main_loop()->notification(MainLoop::NOTIFICATION_WM_FOCUS_IN);
 		OS_OSX::singleton->get_main_loop()->notification(MainLoop::NOTIFICATION_WM_FOCUS_IN);
+	}
 }
 }
 
 
 - (void)windowDidResignKey:(NSNotification *)notification {
 - (void)windowDidResignKey:(NSNotification *)notification {
@@ -365,6 +365,8 @@ static Vector2 get_mouse_pos(NSPoint locationInWindow, CGFloat backingScaleFacto
 	bool imeMode;
 	bool imeMode;
 }
 }
 - (void)cancelComposition;
 - (void)cancelComposition;
+- (BOOL)wantsUpdateLayer;
+- (void)updateLayer;
 @end
 @end
 
 
 @implementation GodotContentView
 @implementation GodotContentView
@@ -375,6 +377,14 @@ static Vector2 get_mouse_pos(NSPoint locationInWindow, CGFloat backingScaleFacto
 	}
 	}
 }
 }
 
 
+- (BOOL)wantsUpdateLayer {
+	return YES;
+}
+
+- (void)updateLayer {
+	[OS_OSX::singleton->context update];
+}
+
 - (id)init {
 - (id)init {
 	self = [super init];
 	self = [super init];
 	trackingArea = nil;
 	trackingArea = nil;