Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

examples/drm: Don't force card{i} enumeration to start at 0 #245

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions examples/drm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,12 +168,14 @@ mod imple {
fn find() -> Result<Card, Box<dyn std::error::Error>> {
for i in 0..10 {
let path = format!("/dev/dri/card{i}");
let device = Card::open(path)?;
// Card enumeration may not start at zero, allow failures while opening
let Ok(device) = Card::open(path) else {
continue;
};

// Only use it if it has connectors.
let handles = match device.resource_handles() {
Ok(handles) => handles,
Err(_) => continue,
let Ok(handles) = device.resource_handles() else {
continue;
};

if handles
Expand Down
5 changes: 4 additions & 1 deletion src/backends/cg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,10 @@ impl<D, W> Drop for CGImpl<D, W> {

impl<D: HasDisplayHandle, W: HasWindowHandle> SurfaceInterface<D, W> for CGImpl<D, W> {
type Context = D;
type Buffer<'a> = BufferImpl<'a, D, W> where Self: 'a;
type Buffer<'a>
= BufferImpl<'a, D, W>
where
Self: 'a;

fn new(window_src: W, _display: &D) -> Result<Self, InitError<W>> {
// `NSView`/`UIView` can only be accessed from the main thread.
Expand Down
5 changes: 4 additions & 1 deletion src/backends/kms.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,10 @@ struct SharedBuffer {

impl<D: HasDisplayHandle + ?Sized, W: HasWindowHandle> SurfaceInterface<D, W> for KmsImpl<D, W> {
type Context = Arc<KmsDisplayImpl<D>>;
type Buffer<'a> = BufferImpl<'a, D, W> where Self: 'a;
type Buffer<'a>
= BufferImpl<'a, D, W>
where
Self: 'a;

/// Create a new KMS backend.
fn new(window: W, display: &Arc<KmsDisplayImpl<D>>) -> Result<Self, InitError<W>> {
Expand Down
5 changes: 4 additions & 1 deletion src/backends/orbital.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,10 @@ impl<D: HasDisplayHandle, W: HasWindowHandle> OrbitalImpl<D, W> {

impl<D: HasDisplayHandle, W: HasWindowHandle> SurfaceInterface<D, W> for OrbitalImpl<D, W> {
type Context = D;
type Buffer<'a> = BufferImpl<'a, D, W> where Self: 'a;
type Buffer<'a>
= BufferImpl<'a, D, W>
where
Self: 'a;

fn new(window: W, _display: &D) -> Result<Self, InitError<W>> {
let raw = window.window_handle()?.as_raw();
Expand Down
5 changes: 4 additions & 1 deletion src/backends/wayland/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,10 @@ impl<D: HasDisplayHandle + ?Sized, W: HasWindowHandle> SurfaceInterface<D, W>
for WaylandImpl<D, W>
{
type Context = Arc<WaylandDisplayImpl<D>>;
type Buffer<'a> = BufferImpl<'a, D, W> where Self: 'a;
type Buffer<'a>
= BufferImpl<'a, D, W>
where
Self: 'a;

fn new(window: W, display: &Arc<WaylandDisplayImpl<D>>) -> Result<Self, InitError<W>> {
// Get the raw Wayland window.
Expand Down
5 changes: 4 additions & 1 deletion src/backends/web.rs
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,10 @@

impl<D: HasDisplayHandle, W: HasWindowHandle> SurfaceInterface<D, W> for WebImpl<D, W> {
type Context = WebDisplayImpl<D>;
type Buffer<'a> = BufferImpl<'a, D, W> where Self: 'a;
type Buffer<'a>
= BufferImpl<'a, D, W>
where
Self: 'a;

fn new(window: W, display: &WebDisplayImpl<D>) -> Result<Self, InitError<W>> {
let raw = window.window_handle()?.as_raw();
Expand Down Expand Up @@ -374,7 +377,7 @@
imp: &'a mut WebImpl<D, W>,
}

impl<'a, D: HasDisplayHandle, W: HasWindowHandle> BufferInterface for BufferImpl<'a, D, W> {

Check failure on line 380 in src/backends/web.rs

View workflow job for this annotation

GitHub Actions / Tests (stable, wasm32-unknown-unknown, ubuntu-latest)

the following explicit lifetimes could be elided: 'a
fn pixels(&self) -> &[u32] {
&self.imp.buffer
}
Expand Down
5 changes: 4 additions & 1 deletion src/backends/win32.rs
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,10 @@

impl<D: HasDisplayHandle, W: HasWindowHandle> SurfaceInterface<D, W> for Win32Impl<D, W> {
type Context = D;
type Buffer<'a> = BufferImpl<'a, D, W> where Self: 'a;
type Buffer<'a>
= BufferImpl<'a, D, W>
where
Self: 'a;

/// Create a new `Win32Impl` from a `Win32WindowHandle`.
fn new(window: W, _display: &D) -> Result<Self, crate::error::InitError<W>> {
Expand Down Expand Up @@ -281,7 +284,7 @@

pub struct BufferImpl<'a, D, W>(&'a mut Win32Impl<D, W>);

impl<'a, D: HasDisplayHandle, W: HasWindowHandle> BufferInterface for BufferImpl<'a, D, W> {

Check failure on line 287 in src/backends/win32.rs

View workflow job for this annotation

GitHub Actions / Tests (stable, i686-pc-windows-msvc, windows-latest)

the following explicit lifetimes could be elided: 'a
#[inline]
fn pixels(&self) -> &[u32] {
self.0.buffer.as_ref().unwrap().pixels()
Expand Down
5 changes: 4 additions & 1 deletion src/backends/x11.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,10 @@ struct ShmBuffer {

impl<D: HasDisplayHandle + ?Sized, W: HasWindowHandle> SurfaceInterface<D, W> for X11Impl<D, W> {
type Context = Arc<X11DisplayImpl<D>>;
type Buffer<'a> = BufferImpl<'a, D, W> where Self: 'a;
type Buffer<'a>
= BufferImpl<'a, D, W>
where
Self: 'a;

/// Create a new `X11Impl` from a `HasWindowHandle`.
fn new(window_src: W, display: &Arc<X11DisplayImpl<D>>) -> Result<Self, InitError<W>> {
Expand Down
Loading