From efaadb8882f6dd43842568bf20c585da8e44d6cc Mon Sep 17 00:00:00 2001 From: Drakulix Date: Sun, 7 Jan 2018 20:24:40 +0100 Subject: [PATCH] Fix a bunch of warnings --- src/backend/drm/backend.rs | 5 +-- src/backend/drm/mod.rs | 59 ++++++++++++++--------------- src/backend/graphics/egl/mod.rs | 2 - src/backend/graphics/egl/native.rs | 2 - src/backend/graphics/egl/wayland.rs | 2 +- src/backend/graphics/glium.rs | 5 +-- src/backend/udev.rs | 2 +- src/backend/winit.rs | 5 +-- 8 files changed, 36 insertions(+), 46 deletions(-) diff --git a/src/backend/drm/backend.rs b/src/backend/drm/backend.rs index 428efd2..f7e8e98 100644 --- a/src/backend/drm/backend.rs +++ b/src/backend/drm/backend.rs @@ -1,10 +1,10 @@ use super::error::*; use super::DevPath; use backend::graphics::GraphicsBackend; -use backend::graphics::egl::{EGLGraphicsBackend, EGLContext, EGLSurface, PixelFormat, SwapBuffersError, EglExtensionNotSupportedError}; +use backend::graphics::egl::{EGLGraphicsBackend, EGLContext, EGLSurface, PixelFormat, SwapBuffersError}; use backend::graphics::egl::error::Result as EGLResult; use backend::graphics::egl::native::{Gbm, GbmSurfaceArguments}; -use backend::graphics::egl::wayland::{EGLWaylandExtensions, EGLDisplay, BufferAccessError, EGLImages}; +use backend::graphics::egl::wayland::{EGLWaylandExtensions, EGLDisplay}; use drm::control::{Device, ResourceInfo}; use drm::control::{connector, crtc, encoder, framebuffer, Mode}; use gbm::{Device as GbmDevice, BufferObject, BufferObjectFlags, Format as GbmFormat, Surface as GbmSurface, SurfaceBufferHandle}; @@ -13,7 +13,6 @@ use nix::libc::c_void; use std::cell::Cell; use std::rc::{Rc, Weak}; use wayland_server::Display; -use wayland_server::protocol::wl_buffer::WlBuffer; pub struct DrmBackend { backend: Rc>, diff --git a/src/backend/drm/mod.rs b/src/backend/drm/mod.rs index e30bbe8..e29eaae 100644 --- a/src/backend/drm/mod.rs +++ b/src/backend/drm/mod.rs @@ -188,11 +188,10 @@ //! ``` #[cfg(feature = "backend_session")] -use backend::graphics::egl::EglExtensionNotSupportedError; -use backend::graphics::egl::context::{EGLContext, GlAttributes, PixelFormatRequirements}; +use backend::graphics::egl::context::{EGLContext, GlAttributes}; use backend::graphics::egl::error::Result as EGLResult; use backend::graphics::egl::native::Gbm; -use backend::graphics::egl::wayland::{EGLWaylandExtensions, EGLDisplay, BufferAccessError, EGLImages}; +use backend::graphics::egl::wayland::{EGLWaylandExtensions, EGLDisplay}; #[cfg(feature = "backend_session")] use backend::session::SessionObserver; use drm::Device as BasicDevice; @@ -215,7 +214,6 @@ use wayland_server::{EventLoopHandle, StateToken}; use wayland_server::sources::{FdEventSource, FdEventSourceImpl, FdInterest}; #[cfg(feature = "backend_session")] use wayland_server::{Display, StateProxy}; -use wayland_server::protocol::wl_buffer::WlBuffer; mod backend; pub mod error; @@ -569,34 +567,33 @@ impl SessionObserver for StateToken> { } fn activate<'a>(&mut self, state: &mut StateProxy<'a>) { - state.with_value(self, |state, device| { - device.active = true; - if let Err(err) = device.set_master() { - crit!( - device.logger, - "Failed to acquire drm master again. Error: {}", - err - ); - } - let mut crtcs = Vec::new(); - for (crtc, backend) in device.backends.iter() { - if let Some(backend) = backend.upgrade() { - backend.unlock_buffer(); - if let Err(err) = backend.page_flip(None) { - error!( - device.logger, - "Failed to activate crtc ({:?}) again. Error: {}", - crtc, - err - ); - } - } else { - crtcs.push(*crtc); + let mut device = state.get_mut(self); + device.active = true; + if let Err(err) = device.set_master() { + crit!( + device.logger, + "Failed to acquire drm master again. Error: {}", + err + ); + } + let mut crtcs = Vec::new(); + for (crtc, backend) in device.backends.iter() { + if let Some(backend) = backend.upgrade() { + backend.unlock_buffer(); + if let Err(err) = backend.page_flip(None) { + error!( + device.logger, + "Failed to activate crtc ({:?}) again. Error: {}", + crtc, + err + ); } + } else { + crtcs.push(*crtc); } - for crtc in crtcs { - device.backends.remove(&crtc); - } - }) + } + for crtc in crtcs { + device.backends.remove(&crtc); + } } } diff --git a/src/backend/graphics/egl/mod.rs b/src/backend/graphics/egl/mod.rs index 06718cc..c3f583c 100644 --- a/src/backend/graphics/egl/mod.rs +++ b/src/backend/graphics/egl/mod.rs @@ -8,8 +8,6 @@ use super::GraphicsBackend; use nix::libc::c_void; use std::fmt; -use wayland_server::Display; -use wayland_server::protocol::wl_buffer::WlBuffer; pub mod context; pub use self::context::EGLContext; diff --git a/src/backend/graphics/egl/native.rs b/src/backend/graphics/egl/native.rs index 801e48b..05848c3 100644 --- a/src/backend/graphics/egl/native.rs +++ b/src/backend/graphics/egl/native.rs @@ -16,8 +16,6 @@ use winit::Window as WinitWindow; #[cfg(feature = "backend_winit")] use winit::os::unix::WindowExt; #[cfg(feature = "backend_winit")] -use nix::libc::c_void; -#[cfg(feature = "backend_winit")] use wayland_client::egl as wegl; pub trait Backend { diff --git a/src/backend/graphics/egl/wayland.rs b/src/backend/graphics/egl/wayland.rs index 5c6ad10..81c0925 100644 --- a/src/backend/graphics/egl/wayland.rs +++ b/src/backend/graphics/egl/wayland.rs @@ -4,7 +4,7 @@ use backend::graphics::egl::ffi::egl::types::EGLImage; use nix::libc::{c_uint}; use std::rc::{Rc, Weak}; use std::fmt; -use wayland_server::{Display, Resource, StateToken, StateProxy}; +use wayland_server::{Display, Resource}; use wayland_server::protocol::wl_buffer::WlBuffer; use wayland_sys::server::wl_display; diff --git a/src/backend/graphics/glium.rs b/src/backend/graphics/glium.rs index bdeb526..d2a8081 100644 --- a/src/backend/graphics/glium.rs +++ b/src/backend/graphics/glium.rs @@ -1,7 +1,7 @@ //! Glium compatibility module -use backend::graphics::egl::{EGLGraphicsBackend, SwapBuffersError, EglExtensionNotSupportedError}; -use backend::graphics::egl::wayland::{BufferAccessError, EGLImages, EGLWaylandExtensions, EGLDisplay}; +use backend::graphics::egl::{EGLGraphicsBackend, SwapBuffersError}; +use backend::graphics::egl::wayland::{EGLWaylandExtensions, EGLDisplay}; use backend::graphics::egl::error::Result as EGLResult; use glium::Frame; use glium::SwapBuffersError as GliumSwapBuffersError; @@ -11,7 +11,6 @@ use std::borrow::Borrow; use std::os::raw::c_void; use std::rc::Rc; use wayland_server::Display; -use wayland_server::protocol::wl_buffer::WlBuffer; impl From for GliumSwapBuffersError { fn from(error: SwapBuffersError) -> Self { diff --git a/src/backend/udev.rs b/src/backend/udev.rs index 99d996a..a925b0f 100644 --- a/src/backend/udev.rs +++ b/src/backend/udev.rs @@ -14,7 +14,7 @@ use drm::control::Device as ControlDevice; use backend::drm::{drm_device_bind, DrmDevice, DrmHandler}; use backend::session::{Session, SessionObserver}; use nix::fcntl; -use nix::sys::stat::{dev_t, fstat}; +use nix::sys::stat::dev_t; use std::collections::HashMap; use std::ffi::OsString; use std::io::{Error as IoError, Result as IoResult}; diff --git a/src/backend/winit.rs b/src/backend/winit.rs index bf00189..bcc80be 100644 --- a/src/backend/winit.rs +++ b/src/backend/winit.rs @@ -1,12 +1,12 @@ //! Implementation of backend traits for types provided by `winit` use backend::graphics::GraphicsBackend; -use backend::graphics::egl::{EGLGraphicsBackend, EGLContext, EGLSurface, PixelFormat, SwapBuffersError, EglExtensionNotSupportedError}; +use backend::graphics::egl::{EGLGraphicsBackend, EGLContext, EGLSurface, PixelFormat, SwapBuffersError}; use backend::graphics::egl::error as egl_error; use backend::graphics::egl::error::Result as EGLResult; use backend::graphics::egl::native; use backend::graphics::egl::context::GlAttributes; -use backend::graphics::egl::wayland::{EGLWaylandExtensions, EGLImages, Format, BufferAccessError, EGLDisplay}; +use backend::graphics::egl::wayland::{EGLWaylandExtensions, EGLDisplay}; use backend::input::{Axis, AxisSource, Event as BackendEvent, InputBackend, InputHandler, KeyState, KeyboardKeyEvent, MouseButton, MouseButtonState, PointerAxisEvent, PointerButtonEvent, PointerMotionAbsoluteEvent, Seat, SeatCapabilities, TouchCancelEvent, TouchDownEvent, @@ -20,7 +20,6 @@ use winit::{ElementState, Event, EventsLoop, KeyboardInput, MouseButton as Winit MouseScrollDelta, Touch, TouchPhase, WindowBuilder, WindowEvent, Window as WinitWindow}; use wayland_client::egl as wegl; use wayland_server::Display; -use wayland_server::protocol::wl_buffer::WlBuffer; error_chain! { errors {