diff --git a/src/backend/egl/device.rs b/src/backend/egl/device.rs index bce5926..5f8b4e0 100644 --- a/src/backend/egl/device.rs +++ b/src/backend/egl/device.rs @@ -44,7 +44,8 @@ impl EGLDevice { // Passing 0 for max devices and a null-pointer for devices is safe because we indicate we only // want the number of devices. - if unsafe { ffi::egl::QueryDevicesEXT(0, ptr::null_mut(), amount.as_mut_ptr()) } == ffi::egl::FALSE + if unsafe { ffi::egl::QueryDevicesEXT(0, ptr::null_mut(), amount.as_mut_ptr()) } + == ffi::egl::FALSE { 0 } else { @@ -63,7 +64,8 @@ impl EGLDevice { // - Vector used as pointer is correct size. // - Device amount will accommodate all available devices because we have checked the size earlier. ffi::egl::QueryDevicesEXT(device_amount, devices.as_mut_ptr(), &mut device_amount) - }).map_err(Error::QueryDevices)?; + }) + .map_err(Error::QueryDevices)?; // Set the length of the vec so that rust does not think it is still empty. diff --git a/src/backend/x11/mod.rs b/src/backend/x11/mod.rs index 06e4a05..6e5671c 100644 --- a/src/backend/x11/mod.rs +++ b/src/backend/x11/mod.rs @@ -37,8 +37,8 @@ //! // Initialize EGL to retrieve the support modifier list //! let egl = EGLDisplay::new(&device, logger.clone()).expect("Failed to create EGLDisplay"); //! let context = EGLContext::new(&egl, logger).expect("Failed to create EGLContext"); -//! let modifiers = context.dmabuf_render_formats().iter().map(|format| format.modifier).collect::>(); -//! +//! let modifiers = context.dmabuf_render_formats().iter().map(|format| format.modifier).collect::>(); +//! //! // Finally create the X11 surface, you will use this to obtain buffers that will be presented to the //! // window. //! let surface = X11Surface::new(&mut backend, device, modifiers.into_iter()); @@ -325,13 +325,13 @@ impl X11Backend { // We cannot fallback on the egl_init method, because there is no way for us to authenticate a primary node. // dri3 does not work for closed-source drivers, but *may* give us a authenticated fd as a fallback. // As a result we try to use egl for a cleaner, better supported approach at first and only if that fails use dri3. - egl_init(&self).or_else(|err| { + egl_init(self).or_else(|err| { slog::warn!( &self.log, "Failed to init X11 surface via egl, falling back to dri3: {}", err ); - dri3_init(&self) + dri3_init(self) }) } } @@ -412,19 +412,17 @@ fn dri3_init(backend: &X11Backend) -> Result { .map_err(AllocateBuffersError::from)?; let drm_node = DrmNode::from_fd(drm_device_fd).map_err(Into::::into)?; - if drm_node.ty() != NodeType::Render { - if drm_node.has_render() { - // Try to get the render node. - if let Some(path) = drm_node.dev_path_with_type(NodeType::Render) { - return Ok(fcntl::open(&path, OFlag::O_RDWR | OFlag::O_CLOEXEC, Mode::empty()) - .map_err(Into::::into) - .map_err(CreateDrmNodeError::Io) - .and_then(DrmNode::from_fd) - .unwrap_or_else(|err| { - slog::warn!(&backend.log, "Could not create render node from existing DRM node ({}), falling back to primary node", err); - drm_node - })); - } + if drm_node.ty() != NodeType::Render && drm_node.has_render() { + // Try to get the render node. + if let Some(path) = drm_node.dev_path_with_type(NodeType::Render) { + return Ok(fcntl::open(&path, OFlag::O_RDWR | OFlag::O_CLOEXEC, Mode::empty()) + .map_err(Into::::into) + .map_err(CreateDrmNodeError::Io) + .and_then(DrmNode::from_fd) + .unwrap_or_else(|err| { + slog::warn!(&backend.log, "Could not create render node from existing DRM node ({}), falling back to primary node", err); + drm_node + })); } } @@ -598,7 +596,7 @@ impl Drop for Present<'_> { match surface.current.userdata().map(Option::unwrap) { Ok(dmabuf) => { - if let Ok(pixmap) = PixmapWrapper::with_dmabuf(&*connection, &surface.window, &dmabuf) { + if let Ok(pixmap) = PixmapWrapper::with_dmabuf(&*connection, &surface.window, dmabuf) { // Now present the current buffer let _ = pixmap.present(&*connection, &surface.window); }