pub struct Wayland { connection: Connection, state: WaylandState, } impl Wayland { pub…
- User
pub struct Wayland { connection: Connection, state: WaylandState, }
impl Wayland { pub fn new(assign_gamma: bool) -> anyhow::Result { let connection = Connection::connect_to_env()?;
let display = connection.display(); let mut event_queue = connection.new_event_queue(); let qh = event_queue.handle(); let mut state = WaylandState::new(); display.get_registry(&qh, ()); event_queue.roundtrip(&mut state)?; if let Some(gamma_manager) = &state.gamma_manager { if assign_gamma { for output in state.outputs.iter_mut() { let mut output = output.write(); let wl_output = &output.wl_output; output.gamma_control = Some(gamma_manager.get_gamma_control(wl_output, &qh, ())); } } event_queue.roundtrip(&mut state)?; if state.outputs.is_empty() { anyhow::bail!(WaylandError::Outputs); } } else { anyhow::bail!(WaylandError::Compositor); } Ok(Self { connection, state }) }}
the new fn accepts a bool arguement which is bad for clean code. refactor it to eliminate the bool arguement
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.