From e75e1f3231419126f48300b0da538b75a2f56bd7 Mon Sep 17 00:00:00 2001 From: bruvzg <7645683+bruvzg@users.noreply.github.com> Date: Fri, 10 Jun 2022 13:59:21 +0300 Subject: [PATCH] [macOS, 3.x] Fix unresponsive redraw during live resizing. --- platform/osx/os_osx.mm | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/platform/osx/os_osx.mm b/platform/osx/os_osx.mm index 4d3b7b5afb0..4bae3488402 100644 --- a/platform/osx/os_osx.mm +++ b/platform/osx/os_osx.mm @@ -471,6 +471,20 @@ static NSCursor *cursorFromSelector(SEL selector, SEL fallback = nil) { @implementation GodotContentView +- (void)drawRect:(NSRect)dirtyRect { + if (OS_OSX::singleton->get_main_loop() && OS_OSX::singleton->is_resizing) { + Main::force_redraw(); + if (!Main::is_iterating()) { // Avoid cyclic loop. + Main::iteration(); + } + } +} + +- (void)setFrameSize:(NSSize)newSize { + [super setFrameSize:newSize]; + [self setNeedsDisplay:YES]; // Force "drawRect" call. +} + + (void)initialize { if (self == [GodotContentView class]) { // nothing left to do here at the moment.. @@ -3356,10 +3370,10 @@ void OS_OSX::force_process_input() { } void OS_OSX::pre_wait_observer_cb(CFRunLoopObserverRef p_observer, CFRunLoopActivity p_activiy, void *p_context) { - // Prevent main loop from sleeping and redraw window during resize / modal popups. - // Do not redraw when rendering is done from the separate thread, it will conflict with the OpenGL context updates triggered by window view resize. + // Prevent main loop from sleeping and redraw window during modal popup display. + // Do not redraw when rendering is done from the separate thread, it will conflict with the OpenGL context updates. - if (get_singleton()->get_main_loop() && (get_singleton()->get_render_thread_mode() != RENDER_SEPARATE_THREAD || !OS_OSX::singleton->is_resizing)) { + if (get_singleton()->get_main_loop() && (get_singleton()->get_render_thread_mode() != RENDER_SEPARATE_THREAD) && !OS_OSX::singleton->is_resizing) { Main::force_redraw(); if (!Main::is_iterating()) { // Avoid cyclic loop. Main::iteration();