From cab7d4bfe5b1d18befad51012eda5e112ac93bb6 Mon Sep 17 00:00:00 2001 From: "Brian J. Tarricone" Date: Fri, 13 May 2022 19:56:19 -0700 Subject: [PATCH] Do xrandr version check on init --- locker/src/main.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/locker/src/main.rs b/locker/src/main.rs index 626d09a..36d35b3 100644 --- a/locker/src/main.rs +++ b/locker/src/main.rs @@ -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(),