From 44a00859bf34be3f1ee60392d8b34235a4ad1402 Mon Sep 17 00:00:00 2001 From: Christian Duerr Date: Tue, 23 Apr 2024 16:34:37 +0200 Subject: [PATCH] Restrict event_loop to macOS --- alacritty/src/event.rs | 24 ++++++++++++++++++++++-- alacritty/src/window_context.rs | 3 +++ 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/alacritty/src/event.rs b/alacritty/src/event.rs index df139482aa..5276776a90 100644 --- a/alacritty/src/event.rs +++ b/alacritty/src/event.rs @@ -217,6 +217,8 @@ pub struct ActionContext<'a, N, T> { pub message_buffer: &'a mut MessageBuffer, pub config: &'a UiConfig, pub cursor_blink_timed_out: &'a mut bool, + #[cfg(target_os = "macos")] + pub event_loop: &'a EventLoopWindowTarget, pub event_proxy: &'a EventLoopProxy, pub scheduler: &'a mut Scheduler, pub search_state: &'a mut SearchState, @@ -1690,7 +1692,14 @@ impl Processor { None => return, }; - window_context.handle_event(&proxy, &mut clipboard, &mut scheduler, event); + window_context.handle_event( + #[cfg(target_os = "macos")] + event_loop, + &proxy, + &mut clipboard, + &mut scheduler, + event, + ); window_context.draw(&mut scheduler); }, @@ -1699,6 +1708,8 @@ impl Processor { // Dispatch event to all windows. for window_context in self.windows.values_mut() { window_context.handle_event( + #[cfg(target_os = "macos")] + event_loop, &proxy, &mut clipboard, &mut scheduler, @@ -1784,6 +1795,8 @@ impl Processor { WinitEvent::UserEvent(event @ Event { window_id: None, .. }) => { for window_context in self.windows.values_mut() { window_context.handle_event( + #[cfg(target_os = "macos")] + event_loop, &proxy, &mut clipboard, &mut scheduler, @@ -1795,7 +1808,14 @@ impl Processor { WinitEvent::WindowEvent { window_id, .. } | WinitEvent::UserEvent(Event { window_id: Some(window_id), .. }) => { if let Some(window_context) = self.windows.get_mut(&window_id) { - window_context.handle_event(&proxy, &mut clipboard, &mut scheduler, event); + window_context.handle_event( + #[cfg(target_os = "macos")] + event_loop, + &proxy, + &mut clipboard, + &mut scheduler, + event, + ); } }, _ => (), diff --git a/alacritty/src/window_context.rs b/alacritty/src/window_context.rs index 0af8afec67..f0f24fe841 100644 --- a/alacritty/src/window_context.rs +++ b/alacritty/src/window_context.rs @@ -399,6 +399,7 @@ impl WindowContext { /// Process events for this terminal window. pub fn handle_event( &mut self, + #[cfg(target_os = "macos")] event_loop: &EventLoopWindowTarget, event_proxy: &EventLoopProxy, clipboard: &mut Clipboard, scheduler: &mut Scheduler, @@ -444,6 +445,8 @@ impl WindowContext { preserve_title: self.preserve_title, config: &self.config, event_proxy, + #[cfg(target_os = "macos")] + event_loop, clipboard, scheduler, };