From 71bd64a6bf8abb260f0d42abeb1a0f32f59f044c Mon Sep 17 00:00:00 2001 From: Victor Brekenfeld Date: Sat, 15 Dec 2018 21:32:28 +0100 Subject: [PATCH 1/3] Fix source code for 2018 edition --- Cargo.toml | 1 + anvil/Cargo.toml | 1 + anvil/src/glium_drawer.rs | 8 ++++---- anvil/src/input_handler.rs | 2 +- anvil/src/shaders.rs | 12 ++++++------ anvil/src/shell.rs | 4 ++-- anvil/src/shm_load.rs | 8 ++++---- anvil/src/udev.rs | 6 +++--- anvil/src/winit.rs | 6 +++--- src/backend/drm/egl/error.rs | 2 +- src/backend/drm/egl/mod.rs | 12 ++++++------ src/backend/drm/egl/session.rs | 6 +++--- src/backend/drm/egl/surface.rs | 12 ++++++------ src/backend/drm/gbm/egl.rs | 10 +++++----- src/backend/drm/gbm/error.rs | 2 +- src/backend/drm/gbm/mod.rs | 2 +- src/backend/drm/gbm/session.rs | 4 ++-- src/backend/drm/gbm/surface.rs | 6 +++--- src/backend/drm/legacy/error.rs | 2 +- src/backend/drm/legacy/mod.rs | 2 +- src/backend/drm/legacy/session.rs | 2 +- src/backend/drm/legacy/surface.rs | 6 +++--- src/backend/egl/context.rs | 4 ++-- src/backend/egl/mod.rs | 2 +- src/backend/egl/native.rs | 2 +- src/backend/egl/surface.rs | 2 +- src/backend/graphics/glium.rs | 2 +- src/backend/libinput.rs | 8 ++++---- src/backend/session/auto.rs | 4 ++-- src/backend/session/dbus/logind.rs | 4 ++-- src/backend/session/direct.rs | 2 +- src/backend/udev.rs | 2 +- src/backend/winit.rs | 6 +++--- src/wayland/compositor/mod.rs | 4 ++-- src/wayland/data_device/dnd_grab.rs | 2 +- src/wayland/data_device/mod.rs | 4 ++-- src/wayland/data_device/server_dnd_grab.rs | 2 +- src/wayland/output/mod.rs | 2 +- src/wayland/seat/keyboard.rs | 2 +- src/wayland/seat/mod.rs | 4 ++-- src/wayland/seat/pointer.rs | 2 +- src/wayland/shell/legacy/mod.rs | 4 ++-- src/wayland/shell/legacy/wl_handlers.rs | 2 +- src/wayland/shell/xdg/mod.rs | 6 +++--- src/wayland/shell/xdg/xdg_handlers.rs | 4 ++-- src/wayland/shell/xdg/zxdgv6_handlers.rs | 4 ++-- src/wayland/shm/mod.rs | 2 +- src/xwayland/xserver.rs | 2 +- 48 files changed, 101 insertions(+), 99 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 433ede9..e8392ef 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,6 +5,7 @@ authors = ["Victor Berger ", "Drakulix (Victor Brekenfeld license = "MIT" description = "Smithay is a library for writing wayland compositors." repository = "https://github.com/Smithay/smithay" +edition = "2018" [workspace] members = [ "anvil" ] diff --git a/anvil/Cargo.toml b/anvil/Cargo.toml index 90565a4..fb02964 100644 --- a/anvil/Cargo.toml +++ b/anvil/Cargo.toml @@ -4,6 +4,7 @@ version = "0.0.1" authors = ["Victor Berger ", "Drakulix (Victor Brekenfeld)"] license = "MIT" publish = false +edition = "2018" [dependencies] slog = { version = "2.1.1" } diff --git a/anvil/src/glium_drawer.rs b/anvil/src/glium_drawer.rs index bb42aa3..4a6ce9f 100644 --- a/anvil/src/glium_drawer.rs +++ b/anvil/src/glium_drawer.rs @@ -30,8 +30,8 @@ use smithay::{ }, }; -use shaders; -use shell::{MyCompositorToken, MyWindowMap}; +use crate::shaders; +use crate::shell::{MyCompositorToken, MyWindowMap}; #[derive(Copy, Clone)] struct Vertex { @@ -181,7 +181,7 @@ impl GliumDrawer { } Ok(TextureMetadata { texture: opengl_texture, - fragment: ::shaders::BUFFER_RGBA, + fragment: crate::shaders::BUFFER_RGBA, y_inverted: images.y_inverted, dimensions: (images.width, images.height), images: Some(images), // I guess we need to keep this alive ? @@ -205,7 +205,7 @@ impl GliumDrawer { fn texture_from_shm_buffer(&self, buffer: Resource) -> Result { match shm_buffer_contents(&buffer, |slice, data| { - ::shm_load::load_shm_buffer(data, slice) + crate::shm_load::load_shm_buffer(data, slice) .map(|(image, kind)| (Texture2d::new(&self.display, image).unwrap(), kind, data)) }) { Ok(Ok((texture, kind, data))) => Ok(TextureMetadata { diff --git a/anvil/src/input_handler.rs b/anvil/src/input_handler.rs index cdb397f..baf66d7 100644 --- a/anvil/src/input_handler.rs +++ b/anvil/src/input_handler.rs @@ -24,7 +24,7 @@ use smithay::{ wayland_server::protocol::wl_pointer, }; -use shell::MyWindowMap; +use crate::shell::MyWindowMap; pub struct AnvilInputHandler { log: Logger, diff --git a/anvil/src/shaders.rs b/anvil/src/shaders.rs index 67685e1..3e6e4c2 100644 --- a/anvil/src/shaders.rs +++ b/anvil/src/shaders.rs @@ -12,7 +12,7 @@ macro_rules! make_program( ($display: expr, $fragment_shader:expr) => { program!($display, 100 => { - vertex: ::shaders::VERTEX_SHADER, + vertex: crate::shaders::VERTEX_SHADER, fragment: $fragment_shader, }, ).unwrap() @@ -23,11 +23,11 @@ macro_rules! make_program( macro_rules! opengl_programs( ($display: expr) => { [ - make_program!($display, ::shaders::FRAGMENT_SHADER_RGBA), - make_program!($display, ::shaders::FRAGMENT_SHADER_ABGR), - make_program!($display, ::shaders::FRAGMENT_SHADER_XBGR), - make_program!($display, ::shaders::FRAGMENT_SHADER_BGRA), - make_program!($display, ::shaders::FRAGMENT_SHADER_BGRX), + make_program!($display, crate::shaders::FRAGMENT_SHADER_RGBA), + make_program!($display, crate::shaders::FRAGMENT_SHADER_ABGR), + make_program!($display, crate::shaders::FRAGMENT_SHADER_XBGR), + make_program!($display, crate::shaders::FRAGMENT_SHADER_BGRA), + make_program!($display, crate::shaders::FRAGMENT_SHADER_BGRX), ] } ); diff --git a/anvil/src/shell.rs b/anvil/src/shell.rs index 3ec7c5f..c0b8d27 100644 --- a/anvil/src/shell.rs +++ b/anvil/src/shell.rs @@ -27,7 +27,7 @@ use smithay::{ }, }; -use window_map::{Kind as SurfaceKind, WindowMap}; +use crate::window_map::{Kind as SurfaceKind, WindowMap}; define_roles!(Roles => [ XdgSurface, XdgSurfaceRole ] @@ -132,7 +132,7 @@ pub fn init_shell( #[derive(Default)] pub struct SurfaceData { pub buffer: Option>, - pub texture: Option<::glium_drawer::TextureMetadata>, + pub texture: Option, } fn surface_commit(surface: &Resource, token: CompositorToken) { diff --git a/anvil/src/shm_load.rs b/anvil/src/shm_load.rs index 7bdf403..fdb2483 100644 --- a/anvil/src/shm_load.rs +++ b/anvil/src/shm_load.rs @@ -33,10 +33,10 @@ pub fn load_shm_buffer(data: BufferData, pool: &[u8]) -> Result<(RawImage2d, // sharders format need to be reversed to account for endianness let (client_format, fragment) = match data.format { - Format::Argb8888 => (ClientFormat::U8U8U8U8, ::shaders::BUFFER_BGRA), - Format::Xrgb8888 => (ClientFormat::U8U8U8U8, ::shaders::BUFFER_BGRX), - Format::Rgba8888 => (ClientFormat::U8U8U8U8, ::shaders::BUFFER_ABGR), - Format::Rgbx8888 => (ClientFormat::U8U8U8U8, ::shaders::BUFFER_XBGR), + Format::Argb8888 => (ClientFormat::U8U8U8U8, crate::shaders::BUFFER_BGRA), + Format::Xrgb8888 => (ClientFormat::U8U8U8U8, crate::shaders::BUFFER_BGRX), + Format::Rgba8888 => (ClientFormat::U8U8U8U8, crate::shaders::BUFFER_ABGR), + Format::Rgbx8888 => (ClientFormat::U8U8U8U8, crate::shaders::BUFFER_XBGR), _ => return Err(data.format), }; Ok(( diff --git a/anvil/src/udev.rs b/anvil/src/udev.rs index 4224baa..c7ea8b0 100644 --- a/anvil/src/udev.rs +++ b/anvil/src/udev.rs @@ -61,9 +61,9 @@ use smithay::{ }, }; -use glium_drawer::GliumDrawer; -use input_handler::AnvilInputHandler; -use shell::{init_shell, MyWindowMap, Roles, SurfaceData}; +use crate::glium_drawer::GliumDrawer; +use crate::input_handler::AnvilInputHandler; +use crate::shell::{init_shell, MyWindowMap, Roles, SurfaceData}; pub struct SessionFd(RawFd); impl AsRawFd for SessionFd { diff --git a/anvil/src/winit.rs b/anvil/src/winit.rs index 6d9e511..6da43b4 100644 --- a/anvil/src/winit.rs +++ b/anvil/src/winit.rs @@ -17,9 +17,9 @@ use smithay::{ use slog::Logger; -use glium_drawer::GliumDrawer; -use input_handler::AnvilInputHandler; -use shell::init_shell; +use crate::glium_drawer::GliumDrawer; +use crate::input_handler::AnvilInputHandler; +use crate::shell::init_shell; pub fn run_winit(display: &mut Display, event_loop: &mut EventLoop<()>, log: Logger) -> Result<(), ()> { let (renderer, mut input) = winit::init(log.clone()).map_err(|_| ())?; diff --git a/src/backend/drm/egl/error.rs b/src/backend/drm/egl/error.rs index f55ccff..66fd2d1 100644 --- a/src/backend/drm/egl/error.rs +++ b/src/backend/drm/egl/error.rs @@ -3,7 +3,7 @@ //! and [`EglSurface`](::backend::drm::egl::EglSurface). //! -use backend::egl::error as egl; +use crate::backend::egl::error as egl; error_chain! { errors { diff --git a/src/backend/drm/egl/mod.rs b/src/backend/drm/egl/mod.rs index fec2968..cc962da 100644 --- a/src/backend/drm/egl/mod.rs +++ b/src/backend/drm/egl/mod.rs @@ -15,12 +15,12 @@ use std::rc::Rc; use wayland_server::Display; use super::{Device, DeviceHandler, Surface}; -use backend::egl::context::GlAttributes; -use backend::egl::error::Result as EGLResult; -use backend::egl::native::{Backend, NativeDisplay, NativeSurface}; -use backend::egl::EGLContext; +use crate::backend::egl::context::GlAttributes; +use crate::backend::egl::error::Result as EGLResult; +use crate::backend::egl::native::{Backend, NativeDisplay, NativeSurface}; +use crate::backend::egl::EGLContext; #[cfg(feature = "native_lib")] -use backend::egl::{EGLDisplay, EGLGraphicsBackend}; +use crate::backend::egl::{EGLDisplay, EGLGraphicsBackend}; pub mod error; use self::error::*; @@ -87,7 +87,7 @@ where where L: Into>, { - let log = ::slog_or_stdlog(logger).new(o!("smithay_module" => "backend_egl")); + let log = crate::slog_or_stdlog(logger).new(o!("smithay_module" => "backend_egl")); dev.clear_handler(); diff --git a/src/backend/drm/egl/session.rs b/src/backend/drm/egl/session.rs index aa8d213..ae404d0 100644 --- a/src/backend/drm/egl/session.rs +++ b/src/backend/drm/egl/session.rs @@ -7,9 +7,9 @@ use drm::control::crtc; use std::os::unix::io::RawFd; use super::EglDevice; -use backend::drm::Device; -use backend::egl::native::{Backend, NativeDisplay, NativeSurface}; -use backend::session::{AsSessionObserver, SessionObserver}; +use crate::backend::drm::Device; +use crate::backend::egl::native::{Backend, NativeDisplay, NativeSurface}; +use crate::backend::session::{AsSessionObserver, SessionObserver}; /// [`SessionObserver`](SessionObserver) /// linked to the [`EglDevice`](EglDevice) it was diff --git a/src/backend/drm/egl/surface.rs b/src/backend/drm/egl/surface.rs index 064825e..7ed7b20 100644 --- a/src/backend/drm/egl/surface.rs +++ b/src/backend/drm/egl/surface.rs @@ -3,14 +3,14 @@ use nix::libc::c_void; use std::rc::Rc; use super::error::*; -use backend::drm::{Device, Surface}; -use backend::egl::native::{Backend, NativeDisplay, NativeSurface}; -use backend::egl::{EGLContext, EGLSurface}; +use crate::backend::drm::{Device, Surface}; +use crate::backend::egl::native::{Backend, NativeDisplay, NativeSurface}; +use crate::backend::egl::{EGLContext, EGLSurface}; #[cfg(feature = "renderer_gl")] -use backend::graphics::gl::GLGraphicsBackend; +use crate::backend::graphics::gl::GLGraphicsBackend; #[cfg(feature = "renderer_gl")] -use backend::graphics::PixelFormat; -use backend::graphics::{CursorBackend, SwapBuffersError}; +use crate::backend::graphics::PixelFormat; +use crate::backend::graphics::{CursorBackend, SwapBuffersError}; /// Egl surface for rendering pub struct EglSurface diff --git a/src/backend/drm/gbm/egl.rs b/src/backend/drm/gbm/egl.rs index a479d0b..d2d32e7 100644 --- a/src/backend/drm/gbm/egl.rs +++ b/src/backend/drm/gbm/egl.rs @@ -4,11 +4,11 @@ //! [`GbmDevice`](GbmDevice) and [`GbmSurface`](GbmSurface). //! -use backend::drm::{Device, RawDevice}; -use backend::egl::error::Result as EglResult; -use backend::egl::ffi; -use backend::egl::native::{Backend, NativeDisplay, NativeSurface}; -use backend::graphics::SwapBuffersError; +use crate::backend::drm::{Device, RawDevice}; +use crate::backend::egl::error::Result as EglResult; +use crate::backend::egl::ffi; +use crate::backend::egl::native::{Backend, NativeDisplay, NativeSurface}; +use crate::backend::graphics::SwapBuffersError; use super::error::{Error, Result}; use super::{GbmDevice, GbmSurface}; diff --git a/src/backend/drm/gbm/error.rs b/src/backend/drm/gbm/error.rs index 46aad9d..3b1c751 100644 --- a/src/backend/drm/gbm/error.rs +++ b/src/backend/drm/gbm/error.rs @@ -49,6 +49,6 @@ error_chain! { } foreign_links { - FailedToSwap(::backend::graphics::SwapBuffersError) #[doc = "Swapping front buffers failed"]; + FailedToSwap(crate::backend::graphics::SwapBuffersError) #[doc = "Swapping front buffers failed"]; } } diff --git a/src/backend/drm/gbm/mod.rs b/src/backend/drm/gbm/mod.rs index af25d00..0395d14 100644 --- a/src/backend/drm/gbm/mod.rs +++ b/src/backend/drm/gbm/mod.rs @@ -65,7 +65,7 @@ impl GbmDevice { ); }); - let log = ::slog_or_stdlog(logger).new(o!("smithay_module" => "backend_gbm")); + let log = crate::slog_or_stdlog(logger).new(o!("smithay_module" => "backend_gbm")); dev.clear_handler(); diff --git a/src/backend/drm/gbm/session.rs b/src/backend/drm/gbm/session.rs index 9f0c135..8d27030 100644 --- a/src/backend/drm/gbm/session.rs +++ b/src/backend/drm/gbm/session.rs @@ -11,8 +11,8 @@ use std::os::unix::io::RawFd; use std::rc::{Rc, Weak}; use super::{GbmDevice, GbmSurfaceInternal}; -use backend::drm::{RawDevice, RawSurface}; -use backend::session::{AsSessionObserver, SessionObserver}; +use crate::backend::drm::{RawDevice, RawSurface}; +use crate::backend::session::{AsSessionObserver, SessionObserver}; /// [`SessionObserver`](SessionObserver) /// linked to the [`GbmDevice`](GbmDevice) it was diff --git a/src/backend/drm/gbm/surface.rs b/src/backend/drm/gbm/surface.rs index c1b99be..441c44b 100644 --- a/src/backend/drm/gbm/surface.rs +++ b/src/backend/drm/gbm/surface.rs @@ -10,9 +10,9 @@ use std::os::unix::io::AsRawFd; use std::rc::Rc; #[cfg(feature = "backend_drm_legacy")] -use backend::drm::legacy::LegacyDrmDevice; -use backend::graphics::CursorBackend; -use backend::graphics::SwapBuffersError; +use crate::backend::drm::legacy::LegacyDrmDevice; +use crate::backend::graphics::CursorBackend; +use crate::backend::graphics::SwapBuffersError; pub(super) struct GbmSurfaceInternal { pub(super) dev: Rc>>, diff --git a/src/backend/drm/legacy/error.rs b/src/backend/drm/legacy/error.rs index d657194..dc51b0f 100644 --- a/src/backend/drm/legacy/error.rs +++ b/src/backend/drm/legacy/error.rs @@ -49,6 +49,6 @@ error_chain! { } foreign_links { - FailedToSwap(::backend::graphics::SwapBuffersError) #[doc = "Swapping front buffers failed"]; + FailedToSwap(crate::backend::graphics::SwapBuffersError) #[doc = "Swapping front buffers failed"]; } } diff --git a/src/backend/drm/legacy/mod.rs b/src/backend/drm/legacy/mod.rs index fadcaa4..dea1b9a 100644 --- a/src/backend/drm/legacy/mod.rs +++ b/src/backend/drm/legacy/mod.rs @@ -94,7 +94,7 @@ impl LegacyDrmDevice { where L: Into>, { - let log = ::slog_or_stdlog(logger).new(o!("smithay_module" => "backend_drm")); + let log = crate::slog_or_stdlog(logger).new(o!("smithay_module" => "backend_drm")); info!(log, "DrmDevice initializing"); let dev_id = fstat(dev.as_raw_fd()) diff --git a/src/backend/drm/legacy/session.rs b/src/backend/drm/legacy/session.rs index 3ba2077..3edaaef 100644 --- a/src/backend/drm/legacy/session.rs +++ b/src/backend/drm/legacy/session.rs @@ -15,7 +15,7 @@ use std::sync::atomic::{AtomicBool, Ordering}; use std::sync::Arc; use super::{Dev, LegacyDrmDevice, LegacyDrmSurfaceInternal}; -use backend::session::{AsSessionObserver, SessionObserver}; +use crate::backend::session::{AsSessionObserver, SessionObserver}; /// [`SessionObserver`](SessionObserver) /// linked to the [`LegacyDrmDevice`](LegacyDrmDevice) diff --git a/src/backend/drm/legacy/surface.rs b/src/backend/drm/legacy/surface.rs index e960174..7dda6b2 100644 --- a/src/backend/drm/legacy/surface.rs +++ b/src/backend/drm/legacy/surface.rs @@ -7,9 +7,9 @@ use std::os::unix::io::{AsRawFd, RawFd}; use std::rc::Rc; use std::sync::RwLock; -use backend::drm::{DevPath, RawSurface, Surface}; -use backend::graphics::CursorBackend; -use backend::graphics::SwapBuffersError; +use crate::backend::drm::{DevPath, RawSurface, Surface}; +use crate::backend::graphics::CursorBackend; +use crate::backend::graphics::SwapBuffersError; use super::{error::*, Dev}; diff --git a/src/backend/egl/context.rs b/src/backend/egl/context.rs index 7133899..9f3322d 100644 --- a/src/backend/egl/context.rs +++ b/src/backend/egl/context.rs @@ -1,7 +1,7 @@ //! EGL context related structs use super::{error::*, ffi, native, EGLSurface}; -use backend::graphics::PixelFormat; +use crate::backend::graphics::PixelFormat; use nix::libc::{c_int, c_void}; use slog; use std::{ @@ -36,7 +36,7 @@ impl> EGLContext { where L: Into>, { - let log = ::slog_or_stdlog(logger.into()).new(o!("smithay_module" => "renderer_egl")); + let log = crate::slog_or_stdlog(logger.into()).new(o!("smithay_module" => "renderer_egl")); let ptr = native.ptr()?; let (context, display, config_id, surface_attributes, pixel_format, wl_drm_support) = unsafe { EGLContext::::new_internal(ptr, attributes, reqs, log.clone()) }?; diff --git a/src/backend/egl/mod.rs b/src/backend/egl/mod.rs index d68f5cd..a1f0486 100644 --- a/src/backend/egl/mod.rs +++ b/src/backend/egl/mod.rs @@ -19,7 +19,7 @@ //! of an EGL-based [`WlBuffer`](wayland_server::protocol::wl_buffer::WlBuffer) for rendering. #[cfg(feature = "renderer_gl")] -use backend::graphics::gl::ffi as gl_ffi; +use crate::backend::graphics::gl::ffi as gl_ffi; use nix::libc::c_uint; use std::{ ffi::CStr, diff --git a/src/backend/egl/native.rs b/src/backend/egl/native.rs index 9d797a9..cb13e0a 100644 --- a/src/backend/egl/native.rs +++ b/src/backend/egl/native.rs @@ -1,7 +1,7 @@ //! Type safe native types for safe context/surface creation use super::{error::*, ffi}; -use backend::graphics::SwapBuffersError; +use crate::backend::graphics::SwapBuffersError; #[cfg(feature = "backend_winit")] use std::ptr; diff --git a/src/backend/egl/surface.rs b/src/backend/egl/surface.rs index df3ac31..45e8814 100644 --- a/src/backend/egl/surface.rs +++ b/src/backend/egl/surface.rs @@ -1,7 +1,7 @@ //! EGL surface related structs use super::{error::*, ffi, native, EGLContext}; -use backend::graphics::SwapBuffersError; +use crate::backend::graphics::SwapBuffersError; use nix::libc::c_int; use std::{ cell::Cell, diff --git a/src/backend/graphics/glium.rs b/src/backend/graphics/glium.rs index d146a28..b71287b 100644 --- a/src/backend/graphics/glium.rs +++ b/src/backend/graphics/glium.rs @@ -1,6 +1,6 @@ //! Glium compatibility module -use backend::graphics::{gl::GLGraphicsBackend, SwapBuffersError}; +use crate::backend::graphics::{gl::GLGraphicsBackend, SwapBuffersError}; use glium::{ backend::{Backend, Context, Facade}, debug::DebugCallbackBehavior, diff --git a/src/backend/libinput.rs b/src/backend/libinput.rs index dbeca0a..0c5fd98 100644 --- a/src/backend/libinput.rs +++ b/src/backend/libinput.rs @@ -1,8 +1,8 @@ //! Implementation of input backend trait for types provided by `libinput` -use backend::input::{self as backend, Axis, InputBackend}; +use crate::backend::input::{self as backend, Axis, InputBackend}; #[cfg(feature = "backend_session")] -use backend::session::{AsErrno, Session, SessionObserver}; +use crate::backend::session::{AsErrno, Session, SessionObserver}; use input as libinput; use input::event; @@ -46,7 +46,7 @@ impl LibinputInputBackend { where L: Into>, { - let log = ::slog_or_stdlog(logger).new(o!("smithay_module" => "backend_libinput")); + let log = crate::slog_or_stdlog(logger).new(o!("smithay_module" => "backend_libinput")); info!(log, "Initializing a libinput backend"); LibinputInputBackend { context, @@ -612,7 +612,7 @@ pub fn libinput_bind( source.set_interest(Ready::readable()); handle.insert_source(source, move |evt, _| { - use backend::input::InputBackend; + use crate::backend::input::InputBackend; let mut backend = evt.source.borrow_mut(); if let Err(error) = backend.0.dispatch_new_events() { diff --git a/src/backend/session/auto.rs b/src/backend/session/auto.rs index 3fe1aed..8196a4c 100644 --- a/src/backend/session/auto.rs +++ b/src/backend/session/auto.rs @@ -88,7 +88,7 @@ impl AutoSession { where L: Into>, { - let logger = ::slog_or_stdlog(logger) + let logger = crate::slog_or_stdlog(logger) .new(o!("smithay_module" => "backend_session_auto", "session_type" => "auto")); info!(logger, "Trying to create logind session"); @@ -121,7 +121,7 @@ impl AutoSession { where L: Into>, { - let logger = ::slog_or_stdlog(logger) + let logger = crate::slog_or_stdlog(logger) .new(o!("smithay_module" => "backend_session_auto", "session_type" => "auto")); info!(logger, "Trying to create tty session"); diff --git a/src/backend/session/dbus/logind.rs b/src/backend/session/dbus/logind.rs index 6a02bef..2f66113 100644 --- a/src/backend/session/dbus/logind.rs +++ b/src/backend/session/dbus/logind.rs @@ -31,7 +31,7 @@ //! It is crucial to avoid errors during that state. Examples for object that might be registered //! for notifications are the [`Libinput`](input::Libinput) context or the [`Device`](::backend::drm::Device). -use backend::session::{AsErrno, Session, SessionNotifier, SessionObserver}; +use crate::backend::session::{AsErrno, Session, SessionNotifier, SessionObserver}; use dbus::{ BusName, BusType, Connection, ConnectionItem, ConnectionItems, Interface, Member, Message, MessageItem, OwnedFd, Path as DbusPath, Watch, WatchEvent, @@ -84,7 +84,7 @@ impl LogindSession { where L: Into>, { - let logger = ::slog_or_stdlog(logger) + let logger = crate::slog_or_stdlog(logger) .new(o!("smithay_module" => "backend_session", "session_type" => "logind")); // Acquire session_id, seat and vt (if any) via libsystemd diff --git a/src/backend/session/direct.rs b/src/backend/session/direct.rs index 00bb98d..a21699a 100644 --- a/src/backend/session/direct.rs +++ b/src/backend/session/direct.rs @@ -175,7 +175,7 @@ impl DirectSession { where L: Into>, { - let logger = ::slog_or_stdlog(logger) + let logger = crate::slog_or_stdlog(logger) .new(o!("smithay_module" => "backend_session", "session_type" => "direct/vt")); let fd = tty diff --git a/src/backend/udev.rs b/src/backend/udev.rs index 2501563..0ff2520 100644 --- a/src/backend/udev.rs +++ b/src/backend/udev.rs @@ -59,7 +59,7 @@ impl UdevBackend { where L: Into>, { - let log = ::slog_or_stdlog(logger).new(o!("smithay_module" => "backend_udev")); + let log = crate::slog_or_stdlog(logger).new(o!("smithay_module" => "backend_udev")); let devices = all_gpus(context, seat)? .into_iter() diff --git a/src/backend/winit.rs b/src/backend/winit.rs index 2ad70b6..68b1e9b 100644 --- a/src/backend/winit.rs +++ b/src/backend/winit.rs @@ -1,6 +1,6 @@ //! Implementation of backend traits for types provided by `winit` -use backend::{ +use crate::backend::{ egl::{ context::GlAttributes, error::Result as EGLResult, native, EGLContext, EGLDisplay, EGLGraphicsBackend, EGLSurface, @@ -30,7 +30,7 @@ use winit::{ /// Errors thrown by the `winit` backends pub mod errors { - use backend::egl::error as egl_error; + use crate::backend::egl::error as egl_error; error_chain! { errors { @@ -152,7 +152,7 @@ pub fn init_from_builder_with_gl_attr( where L: Into>, { - let log = ::slog_or_stdlog(logger).new(o!("smithay_module" => "backend_winit")); + let log = crate::slog_or_stdlog(logger).new(o!("smithay_module" => "backend_winit")); info!(log, "Initializing a winit backend"); let events_loop = EventsLoop::new(); diff --git a/src/wayland/compositor/mod.rs b/src/wayland/compositor/mod.rs index f795c50..84b3718 100644 --- a/src/wayland/compositor/mod.rs +++ b/src/wayland/compositor/mod.rs @@ -90,7 +90,7 @@ use self::{ roles::{Role, RoleType, WrongRole}, tree::SurfaceData, }; -use utils::Rectangle; +use crate::utils::Rectangle; use wayland_server::{ protocol::{ wl_buffer, wl_callback, wl_compositor, wl_output, wl_region, wl_subcompositor, wl_surface::WlSurface, @@ -467,7 +467,7 @@ where R: Default + RoleType + Role + 'static, Impl: FnMut(SurfaceEvent, Resource, CompositorToken) + 'static, { - let log = ::slog_or_stdlog(logger).new(o!("smithay_module" => "compositor_handler")); + let log = crate::slog_or_stdlog(logger).new(o!("smithay_module" => "compositor_handler")); let implem = Rc::new(RefCell::new(implem)); let comp_token = display.get_token(); diff --git a/src/wayland/data_device/dnd_grab.rs b/src/wayland/data_device/dnd_grab.rs index b72449e..e775d84 100644 --- a/src/wayland/data_device/dnd_grab.rs +++ b/src/wayland/data_device/dnd_grab.rs @@ -8,7 +8,7 @@ use wayland_server::{ NewResource, Resource, }; -use wayland::{ +use crate::wayland::{ compositor::{roles::Role, CompositorToken}, seat::{AxisFrame, PointerGrab, PointerInnerHandle, Seat}, }; diff --git a/src/wayland/data_device/mod.rs b/src/wayland/data_device/mod.rs index e883cd6..c9eb113 100644 --- a/src/wayland/data_device/mod.rs +++ b/src/wayland/data_device/mod.rs @@ -68,7 +68,7 @@ use wayland_server::{ Client, Display, Global, NewResource, Resource, }; -use wayland::{ +use crate::wayland::{ compositor::{roles::Role, CompositorToken}, seat::Seat, }; @@ -294,7 +294,7 @@ where U: 'static, L: Into>, { - let log = ::slog_or_stdlog(logger).new(o!("smithay_module" => "data_device_mgr")); + let log = crate::slog_or_stdlog(logger).new(o!("smithay_module" => "data_device_mgr")); let action_choice = Arc::new(Mutex::new(action_choice)); let callback = Arc::new(Mutex::new(callback)); let global = display.create_global(3, move |new_ddm, _version| { diff --git a/src/wayland/data_device/server_dnd_grab.rs b/src/wayland/data_device/server_dnd_grab.rs index b48b49e..c885e55 100644 --- a/src/wayland/data_device/server_dnd_grab.rs +++ b/src/wayland/data_device/server_dnd_grab.rs @@ -6,7 +6,7 @@ use wayland_server::{ NewResource, Resource, }; -use wayland::seat::{AxisFrame, PointerGrab, PointerInnerHandle, Seat}; +use crate::wayland::seat::{AxisFrame, PointerGrab, PointerInnerHandle, Seat}; use super::{DataDeviceData, SeatData}; diff --git a/src/wayland/output/mod.rs b/src/wayland/output/mod.rs index 1df3266..51e0f70 100644 --- a/src/wayland/output/mod.rs +++ b/src/wayland/output/mod.rs @@ -179,7 +179,7 @@ impl Output { where L: Into>, { - let log = ::slog_or_stdlog(logger).new(o!("smithay_module" => "output_handler")); + let log = crate::slog_or_stdlog(logger).new(o!("smithay_module" => "output_handler")); info!(log, "Creating new wl_output"; "name" => &name); diff --git a/src/wayland/seat/keyboard.rs b/src/wayland/seat/keyboard.rs index 7c71dfc..556d34c 100644 --- a/src/wayland/seat/keyboard.rs +++ b/src/wayland/seat/keyboard.rs @@ -1,4 +1,4 @@ -use backend::input::KeyState; +use crate::backend::input::KeyState; use std::{ default::Default, io::{Error as IoError, Write}, diff --git a/src/wayland/seat/mod.rs b/src/wayland/seat/mod.rs index 77050f8..2e56f78 100644 --- a/src/wayland/seat/mod.rs +++ b/src/wayland/seat/mod.rs @@ -55,7 +55,7 @@ pub use self::{ }, }; -use wayland::compositor::{roles::Role, CompositorToken}; +use crate::wayland::compositor::{roles::Role, CompositorToken}; use wayland_commons::utils::UserDataMap; @@ -133,7 +133,7 @@ impl Seat { R: Role + 'static, L: Into>, { - let log = ::slog_or_stdlog(logger); + let log = crate::slog_or_stdlog(logger); let arc = Arc::new(SeatArc { inner: Mutex::new(Inner { pointer: None, diff --git a/src/wayland/seat/pointer.rs b/src/wayland/seat/pointer.rs index 15ce763..3150577 100644 --- a/src/wayland/seat/pointer.rs +++ b/src/wayland/seat/pointer.rs @@ -7,7 +7,7 @@ use wayland_server::{ NewResource, Resource, }; -use wayland::compositor::{roles::Role, CompositorToken}; +use crate::wayland::compositor::{roles::Role, CompositorToken}; /// The role representing a surface set as the pointer cursor #[derive(Default, Copy, Clone)] diff --git a/src/wayland/shell/legacy/mod.rs b/src/wayland/shell/legacy/mod.rs index d02a56e..c994f9a 100644 --- a/src/wayland/shell/legacy/mod.rs +++ b/src/wayland/shell/legacy/mod.rs @@ -76,7 +76,7 @@ use std::{ sync::{Arc, Mutex}, }; -use wayland::compositor::{roles::Role, CompositorToken}; +use crate::wayland::compositor::{roles::Role, CompositorToken}; use wayland_server::{ protocol::{wl_output, wl_seat, wl_shell, wl_shell_surface, wl_surface}, @@ -327,7 +327,7 @@ where L: Into>, Impl: FnMut(ShellRequest) + 'static, { - let _log = ::slog_or_stdlog(logger); + let _log = crate::slog_or_stdlog(logger); let implementation = Rc::new(RefCell::new(implementation)); diff --git a/src/wayland/shell/legacy/wl_handlers.rs b/src/wayland/shell/legacy/wl_handlers.rs index b72c570..b39bd80 100644 --- a/src/wayland/shell/legacy/wl_handlers.rs +++ b/src/wayland/shell/legacy/wl_handlers.rs @@ -9,7 +9,7 @@ use wayland_server::{ DisplayToken, NewResource, Resource, }; -use wayland::compositor::{roles::Role, CompositorToken}; +use crate::wayland::compositor::{roles::Role, CompositorToken}; use super::{ShellRequest, ShellState, ShellSurface, ShellSurfaceKind, ShellSurfaceRole}; diff --git a/src/wayland/shell/xdg/mod.rs b/src/wayland/shell/xdg/mod.rs index 08b4151..632a75c 100644 --- a/src/wayland/shell/xdg/mod.rs +++ b/src/wayland/shell/xdg/mod.rs @@ -95,8 +95,8 @@ use std::{ rc::Rc, sync::{Arc, Mutex}, }; -use utils::Rectangle; -use wayland::compositor::{roles::Role, CompositorToken}; +use crate::utils::Rectangle; +use crate::wayland::compositor::{roles::Role, CompositorToken}; use wayland_protocols::{ unstable::xdg_shell::v6::server::{zxdg_popup_v6, zxdg_shell_v6, zxdg_surface_v6, zxdg_toplevel_v6}, xdg_shell::server::{xdg_popup, xdg_positioner, xdg_surface, xdg_toplevel, xdg_wm_base}, @@ -297,7 +297,7 @@ where L: Into>, Impl: FnMut(XdgRequest) + 'static, { - let log = ::slog_or_stdlog(logger); + let log = crate::slog_or_stdlog(logger); let shell_state = Arc::new(Mutex::new(ShellState { known_toplevels: Vec::new(), known_popups: Vec::new(), diff --git a/src/wayland/shell/xdg/xdg_handlers.rs b/src/wayland/shell/xdg/xdg_handlers.rs index dd722cb..9fe17b4 100644 --- a/src/wayland/shell/xdg/xdg_handlers.rs +++ b/src/wayland/shell/xdg/xdg_handlers.rs @@ -1,12 +1,12 @@ use std::{cell::RefCell, sync::Mutex}; -use wayland::compositor::{roles::*, CompositorToken}; +use crate::wayland::compositor::{roles::*, CompositorToken}; use wayland_protocols::xdg_shell::server::{ xdg_popup, xdg_positioner, xdg_surface, xdg_toplevel, xdg_wm_base, }; use wayland_server::{protocol::wl_surface, DisplayToken, NewResource, Resource}; -use utils::Rectangle; +use crate::utils::Rectangle; use super::{ make_shell_client_data, PopupConfigure, PopupKind, PopupState, PositionerState, ShellClient, diff --git a/src/wayland/shell/xdg/zxdgv6_handlers.rs b/src/wayland/shell/xdg/zxdgv6_handlers.rs index eb8cc17..a62f436 100644 --- a/src/wayland/shell/xdg/zxdgv6_handlers.rs +++ b/src/wayland/shell/xdg/zxdgv6_handlers.rs @@ -1,6 +1,6 @@ use std::{cell::RefCell, sync::Mutex}; -use wayland::compositor::{roles::*, CompositorToken}; +use crate::wayland::compositor::{roles::*, CompositorToken}; use wayland_protocols::{ unstable::xdg_shell::v6::server::{ zxdg_popup_v6, zxdg_positioner_v6, zxdg_shell_v6, zxdg_surface_v6, zxdg_toplevel_v6, @@ -9,7 +9,7 @@ use wayland_protocols::{ }; use wayland_server::{protocol::wl_surface, DisplayToken, NewResource, Resource}; -use utils::Rectangle; +use crate::utils::Rectangle; use super::{ make_shell_client_data, PopupConfigure, PopupKind, PopupState, PositionerState, ShellClient, diff --git a/src/wayland/shm/mod.rs b/src/wayland/shm/mod.rs index fe673a6..e0f0506 100644 --- a/src/wayland/shm/mod.rs +++ b/src/wayland/shm/mod.rs @@ -115,7 +115,7 @@ pub fn init_shm_global( where L: Into>, { - let log = ::slog_or_stdlog(logger); + let log = crate::slog_or_stdlog(logger); // always add the mandatory formats formats.push(wl_shm::Format::Argb8888); diff --git a/src/xwayland/xserver.rs b/src/xwayland/xserver.rs index 32eb4c2..fb76835 100644 --- a/src/xwayland/xserver.rs +++ b/src/xwayland/xserver.rs @@ -86,7 +86,7 @@ impl XWayland { where L: Into>, { - let log = ::slog_or_stdlog(logger); + let log = crate::slog_or_stdlog(logger); let inner = Rc::new(RefCell::new(Inner { wm, source_maker: Box::new(move |inner| { From e5f8c351c7436c6ab8ac241a79f496093b42d5e5 Mon Sep 17 00:00:00 2001 From: Victor Brekenfeld Date: Sat, 15 Dec 2018 21:58:43 +0100 Subject: [PATCH 2/3] Check for rust_2018_idioms --- anvil/src/glium_drawer.rs | 4 +- anvil/src/input_handler.rs | 2 +- anvil/src/main.rs | 8 ++-- anvil/src/shell.rs | 2 +- anvil/src/shm_load.rs | 6 +-- anvil/src/udev.rs | 2 +- anvil/src/window_map.rs | 2 +- anvil/src/winit.rs | 2 +- examples/raw_drm.rs | 6 +-- src/backend/drm/egl/mod.rs | 2 +- src/backend/drm/gbm/mod.rs | 2 +- src/backend/drm/legacy/mod.rs | 2 +- src/backend/drm/legacy/surface.rs | 4 +- src/backend/egl/context.rs | 4 +- src/backend/egl/ffi.rs | 2 +- src/backend/egl/mod.rs | 14 +++---- src/backend/graphics/errors.rs | 4 +- src/backend/graphics/gl.rs | 3 +- src/backend/graphics/glium.rs | 4 +- src/backend/input.rs | 4 +- src/backend/libinput.rs | 6 +-- src/backend/session/dbus/logind.rs | 6 +-- src/backend/session/direct.rs | 2 +- src/backend/session/multi.rs | 8 ++-- src/backend/winit.rs | 26 ++++++------ src/lib.rs | 47 +--------------------- src/wayland/compositor/handlers.rs | 2 +- src/wayland/data_device/dnd_grab.rs | 12 +++--- src/wayland/data_device/mod.rs | 4 +- src/wayland/data_device/server_dnd_grab.rs | 8 ++-- src/wayland/seat/keyboard.rs | 8 ++-- src/wayland/seat/mod.rs | 2 +- src/wayland/seat/pointer.rs | 24 +++++------ src/wayland/shell/xdg/mod.rs | 2 +- src/xwayland/xserver.rs | 2 +- 35 files changed, 95 insertions(+), 143 deletions(-) diff --git a/anvil/src/glium_drawer.rs b/anvil/src/glium_drawer.rs index 4a6ce9f..1f17b5d 100644 --- a/anvil/src/glium_drawer.rs +++ b/anvil/src/glium_drawer.rs @@ -24,7 +24,7 @@ use smithay::{ seat::CursorImageRole, shm::with_buffer_contents as shm_buffer_contents, }, - wayland_server::{ + reexports::wayland_server::{ protocol::{wl_buffer, wl_surface}, Resource, }, @@ -52,7 +52,7 @@ pub struct GliumDrawer { } impl GliumDrawer { - pub fn borrow(&self) -> Ref { + pub fn borrow(&self) -> Ref<'_, F> { self.display.borrow() } } diff --git a/anvil/src/input_handler.rs b/anvil/src/input_handler.rs index baf66d7..96d495b 100644 --- a/anvil/src/input_handler.rs +++ b/anvil/src/input_handler.rs @@ -21,7 +21,7 @@ use smithay::{ seat::{keysyms as xkb, AxisFrame, KeyboardHandle, Keysym, ModifiersState, PointerHandle}, SERIAL_COUNTER as SCOUNTER, }, - wayland_server::protocol::wl_pointer, + reexports::wayland_server::protocol::wl_pointer, }; use crate::shell::MyWindowMap; diff --git a/anvil/src/main.rs b/anvil/src/main.rs index b920d2e..f4821ee 100644 --- a/anvil/src/main.rs +++ b/anvil/src/main.rs @@ -1,16 +1,14 @@ +#![warn(rust_2018_idioms)] + #[macro_use] extern crate glium; -extern crate rand; #[macro_use] extern crate slog; -extern crate slog_async; -extern crate slog_term; #[macro_use(define_roles)] extern crate smithay; -extern crate xkbcommon; use slog::Drain; -use smithay::wayland_server::{calloop::EventLoop, Display}; +use smithay::reexports::wayland_server::{calloop::EventLoop, Display}; #[macro_use] mod shaders; diff --git a/anvil/src/shell.rs b/anvil/src/shell.rs index c0b8d27..f96a5f0 100644 --- a/anvil/src/shell.rs +++ b/anvil/src/shell.rs @@ -21,7 +21,7 @@ use smithay::{ }, }, }, - wayland_server::{ + reexports::wayland_server::{ protocol::{wl_buffer, wl_callback, wl_shell_surface, wl_surface}, Display, Resource, }, diff --git a/anvil/src/shm_load.rs b/anvil/src/shm_load.rs index fdb2483..38283b5 100644 --- a/anvil/src/shm_load.rs +++ b/anvil/src/shm_load.rs @@ -1,10 +1,10 @@ use std::borrow::Cow; -use smithay::{wayland::shm::BufferData, wayland_server::protocol::wl_shm::Format}; +use smithay::{wayland::shm::BufferData, reexports::wayland_server::protocol::wl_shm::Format}; use glium::texture::{ClientFormat, RawImage2d}; -pub fn load_shm_buffer(data: BufferData, pool: &[u8]) -> Result<(RawImage2d, usize), Format> { +pub fn load_shm_buffer(data: BufferData, pool: &[u8]) -> Result<(RawImage2d<'_, u8>, usize), Format> { let offset = data.offset as usize; let width = data.width as usize; let height = data.height as usize; @@ -17,7 +17,7 @@ pub fn load_shm_buffer(data: BufferData, pool: &[u8]) -> Result<(RawImage2d, // ensure consistency, the SHM handler of smithay should ensure this assert!(offset + (height - 1) * stride + width * pixelsize <= pool.len()); - let slice: Cow<[u8]> = if stride == width * pixelsize { + let slice: Cow<'_, [u8]> = if stride == width * pixelsize { // the buffer is cleanly continuous, use as-is Cow::Borrowed(&pool[offset..(offset + height * width * pixelsize)]) } else { diff --git a/anvil/src/udev.rs b/anvil/src/udev.rs index c7ea8b0..4447dc5 100644 --- a/anvil/src/udev.rs +++ b/anvil/src/udev.rs @@ -110,7 +110,7 @@ pub fn run_udev(mut display: Display, mut event_loop: EventLoop<()>, log: Logger /* * Initialize the udev backend */ - let context = ::smithay::udev::Context::new().map_err(|_| ())?; + let context = ::smithay::reexports::udev::Context::new().map_err(|_| ())?; let seat = session.seat(); let primary_gpu = primary_gpu(&context, &seat).unwrap_or_default(); diff --git a/anvil/src/window_map.rs b/anvil/src/window_map.rs index dc12e10..9069c88 100644 --- a/anvil/src/window_map.rs +++ b/anvil/src/window_map.rs @@ -7,7 +7,7 @@ use smithay::{ xdg::{ToplevelSurface, XdgSurfaceRole}, }, }, - wayland_server::{protocol::wl_surface, Resource}, + reexports::wayland_server::{protocol::wl_surface, Resource}, }; pub enum Kind { diff --git a/anvil/src/winit.rs b/anvil/src/winit.rs index 6da43b4..9b5e04a 100644 --- a/anvil/src/winit.rs +++ b/anvil/src/winit.rs @@ -12,7 +12,7 @@ use smithay::{ seat::{CursorImageStatus, Seat, XkbConfig}, shm::init_shm_global, }, - wayland_server::{calloop::EventLoop, protocol::wl_output, Display}, + reexports::wayland_server::{calloop::EventLoop, protocol::wl_output, Display}, }; use slog::Logger; diff --git a/examples/raw_drm.rs b/examples/raw_drm.rs index dbc008b..52041d4 100644 --- a/examples/raw_drm.rs +++ b/examples/raw_drm.rs @@ -1,7 +1,7 @@ -extern crate smithay; +#![warn(rust_2018_idioms)] + #[macro_use] extern crate slog; -extern crate slog_term; use slog::Drain; use smithay::{ @@ -145,7 +145,7 @@ impl DeviceHandler for DrmHandlerImpl { // now we could render to the mapping via software rendering. // this example just sets some grey color - for mut x in mapping.as_mut() { + for x in mapping.as_mut() { *x = 128; } } diff --git a/src/backend/drm/egl/mod.rs b/src/backend/drm/egl/mod.rs index cc962da..9f0015d 100644 --- a/src/backend/drm/egl/mod.rs +++ b/src/backend/drm/egl/mod.rs @@ -108,7 +108,7 @@ where D: Device + NativeDisplay + 'static, ::Surface: NativeSurface, { - handler: Box> + 'static>, + handler: Box> + 'static>, } impl DeviceHandler for InternalDeviceHandler diff --git a/src/backend/drm/gbm/mod.rs b/src/backend/drm/gbm/mod.rs index 0395d14..97ebfb2 100644 --- a/src/backend/drm/gbm/mod.rs +++ b/src/backend/drm/gbm/mod.rs @@ -82,7 +82,7 @@ impl GbmDevice { } struct InternalDeviceHandler { - handler: Box> + 'static>, + handler: Box> + 'static>, backends: Weak>>>>, logger: ::slog::Logger, } diff --git a/src/backend/drm/legacy/mod.rs b/src/backend/drm/legacy/mod.rs index dea1b9a..fe098c4 100644 --- a/src/backend/drm/legacy/mod.rs +++ b/src/backend/drm/legacy/mod.rs @@ -38,7 +38,7 @@ pub struct LegacyDrmDevice { dev_id: dev_t, active: Arc, backends: Rc>>>>, - handler: Option>>>>, + handler: Option>>>>, logger: ::slog::Logger, } diff --git a/src/backend/drm/legacy/surface.rs b/src/backend/drm/legacy/surface.rs index 7dda6b2..cdd9b7d 100644 --- a/src/backend/drm/legacy/surface.rs +++ b/src/backend/drm/legacy/surface.rs @@ -37,7 +37,7 @@ impl BasicDevice for LegacyDrmSurfaceInternal {} impl ControlDevice for LegacyDrmSurfaceInternal {} impl<'a, A: AsRawFd + 'static> CursorBackend<'a> for LegacyDrmSurfaceInternal { - type CursorFormat = &'a Buffer; + type CursorFormat = &'a dyn Buffer; type Error = Error; fn set_cursor_position(&self, x: u32, y: u32) -> Result<()> { @@ -250,7 +250,7 @@ impl BasicDevice for LegacyDrmSurface {} impl ControlDevice for LegacyDrmSurface {} impl<'a, A: AsRawFd + 'static> CursorBackend<'a> for LegacyDrmSurface { - type CursorFormat = &'a Buffer; + type CursorFormat = &'a dyn Buffer; type Error = Error; fn set_cursor_position(&self, x: u32, y: u32) -> Result<()> { diff --git a/src/backend/egl/context.rs b/src/backend/egl/context.rs index 9f3322d..ba44c55 100644 --- a/src/backend/egl/context.rs +++ b/src/backend/egl/context.rs @@ -452,7 +452,7 @@ impl> EGLContext { /// This follows the same semantics as [`std::cell:RefCell`](std::cell::RefCell). /// Multiple read-only borrows are possible. Borrowing the /// backend while there is a mutable reference will panic. - pub fn borrow(&self) -> Ref { + pub fn borrow(&self) -> Ref<'_, N> { self.native.borrow() } @@ -462,7 +462,7 @@ impl> EGLContext { /// Holding any other borrow while trying to borrow the backend /// mutably will panic. Note that EGL will borrow the display /// mutably during surface creation. - pub fn borrow_mut(&self) -> RefMut { + pub fn borrow_mut(&self) -> RefMut<'_, N> { self.native.borrow_mut() } } diff --git a/src/backend/egl/ffi.rs b/src/backend/egl/ffi.rs index a7d2606..5fb30f1 100644 --- a/src/backend/egl/ffi.rs +++ b/src/backend/egl/ffi.rs @@ -13,7 +13,7 @@ pub type NativeDisplayType = *const c_void; pub type NativePixmapType = *const c_void; pub type NativeWindowType = *const c_void; -#[cfg_attr(feature = "cargo-clippy", allow(clippy))] +#[allow(clippy::all, rust_2018_idioms)] pub mod egl { use super::*; use libloading::Library; diff --git a/src/backend/egl/mod.rs b/src/backend/egl/mod.rs index a1f0486..689f08e 100644 --- a/src/backend/egl/mod.rs +++ b/src/backend/egl/mod.rs @@ -51,7 +51,7 @@ pub use self::surface::EGLSurface; pub struct EglExtensionNotSupportedError(&'static [&'static str]); impl fmt::Display for EglExtensionNotSupportedError { - fn fmt(&self, formatter: &mut fmt::Formatter) -> ::std::result::Result<(), fmt::Error> { + fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> ::std::result::Result<(), fmt::Error> { write!( formatter, "None of the following EGL extensions is supported by the underlying EGL implementation, @@ -66,7 +66,7 @@ impl ::std::error::Error for EglExtensionNotSupportedError { "The required EGL extension is not supported by the underlying EGL implementation" } - fn cause(&self) -> Option<&::std::error::Error> { + fn cause(&self) -> Option<&dyn ::std::error::Error> { None } } @@ -84,7 +84,7 @@ pub enum BufferAccessError { } impl fmt::Debug for BufferAccessError { - fn fmt(&self, formatter: &mut fmt::Formatter) -> ::std::result::Result<(), fmt::Error> { + fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> ::std::result::Result<(), fmt::Error> { match *self { BufferAccessError::ContextLost => write!(formatter, "BufferAccessError::ContextLost"), BufferAccessError::NotManaged(_) => write!(formatter, "BufferAccessError::NotManaged"), @@ -97,7 +97,7 @@ impl fmt::Debug for BufferAccessError { } impl fmt::Display for BufferAccessError { - fn fmt(&self, formatter: &mut fmt::Formatter) -> ::std::result::Result<(), fmt::Error> { + fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> ::std::result::Result<(), fmt::Error> { use std::error::Error; match *self { BufferAccessError::ContextLost @@ -118,7 +118,7 @@ impl ::std::error::Error for BufferAccessError { } } - fn cause(&self) -> Option<&::std::error::Error> { + fn cause(&self) -> Option<&dyn ::std::error::Error> { match *self { BufferAccessError::EglExtensionNotSupported(ref err) => Some(err), _ => None, @@ -158,7 +158,7 @@ pub enum TextureCreationError { } impl fmt::Display for TextureCreationError { - fn fmt(&self, formatter: &mut fmt::Formatter) -> ::std::result::Result<(), fmt::Error> { + fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> ::std::result::Result<(), fmt::Error> { use std::error::Error; match *self { TextureCreationError::ContextLost => write!(formatter, "{}", self.description()), @@ -185,7 +185,7 @@ impl ::std::error::Error for TextureCreationError { } } - fn cause(&self) -> Option<&::std::error::Error> { + fn cause(&self) -> Option<&dyn ::std::error::Error> { None } } diff --git a/src/backend/graphics/errors.rs b/src/backend/graphics/errors.rs index fa9e9a7..e0c3b5b 100644 --- a/src/backend/graphics/errors.rs +++ b/src/backend/graphics/errors.rs @@ -22,7 +22,7 @@ pub enum SwapBuffersError { } impl fmt::Display for SwapBuffersError { - fn fmt(&self, formatter: &mut fmt::Formatter) -> Result<(), fmt::Error> { + fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> { use std::error::Error; write!(formatter, "{}", self.description()) } @@ -39,7 +39,7 @@ impl Error for SwapBuffersError { } } - fn cause(&self) -> Option<&Error> { + fn cause(&self) -> Option<&dyn Error> { None } } diff --git a/src/backend/graphics/gl.rs b/src/backend/graphics/gl.rs index 8f9d714..27fc86d 100644 --- a/src/backend/graphics/gl.rs +++ b/src/backend/graphics/gl.rs @@ -4,8 +4,7 @@ use nix::libc::c_void; use super::{PixelFormat, SwapBuffersError}; -#[cfg_attr(feature = "cargo-clippy", allow(clippy))] -#[allow(missing_docs)] +#[allow(clippy::all, rust_2018_idioms, missing_docs)] pub(crate) mod ffi { include!(concat!(env!("OUT_DIR"), "/gl_bindings.rs")); } diff --git a/src/backend/graphics/glium.rs b/src/backend/graphics/glium.rs index b71287b..5299683 100644 --- a/src/backend/graphics/glium.rs +++ b/src/backend/graphics/glium.rs @@ -59,7 +59,7 @@ impl GliumGraphicsBackend { /// This follows the same semantics as [`std::cell::RefCell`](RefCell::borrow). /// Multiple read-only borrows are possible. Borrowing the /// backend while there is a mutable reference will panic. - pub fn borrow(&self) -> Ref { + pub fn borrow(&self) -> Ref<'_, T> { self.backend.0.borrow() } @@ -69,7 +69,7 @@ impl GliumGraphicsBackend { /// Holding any other borrow while trying to borrow the backend /// mutably will panic. Note that Glium will borrow the backend /// (not mutably) during rendering. - pub fn borrow_mut(&self) -> RefMut { + pub fn borrow_mut(&self) -> RefMut<'_, T> { self.backend.0.borrow_mut() } } diff --git a/src/backend/input.rs b/src/backend/input.rs index 4db03de..a9317cb 100644 --- a/src/backend/input.rs +++ b/src/backend/input.rs @@ -521,7 +521,7 @@ pub trait InputBackend: Sized { /// Sets a new handler for this [`InputBackend`] fn set_handler + 'static>(&mut self, handler: H); /// Get a reference to the currently set handler, if any - fn get_handler(&mut self) -> Option<&mut InputHandler>; + fn get_handler(&mut self) -> Option<&mut dyn InputHandler>; /// Clears the currently handler, if one is set fn clear_handler(&mut self); @@ -626,7 +626,7 @@ pub trait InputHandler { fn on_input_config_changed(&mut self, config: &mut B::InputConfig); } -impl InputHandler for Box> { +impl InputHandler for Box> { fn on_seat_created(&mut self, seat: &Seat) { (**self).on_seat_created(seat) } diff --git a/src/backend/libinput.rs b/src/backend/libinput.rs index 0c5fd98..9866007 100644 --- a/src/backend/libinput.rs +++ b/src/backend/libinput.rs @@ -35,7 +35,7 @@ pub struct LibinputInputBackend { context: libinput::Libinput, devices: Vec, seats: HashMap, - handler: Option + 'static>>, + handler: Option + 'static>>, logger: ::slog::Logger, } @@ -275,10 +275,10 @@ impl InputBackend for LibinputInputBackend { self.handler = Some(Box::new(handler)); } - fn get_handler(&mut self) -> Option<&mut backend::InputHandler> { + fn get_handler(&mut self) -> Option<&mut dyn backend::InputHandler> { self.handler .as_mut() - .map(|handler| handler as &mut backend::InputHandler) + .map(|handler| handler as &mut dyn backend::InputHandler) } fn clear_handler(&mut self) { diff --git a/src/backend/session/dbus/logind.rs b/src/backend/session/dbus/logind.rs index 2f66113..11f179a 100644 --- a/src/backend/session/dbus/logind.rs +++ b/src/backend/session/dbus/logind.rs @@ -60,7 +60,7 @@ struct LogindSessionImpl { conn: RefCell, session_path: DbusPath<'static>, active: AtomicBool, - signals: RefCell>>>, + signals: RefCell>>>, seat: String, logger: ::slog::Logger, } @@ -246,7 +246,7 @@ impl LogindSessionImpl { } } - fn handle_signals(&self, signals: ConnectionItems) -> Result<()> { + fn handle_signals(&self, signals: ConnectionItems<'_>) -> Result<()> { for item in signals { let message = if let ConnectionItem::Signal(ref s) = item { s @@ -314,7 +314,7 @@ impl LogindSessionImpl { use dbus::arg::{Array, Dict, Get, Iter, Variant}; let (_, changed, _) = - message.get3::, Iter>, Array>(); + message.get3::>, Iter<'_>>, Array<'_, String, Iter<'_>>>(); let mut changed = changed.chain_err(|| ErrorKind::UnexpectedMethodReturn)?; if let Some((_, mut value)) = changed.find(|&(ref key, _)| &*key == "Active") { if let Some(active) = Get::get(&mut value.0) { diff --git a/src/backend/session/direct.rs b/src/backend/session/direct.rs index a21699a..fb10b19 100644 --- a/src/backend/session/direct.rs +++ b/src/backend/session/direct.rs @@ -162,7 +162,7 @@ pub struct DirectSession { pub struct DirectSessionNotifier { tty: RawFd, active: Arc, - signals: Vec>>, + signals: Vec>>, signal: Signal, logger: ::slog::Logger, } diff --git a/src/backend/session/multi.rs b/src/backend/session/multi.rs index 9054e5c..18c088a 100644 --- a/src/backend/session/multi.rs +++ b/src/backend/session/multi.rs @@ -16,26 +16,26 @@ static ID_COUNTER: AtomicUsize = AtomicUsize::new(0); pub struct Id(usize); struct MultiObserver { - observer: Arc>>>, + observer: Arc>>>, } impl SessionObserver for MultiObserver { fn pause(&mut self, device: Option<(u32, u32)>) { let mut lock = self.observer.lock().unwrap(); - for mut observer in lock.values_mut() { + for observer in lock.values_mut() { observer.pause(device) } } fn activate(&mut self, device: Option<(u32, u32, Option)>) { let mut lock = self.observer.lock().unwrap(); - for mut observer in lock.values_mut() { + for observer in lock.values_mut() { observer.activate(device) } } } struct MultiNotifier { - observer: Arc>>>, + observer: Arc>>>, } impl SessionNotifier for MultiNotifier { diff --git a/src/backend/winit.rs b/src/backend/winit.rs index 68b1e9b..fc76496 100644 --- a/src/backend/winit.rs +++ b/src/backend/winit.rs @@ -64,7 +64,7 @@ enum Window { } impl Window { - fn window(&self) -> Ref { + fn window(&self) -> Ref<'_, WinitWindow> { match *self { Window::Wayland { ref context, .. } => context.borrow(), Window::X11 { ref context, .. } => context.borrow(), @@ -91,13 +91,13 @@ pub struct WinitGraphicsBackend { /// periodically to receive any events. pub struct WinitInputBackend { events_loop: EventsLoop, - events_handler: Option>, + events_handler: Option>, window: Rc, time: Instant, key_counter: u32, seat: Seat, input_config: (), - handler: Option + 'static>>, + handler: Option + 'static>>, logger: ::slog::Logger, size: Rc>, } @@ -162,12 +162,12 @@ where let reqs = Default::default(); let window = Rc::new( if native::NativeDisplay::::is_backend(&winit_window) { - let mut context = + let context = EGLContext::::new(winit_window, attributes, reqs, log.clone())?; let surface = context.create_surface(())?; Window::Wayland { context, surface } } else if native::NativeDisplay::::is_backend(&winit_window) { - let mut context = + let context = EGLContext::::new(winit_window, attributes, reqs, log.clone())?; let surface = context.create_surface(())?; Window::X11 { context, surface } @@ -227,7 +227,7 @@ pub trait WinitEventsHandler { impl WinitGraphicsBackend { /// Get a reference to the internally used [`WinitWindow`] - pub fn winit_window(&self) -> Ref { + pub fn winit_window(&self) -> Ref<'_, WinitWindow> { self.window.window() } } @@ -339,7 +339,7 @@ impl ::std::error::Error for WinitInputError { } impl fmt::Display for WinitInputError { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { use std::error::Error; write!(f, "{}", self.description()) } @@ -606,10 +606,10 @@ impl WinitInputBackend { } /// Get a reference to the set events handler, if any - pub fn get_events_handler(&mut self) -> Option<&mut WinitEventsHandler> { + pub fn get_events_handler(&mut self) -> Option<&mut dyn WinitEventsHandler> { self.events_handler .as_mut() - .map(|handler| &mut **handler as &mut WinitEventsHandler) + .map(|handler| &mut **handler as &mut dyn WinitEventsHandler) } /// Clear out the currently set events handler @@ -644,10 +644,10 @@ impl InputBackend for WinitInputBackend { self.handler = Some(Box::new(handler)); } - fn get_handler(&mut self) -> Option<&mut InputHandler> { + fn get_handler(&mut self) -> Option<&mut dyn InputHandler> { self.handler .as_mut() - .map(|handler| handler as &mut InputHandler) + .map(|handler| handler as &mut dyn InputHandler) } fn clear_handler(&mut self) { @@ -683,8 +683,8 @@ impl InputBackend for WinitInputBackend { // upcoming closure, which is why all are borrowed manually and the // assignments are then moved into the closure to avoid rustc's // wrong interference. - let mut closed_ptr = &mut closed; - let mut key_counter = &mut self.key_counter; + let closed_ptr = &mut closed; + let key_counter = &mut self.key_counter; let time = &self.time; let seat = &self.seat; let window = &self.window; diff --git a/src/lib.rs b/src/lib.rs index 1239f55..3d3327a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,4 +1,4 @@ -#![warn(missing_docs)] +#![warn(missing_docs, rust_2018_idioms)] //! **Smithay: the Wayland compositor smithy** //! //! Most entry points in the modules can take an optional [`slog::Logger`](::slog::Logger) as argument @@ -7,58 +7,13 @@ // `error_chain!` can recurse deeply #![recursion_limit = "1024"] -#[cfg(feature = "backend_drm_gbm")] -#[doc(hidden)] -pub extern crate image; #[cfg_attr(feature = "backend_session", macro_use)] #[doc(hidden)] pub extern crate nix; -extern crate tempfile; -#[doc(hidden)] -pub extern crate wayland_commons; -#[doc(hidden)] -pub extern crate wayland_protocols; -#[doc(hidden)] -pub extern crate wayland_server; -#[cfg(feature = "native_lib")] -extern crate wayland_sys; -extern crate xkbcommon; - -#[cfg(feature = "dbus")] -#[doc(hidden)] -pub extern crate dbus; -#[cfg(feature = "backend_drm")] -#[doc(hidden)] -pub extern crate drm; -#[cfg(feature = "backend_drm_gbm")] -#[doc(hidden)] -pub extern crate gbm; -#[cfg(feature = "backend_libinput")] -#[doc(hidden)] -pub extern crate input; -#[cfg(feature = "backend_session_logind")] -#[doc(hidden)] -pub extern crate systemd; -#[cfg(feature = "backend_udev")] -#[doc(hidden)] -pub extern crate udev; -#[cfg(feature = "backend_winit")] -extern crate wayland_client; -#[cfg(feature = "backend_winit")] -extern crate winit; - -extern crate libloading; - -#[cfg(feature = "renderer_glium")] -extern crate glium; - #[macro_use] extern crate slog; -extern crate slog_stdlog; - #[macro_use] extern crate error_chain; - #[macro_use] extern crate lazy_static; diff --git a/src/wayland/compositor/handlers.rs b/src/wayland/compositor/handlers.rs index dab50ae..62def3a 100644 --- a/src/wayland/compositor/handlers.rs +++ b/src/wayland/compositor/handlers.rs @@ -51,7 +51,7 @@ where // Internal implementation data of surfaces pub(crate) struct SurfaceImplem { log: ::slog::Logger, - implem: Rc, CompositorToken)>>, + implem: Rc, CompositorToken)>>, } impl SurfaceImplem { diff --git a/src/wayland/data_device/dnd_grab.rs b/src/wayland/data_device/dnd_grab.rs index e775d84..4be6aeb 100644 --- a/src/wayland/data_device/dnd_grab.rs +++ b/src/wayland/data_device/dnd_grab.rs @@ -22,7 +22,7 @@ pub(crate) struct DnDGrab { offer_data: Option>>, icon: Option>, origin: Resource, - callback: Arc>, + callback: Arc>, token: CompositorToken, seat: Seat, } @@ -34,7 +34,7 @@ impl + 'static> DnDGrab { seat: Seat, icon: Option>, token: CompositorToken, - callback: Arc>, + callback: Arc>, ) -> DnDGrab { DnDGrab { data_source: source, @@ -53,7 +53,7 @@ impl + 'static> DnDGrab { impl + 'static> PointerGrab for DnDGrab { fn motion( &mut self, - _handle: &mut PointerInnerHandle, + _handle: &mut PointerInnerHandle<'_>, location: (f64, f64), focus: Option<(Resource, (f64, f64))>, serial: u32, @@ -179,7 +179,7 @@ impl + 'static> PointerGrab for DnDGrab { fn button( &mut self, - handle: &mut PointerInnerHandle, + handle: &mut PointerInnerHandle<'_>, _button: u32, _state: wl_pointer::ButtonState, serial: u32, @@ -239,7 +239,7 @@ impl + 'static> PointerGrab for DnDGrab { } } - fn axis(&mut self, handle: &mut PointerInnerHandle, details: AxisFrame) { + fn axis(&mut self, handle: &mut PointerInnerHandle<'_>, details: AxisFrame) { // we just forward the axis events as is handle.axis(details); } @@ -256,7 +256,7 @@ fn implement_dnd_data_offer( offer: NewResource, source: Resource, offer_data: Arc>, - action_choice: Arc DndAction + Send + 'static>>, + action_choice: Arc DndAction + Send + 'static>>, ) -> Resource { use self::wl_data_offer::Request; offer.implement( diff --git a/src/wayland/data_device/mod.rs b/src/wayland/data_device/mod.rs index c9eb113..6100898 100644 --- a/src/wayland/data_device/mod.rs +++ b/src/wayland/data_device/mod.rs @@ -419,8 +419,8 @@ where } struct DataDeviceData { - callback: Arc>, - action_choice: Arc DndAction + Send + 'static>>, + callback: Arc>, + action_choice: Arc DndAction + Send + 'static>>, } fn implement_data_device( diff --git a/src/wayland/data_device/server_dnd_grab.rs b/src/wayland/data_device/server_dnd_grab.rs index c885e55..ef45c03 100644 --- a/src/wayland/data_device/server_dnd_grab.rs +++ b/src/wayland/data_device/server_dnd_grab.rs @@ -67,7 +67,7 @@ where { fn motion( &mut self, - _handle: &mut PointerInnerHandle, + _handle: &mut PointerInnerHandle<'_>, location: (f64, f64), focus: Option<(Resource, (f64, f64))>, serial: u32, @@ -169,7 +169,7 @@ where fn button( &mut self, - handle: &mut PointerInnerHandle, + handle: &mut PointerInnerHandle<'_>, _button: u32, _state: wl_pointer::ButtonState, serial: u32, @@ -220,7 +220,7 @@ where } } - fn axis(&mut self, handle: &mut PointerInnerHandle, details: AxisFrame) { + fn axis(&mut self, handle: &mut PointerInnerHandle<'_>, details: AxisFrame) { // we just forward the axis events as is handle.axis(details); } @@ -238,7 +238,7 @@ fn implement_dnd_data_offer( metadata: super::SourceMetadata, offer_data: Arc>, callback: Arc>, - action_choice: Arc DndAction + Send + 'static>>, + action_choice: Arc DndAction + Send + 'static>>, ) -> Resource where C: FnMut(ServerDndEvent) + Send + 'static, diff --git a/src/wayland/seat/keyboard.rs b/src/wayland/seat/keyboard.rs index 556d34c..5ac432f 100644 --- a/src/wayland/seat/keyboard.rs +++ b/src/wayland/seat/keyboard.rs @@ -112,7 +112,7 @@ struct KbdInternal { state: xkb::State, repeat_rate: i32, repeat_delay: i32, - focus_hook: Box>)>, + focus_hook: Box>)>, } // This is OK because all parts of `xkb` will remain on the @@ -121,10 +121,10 @@ unsafe impl Send for KbdInternal {} impl KbdInternal { fn new( - xkb_config: XkbConfig, + xkb_config: XkbConfig<'_>, repeat_rate: i32, repeat_delay: i32, - focus_hook: Box>)>, + focus_hook: Box>)>, ) -> Result { // we create a new contex for each keyboard because libxkbcommon is actually NOT threadsafe // so confining it inside the KbdInternal allows us to use Rusts mutability rules to make @@ -228,7 +228,7 @@ pub enum Error { /// Create a keyboard handler from a set of RMLVO rules pub(crate) fn create_keyboard_handler( - xkb_config: XkbConfig, + xkb_config: XkbConfig<'_>, repeat_delay: i32, repeat_rate: i32, logger: &::slog::Logger, diff --git a/src/wayland/seat/mod.rs b/src/wayland/seat/mod.rs index 2e56f78..b8f3506 100644 --- a/src/wayland/seat/mod.rs +++ b/src/wayland/seat/mod.rs @@ -281,7 +281,7 @@ impl Seat { /// ``` pub fn add_keyboard( &mut self, - xkb_config: keyboard::XkbConfig, + xkb_config: keyboard::XkbConfig<'_>, repeat_delay: i32, repeat_rate: i32, mut focus_hook: F, diff --git a/src/wayland/seat/pointer.rs b/src/wayland/seat/pointer.rs index 3150577..8aba91e 100644 --- a/src/wayland/seat/pointer.rs +++ b/src/wayland/seat/pointer.rs @@ -29,7 +29,7 @@ pub enum CursorImageStatus { enum GrabStatus { None, - Active(u32, Box), + Active(u32, Box), Borrowed, } @@ -40,7 +40,7 @@ struct PointerInternal { location: (f64, f64), grab: GrabStatus, pressed_buttons: Vec, - image_callback: Box, + image_callback: Box, } impl PointerInternal { @@ -95,7 +95,7 @@ impl PointerInternal { fn with_grab(&mut self, f: F) where - F: FnOnce(PointerInnerHandle, &mut PointerGrab), + F: FnOnce(PointerInnerHandle<'_>, &mut dyn PointerGrab), { let mut grab = ::std::mem::replace(&mut self.grab, GrabStatus::Borrowed); match grab { @@ -239,7 +239,7 @@ pub trait PointerGrab: Send + Sync { /// A motion was reported fn motion( &mut self, - handle: &mut PointerInnerHandle, + handle: &mut PointerInnerHandle<'_>, location: (f64, f64), focus: Option<(Resource, (f64, f64))>, serial: u32, @@ -248,14 +248,14 @@ pub trait PointerGrab: Send + Sync { /// A button press was reported fn button( &mut self, - handle: &mut PointerInnerHandle, + handle: &mut PointerInnerHandle<'_>, button: u32, state: ButtonState, serial: u32, time: u32, ); /// An axis scroll was reported - fn axis(&mut self, handle: &mut PointerInnerHandle, details: AxisFrame); + fn axis(&mut self, handle: &mut PointerInnerHandle<'_>, details: AxisFrame); } /// This inner handle is accessed from inside a pointer grab logic, and directly @@ -644,7 +644,7 @@ struct DefaultGrab; impl PointerGrab for DefaultGrab { fn motion( &mut self, - handle: &mut PointerInnerHandle, + handle: &mut PointerInnerHandle<'_>, location: (f64, f64), focus: Option<(Resource, (f64, f64))>, serial: u32, @@ -654,7 +654,7 @@ impl PointerGrab for DefaultGrab { } fn button( &mut self, - handle: &mut PointerInnerHandle, + handle: &mut PointerInnerHandle<'_>, button: u32, state: ButtonState, serial: u32, @@ -670,7 +670,7 @@ impl PointerGrab for DefaultGrab { }, ); } - fn axis(&mut self, handle: &mut PointerInnerHandle, details: AxisFrame) { + fn axis(&mut self, handle: &mut PointerInnerHandle<'_>, details: AxisFrame) { handle.axis(details); } } @@ -688,7 +688,7 @@ struct ClickGrab { impl PointerGrab for ClickGrab { fn motion( &mut self, - handle: &mut PointerInnerHandle, + handle: &mut PointerInnerHandle<'_>, location: (f64, f64), focus: Option<(Resource, (f64, f64))>, serial: u32, @@ -700,7 +700,7 @@ impl PointerGrab for ClickGrab { } fn button( &mut self, - handle: &mut PointerInnerHandle, + handle: &mut PointerInnerHandle<'_>, button: u32, state: ButtonState, serial: u32, @@ -712,7 +712,7 @@ impl PointerGrab for ClickGrab { handle.unset_grab(serial, time); } } - fn axis(&mut self, handle: &mut PointerInnerHandle, details: AxisFrame) { + fn axis(&mut self, handle: &mut PointerInnerHandle<'_>, details: AxisFrame) { handle.axis(details); } } diff --git a/src/wayland/shell/xdg/mod.rs b/src/wayland/shell/xdg/mod.rs index 632a75c..4f0dca8 100644 --- a/src/wayland/shell/xdg/mod.rs +++ b/src/wayland/shell/xdg/mod.rs @@ -263,7 +263,7 @@ pub(crate) struct ShellData { log: ::slog::Logger, compositor_token: CompositorToken, display_token: DisplayToken, - user_impl: Rc)>>, + user_impl: Rc)>>, shell_state: Arc>>, } diff --git a/src/xwayland/xserver.rs b/src/xwayland/xserver.rs index fb76835..524cb04 100644 --- a/src/xwayland/xserver.rs +++ b/src/xwayland/xserver.rs @@ -127,7 +127,7 @@ struct XWaylandInstance { // Inner implementation of the XWayland manager struct Inner { wm: WM, - source_maker: Box>>) -> Result, ()>>, + source_maker: Box>>) -> Result, ()>>, wayland_display: Rc>, instance: Option, log: ::slog::Logger, From cc5d55f5354c93755b6949b49f3178aa5eecfc8b Mon Sep 17 00:00:00 2001 From: Victor Brekenfeld Date: Sat, 15 Dec 2018 22:01:24 +0100 Subject: [PATCH 3/3] rustfmt fixes --- anvil/src/glium_drawer.rs | 8 ++++---- anvil/src/input_handler.rs | 2 +- anvil/src/shell.rs | 8 ++++---- anvil/src/shm_load.rs | 2 +- anvil/src/window_map.rs | 2 +- anvil/src/winit.rs | 2 +- src/wayland/shell/xdg/mod.rs | 4 ++-- 7 files changed, 14 insertions(+), 14 deletions(-) diff --git a/anvil/src/glium_drawer.rs b/anvil/src/glium_drawer.rs index 1f17b5d..dc05b67 100644 --- a/anvil/src/glium_drawer.rs +++ b/anvil/src/glium_drawer.rs @@ -18,16 +18,16 @@ use smithay::{ egl::{BufferAccessError, EGLImages, Format}, graphics::{gl::GLGraphicsBackend, glium::GliumGraphicsBackend}, }, + reexports::wayland_server::{ + protocol::{wl_buffer, wl_surface}, + Resource, + }, wayland::{ compositor::{roles::Role, SubsurfaceRole, TraversalAction}, data_device::DnDIconRole, seat::CursorImageRole, shm::with_buffer_contents as shm_buffer_contents, }, - reexports::wayland_server::{ - protocol::{wl_buffer, wl_surface}, - Resource, - }, }; use crate::shaders; diff --git a/anvil/src/input_handler.rs b/anvil/src/input_handler.rs index 96d495b..78a8172 100644 --- a/anvil/src/input_handler.rs +++ b/anvil/src/input_handler.rs @@ -17,11 +17,11 @@ use smithay::{ self, Event, InputBackend, InputHandler, KeyState, KeyboardKeyEvent, PointerAxisEvent, PointerButtonEvent, PointerMotionAbsoluteEvent, PointerMotionEvent, }, + reexports::wayland_server::protocol::wl_pointer, wayland::{ seat::{keysyms as xkb, AxisFrame, KeyboardHandle, Keysym, ModifiersState, PointerHandle}, SERIAL_COUNTER as SCOUNTER, }, - reexports::wayland_server::protocol::wl_pointer, }; use crate::shell::MyWindowMap; diff --git a/anvil/src/shell.rs b/anvil/src/shell.rs index f96a5f0..9e6fe7c 100644 --- a/anvil/src/shell.rs +++ b/anvil/src/shell.rs @@ -7,6 +7,10 @@ use std::{ use rand; use smithay::{ + reexports::wayland_server::{ + protocol::{wl_buffer, wl_callback, wl_shell_surface, wl_surface}, + Display, Resource, + }, wayland::{ compositor::{compositor_init, CompositorToken, SurfaceAttributes, SurfaceEvent}, data_device::DnDIconRole, @@ -21,10 +25,6 @@ use smithay::{ }, }, }, - reexports::wayland_server::{ - protocol::{wl_buffer, wl_callback, wl_shell_surface, wl_surface}, - Display, Resource, - }, }; use crate::window_map::{Kind as SurfaceKind, WindowMap}; diff --git a/anvil/src/shm_load.rs b/anvil/src/shm_load.rs index 38283b5..1a9f26e 100644 --- a/anvil/src/shm_load.rs +++ b/anvil/src/shm_load.rs @@ -1,6 +1,6 @@ use std::borrow::Cow; -use smithay::{wayland::shm::BufferData, reexports::wayland_server::protocol::wl_shm::Format}; +use smithay::{reexports::wayland_server::protocol::wl_shm::Format, wayland::shm::BufferData}; use glium::texture::{ClientFormat, RawImage2d}; diff --git a/anvil/src/window_map.rs b/anvil/src/window_map.rs index 9069c88..5c54f68 100644 --- a/anvil/src/window_map.rs +++ b/anvil/src/window_map.rs @@ -1,4 +1,5 @@ use smithay::{ + reexports::wayland_server::{protocol::wl_surface, Resource}, utils::Rectangle, wayland::{ compositor::{roles::Role, CompositorToken, SubsurfaceRole, SurfaceAttributes, TraversalAction}, @@ -7,7 +8,6 @@ use smithay::{ xdg::{ToplevelSurface, XdgSurfaceRole}, }, }, - reexports::wayland_server::{protocol::wl_surface, Resource}, }; pub enum Kind { diff --git a/anvil/src/winit.rs b/anvil/src/winit.rs index 9b5e04a..59cd608 100644 --- a/anvil/src/winit.rs +++ b/anvil/src/winit.rs @@ -6,13 +6,13 @@ use std::{ use smithay::{ backend::{egl::EGLGraphicsBackend, graphics::gl::GLGraphicsBackend, input::InputBackend, winit}, + reexports::wayland_server::{calloop::EventLoop, protocol::wl_output, Display}, wayland::{ data_device::{default_action_chooser, init_data_device, set_data_device_focus, DataDeviceEvent}, output::{Mode, Output, PhysicalProperties}, seat::{CursorImageStatus, Seat, XkbConfig}, shm::init_shm_global, }, - reexports::wayland_server::{calloop::EventLoop, protocol::wl_output, Display}, }; use slog::Logger; diff --git a/src/wayland/shell/xdg/mod.rs b/src/wayland/shell/xdg/mod.rs index 4f0dca8..5ac3ee2 100644 --- a/src/wayland/shell/xdg/mod.rs +++ b/src/wayland/shell/xdg/mod.rs @@ -90,13 +90,13 @@ //! the subhandler you provided, or via methods on the [`ShellState`](::wayland::shell::xdg::ShellState) //! that you are given (in an `Arc>`) as return value of the `init` function. +use crate::utils::Rectangle; +use crate::wayland::compositor::{roles::Role, CompositorToken}; use std::{ cell::RefCell, rc::Rc, sync::{Arc, Mutex}, }; -use crate::utils::Rectangle; -use crate::wayland::compositor::{roles::Role, CompositorToken}; use wayland_protocols::{ unstable::xdg_shell::v6::server::{zxdg_popup_v6, zxdg_shell_v6, zxdg_surface_v6, zxdg_toplevel_v6}, xdg_shell::server::{xdg_popup, xdg_positioner, xdg_surface, xdg_toplevel, xdg_wm_base},