Split Monitor detection/creation

This commit is contained in:
Brian Tarricone 2022-05-27 18:16:02 -07:00
parent e89b6cb604
commit 761b906fb7

View File

@ -48,9 +48,17 @@ impl Monitor {
crtc: output_info.crtc(), crtc: output_info.crtc(),
config_timestamp, config_timestamp,
}); });
let reply = conn.wait_for_reply(cookie)?; let crtc_info = conn.wait_for_reply(cookie)?;
monitors.push(Monitor::new(conn, &screen, *output, &crtc_info)?);
}
}
}
let (blanker_window, unlock_window) = create_windows(conn, &screen, &reply)?; Ok(monitors)
}
pub fn new(conn: &xcb::Connection, screen: &x::Screen, output: randr::Output, crtc_info: &randr::GetCrtcInfoReply) -> xcb::Result<Monitor> {
let (blanker_window, unlock_window) = create_windows(conn, &screen, &crtc_info)?;
let blank_cursor = create_blank_cursor(conn, &screen)?; let blank_cursor = create_blank_cursor(conn, &screen)?;
let black_gc: x::Gcontext = conn.generate_id(); let black_gc: x::Gcontext = conn.generate_id();
@ -63,29 +71,24 @@ impl Monitor {
], ],
})?; })?;
let backlight_control = find_backlight_control(conn, *output); let backlight_control = find_backlight_control(conn, output);
if let Err(err) = &backlight_control { if let Err(err) = &backlight_control {
warn!("Failed to find backlight control: {}", err); warn!("Failed to find backlight control: {}", err);
} }
monitors.push(Monitor { Ok(Monitor {
root: screen.root(), root: screen.root(),
black_gc, black_gc,
output: *output, output,
blanker_window, blanker_window,
unlock_window, unlock_window,
blank_cursor, blank_cursor,
x: reply.x(), x: crtc_info.x(),
y: reply.y(), y: crtc_info.y(),
width: reply.width(), width: crtc_info.width(),
height: reply.height(), height: crtc_info.height(),
backlight_control: backlight_control.ok().flatten(), backlight_control: backlight_control.ok().flatten(),
}); })
}
}
}
Ok(monitors)
} }
pub fn release(self, conn: &xcb::Connection) { pub fn release(self, conn: &xcb::Connection) {