Do xrandr version check on init

This commit is contained in:
Brian Tarricone 2022-05-13 19:56:19 -07:00
parent 64dc809295
commit cab7d4bfe5

View File

@ -309,7 +309,16 @@ fn init_xinput(conn: &xcb::Connection) -> xcb::Result<()> {
Ok(())
}
fn init_randr(conn: &xcb::Connection) -> xcb::Result<()> {
fn init_randr(conn: &xcb::Connection) -> anyhow::Result<()> {
let cookie = conn.send_request(&randr::QueryVersion {
major_version: 1,
minor_version: 2,
});
let reply = conn.wait_for_reply(cookie)?;
if reply.major_version() < 1 || (reply.major_version() == 1 && reply.minor_version() < 2) {
Err(anyhow::anyhow!("XRandR extension version 1.2 or greater is required, but the X server only supports {}.{}", reply.major_version(), reply.minor_version()))?;
}
for screen in conn.get_setup().roots() {
conn.send_and_check_request(&randr::SelectInput {
window: screen.root(),