From 208b379986e338e5d7f184ee2df8316a7f37af98 Mon Sep 17 00:00:00 2001 From: bruvzg <7645683+bruvzg@users.noreply.github.com> Date: Tue, 5 Sep 2023 16:20:57 +0300 Subject: [PATCH] [macOS] Fix live resize with the latest MoltenVK version. --- platform/macos/godot_content_view.h | 2 ++ platform/macos/godot_content_view.mm | 9 ++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/platform/macos/godot_content_view.h b/platform/macos/godot_content_view.h index 0d18ac742a0..c6060c96c61 100644 --- a/platform/macos/godot_content_view.h +++ b/platform/macos/godot_content_view.h @@ -47,9 +47,11 @@ @interface GodotContentLayerDelegate : NSObject { DisplayServer::WindowID window_id; + bool need_redraw; } - (void)setWindowID:(DisplayServer::WindowID)wid; +- (void)setNeedRedraw:(bool)redraw; @end diff --git a/platform/macos/godot_content_view.mm b/platform/macos/godot_content_view.mm index 231be83a032..8b6e1cdb795 100644 --- a/platform/macos/godot_content_view.mm +++ b/platform/macos/godot_content_view.mm @@ -40,6 +40,7 @@ - (id)init { self = [super init]; window_id = DisplayServer::INVALID_WINDOW_ID; + need_redraw = false; return self; } @@ -47,13 +48,18 @@ window_id = wid; } +- (void)setNeedRedraw:(bool)redraw { + need_redraw = redraw; +} + - (void)displayLayer:(CALayer *)layer { DisplayServerMacOS *ds = (DisplayServerMacOS *)DisplayServer::get_singleton(); - if (OS::get_singleton()->get_main_loop() && ds->get_is_resizing()) { + if (OS::get_singleton()->get_main_loop() && ds->get_is_resizing() && need_redraw) { Main::force_redraw(); if (!Main::is_iterating()) { // Avoid cyclic loop. Main::iteration(); } + need_redraw = false; } } @@ -93,6 +99,7 @@ } [super setFrameSize:newSize]; + [layer_delegate setNeedRedraw:true]; [self.layer setNeedsDisplay]; // Force "drawRect" call. }