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

Code before:
        #[cfg(all(feature = "wayland", not(any(target_os = "macos", windows))))]
        let wayland_event_queue = _event_loop.wayland_display().map(|display| {
            let display = unsafe { WaylandDisplay::from_external_display(display as _) };
            display.create_event_queue()
        });

        Processor {
            windows: HashMap::new(),
            cli_options,
            config,
            #[cfg(all(feature = "wayland", not(any(target_os = "macos", windows))))]
            wayland_event_queue,
        }
    }

    /// Create a new terminal window.
    pub fn create_window(
        &mut self,
        event_loop: &EventLoopWindowTarget<Event>,
        proxy: EventLoopProxy<Event>,
        options: NewWindowOptions,
    ) -> Result<(), Box<dyn Error>> {
        let mut pty_config = self.config.terminal_config.pty_config.clone();
        let mut window_identity = self.config.window.identity.clone();
        options.terminal_options.override_pty_config(&mut pty_config);
        options.window_options.override_identity_config(&mut window_identity);

        let window_context = WindowContext::new(
            &self.config,
            &pty_config,
            &window_identity,
            event_loop,
            proxy,
            #[cfg(all(feature = "wayland", not(any(target_os = "macos", windows))))]
            self.wayland_event_queue.as_ref(),
        )?;
        self.windows.insert(window_context.id(), window_context);
        Ok(())
    }

    /// Run the event loop.
    pub fn run(&mut self, mut event_loop: EventLoop<Event>) {
        let proxy = event_loop.create_proxy();
        let mut scheduler = Scheduler::new(proxy.clone());

        // NOTE: Since this takes a pointer to the winit event loop, it MUST be dropped first.
        #[cfg(all(feature = "wayland", not(any(target_os = "macos", windows))))]
        let mut clipboard = unsafe { Clipboard::new(event_loop.wayland_display()) };
        #[cfg(any(not(feature = "wayland"), target_os = "macos", windows))]
        let mut clipboard = Clipboard::new();


Review comment (suggestion):
I'd swap these around so `options.terminal_options.override_pty_config(&mut pty_config);` is above `let mut window_identity = ...`.

The way it currently is I first thought what we're modifying would be `options`, since those are the things grouped together. But what we actually want to do here is modify `pty_config`/`window_identity` so the `options` is kinda just what we use to do so. So I wouldn't use that to group things.

Code after:
            let display = unsafe { WaylandDisplay::from_external_display(display as _) };
            display.create_event_queue()
        });

        Processor {
            windows: HashMap::new(),
            cli_options,
            config,
            #[cfg(all(feature = "wayland", not(any(target_os = "macos", windows))))]
            wayland_event_queue,
        }
    }

    /// Create a new terminal window.
    pub fn create_window(
        &mut self,
        event_loop: &EventLoopWindowTarget<Event>,
        proxy: EventLoopProxy<Event>,
        options: WindowOptions,
    ) -> Result<(), Box<dyn Error>> {
        let window_context = WindowContext::new(
            &self.config,
            &options,
            event_loop,
            proxy,
            #[cfg(all(feature = "wayland", not(any(target_os = "macos", windows))))]
            self.wayland_event_queue.as_ref(),
        )?;
        self.windows.insert(window_context.id(), window_context);
        Ok(())
    }

    /// Run the event loop.
    pub fn run(&mut self, mut event_loop: EventLoop<Event>) {
        let proxy = event_loop.create_proxy();
        let mut scheduler = Scheduler::new(proxy.clone());

        // NOTE: Since this takes a pointer to the winit event loop, it MUST be dropped first.
        #[cfg(all(feature = "wayland", not(any(target_os = "macos", windows))))]
        let mut clipboard = unsafe { Clipboard::new(event_loop.wayland_display()) };
        #[cfg(any(not(feature = "wayland"), target_os = "macos", windows))]
        let mut clipboard = Clipboard::new();

        event_loop.run_return(|event, event_loop, control_flow| {
            if self.config.debug.print_events {
                info!("glutin event: {:?}", event);
            }

            // Ignore all events we do not care about.
            if Self::skip_event(&event) {
                return;