Simplify the event loop code

Also reduce input latency by ignoring repaint_delay when
there is actual pending input.

Gets rid of request_tick_callback(). Now empty events
result in the tick callback being called so there is only a
single mechanism for waking up the main loop and getting
the tick callback called.
This commit is contained in:
Kovid Goyal
2019-07-18 14:25:11 +05:30
parent 5521d6b623
commit 1cb15dedac
17 changed files with 95 additions and 82 deletions

View File

@@ -579,7 +579,7 @@ static GLFWapplicationshouldhandlereopenfun handle_reopen_callback = NULL;
[NSApp stop:nil];
CGDisplayRegisterReconfigurationCallback(display_reconfigured, NULL);
_glfwPlatformPostEmptyEvent();
_glfwCocoaPostEmptyEvent();
}
- (void)applicationWillTerminate:(NSNotification *)aNotification
@@ -1916,29 +1916,6 @@ _glfwDispatchRenderFrame(CGDirectDisplayID displayID) {
}
}
void _glfwCocoaPostEmptyEvent(short subtype, long data1, bool at_start)
{
@autoreleasepool {
NSEvent* event = [NSEvent otherEventWithType:NSEventTypeApplicationDefined
location:NSMakePoint(0, 0)
modifierFlags:0
timestamp:0
windowNumber:0
context:nil
subtype:subtype
data1:data1
data2:0];
[NSApp postEvent:event atStart:at_start ? YES : NO];
} // autoreleasepool
}
void _glfwPlatformPostEmptyEvent(void)
{
_glfwCocoaPostEmptyEvent(0, 0, true);
}
void _glfwPlatformGetCursorPos(_GLFWwindow* window, double* xpos, double* ypos)
{
const NSRect contentRect = [window->ns.view frame];
@@ -2381,3 +2358,16 @@ float _glfwTransformYNS(float y)
{
return CGDisplayBounds(CGMainDisplayID()).size.height - y - 1;
}
void _glfwCocoaPostEmptyEvent(void) {
NSEvent* event = [NSEvent otherEventWithType:NSEventTypeApplicationDefined
location:NSMakePoint(0, 0)
modifierFlags:0
timestamp:0
windowNumber:0
context:nil
subtype:0
data1:0
data2:0];
[NSApp postEvent:event atStart:YES];
}