Skip to content

Commit

Permalink
linux: Fix panic missing screen mode for crtc specified mode ID (#9106)
Browse files Browse the repository at this point in the history
Fix panic caused by missing screen mode for specified crtc mode id #9105
by searching over all crtcs instead of using the first one which may be
invalid.
  • Loading branch information
VitorRamos authored Mar 11, 2024
1 parent 95b311c commit 3bd9d14
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions crates/gpui/src/platform/linux/x11/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -314,19 +314,19 @@ impl Client for X11Client {
.xcb_connection
.send_request(&xcb::randr::GetScreenResourcesCurrent { window: x_window });
let screen_resources = self.xcb_connection.wait_for_reply(cookie).expect("TODO");
let crtc = screen_resources.crtcs().first().expect("TODO");

let cookie = self.xcb_connection.send_request(&xcb::randr::GetCrtcInfo {
crtc: crtc.to_owned(),
config_timestamp: xcb::x::Time::CurrentTime as u32,
});
let crtc_info = self.xcb_connection.wait_for_reply(cookie).expect("TODO");

let mode_id = crtc_info.mode().resource_id();
let mode = screen_resources
.modes()
.crtcs()
.iter()
.find(|m| m.id == mode_id)
.find_map(|crtc| {
let cookie = self.xcb_connection.send_request(&xcb::randr::GetCrtcInfo {
crtc: crtc.to_owned(),
config_timestamp: xcb::x::Time::CurrentTime as u32,
});
let crtc_info = self.xcb_connection.wait_for_reply(cookie).expect("TODO");

let mode_id = crtc_info.mode().resource_id();
screen_resources.modes().iter().find(|m| m.id == mode_id)
})
.expect("Missing screen mode for crtc specified mode id");

let refresh_event_token = self
Expand Down

0 comments on commit 3bd9d14

Please sign in to comment.