mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 07:30:19 +00:00
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:
parent
1b859bac64
commit
478ceb71ec
Notes:
sideshowbarker
2024-07-17 04:32:07 +09:00
Author: https://github.com/trflynn89 Commit: https://github.com/SerenityOS/serenity/commit/478ceb71ec Pull-request: https://github.com/SerenityOS/serenity/pull/24151 Reviewed-by: https://github.com/ADKaster ✅
2 changed files with 11 additions and 5 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue