diff --git a/build.rs b/build.rs index 2ea7864..700499f 100644 --- a/build.rs +++ b/build.rs @@ -1,9 +1,7 @@ extern crate gl_generator; use gl_generator::{Api, Fallbacks, Profile, Registry}; -use std::env; -use std::fs::File; -use std::path::PathBuf; +use std::{env, fs::File, path::PathBuf}; fn main() { let dest = PathBuf::from(&env::var("OUT_DIR").unwrap()); diff --git a/src/backend/drm/backend.rs b/src/backend/drm/backend.rs index 9779bc6..6abd4bb 100644 --- a/src/backend/drm/backend.rs +++ b/src/backend/drm/backend.rs @@ -1,22 +1,28 @@ -use super::error::*; -use super::DevPath; -use backend::graphics::egl::error::Result as EGLResult; -use backend::graphics::egl::native::{Gbm, GbmSurfaceArguments}; -use backend::graphics::egl::wayland::{EGLDisplay, EGLWaylandExtensions}; -use backend::graphics::egl::{EGLContext, EGLGraphicsBackend, EGLSurface, PixelFormat, SwapBuffersError}; -use backend::graphics::GraphicsBackend; -use drm::control::{connector, crtc, encoder, framebuffer, Mode}; -use drm::control::{Device, ResourceInfo}; -use drm::Device as BasicDevice; +use super::{error::*, DevPath}; +use backend::graphics::{ + egl::{ + error::Result as EGLResult, + native::{Gbm, GbmSurfaceArguments}, + wayland::{EGLDisplay, EGLWaylandExtensions}, + EGLContext, EGLGraphicsBackend, EGLSurface, PixelFormat, SwapBuffersError, + }, + GraphicsBackend, +}; +use drm::{ + control::{connector, crtc, encoder, framebuffer, Device, Mode, ResourceInfo}, + Device as BasicDevice, +}; use gbm::{ BufferObject, BufferObjectFlags, Device as GbmDevice, Format as GbmFormat, Surface as GbmSurface, SurfaceBufferHandle, }; use image::{ImageBuffer, Rgba}; use nix::libc::c_void; -use std::cell::Cell; -use std::os::unix::io::{AsRawFd, RawFd}; -use std::rc::{Rc, Weak}; +use std::{ + cell::Cell, + os::unix::io::{AsRawFd, RawFd}, + rc::{Rc, Weak}, +}; use wayland_server::Display; /// Backend based on a `DrmDevice` and a given crtc diff --git a/src/backend/drm/mod.rs b/src/backend/drm/mod.rs index 3a216b1..ddd3f00 100644 --- a/src/backend/drm/mod.rs +++ b/src/backend/drm/mod.rs @@ -209,41 +209,52 @@ //! # } //! ``` -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::{EGLDisplay, EGLWaylandExtensions}; +use backend::graphics::egl::{ + context::{EGLContext, GlAttributes}, + error::Result as EGLResult, + native::Gbm, + wayland::{EGLDisplay, EGLWaylandExtensions}, +}; #[cfg(feature = "backend_session")] use backend::session::{AsSessionObserver, SessionObserver}; -use drm::control::framebuffer; -use drm::control::Device as ControlDevice; -use drm::control::{connector, crtc, encoder, Mode, ResourceInfo}; -use drm::result::Error as DrmError; -use drm::Device as BasicDevice; +use drm::{ + control::{connector, crtc, encoder, framebuffer, Device as ControlDevice, Mode, ResourceInfo}, + result::Error as DrmError, + Device as BasicDevice, +}; use gbm::{BufferObject, Device as GbmDevice}; -use nix; -use nix::sys::stat::{self, dev_t, fstat}; -use std::cell::RefCell; -use std::collections::HashMap; -use std::hash::{Hash, Hasher}; -use std::io::Error as IoError; -use std::os::unix::io::{AsRawFd, RawFd}; -use std::path::PathBuf; -use std::rc::{Rc, Weak}; -use std::sync::atomic::{AtomicBool, Ordering}; -use std::sync::{Arc, Once, ONCE_INIT}; -use std::time::Duration; +use nix::{ + self, + sys::stat::{self, dev_t, fstat}, +}; +use std::{ + cell::RefCell, + collections::HashMap, + hash::{Hash, Hasher}, + io::Error as IoError, + os::unix::io::{AsRawFd, RawFd}, + path::PathBuf, + rc::{Rc, Weak}, + sync::{ + atomic::{AtomicBool, Ordering}, + Arc, Once, ONCE_INIT, + }, + time::Duration, +}; -use wayland_server::calloop::generic::{EventedRawFd, Generic}; -use wayland_server::calloop::{LoopHandle, Ready, Source}; -use wayland_server::Display; +use wayland_server::{ + calloop::{ + generic::{EventedRawFd, Generic}, + LoopHandle, Ready, Source, + }, + Display, +}; mod backend; pub mod error; pub use self::backend::DrmBackend; -use self::backend::DrmBackendInternal; -use self::error::*; +use self::{backend::DrmBackendInternal, error::*}; static LOAD: Once = ONCE_INIT; diff --git a/src/backend/graphics/egl/context.rs b/src/backend/graphics/egl/context.rs index 26ef24d..af02410 100644 --- a/src/backend/graphics/egl/context.rs +++ b/src/backend/graphics/egl/context.rs @@ -1,8 +1,6 @@ //! EGL context related structs -use super::error::*; -use super::native; -use super::{ffi, EGLSurface, PixelFormat}; +use super::{error::*, ffi, native, EGLSurface, PixelFormat}; #[cfg(feature = "backend_drm")] use drm::control::Device as ControlDevice; #[cfg(feature = "backend_drm")] @@ -11,14 +9,16 @@ use drm::Device as BasicDevice; use gbm::Device as GbmDevice; use nix::libc::{c_int, c_void}; use slog; -use std::ffi::{CStr, CString}; -use std::marker::PhantomData; -use std::mem; -use std::ops::{Deref, DerefMut}; #[cfg(feature = "backend_drm")] use std::os::unix::io::{AsRawFd, RawFd}; -use std::ptr; -use std::rc::Rc; +use std::{ + ffi::{CStr, CString}, + marker::PhantomData, + mem, + ops::{Deref, DerefMut}, + ptr, + rc::Rc, +}; /// EGL context for rendering pub struct EGLContext> { diff --git a/src/backend/graphics/egl/ffi.rs b/src/backend/graphics/egl/ffi.rs index edc8e27..f5ace9f 100644 --- a/src/backend/graphics/egl/ffi.rs +++ b/src/backend/graphics/egl/ffi.rs @@ -81,8 +81,7 @@ pub mod egl { } mod wayland_storage { - use super::FnPtr; - use super::__gl_imports::raw; + use super::{FnPtr, __gl_imports::raw}; pub static mut BindWaylandDisplayWL: FnPtr = FnPtr { f: super::missing_fn_panic as *const raw::c_void, is_loaded: false, @@ -99,9 +98,7 @@ pub mod egl { #[allow(non_snake_case)] pub mod BindWaylandDisplayWL { - use super::FnPtr; - use super::__gl_imports::raw; - use super::{metaloadfn, wayland_storage}; + use super::{FnPtr, __gl_imports::raw, metaloadfn, wayland_storage}; #[inline] #[allow(dead_code)] @@ -123,9 +120,7 @@ pub mod egl { #[allow(non_snake_case)] pub mod UnbindWaylandDisplayWL { - use super::FnPtr; - use super::__gl_imports::raw; - use super::{metaloadfn, wayland_storage}; + use super::{FnPtr, __gl_imports::raw, metaloadfn, wayland_storage}; #[inline] #[allow(dead_code)] @@ -147,9 +142,7 @@ pub mod egl { #[allow(non_snake_case)] pub mod QueryWaylandBufferWL { - use super::FnPtr; - use super::__gl_imports::raw; - use super::{metaloadfn, wayland_storage}; + use super::{FnPtr, __gl_imports::raw, metaloadfn, wayland_storage}; #[inline] #[allow(dead_code)] diff --git a/src/backend/graphics/egl/native.rs b/src/backend/graphics/egl/native.rs index 24380cd..12744f7 100644 --- a/src/backend/graphics/egl/native.rs +++ b/src/backend/graphics/egl/native.rs @@ -1,7 +1,6 @@ //! Type safe native types for safe context/surface creation -use super::error::*; -use super::ffi; +use super::{error::*, ffi}; #[cfg(feature = "backend_drm")] use backend::drm::error::{Error as DrmError, ErrorKind as DrmErrorKind, Result as DrmResult}; #[cfg(feature = "backend_drm")] diff --git a/src/backend/graphics/egl/surface.rs b/src/backend/graphics/egl/surface.rs index b9bc87d..ed8415d 100644 --- a/src/backend/graphics/egl/surface.rs +++ b/src/backend/graphics/egl/surface.rs @@ -1,11 +1,10 @@ //! EGL surface related structs -use super::error::*; -use super::ffi; -use super::native; -use super::{EGLContext, SwapBuffersError}; -use std::ops::{Deref, DerefMut}; -use std::rc::{Rc, Weak}; +use super::{error::*, ffi, native, EGLContext, SwapBuffersError}; +use std::{ + ops::{Deref, DerefMut}, + rc::{Rc, Weak}, +}; /// EGL surface of a given egl context for rendering pub struct EGLSurface { diff --git a/src/backend/graphics/egl/wayland.rs b/src/backend/graphics/egl/wayland.rs index adf4c4e..a2a6cd1 100644 --- a/src/backend/graphics/egl/wayland.rs +++ b/src/backend/graphics/egl/wayland.rs @@ -10,14 +10,20 @@ //! You may then use the resulting `EGLDisplay` to recieve `EGLImages` of an egl-based `WlBuffer` //! for rendering. -use backend::graphics::egl::error::*; -use backend::graphics::egl::ffi::egl::types::EGLImage; -use backend::graphics::egl::{ffi, native, EGLContext, EglExtensionNotSupportedError}; +use backend::graphics::egl::{ + error::*, + ffi::{self, egl::types::EGLImage}, + native, EGLContext, EglExtensionNotSupportedError, +}; use nix::libc::c_uint; -use std::fmt; -use std::rc::{Rc, Weak}; -use wayland_server::protocol::wl_buffer::{self, WlBuffer}; -use wayland_server::{Display, Resource}; +use std::{ + fmt, + rc::{Rc, Weak}, +}; +use wayland_server::{ + protocol::wl_buffer::{self, WlBuffer}, + Display, Resource, +}; use wayland_sys::server::wl_display; /// Error that can occur when accessing an EGL buffer diff --git a/src/backend/graphics/glium.rs b/src/backend/graphics/glium.rs index 3a44bbd..ff8fd35 100644 --- a/src/backend/graphics/glium.rs +++ b/src/backend/graphics/glium.rs @@ -1,15 +1,20 @@ //! Glium compatibility module -use backend::graphics::egl::error::Result as EGLResult; -use backend::graphics::egl::wayland::{EGLDisplay, EGLWaylandExtensions}; -use backend::graphics::egl::{EGLGraphicsBackend, SwapBuffersError}; -use glium::backend::{Backend, Context, Facade}; -use glium::debug::DebugCallbackBehavior; -use glium::Frame; -use glium::SwapBuffersError as GliumSwapBuffersError; -use std::cell::{Ref, RefCell, RefMut}; -use std::os::raw::c_void; -use std::rc::Rc; +use backend::graphics::egl::{ + error::Result as EGLResult, + wayland::{EGLDisplay, EGLWaylandExtensions}, + EGLGraphicsBackend, SwapBuffersError, +}; +use glium::{ + backend::{Backend, Context, Facade}, + debug::DebugCallbackBehavior, + Frame, SwapBuffersError as GliumSwapBuffersError, +}; +use std::{ + cell::{Ref, RefCell, RefMut}, + os::raw::c_void, + rc::Rc, +}; use wayland_server::Display; impl From for GliumSwapBuffersError { diff --git a/src/backend/input.rs b/src/backend/input.rs index 180ab09..760270b 100644 --- a/src/backend/input.rs +++ b/src/backend/input.rs @@ -1,7 +1,6 @@ //! Common traits for input backends to receive input from. -use std::error::Error; -use std::string::ToString; +use std::{error::Error, string::ToString}; /// A seat describes a group of input devices and at least one /// graphics device belonging together. diff --git a/src/backend/libinput.rs b/src/backend/libinput.rs index f29a344..d3c0985 100644 --- a/src/backend/libinput.rs +++ b/src/backend/libinput.rs @@ -1,22 +1,25 @@ //! Implementation of input backend trait for types provided by `libinput` -use backend::input as backend; -use backend::input::Axis; #[cfg(feature = "backend_session")] use backend::session::{AsErrno, Session, SessionObserver}; +use backend::{input as backend, input::Axis}; use input as libinput; use input::event; -use std::cell::RefCell; -use std::collections::hash_map::{DefaultHasher, Entry, HashMap}; -use std::hash::{Hash, Hasher}; -use std::io::Error as IoError; -use std::os::unix::io::RawFd; -use std::path::Path; -use std::rc::Rc; +use std::{ + cell::RefCell, + collections::hash_map::{DefaultHasher, Entry, HashMap}, + hash::{Hash, Hasher}, + io::Error as IoError, + os::unix::io::RawFd, + path::Path, + rc::Rc, +}; -use wayland_server::calloop::generic::{EventedRawFd, Generic}; -use wayland_server::calloop::{LoopHandle, Ready, Source}; +use wayland_server::calloop::{ + generic::{EventedRawFd, Generic}, + LoopHandle, Ready, Source, +}; // No idea if this is the same across unix platforms // Lets make this linux exclusive for now, once someone tries to build it for diff --git a/src/backend/session/auto.rs b/src/backend/session/auto.rs index 652d11b..8ff70a8 100644 --- a/src/backend/session/auto.rs +++ b/src/backend/session/auto.rs @@ -28,16 +28,14 @@ //! automatically by the `UdevBackend`, if not done manually). //! ``` -use super::direct::{self, direct_session_bind, BoundDirectSession, DirectSession, DirectSessionNotifier}; #[cfg(feature = "backend_session_logind")] use super::logind::{self, logind_session_bind, BoundLogindSession, LogindSession, LogindSessionNotifier}; -use super::{AsErrno, AsSessionObserver, Session, SessionNotifier, SessionObserver}; +use super::{ + direct::{self, direct_session_bind, BoundDirectSession, DirectSession, DirectSessionNotifier}, + AsErrno, AsSessionObserver, Session, SessionNotifier, SessionObserver, +}; use nix::fcntl::OFlag; -use std::cell::RefCell; -use std::io::Error as IoError; -use std::os::unix::io::RawFd; -use std::path::Path; -use std::rc::Rc; +use std::{cell::RefCell, io::Error as IoError, os::unix::io::RawFd, path::Path, rc::Rc}; use wayland_server::calloop::LoopHandle; diff --git a/src/backend/session/dbus/logind.rs b/src/backend/session/dbus/logind.rs index 625802c..a46a3ab 100644 --- a/src/backend/session/dbus/logind.rs +++ b/src/backend/session/dbus/logind.rs @@ -35,18 +35,24 @@ use dbus::{ BusName, BusType, Connection, ConnectionItem, ConnectionItems, Interface, Member, Message, MessageItem, OwnedFd, Path as DbusPath, Watch, WatchEvent, }; -use nix::fcntl::OFlag; -use nix::sys::stat::{fstat, major, minor, stat}; -use std::cell::RefCell; -use std::io::Error as IoError; -use std::os::unix::io::RawFd; -use std::path::Path; -use std::rc::{Rc, Weak}; -use std::sync::atomic::{AtomicBool, Ordering}; +use nix::{ + fcntl::OFlag, + sys::stat::{fstat, major, minor, stat}, +}; +use std::{ + cell::RefCell, + io::Error as IoError, + os::unix::io::RawFd, + path::Path, + rc::{Rc, Weak}, + sync::atomic::{AtomicBool, Ordering}, +}; use systemd::login; -use wayland_server::calloop::generic::{Event, EventedRawFd, Generic}; -use wayland_server::calloop::{LoopHandle, Ready, Source}; +use wayland_server::calloop::{ + generic::{Event, EventedRawFd, Generic}, + LoopHandle, Ready, Source, +}; struct LogindSessionImpl { conn: RefCell, diff --git a/src/backend/session/direct.rs b/src/backend/session/direct.rs index c987e13..63dfa9a 100644 --- a/src/backend/session/direct.rs +++ b/src/backend/session/direct.rs @@ -46,23 +46,30 @@ //! automatically by the `UdevBackend`, if not done manually). use super::{AsErrno, AsSessionObserver, Session, SessionNotifier, SessionObserver}; -use nix::fcntl::{self, open, OFlag}; -use nix::libc::c_int; -use nix::sys::signal::{self, Signal}; -use nix::sys::stat::{dev_t, fstat, major, minor, Mode}; -use nix::unistd::{close, dup}; -use nix::{Error as NixError, Result as NixResult}; -use std::cell::RefCell; -use std::io::Error as IoError; -use std::os::unix::io::RawFd; -use std::path::Path; -use std::rc::Rc; -use std::sync::atomic::{AtomicBool, Ordering}; -use std::sync::Arc; +use nix::{ + fcntl::{self, open, OFlag}, + libc::c_int, + sys::{ + signal::{self, Signal}, + stat::{dev_t, fstat, major, minor, Mode}, + }, + unistd::{close, dup}, + Error as NixError, Result as NixResult, +}; +use std::{ + cell::RefCell, + io::Error as IoError, + os::unix::io::RawFd, + path::Path, + rc::Rc, + sync::{ + atomic::{AtomicBool, Ordering}, + Arc, + }, +}; #[cfg(feature = "backend_session_udev")] use udev::Context; -use wayland_server::calloop::signals::Signals; -use wayland_server::calloop::{LoopHandle, Source}; +use wayland_server::calloop::{signals::Signals, LoopHandle, Source}; #[allow(dead_code)] mod tty { diff --git a/src/backend/session/mod.rs b/src/backend/session/mod.rs index 23d0ea3..a116e35 100644 --- a/src/backend/session/mod.rs +++ b/src/backend/session/mod.rs @@ -11,11 +11,13 @@ //! - direct - legacy tty / virtual terminal kernel api //! use nix::fcntl::OFlag; -use std::cell::RefCell; -use std::os::unix::io::RawFd; -use std::path::Path; -use std::rc::Rc; -use std::sync::{Arc, Mutex}; +use std::{ + cell::RefCell, + os::unix::io::RawFd, + path::Path, + rc::Rc, + sync::{Arc, Mutex}, +}; /// General session interface. /// diff --git a/src/backend/udev.rs b/src/backend/udev.rs index 4bfcc60..4970f49 100644 --- a/src/backend/udev.rs +++ b/src/backend/udev.rs @@ -9,24 +9,28 @@ //! See also `examples/udev.rs` for pure hardware backed example of a compositor utilizing this //! backend. -use backend::drm::{drm_device_bind, DrmDevice, DrmHandler}; -use backend::session::{AsSessionObserver, Session, SessionObserver}; -use drm::control::Device as ControlDevice; -use drm::Device as BasicDevice; -use nix::fcntl; -use nix::sys::stat::dev_t; -use std::cell::RefCell; -use std::collections::HashMap; -use std::ffi::OsString; -use std::io::Error as IoError; -use std::mem::drop; -use std::os::unix::io::{AsRawFd, RawFd}; -use std::path::{Path, PathBuf}; -use std::rc::{Rc, Weak}; +use backend::{ + drm::{drm_device_bind, DrmDevice, DrmHandler}, + session::{AsSessionObserver, Session, SessionObserver}, +}; +use drm::{control::Device as ControlDevice, Device as BasicDevice}; +use nix::{fcntl, sys::stat::dev_t}; +use std::{ + cell::RefCell, + collections::HashMap, + ffi::OsString, + io::Error as IoError, + mem::drop, + os::unix::io::{AsRawFd, RawFd}, + path::{Path, PathBuf}, + rc::{Rc, Weak}, +}; use udev::{Context, Enumerator, Event, EventType, MonitorBuilder, MonitorSocket, Result as UdevResult}; -use wayland_server::calloop::generic::{EventedRawFd, Generic}; -use wayland_server::calloop::{LoopHandle, Ready, Source}; +use wayland_server::calloop::{ + generic::{EventedRawFd, Generic}, + LoopHandle, Ready, Source, +}; /// Udev's `DrmDevice` type based on the underlying session pub struct SessionFdDrmDevice(RawFd); diff --git a/src/backend/winit.rs b/src/backend/winit.rs index 4976935..9ec9b9a 100644 --- a/src/backend/winit.rs +++ b/src/backend/winit.rs @@ -1,28 +1,30 @@ //! Implementation of backend traits for types provided by `winit` -use backend::graphics::egl::context::GlAttributes; -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::wayland::{EGLDisplay, EGLWaylandExtensions}; -use backend::graphics::egl::{EGLContext, EGLGraphicsBackend, EGLSurface, PixelFormat, SwapBuffersError}; -use backend::graphics::GraphicsBackend; -use backend::input::{ - Axis, AxisSource, Event as BackendEvent, InputBackend, InputHandler, KeyState, KeyboardKeyEvent, - MouseButton, MouseButtonState, PointerAxisEvent, PointerButtonEvent, PointerMotionAbsoluteEvent, Seat, - SeatCapabilities, TouchCancelEvent, TouchDownEvent, TouchMotionEvent, TouchSlot, TouchUpEvent, - UnusedEvent, +use backend::{ + graphics::{ + egl::{ + context::GlAttributes, + error as egl_error, + error::Result as EGLResult, + native, + wayland::{EGLDisplay, EGLWaylandExtensions}, + EGLContext, EGLGraphicsBackend, EGLSurface, PixelFormat, SwapBuffersError, + }, + GraphicsBackend, + }, + input::{ + Axis, AxisSource, Event as BackendEvent, InputBackend, InputHandler, KeyState, KeyboardKeyEvent, + MouseButton, MouseButtonState, PointerAxisEvent, PointerButtonEvent, PointerMotionAbsoluteEvent, + Seat, SeatCapabilities, TouchCancelEvent, TouchDownEvent, TouchMotionEvent, TouchSlot, TouchUpEvent, + UnusedEvent, + }, }; use nix::libc::c_void; -use std::cmp; -use std::error; -use std::fmt; -use std::rc::Rc; -use std::time::Instant; +use std::{cmp, error, fmt, rc::Rc, time::Instant}; use wayland_client::egl as wegl; use wayland_server::Display; -use winit::dpi::{LogicalPosition, LogicalSize}; use winit::{ + dpi::{LogicalPosition, LogicalSize}, ElementState, Event, EventsLoop, KeyboardInput, MouseButton as WinitMouseButton, MouseCursor, MouseScrollDelta, Touch, TouchPhase, Window as WinitWindow, WindowBuilder, WindowEvent, }; diff --git a/src/wayland/compositor/handlers.rs b/src/wayland/compositor/handlers.rs index 367489f..dab50ae 100644 --- a/src/wayland/compositor/handlers.rs +++ b/src/wayland/compositor/handlers.rs @@ -1,12 +1,12 @@ -use std::cell::RefCell; -use std::rc::Rc; -use std::sync::Mutex; +use std::{cell::RefCell, rc::Rc, sync::Mutex}; -use wayland_server::protocol::{wl_compositor, wl_region, wl_subcompositor, wl_subsurface, wl_surface}; -use wayland_server::{DisplayToken, NewResource, Resource}; +use wayland_server::{ + protocol::{wl_compositor, wl_region, wl_subcompositor, wl_subsurface, wl_surface}, + DisplayToken, NewResource, Resource, +}; -use super::tree::{Location, SurfaceData}; use super::{ + tree::{Location, SurfaceData}, CompositorToken, Damage, Rectangle, RectangleKind, RegionAttributes, Role, RoleType, SubsurfaceRole, SurfaceEvent, }; diff --git a/src/wayland/compositor/mod.rs b/src/wayland/compositor/mod.rs index 2d70ad2..450939b 100644 --- a/src/wayland/compositor/mod.rs +++ b/src/wayland/compositor/mod.rs @@ -76,23 +76,24 @@ //! This `CompositorToken` also provides access to the metadata associated with the role of the //! surfaces. See the documentation of the `roles` submodule for a detailed explanation. -use std::cell::RefCell; -use std::rc::Rc; -use std::sync::Mutex; +use std::{cell::RefCell, rc::Rc, sync::Mutex}; mod handlers; pub mod roles; mod tree; -use self::roles::{Role, RoleType, WrongRole}; -use self::tree::SurfaceData; pub use self::tree::TraversalAction; -use utils::Rectangle; -use wayland_server::protocol::wl_surface::WlSurface; -use wayland_server::protocol::{ - wl_buffer, wl_callback, wl_compositor, wl_output, wl_region, wl_subcompositor, +use self::{ + roles::{Role, RoleType, WrongRole}, + tree::SurfaceData, +}; +use utils::Rectangle; +use wayland_server::{ + protocol::{ + wl_buffer, wl_callback, wl_compositor, wl_output, wl_region, wl_subcompositor, wl_surface::WlSurface, + }, + Display, Global, NewResource, Resource, }; -use wayland_server::{Display, Global, NewResource, Resource}; /// Description of which part of a surface /// should be considered damaged and needs to be redrawn diff --git a/src/wayland/compositor/tree.rs b/src/wayland/compositor/tree.rs index f69701e..1c0d97a 100644 --- a/src/wayland/compositor/tree.rs +++ b/src/wayland/compositor/tree.rs @@ -1,8 +1,6 @@ -use super::roles::*; -use super::{SubsurfaceRole, SurfaceAttributes}; +use super::{roles::*, SubsurfaceRole, SurfaceAttributes}; use std::sync::Mutex; -use wayland_server::protocol::wl_surface::WlSurface; -use wayland_server::Resource; +use wayland_server::{protocol::wl_surface::WlSurface, Resource}; /// Node of a subsurface tree, holding some user specified data type U /// at each node diff --git a/src/wayland/output/mod.rs b/src/wayland/output/mod.rs index 95092a5..5d4e6ca 100644 --- a/src/wayland/output/mod.rs +++ b/src/wayland/output/mod.rs @@ -53,9 +53,11 @@ use std::sync::{Arc, Mutex}; -use wayland_server::protocol::wl_output::{Event, Mode as WMode, Request, WlOutput}; pub use wayland_server::protocol::wl_output::{Subpixel, Transform}; -use wayland_server::{Display, Global, NewResource, Resource}; +use wayland_server::{ + protocol::wl_output::{Event, Mode as WMode, Request, WlOutput}, + Display, Global, NewResource, Resource, +}; /// An output mode /// diff --git a/src/wayland/seat/keyboard.rs b/src/wayland/seat/keyboard.rs index 3e66331..1a69f75 100644 --- a/src/wayland/seat/keyboard.rs +++ b/src/wayland/seat/keyboard.rs @@ -1,14 +1,18 @@ use backend::input::KeyState; -use std::default::Default; -use std::io::{Error as IoError, Write}; -use std::os::unix::io::AsRawFd; -use std::sync::{Arc, Mutex}; -use tempfile::tempfile; -use wayland_server::protocol::wl_keyboard::{ - Event, KeyState as WlKeyState, KeymapFormat, Request, WlKeyboard, +use std::{ + default::Default, + io::{Error as IoError, Write}, + os::unix::io::AsRawFd, + sync::{Arc, Mutex}, +}; +use tempfile::tempfile; +use wayland_server::{ + protocol::{ + wl_keyboard::{Event, KeyState as WlKeyState, KeymapFormat, Request, WlKeyboard}, + wl_surface::WlSurface, + }, + NewResource, Resource, }; -use wayland_server::protocol::wl_surface::WlSurface; -use wayland_server::{NewResource, Resource}; use xkbcommon::xkb; pub use xkbcommon::xkb::{keysyms, Keysym}; diff --git a/src/wayland/seat/mod.rs b/src/wayland/seat/mod.rs index 8542873..68d2860 100644 --- a/src/wayland/seat/mod.rs +++ b/src/wayland/seat/mod.rs @@ -59,12 +59,11 @@ use std::sync::{Arc, Mutex}; mod keyboard; mod pointer; -pub use self::keyboard::{ - keysyms, Error as KeyboardError, KeyboardHandle, Keysym, ModifiersState, XkbConfig, +pub use self::{ + keyboard::{keysyms, Error as KeyboardError, KeyboardHandle, Keysym, ModifiersState, XkbConfig}, + pointer::{PointerAxisHandle, PointerHandle}, }; -pub use self::pointer::{PointerAxisHandle, PointerHandle}; -use wayland_server::protocol::wl_seat; -use wayland_server::{Display, Global, NewResource, Resource}; +use wayland_server::{protocol::wl_seat, Display, Global, NewResource, Resource}; struct Inner { log: ::slog::Logger, diff --git a/src/wayland/seat/pointer.rs b/src/wayland/seat/pointer.rs index b20bb33..fbccada 100644 --- a/src/wayland/seat/pointer.rs +++ b/src/wayland/seat/pointer.rs @@ -1,7 +1,11 @@ use std::sync::{Arc, Mutex, MutexGuard}; -use wayland_server::protocol::wl_pointer::{Axis, AxisSource, ButtonState, Event, Request, WlPointer}; -use wayland_server::protocol::wl_surface::WlSurface; -use wayland_server::{NewResource, Resource}; +use wayland_server::{ + protocol::{ + wl_pointer::{Axis, AxisSource, ButtonState, Event, Request, WlPointer}, + wl_surface::WlSurface, + }, + NewResource, Resource, +}; // TODO: handle pointer surface role diff --git a/src/wayland/shell/legacy/mod.rs b/src/wayland/shell/legacy/mod.rs index 93bbb61..df57455 100644 --- a/src/wayland/shell/legacy/mod.rs +++ b/src/wayland/shell/legacy/mod.rs @@ -70,15 +70,18 @@ //! # } //! ``` -use std::cell::RefCell; -use std::rc::Rc; -use std::sync::{Arc, Mutex}; +use std::{ + cell::RefCell, + rc::Rc, + sync::{Arc, Mutex}, +}; -use wayland::compositor::roles::Role; -use wayland::compositor::CompositorToken; +use wayland::compositor::{roles::Role, CompositorToken}; -use wayland_server::protocol::{wl_output, wl_seat, wl_shell, wl_shell_surface, wl_surface}; -use wayland_server::{Display, Global, Resource}; +use wayland_server::{ + protocol::{wl_output, wl_seat, wl_shell, wl_shell_surface, wl_surface}, + Display, Global, Resource, +}; mod wl_handlers; diff --git a/src/wayland/shell/legacy/wl_handlers.rs b/src/wayland/shell/legacy/wl_handlers.rs index 8987e65..7793a30 100644 --- a/src/wayland/shell/legacy/wl_handlers.rs +++ b/src/wayland/shell/legacy/wl_handlers.rs @@ -1,12 +1,15 @@ -use std::cell::RefCell; -use std::rc::Rc; -use std::sync::{Arc, Mutex}; +use std::{ + cell::RefCell, + rc::Rc, + sync::{Arc, Mutex}, +}; -use wayland_server::protocol::{wl_shell, wl_shell_surface, wl_surface}; -use wayland_server::{DisplayToken, NewResource, Resource}; +use wayland_server::{ + protocol::{wl_shell, wl_shell_surface, wl_surface}, + DisplayToken, NewResource, Resource, +}; -use wayland::compositor::roles::Role; -use wayland::compositor::CompositorToken; +use 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 6f008d5..d7cb20a 100644 --- a/src/wayland/shell/xdg/mod.rs +++ b/src/wayland/shell/xdg/mod.rs @@ -85,20 +85,21 @@ //! the subhandler you provided, or via methods on the `ShellState` that you are given //! (in an `Arc>`) as return value of the init function. -use std::cell::RefCell; -use std::rc::Rc; -use std::sync::{Arc, Mutex}; +use std::{ + cell::RefCell, + rc::Rc, + sync::{Arc, Mutex}, +}; use utils::Rectangle; -use wayland::compositor::roles::Role; -use wayland::compositor::CompositorToken; -use wayland_protocols::unstable::xdg_shell::v6::server::{ - zxdg_popup_v6, zxdg_shell_v6, zxdg_surface_v6, zxdg_toplevel_v6, +use 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}, }; -use wayland_protocols::xdg_shell::server::{ - xdg_popup, xdg_positioner, xdg_surface, xdg_toplevel, xdg_wm_base, +use wayland_server::{ + protocol::{wl_output, wl_seat, wl_surface}, + Display, DisplayToken, Global, Resource, }; -use wayland_server::protocol::{wl_output, wl_seat, wl_surface}; -use wayland_server::{Display, DisplayToken, Global, Resource}; // handlers for the xdg_shell protocol mod xdg_handlers; diff --git a/src/wayland/shell/xdg/xdg_handlers.rs b/src/wayland/shell/xdg/xdg_handlers.rs index 44fe735..4264509 100644 --- a/src/wayland/shell/xdg/xdg_handlers.rs +++ b/src/wayland/shell/xdg/xdg_handlers.rs @@ -1,13 +1,10 @@ -use std::cell::RefCell; -use std::sync::Mutex; +use std::{cell::RefCell, sync::Mutex}; -use wayland::compositor::roles::*; -use wayland::compositor::CompositorToken; +use 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; -use wayland_server::{DisplayToken, NewResource, Resource}; +use wayland_server::{protocol::wl_surface, DisplayToken, NewResource, Resource}; use utils::Rectangle; diff --git a/src/wayland/shell/xdg/zxdgv6_handlers.rs b/src/wayland/shell/xdg/zxdgv6_handlers.rs index 0136835..5bf5f62 100644 --- a/src/wayland/shell/xdg/zxdgv6_handlers.rs +++ b/src/wayland/shell/xdg/zxdgv6_handlers.rs @@ -1,14 +1,13 @@ -use std::cell::RefCell; -use std::sync::Mutex; +use std::{cell::RefCell, sync::Mutex}; -use wayland::compositor::roles::*; -use wayland::compositor::CompositorToken; -use wayland_protocols::unstable::xdg_shell::v6::server::{ - zxdg_popup_v6, zxdg_positioner_v6, zxdg_shell_v6, zxdg_surface_v6, zxdg_toplevel_v6, +use 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, + }, + xdg_shell::server::{xdg_positioner, xdg_toplevel}, }; -use wayland_protocols::xdg_shell::server::{xdg_positioner, xdg_toplevel}; -use wayland_server::protocol::wl_surface; -use wayland_server::{DisplayToken, NewResource, Resource}; +use wayland_server::{protocol::wl_surface, DisplayToken, NewResource, Resource}; use utils::Rectangle; diff --git a/src/wayland/shm/mod.rs b/src/wayland/shm/mod.rs index 416efa8..363c32e 100644 --- a/src/wayland/shm/mod.rs +++ b/src/wayland/shm/mod.rs @@ -78,10 +78,11 @@ //! If you are already using an handler for this signal, you probably don't want to use this handler. use self::pool::{Pool, ResizeError}; -use std::rc::Rc; -use std::sync::Arc; -use wayland_server::protocol::{wl_buffer, wl_shm, wl_shm_pool}; -use wayland_server::{Display, DisplayToken, Global, NewResource, Resource}; +use std::{rc::Rc, sync::Arc}; +use wayland_server::{ + protocol::{wl_buffer, wl_shm, wl_shm_pool}, + Display, DisplayToken, Global, NewResource, Resource, +}; mod pool; diff --git a/src/wayland/shm/pool.rs b/src/wayland/shm/pool.rs index 13e69b0..b8a3b06 100644 --- a/src/wayland/shm/pool.rs +++ b/src/wayland/shm/pool.rs @@ -1,10 +1,17 @@ -use nix::sys::mman; -use nix::sys::signal::{self, SigAction, SigHandler, Signal}; -use nix::{libc, unistd}; -use std::cell::Cell; -use std::os::unix::io::RawFd; -use std::ptr; -use std::sync::{Once, RwLock, ONCE_INIT}; +use nix::{ + libc, + sys::{ + mman, + signal::{self, SigAction, SigHandler, Signal}, + }, + unistd, +}; +use std::{ + cell::Cell, + os::unix::io::RawFd, + ptr, + sync::{Once, RwLock, ONCE_INIT}, +}; thread_local!(static SIGBUS_GUARD: Cell<(*const MemMap, bool)> = Cell::new((ptr::null_mut(), false))); diff --git a/src/xwayland/x11_sockets.rs b/src/xwayland/x11_sockets.rs index fc64e03..3a497e3 100644 --- a/src/xwayland/x11_sockets.rs +++ b/src/xwayland/x11_sockets.rs @@ -1,10 +1,9 @@ -use std::io::{Read, Write}; -use std::os::unix::io::FromRawFd; -use std::os::unix::net::UnixStream; +use std::{ + io::{Read, Write}, + os::unix::{io::FromRawFd, net::UnixStream}, +}; -use nix::errno::Errno; -use nix::sys::socket; -use nix::{Error as NixError, Result as NixResult}; +use nix::{errno::Errno, sys::socket, Error as NixError, Result as NixResult}; /// Find a free X11 display slot and setup pub(crate) fn prepare_x11_sockets(log: ::slog::Logger) -> Result<(X11Lock, [UnixStream; 2]), ()> { diff --git a/src/xwayland/xserver.rs b/src/xwayland/xserver.rs index dfec5b6..e1e7f33 100644 --- a/src/xwayland/xserver.rs +++ b/src/xwayland/xserver.rs @@ -24,21 +24,31 @@ * cf https://github.com/swaywm/wlroots/blob/master/xwayland/xwayland.c * */ -use std::cell::RefCell; -use std::env; -use std::ffi::CString; -use std::os::unix::io::{AsRawFd, IntoRawFd}; -use std::os::unix::net::UnixStream; -use std::rc::Rc; +use std::{ + cell::RefCell, + env, + ffi::CString, + os::unix::{ + io::{AsRawFd, IntoRawFd}, + net::UnixStream, + }, + rc::Rc, +}; -use nix::errno::Errno; -use nix::sys::signal; -use nix::unistd::{fork, ForkResult, Pid}; -use nix::{Error as NixError, Result as NixResult}; +use nix::{ + errno::Errno, + sys::signal, + unistd::{fork, ForkResult, Pid}, + Error as NixError, Result as NixResult, +}; -use wayland_server::calloop::signals::{Signal, Signals}; -use wayland_server::calloop::{LoopHandle, Source}; -use wayland_server::{Client, Display}; +use wayland_server::{ + calloop::{ + signals::{Signal, Signals}, + LoopHandle, Source, + }, + Client, Display, +}; use super::x11_sockets::{prepare_x11_sockets, X11Lock};