Repository: alacritty/alacritty
File: alacritty/src/event.rs (Rust)

Code before:

impl<N: Notify + OnResize> Processor<N> {
    /// Create a new event processor
    ///
    /// Takes a writer which is expected to be hooked up to the write end of a
    /// pty.
    pub fn new(
        notifier: N,
        message_buffer: MessageBuffer,
        config: Config,
        display: Display,
    ) -> Processor<N> {
        Processor {
            notifier,
            mouse: Default::default(),
            received_count: 0,
            suppress_chars: false,
            modifiers: Default::default(),
            font_size: config.font.size,
            config,
            message_buffer,
            display,
        }
    }

    /// Dispatch wayland event queue
    ///
    /// Return `false` if queue is not presented or empty, `true` otherwise.
    #[inline]
    #[cfg(not(any(target_os = "macos", windows)))]
    pub fn dispatch_wayland_queue(&mut self) -> bool {
        if let Some(wayland_event_queue) = self.display.wayland_event_queue.as_mut() {
            let events_dispatched = wayland_event_queue
                .dispatch_pending(&mut (), |_, _, _| {})
                .expect("failed to dispatch event queue");
            // We've dispatched some events
            events_dispatched != 0
        } else {
            false
        }
    }

    /// Run the event loop.
    pub fn run<T>(&mut self, terminal: Arc<FairMutex<Term<T>>>, mut event_loop: EventLoop<Event>)
    where
        T: EventListener,
    {
        let mut event_queue = Vec::new();

        event_loop.run_return(|event, event_loop, control_flow| {
            if self.config.debug.print_events {

Review comment (suggestion):
```suggestion
    /// Dispatch wayland event queue.
```

Code after:
}

impl<N: Notify + OnResize> Processor<N> {
    /// Create a new event processor
    ///
    /// Takes a writer which is expected to be hooked up to the write end of a
    /// pty.
    pub fn new(
        notifier: N,
        message_buffer: MessageBuffer,
        config: Config,
        display: Display,
    ) -> Processor<N> {
        Processor {
            notifier,
            mouse: Default::default(),
            received_count: 0,
            suppress_chars: false,
            modifiers: Default::default(),
            font_size: config.font.size,
            config,
            message_buffer,
            display,
            event_queue: Vec::new(),
        }
    }

    /// Return `true` if `event_queue` is empty, `false` otherwise.
    #[inline]
    #[cfg(not(any(target_os = "macos", windows)))]
    fn event_queue_empty(&mut self) -> bool {
        let wayland_event_queue = match self.display.wayland_event_queue.as_mut() {
            Some(wayland_event_queue) => wayland_event_queue,
            // Since frame callbacks do not exist on X11, just check for event queue.
            None => return self.event_queue.is_empty(),
        };

        // Check for pending frame callbacks on Wayland.
        let events_dispatched = wayland_event_queue
            .dispatch_pending(&mut (), |_, _, _| {})
            .expect("failed to dispatch event queue");

        self.event_queue.is_empty() && events_dispatched == 0
    }

    /// Return `true` if `event_queue` is empty, `false` otherwise.
    #[inline]
    #[cfg(any(target_os = "macos", windows))]
    fn event_queue_empty(&mut self) -> bool {
        self.event_queue.is_empty()
    }