Ladybird/AppKit: Ensure LibCore events are processed

When we receive a LibCore event, we post an "application defined" Cocoa
event to the NSApp. However, we are currently only processing these from
`pump`, which is only invoked manually.

Instead, we should listen for the event that we've posted and process
the event queue at that time. This is much closer to how Qt's event loop
behaves as well with EventLoopImplementationQtEventTarget.
This commit is contained in:
Timothy Flynn 2024-04-28 10:48:29 -04:00 committed by Andrew Kaster
parent 1b859bac64
commit 478ceb71ec
Notes: sideshowbarker 2024-07-17 04:32:07 +09:00
2 changed files with 11 additions and 5 deletions

View file

@ -7,6 +7,7 @@
#include <AK/ByteString.h>
#include <Application/ApplicationBridge.h>
#include <LibCore/EventLoop.h>
#include <LibCore/ThreadEventQueue.h>
#include <LibWebView/WebContentClient.h>
#import <Application/Application.h>
@ -62,4 +63,13 @@
Core::EventLoop::current().quit(0);
}
- (void)sendEvent:(NSEvent*)event
{
if ([event type] == NSEventTypeApplicationDefined) {
Core::ThreadEventQueue::current().process();
} else {
[super sendEvent:event];
}
}
@end

View file

@ -177,11 +177,7 @@ size_t CFEventLoopImplementation::pump(PumpMode mode)
dequeue:YES];
while (event) {
if (event.type == NSEventTypeApplicationDefined) {
m_thread_event_queue.process();
} else {
[NSApp sendEvent:event];
}
[NSApp sendEvent:event];
event = [NSApp nextEventMatchingMask:NSEventMaskAny
untilDate:nil