Repository: alacritty/alacritty
File: alacritty/src/display/mod.rs (Rust)

Code before:
    fn request_frame(&mut self, scheduler: &mut Scheduler) {
        // Mark that we've used a frame.
        self.window.has_frame.store(false, Ordering::Relaxed);

        #[cfg(all(feature = "wayland", not(any(target_os = "macos", windows))))]
        if let Some(surface) = self.window.wayland_surface() {
            let has_frame = self.window.has_frame.clone();
            // Request a new frame.
            surface.frame().quick_assign(move |_, _, _| {
                has_frame.store(true, Ordering::Relaxed);
            });

            return;
        }

        // Get the display vblank interval in micro seconds.
        let monitor_vblank_interval = Duration::from_micros(
            (1e6 / (self
                .window
                .current_monitor()
                .and_then(|monitor| monitor.refresh_rate_millihertz())
                .unwrap_or(60_000) as f64
                / 1e3)) as u64,
        );

        let swap_delay = self.frame_timer_info.compute_delay(monitor_vblank_interval);

        let window_id = self.window.id();
        let timer_id = TimerId::new(Topic::Frame, window_id);
        let event = Event::new(EventType::Frame, window_id);

        scheduler.schedule(event, swap_delay, false, timer_id);
    }
}

impl Drop for Display {
    fn drop(&mut self) {
        // Switch OpenGL context before dropping, otherwise objects (like programs) from other
        // contexts might be deleted during droping renderer.
        self.make_current();
        unsafe {
            ManuallyDrop::drop(&mut self.renderer);
            ManuallyDrop::drop(&mut self.context);
            ManuallyDrop::drop(&mut self.surface);
        }
    }
}

/// Input method state.
#[derive(Debug, Default)]
pub struct Ime {

Review comment (suggestion):
Not sure `delay` is the right word here? Maybe `timeout` is more appropriate? Though I don't love it either.

Code after:
            let y = self.size_info.height() - damage_rect.y as f32 - height;
            let render_rect = RenderRect::new(x, y, width, height, DAMAGE_RECT_COLOR, 0.5);

            render_rects.push(render_rect);
        }
    }

    /// Requst a new frame for a window on Wayland.
    fn request_frame(&mut self, scheduler: &mut Scheduler) {
        // Mark that we've used a frame.
        self.window.has_frame.store(false, Ordering::Relaxed);

        #[cfg(all(feature = "wayland", not(any(target_os = "macos", windows))))]
        if let Some(surface) = self.window.wayland_surface() {
            let has_frame = self.window.has_frame.clone();
            // Request a new frame.
            surface.frame().quick_assign(move |_, _, _| {
                has_frame.store(true, Ordering::Relaxed);
            });

            return;
        }

        // Get the display vblank interval.
        let monitor_vblank_interval = 1_000_000.
            / self
                .window
                .current_monitor()
                .and_then(|monitor| monitor.refresh_rate_millihertz())
                .unwrap_or(60_000) as f64;

        // Now convert it to micro seconds.
        let monitor_vblank_interval =
            Duration::from_micros((1000. * monitor_vblank_interval) as u64);

        let swap_timeout = self.frame_timer.compute_timeout(monitor_vblank_interval);

        let window_id = self.window.id();
        let timer_id = TimerId::new(Topic::Frame, window_id);
        let event = Event::new(EventType::Frame, window_id);

        scheduler.schedule(event, swap_timeout, false, timer_id);
    }
}

impl Drop for Display {
    fn drop(&mut self) {
        // Switch OpenGL context before dropping, otherwise objects (like programs) from other
        // contexts might be deleted during droping renderer.
        self.make_current();
        unsafe {