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

Code before:
                Processor::handle_event(event, &mut processor);
            }

            // Process DisplayUpdate events
            if !display_update_pending.is_empty() {
                self.display.handle_update(
                    &mut terminal,
                    &mut self.notifier,
                    &self.message_buffer,
                    &self.config,
                    display_update_pending,
                );
            }

            #[cfg(not(any(target_os = "macos", windows)))]
            {
                if event_loop.is_wayland()
                    && !self.display.window.should_draw.load(Ordering::Relaxed)
                {
                    return;
                }
            }

            if terminal.dirty {
                terminal.dirty = false;

                // Request immediate re-draw if visual bell animation is not finished yet
                if !terminal.visual_bell.completed() {
                    self.event_queue.push(GlutinEvent::UserEvent(Event::Wakeup));
                }

                // Redraw screen
                self.display.draw(
                    terminal,
                    &self.message_buffer,
                    &self.config,
                    &self.mouse,
                    self.modifiers,
                );
            }
        });

        // Write ref tests to disk
        self.write_ref_test_results(&terminal.lock());
    }

    /// Handle events from glutin
    ///
    /// Doesn't take self mutably due to borrow checking.
    fn handle_event<T>(
        event: GlutinEvent<Event>,

Review comment (suggestion):
Maybe add a comment to this? Would probably be generous. Just something short and sweet to explain what we're doing here.

Suggestion:

```
// Skip rendering on Wayland if the next vblank hasn't been reached.
```

Alternatively if 'vblank' is too weird:

```
// Skip rendering on Wayland if the next frame hasn't been requested yet.
```

Maybe that's a little easier to understand, more accessible? I'll leave it up to you.

Code after:
            let mut processor = input::Processor::new(context, &self.display.highlighted_url);

            for event in self.event_queue.drain(..) {
                Processor::handle_event(event, &mut processor);
            }

            // Process DisplayUpdate events.
            if !display_update_pending.is_empty() {
                self.display.handle_update(
                    &mut terminal,
                    &mut self.notifier,
                    &self.message_buffer,
                    &self.config,
                    display_update_pending,
                );
            }

            #[cfg(not(any(target_os = "macos", windows)))]
            {
                // Skip rendering on Wayland until we get frame event from compositor.
                if event_loop.is_wayland()
                    && !self.display.window.should_draw.load(Ordering::Relaxed)
                {
                    return;
                }
            }

            if terminal.dirty {
                terminal.dirty = false;

                // Request immediate re-draw if visual bell animation is not finished yet.
                if !terminal.visual_bell.completed() {
                    self.event_queue.push(GlutinEvent::UserEvent(Event::Wakeup));
                }

                // Redraw screen.
                self.display.draw(
                    terminal,
                    &self.message_buffer,
                    &self.config,
                    &self.mouse,
                    self.modifiers,
                );
            }
        });

        // Write ref tests to disk
        self.write_ref_test_results(&terminal.lock());
    }

    /// Handle events from glutin