Skip to content

Commit

Permalink
x11: Support visuals with depth 32
Browse files Browse the repository at this point in the history
This can lead to weird results in some cases, but it's better than crashing.
Once we have a better format API we can work around this.

ref rust-windowing/winit#3646

Signed-off-by: John Nunley <[email protected]>
  • Loading branch information
notgull committed Jun 22, 2024
1 parent 532e172 commit 9bf96b9
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/backends/x11.rs
Original file line number Diff line number Diff line change
Expand Up @@ -882,13 +882,15 @@ fn is_shm_available(c: &impl Connection) -> bool {
/// Collect all visuals that use softbuffer's pixel format
fn supported_visuals(c: &impl Connection) -> HashSet<Visualid> {
// Check that depth 24 uses 32 bits per pixels
// HACK(notgull): Also support depth 32 for transparent visuals.
// Otherwise winit users get weird errors.
if !c
.setup()
.pixmap_formats
.iter()
.any(|f| f.depth == 24 && f.bits_per_pixel == 32)
.any(|f| (f.depth == 24 || f.depth == 32) && f.bits_per_pixel == 32)
{
log::warn!("X11 server does not have a depth 24 format with 32 bits per pixel");
log::warn!("X11 server does not have a depth 24/32 format with 32 bits per pixel");
return HashSet::new();
}

Expand All @@ -911,7 +913,7 @@ fn supported_visuals(c: &impl Connection) -> HashSet<Visualid> {
screen
.allowed_depths
.iter()
.filter(|depth| depth.depth == 24)
.filter(|depth| depth.depth == 24 || depth.depth == 32)
.flat_map(|depth| {
depth
.visuals
Expand Down

0 comments on commit 9bf96b9

Please sign in to comment.