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

Code before:
            WindowContext::initial(event_loop, proxy, self.config.clone(), options)?;

        self.gl_display = Some(window_context.display.gl_context().display());
        self.windows.insert(window_context.id(), window_context);

        Ok(())
    }

    /// 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 = self.windows.iter().next().as_ref().unwrap().1;

        #[allow(unused_mut)]
        let mut config = self.config.clone();

        #[cfg(target_os = "macos")]
        if options.window_tabbing_id.is_some() && config.window.startup_mode != Default::default() {
            let mut inner_config = config.as_ref().clone();
            inner_config.window.startup_mode = Default::default();
            config = Rc::new(inner_config);
        }

        #[allow(unused_mut)]
        let mut window_context = window.additional(event_loop, proxy, config, options)?;

        // Apply global IPC options.
        #[cfg(unix)]
        {
            let options = self.global_ipc_options.clone();
            let ipc_config = IpcConfig { options, window_id: None, reset: false };
            window_context.update_ipc_config(self.config.clone(), ipc_config);
        }

        self.windows.insert(window_context.id(), window_context);
        Ok(())
    }

    /// Run the event loop.
    ///
    /// The result is exit code generate from the loop.
    pub fn run(
        &mut self,
        event_loop: EventLoop<Event>,
        initial_window_options: WindowOptions,
    ) -> Result<(), Box<dyn Error>> {
        let proxy = event_loop.create_proxy();

Review comment (suggestion):
I don't actually think this is a viable option. It would create a separate config for every single tab on macOS for users with startup mode set, which is just unnecessary memory usage.

If it needs to be fixed right here, my best idea would be interior mutability. But there's a chance it might be easier to handle this separately in the location where the primary window is first loaded, but I'd have to look into this myself later.

Code after:
            WindowContext::initial(event_loop, proxy, self.config.clone(), options)?;

        self.gl_display = Some(window_context.display.gl_context().display());
        self.windows.insert(window_context.id(), window_context);

        Ok(())
    }

    /// 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 = self.windows.iter().next().as_ref().unwrap().1;

        #[allow(unused_mut)]
        let mut window_context =
            window.additional(event_loop, proxy, self.config.clone(), options)?;

        // Apply global IPC options.
        #[cfg(unix)]
        {
            let options = self.global_ipc_options.clone();
            let ipc_config = IpcConfig { options, window_id: None, reset: false };
            window_context.update_ipc_config(self.config.clone(), ipc_config);
        }

        self.windows.insert(window_context.id(), window_context);
        Ok(())
    }

    /// Run the event loop.
    ///
    /// The result is exit code generate from the loop.
    pub fn run(
        &mut self,
        event_loop: EventLoop<Event>,
        initial_window_options: WindowOptions,
    ) -> Result<(), Box<dyn Error>> {
        let proxy = event_loop.create_proxy();
        let mut scheduler = Scheduler::new(proxy.clone());
        let mut initial_window_options = Some(initial_window_options);

        // Disable all device events, since we don't care about them.
        event_loop.listen_device_events(DeviceEvents::Never);

        let mut initial_window_error = Ok(());
        let initial_window_error_loop = &mut initial_window_error;
        // SAFETY: Since this takes a pointer to the winit event loop, it MUST be dropped first,