Merge pull request #54757 from bruvzg/pre_wait_observer_redraw3
This commit is contained in:
commit
bfcf6162fe
2 changed files with 22 additions and 13 deletions
|
@ -175,6 +175,8 @@ public:
|
|||
|
||||
void _update_global_menu();
|
||||
|
||||
static void pre_wait_observer_cb(CFRunLoopObserverRef p_observer, CFRunLoopActivity p_activiy, void *p_context);
|
||||
|
||||
protected:
|
||||
virtual void initialize_core();
|
||||
virtual Error initialize(const VideoMode &p_desired, int p_video_driver, int p_audio_driver);
|
||||
|
|
|
@ -389,14 +389,6 @@ static NSCursor *cursorFromSelector(SEL selector, SEL fallback = nil) {
|
|||
CGLEnable((CGLContextObj)[OS_OSX::singleton->context CGLContextObj], kCGLCESurfaceBackingSize);
|
||||
}
|
||||
|
||||
if (OS_OSX::singleton->main_loop) {
|
||||
Main::force_redraw();
|
||||
//Event retrieval blocks until resize is over. Call Main::iteration() directly.
|
||||
if (!Main::is_iterating()) { //avoid cyclic loop
|
||||
Main::iteration();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
_GodotInputFramebufferSize(window, fbRect.size.width, fbRect.size.height);
|
||||
_GodotInputWindowSize(window, contentRect.size.width, contentRect.size.height);
|
||||
|
@ -3295,11 +3287,25 @@ void OS_OSX::force_process_input() {
|
|||
joypad_osx->process_joypads();
|
||||
}
|
||||
|
||||
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.
|
||||
|
||||
if (get_singleton()->get_main_loop()) {
|
||||
Main::force_redraw();
|
||||
if (!Main::is_iterating()) { // Avoid cyclic loop.
|
||||
Main::iteration();
|
||||
}
|
||||
}
|
||||
|
||||
CFRunLoopWakeUp(CFRunLoopGetCurrent()); // Prevent main loop from sleeping.
|
||||
}
|
||||
|
||||
void OS_OSX::run() {
|
||||
force_quit = false;
|
||||
|
||||
if (!main_loop)
|
||||
if (!main_loop) {
|
||||
return;
|
||||
}
|
||||
|
||||
main_loop->init();
|
||||
|
||||
|
@ -3308,10 +3314,8 @@ void OS_OSX::run() {
|
|||
set_window_fullscreen(true);
|
||||
}
|
||||
|
||||
//uint64_t last_ticks=get_ticks_usec();
|
||||
|
||||
//int frames=0;
|
||||
//uint64_t frame=0;
|
||||
CFRunLoopObserverRef pre_wait_observer = CFRunLoopObserverCreate(kCFAllocatorDefault, kCFRunLoopBeforeWaiting, true, 0, &pre_wait_observer_cb, nullptr);
|
||||
CFRunLoopAddObserver(CFRunLoopGetCurrent(), pre_wait_observer, kCFRunLoopCommonModes);
|
||||
|
||||
bool quit = false;
|
||||
|
||||
|
@ -3328,6 +3332,9 @@ void OS_OSX::run() {
|
|||
}
|
||||
};
|
||||
|
||||
CFRunLoopRemoveObserver(CFRunLoopGetCurrent(), pre_wait_observer, kCFRunLoopCommonModes);
|
||||
CFRelease(pre_wait_observer);
|
||||
|
||||
main_loop->finish();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue