Reimplement ui_application_cocoa_process_event

This commit is contained in:
Twinaphex 2020-09-14 16:50:26 +02:00
parent fb6642192d
commit a8beb91f0f

View File

@ -31,18 +31,22 @@ static void* ui_application_cocoa_initialize(void)
static void ui_application_cocoa_process_events(void)
{
SEL sel_nextEventMatchingMask_untilDate_inMode_dequeue =
sel_registerName("nextEventMatchingMask:untilDate:inMode:dequeue:");
Class class_NSDate = objc_getClass("NSDate");
SEL sel_distantPast = sel_registerName("distantPast");
SEL sel_sendEvent = sel_registerName("sendEvent:");
id distant_past = ((id (*)(Class, SEL))objc_msgSend)(class_NSDate, sel_distantPast);
for (;;)
{
NSEvent *event = [NSApp nextEventMatchingMask:NSEventMaskAny untilDate:[NSDate distantPast] inMode:NSDefaultRunLoopMode dequeue:YES];
if (!event)
id event = ((id (*)(id, SEL, NSUInteger, id, id, BOOL))objc_msgSend)(NSApp, sel_nextEventMatchingMask_untilDate_inMode_dequeue,
NSUIntegerMax,
distant_past,
NSDefaultRunLoopMode,
YES);
if (event == nil)
break;
#ifndef HAVE_COCOA_METAL
[event retain];
#endif
[NSApp sendEvent: event];
#ifndef HAVE_COCOA_METAL
[event retain];
#endif
((id (*)(id, SEL, id))objc_msgSend)(NSApp, sel_sendEvent, event);
}
}