macOS: Improve event queuing (#3708)

* Use AppKit's internal queuing mechanisms

This allows events to be queued in a more consistent order, they're now
interleaved with events that we handle immediately (like redraw events),
instead of being handled afterwards.

* Only queue events if necessary

This makes the call stack / backtraces easier to understand whenever
possible, and generally improves upon the order in which events are
delivered.
This commit is contained in:
Mads Marquart 2024-06-06 12:32:02 +02:00 committed by GitHub
parent 0e74d37ff5
commit 279e3edc54
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 172 additions and 113 deletions

View file

@ -686,7 +686,7 @@ declare_class!(
self.update_modifiers(event, false);
self.queue_device_event(DeviceEvent::MouseWheel { delta });
self.ivars().app_delegate.maybe_queue_device_event(DeviceEvent::MouseWheel { delta });
self.queue_event(WindowEvent::MouseWheel {
device_id: DEVICE_ID,
delta,
@ -830,11 +830,7 @@ impl WinitView {
}
fn queue_event(&self, event: WindowEvent) {
self.ivars().app_delegate.queue_window_event(self.window().id(), event);
}
fn queue_device_event(&self, event: DeviceEvent) {
self.ivars().app_delegate.queue_device_event(event);
self.ivars().app_delegate.maybe_queue_window_event(self.window().id(), event);
}
fn scale_factor(&self) -> f64 {