mirror of
https://github.com/godotengine/godot.git
synced 2025-12-08 06:09:55 +00:00
Use system timer/wait functions for frame delay when screen reader is active.
This commit is contained in:
parent
1b37dacc18
commit
98f377d9d0
9 changed files with 70 additions and 13 deletions
|
|
@ -49,6 +49,28 @@
|
|||
#include <os/log.h>
|
||||
#include <sys/sysctl.h>
|
||||
|
||||
void OS_MacOS::add_frame_delay(bool p_can_draw, bool p_wake_for_events) {
|
||||
if (p_wake_for_events) {
|
||||
uint64_t delay = get_frame_delay(p_can_draw);
|
||||
if (delay == 0) {
|
||||
return;
|
||||
}
|
||||
if (wait_timer) {
|
||||
CFRunLoopTimerInvalidate(wait_timer);
|
||||
CFRelease(wait_timer);
|
||||
}
|
||||
wait_timer = CFRunLoopTimerCreateWithHandler(kCFAllocatorDefault, CFAbsoluteTimeGetCurrent() + (double(delay) / 1000000.0), 0, 0, 0,
|
||||
^(CFRunLoopTimerRef timer) {
|
||||
CFRunLoopTimerInvalidate(wait_timer);
|
||||
CFRelease(wait_timer);
|
||||
wait_timer = nil;
|
||||
});
|
||||
CFRunLoopAddTimer(CFRunLoopGetCurrent(), wait_timer, kCFRunLoopCommonModes);
|
||||
return;
|
||||
}
|
||||
OS_Unix::add_frame_delay(p_can_draw, p_wake_for_events);
|
||||
}
|
||||
|
||||
void OS_MacOS::initialize() {
|
||||
crash_handler.initialize();
|
||||
|
||||
|
|
@ -995,8 +1017,9 @@ void OS_MacOS_NSApp::start_main() {
|
|||
ERR_PRINT("NSException: " + String::utf8([exception reason].UTF8String));
|
||||
}
|
||||
}
|
||||
|
||||
CFRunLoopWakeUp(CFRunLoopGetCurrent()); // Prevent main loop from sleeping.
|
||||
if (wait_timer == nil) {
|
||||
CFRunLoopWakeUp(CFRunLoopGetCurrent()); // Prevent main loop from sleeping.
|
||||
}
|
||||
});
|
||||
CFRunLoopAddObserver(CFRunLoopGetCurrent(), pre_wait_observer, kCFRunLoopCommonModes);
|
||||
return;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue