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

Code before:
use alacritty_terminal::tty;

use crate::clipboard::Clipboard;
use crate::config::window::WindowIdentityConfig;
use crate::config::UiConfig;
use crate::display::Display;
use crate::event::{ActionContext, Event, EventProxy, EventType, Mouse, SearchState};
use crate::input;
use crate::message_bar::MessageBuffer;
use crate::scheduler::Scheduler;

/// Event context for one individual Alacritty window.
pub struct WindowContext {
    pub message_buffer: MessageBuffer,
    pub display: Display,
    event_queue: Vec<GlutinEvent<'static, Event>>,
    terminal: Arc<FairMutex<Term<EventProxy>>>,
    modifiers: ModifiersState,
    search_state: SearchState,
    received_count: usize,
    suppress_chars: bool,
    notifier: Notifier,
    font_size: Size,
    mouse: Mouse,
    dirty: bool,
    /// Initial information to identify the window such as default class and title.
    identity: WindowIdentityConfig,
    #[cfg(not(windows))]
    master_fd: RawFd,
    #[cfg(not(windows))]
    shell_pid: u32,
}

impl WindowContext {
    /// Create a new terminal window context.
    pub fn new(
        config: &UiConfig,
        pty_config: &PtyConfig,
        identity: &WindowIdentityConfig,
        window_event_loop: &EventLoopWindowTarget<Event>,
        proxy: EventLoopProxy<Event>,
        #[cfg(all(feature = "wayland", not(any(target_os = "macos", windows))))]
        wayland_event_queue: Option<&EventQueue>,
    ) -> Result<Self, Box<dyn Error>> {
        // Create a display.
        //
        // The display manages a window and can draw the terminal.
        let display = Display::new(
            config,
            window_event_loop,
            identity,

Review comment (suggestion):
```suggestion
```

None of the other fields are documented, so I think it's odd to explicitly document this one. Especially because it's not particularly difficult to understand.

I have to say though `WindowContext` is getting **big**, I guess that's to be expected though since it holds everything important for a window. Maybe breaking it down in the future into separate structs might make sense, but don't think that's what we should do now.

Code after:

use crate::cli::WindowOptions;
use crate::clipboard::Clipboard;
use crate::config::UiConfig;
use crate::display::Display;
use crate::event::{ActionContext, Event, EventProxy, EventType, Mouse, SearchState};
use crate::input;
use crate::message_bar::MessageBuffer;
use crate::scheduler::Scheduler;

/// Event context for one individual Alacritty window.
pub struct WindowContext {
    pub message_buffer: MessageBuffer,
    pub display: Display,
    event_queue: Vec<GlutinEvent<'static, Event>>,
    terminal: Arc<FairMutex<Term<EventProxy>>>,
    modifiers: ModifiersState,
    search_state: SearchState,
    received_count: usize,
    suppress_chars: bool,
    notifier: Notifier,
    font_size: Size,
    mouse: Mouse,
    dirty: bool,
    preserve_title: bool,
    #[cfg(not(windows))]
    master_fd: RawFd,
    #[cfg(not(windows))]
    shell_pid: u32,
}

impl WindowContext {
    /// Create a new terminal window context.
    pub fn new(
        config: &UiConfig,
        options: &WindowOptions,
        window_event_loop: &EventLoopWindowTarget<Event>,
        proxy: EventLoopProxy<Event>,
        #[cfg(all(feature = "wayland", not(any(target_os = "macos", windows))))]
        wayland_event_queue: Option<&EventQueue>,
    ) -> Result<Self, Box<dyn Error>> {
        let mut pty_config = config.terminal_config.pty_config.clone();
        options.terminal_options.override_pty_config(&mut pty_config);

        let mut identity = config.window.identity.clone();
        let preserve_title = options.window_identity.title.is_some();
        options.window_identity.override_identity_config(&mut identity);

        // Create a display.
        //
        // The display manages a window and can draw the terminal.