lib: Use nested imports

This commit is contained in:
Jonas Platte 2018-10-05 00:37:43 +02:00 committed by Victor Berger
parent 850ff6983a
commit a77e29d9b5
33 changed files with 346 additions and 280 deletions

View File

@ -1,9 +1,7 @@
extern crate gl_generator; extern crate gl_generator;
use gl_generator::{Api, Fallbacks, Profile, Registry}; use gl_generator::{Api, Fallbacks, Profile, Registry};
use std::env; use std::{env, fs::File, path::PathBuf};
use std::fs::File;
use std::path::PathBuf;
fn main() { fn main() {
let dest = PathBuf::from(&env::var("OUT_DIR").unwrap()); let dest = PathBuf::from(&env::var("OUT_DIR").unwrap());

View File

@ -1,22 +1,28 @@
use super::error::*; use super::{error::*, DevPath};
use super::DevPath; use backend::graphics::{
use backend::graphics::egl::error::Result as EGLResult; egl::{
use backend::graphics::egl::native::{Gbm, GbmSurfaceArguments}; error::Result as EGLResult,
use backend::graphics::egl::wayland::{EGLDisplay, EGLWaylandExtensions}; native::{Gbm, GbmSurfaceArguments},
use backend::graphics::egl::{EGLContext, EGLGraphicsBackend, EGLSurface, PixelFormat, SwapBuffersError}; wayland::{EGLDisplay, EGLWaylandExtensions},
use backend::graphics::GraphicsBackend; EGLContext, EGLGraphicsBackend, EGLSurface, PixelFormat, SwapBuffersError,
use drm::control::{connector, crtc, encoder, framebuffer, Mode}; },
use drm::control::{Device, ResourceInfo}; GraphicsBackend,
use drm::Device as BasicDevice; };
use drm::{
control::{connector, crtc, encoder, framebuffer, Device, Mode, ResourceInfo},
Device as BasicDevice,
};
use gbm::{ use gbm::{
BufferObject, BufferObjectFlags, Device as GbmDevice, Format as GbmFormat, Surface as GbmSurface, BufferObject, BufferObjectFlags, Device as GbmDevice, Format as GbmFormat, Surface as GbmSurface,
SurfaceBufferHandle, SurfaceBufferHandle,
}; };
use image::{ImageBuffer, Rgba}; use image::{ImageBuffer, Rgba};
use nix::libc::c_void; use nix::libc::c_void;
use std::cell::Cell; use std::{
use std::os::unix::io::{AsRawFd, RawFd}; cell::Cell,
use std::rc::{Rc, Weak}; os::unix::io::{AsRawFd, RawFd},
rc::{Rc, Weak},
};
use wayland_server::Display; use wayland_server::Display;
/// Backend based on a `DrmDevice` and a given crtc /// Backend based on a `DrmDevice` and a given crtc

View File

@ -209,41 +209,52 @@
//! # } //! # }
//! ``` //! ```
use backend::graphics::egl::context::{EGLContext, GlAttributes}; use backend::graphics::egl::{
use backend::graphics::egl::error::Result as EGLResult; context::{EGLContext, GlAttributes},
use backend::graphics::egl::native::Gbm; error::Result as EGLResult,
use backend::graphics::egl::wayland::{EGLDisplay, EGLWaylandExtensions}; native::Gbm,
wayland::{EGLDisplay, EGLWaylandExtensions},
};
#[cfg(feature = "backend_session")] #[cfg(feature = "backend_session")]
use backend::session::{AsSessionObserver, SessionObserver}; use backend::session::{AsSessionObserver, SessionObserver};
use drm::control::framebuffer; use drm::{
use drm::control::Device as ControlDevice; control::{connector, crtc, encoder, framebuffer, Device as ControlDevice, Mode, ResourceInfo},
use drm::control::{connector, crtc, encoder, Mode, ResourceInfo}; result::Error as DrmError,
use drm::result::Error as DrmError; Device as BasicDevice,
use drm::Device as BasicDevice; };
use gbm::{BufferObject, Device as GbmDevice}; use gbm::{BufferObject, Device as GbmDevice};
use nix; use nix::{
use nix::sys::stat::{self, dev_t, fstat}; self,
use std::cell::RefCell; sys::stat::{self, dev_t, fstat},
use std::collections::HashMap; };
use std::hash::{Hash, Hasher}; use std::{
use std::io::Error as IoError; cell::RefCell,
use std::os::unix::io::{AsRawFd, RawFd}; collections::HashMap,
use std::path::PathBuf; hash::{Hash, Hasher},
use std::rc::{Rc, Weak}; io::Error as IoError,
use std::sync::atomic::{AtomicBool, Ordering}; os::unix::io::{AsRawFd, RawFd},
use std::sync::{Arc, Once, ONCE_INIT}; path::PathBuf,
use std::time::Duration; rc::{Rc, Weak},
sync::{
atomic::{AtomicBool, Ordering},
Arc, Once, ONCE_INIT,
},
time::Duration,
};
use wayland_server::calloop::generic::{EventedRawFd, Generic}; use wayland_server::{
use wayland_server::calloop::{LoopHandle, Ready, Source}; calloop::{
use wayland_server::Display; generic::{EventedRawFd, Generic},
LoopHandle, Ready, Source,
},
Display,
};
mod backend; mod backend;
pub mod error; pub mod error;
pub use self::backend::DrmBackend; pub use self::backend::DrmBackend;
use self::backend::DrmBackendInternal; use self::{backend::DrmBackendInternal, error::*};
use self::error::*;
static LOAD: Once = ONCE_INIT; static LOAD: Once = ONCE_INIT;

View File

@ -1,8 +1,6 @@
//! EGL context related structs //! EGL context related structs
use super::error::*; use super::{error::*, ffi, native, EGLSurface, PixelFormat};
use super::native;
use super::{ffi, EGLSurface, PixelFormat};
#[cfg(feature = "backend_drm")] #[cfg(feature = "backend_drm")]
use drm::control::Device as ControlDevice; use drm::control::Device as ControlDevice;
#[cfg(feature = "backend_drm")] #[cfg(feature = "backend_drm")]
@ -11,14 +9,16 @@ use drm::Device as BasicDevice;
use gbm::Device as GbmDevice; use gbm::Device as GbmDevice;
use nix::libc::{c_int, c_void}; use nix::libc::{c_int, c_void};
use slog; use slog;
use std::ffi::{CStr, CString};
use std::marker::PhantomData;
use std::mem;
use std::ops::{Deref, DerefMut};
#[cfg(feature = "backend_drm")] #[cfg(feature = "backend_drm")]
use std::os::unix::io::{AsRawFd, RawFd}; use std::os::unix::io::{AsRawFd, RawFd};
use std::ptr; use std::{
use std::rc::Rc; ffi::{CStr, CString},
marker::PhantomData,
mem,
ops::{Deref, DerefMut},
ptr,
rc::Rc,
};
/// EGL context for rendering /// EGL context for rendering
pub struct EGLContext<B: native::Backend, N: native::NativeDisplay<B>> { pub struct EGLContext<B: native::Backend, N: native::NativeDisplay<B>> {

View File

@ -81,8 +81,7 @@ pub mod egl {
} }
mod wayland_storage { mod wayland_storage {
use super::FnPtr; use super::{FnPtr, __gl_imports::raw};
use super::__gl_imports::raw;
pub static mut BindWaylandDisplayWL: FnPtr = FnPtr { pub static mut BindWaylandDisplayWL: FnPtr = FnPtr {
f: super::missing_fn_panic as *const raw::c_void, f: super::missing_fn_panic as *const raw::c_void,
is_loaded: false, is_loaded: false,
@ -99,9 +98,7 @@ pub mod egl {
#[allow(non_snake_case)] #[allow(non_snake_case)]
pub mod BindWaylandDisplayWL { pub mod BindWaylandDisplayWL {
use super::FnPtr; use super::{FnPtr, __gl_imports::raw, metaloadfn, wayland_storage};
use super::__gl_imports::raw;
use super::{metaloadfn, wayland_storage};
#[inline] #[inline]
#[allow(dead_code)] #[allow(dead_code)]
@ -123,9 +120,7 @@ pub mod egl {
#[allow(non_snake_case)] #[allow(non_snake_case)]
pub mod UnbindWaylandDisplayWL { pub mod UnbindWaylandDisplayWL {
use super::FnPtr; use super::{FnPtr, __gl_imports::raw, metaloadfn, wayland_storage};
use super::__gl_imports::raw;
use super::{metaloadfn, wayland_storage};
#[inline] #[inline]
#[allow(dead_code)] #[allow(dead_code)]
@ -147,9 +142,7 @@ pub mod egl {
#[allow(non_snake_case)] #[allow(non_snake_case)]
pub mod QueryWaylandBufferWL { pub mod QueryWaylandBufferWL {
use super::FnPtr; use super::{FnPtr, __gl_imports::raw, metaloadfn, wayland_storage};
use super::__gl_imports::raw;
use super::{metaloadfn, wayland_storage};
#[inline] #[inline]
#[allow(dead_code)] #[allow(dead_code)]

View File

@ -1,7 +1,6 @@
//! Type safe native types for safe context/surface creation //! Type safe native types for safe context/surface creation
use super::error::*; use super::{error::*, ffi};
use super::ffi;
#[cfg(feature = "backend_drm")] #[cfg(feature = "backend_drm")]
use backend::drm::error::{Error as DrmError, ErrorKind as DrmErrorKind, Result as DrmResult}; use backend::drm::error::{Error as DrmError, ErrorKind as DrmErrorKind, Result as DrmResult};
#[cfg(feature = "backend_drm")] #[cfg(feature = "backend_drm")]

View File

@ -1,11 +1,10 @@
//! EGL surface related structs //! EGL surface related structs
use super::error::*; use super::{error::*, ffi, native, EGLContext, SwapBuffersError};
use super::ffi; use std::{
use super::native; ops::{Deref, DerefMut},
use super::{EGLContext, SwapBuffersError}; rc::{Rc, Weak},
use std::ops::{Deref, DerefMut}; };
use std::rc::{Rc, Weak};
/// EGL surface of a given egl context for rendering /// EGL surface of a given egl context for rendering
pub struct EGLSurface<N: native::NativeSurface> { pub struct EGLSurface<N: native::NativeSurface> {

View File

@ -10,14 +10,20 @@
//! You may then use the resulting `EGLDisplay` to recieve `EGLImages` of an egl-based `WlBuffer` //! You may then use the resulting `EGLDisplay` to recieve `EGLImages` of an egl-based `WlBuffer`
//! for rendering. //! for rendering.
use backend::graphics::egl::error::*; use backend::graphics::egl::{
use backend::graphics::egl::ffi::egl::types::EGLImage; error::*,
use backend::graphics::egl::{ffi, native, EGLContext, EglExtensionNotSupportedError}; ffi::{self, egl::types::EGLImage},
native, EGLContext, EglExtensionNotSupportedError,
};
use nix::libc::c_uint; use nix::libc::c_uint;
use std::fmt; use std::{
use std::rc::{Rc, Weak}; fmt,
use wayland_server::protocol::wl_buffer::{self, WlBuffer}; rc::{Rc, Weak},
use wayland_server::{Display, Resource}; };
use wayland_server::{
protocol::wl_buffer::{self, WlBuffer},
Display, Resource,
};
use wayland_sys::server::wl_display; use wayland_sys::server::wl_display;
/// Error that can occur when accessing an EGL buffer /// Error that can occur when accessing an EGL buffer

View File

@ -1,15 +1,20 @@
//! Glium compatibility module //! Glium compatibility module
use backend::graphics::egl::error::Result as EGLResult; use backend::graphics::egl::{
use backend::graphics::egl::wayland::{EGLDisplay, EGLWaylandExtensions}; error::Result as EGLResult,
use backend::graphics::egl::{EGLGraphicsBackend, SwapBuffersError}; wayland::{EGLDisplay, EGLWaylandExtensions},
use glium::backend::{Backend, Context, Facade}; EGLGraphicsBackend, SwapBuffersError,
use glium::debug::DebugCallbackBehavior; };
use glium::Frame; use glium::{
use glium::SwapBuffersError as GliumSwapBuffersError; backend::{Backend, Context, Facade},
use std::cell::{Ref, RefCell, RefMut}; debug::DebugCallbackBehavior,
use std::os::raw::c_void; Frame, SwapBuffersError as GliumSwapBuffersError,
use std::rc::Rc; };
use std::{
cell::{Ref, RefCell, RefMut},
os::raw::c_void,
rc::Rc,
};
use wayland_server::Display; use wayland_server::Display;
impl From<SwapBuffersError> for GliumSwapBuffersError { impl From<SwapBuffersError> for GliumSwapBuffersError {

View File

@ -1,7 +1,6 @@
//! Common traits for input backends to receive input from. //! Common traits for input backends to receive input from.
use std::error::Error; use std::{error::Error, string::ToString};
use std::string::ToString;
/// A seat describes a group of input devices and at least one /// A seat describes a group of input devices and at least one
/// graphics device belonging together. /// graphics device belonging together.

View File

@ -1,22 +1,25 @@
//! Implementation of input backend trait for types provided by `libinput` //! Implementation of input backend trait for types provided by `libinput`
use backend::input as backend;
use backend::input::Axis;
#[cfg(feature = "backend_session")] #[cfg(feature = "backend_session")]
use backend::session::{AsErrno, Session, SessionObserver}; use backend::session::{AsErrno, Session, SessionObserver};
use backend::{input as backend, input::Axis};
use input as libinput; use input as libinput;
use input::event; use input::event;
use std::cell::RefCell; use std::{
use std::collections::hash_map::{DefaultHasher, Entry, HashMap}; cell::RefCell,
use std::hash::{Hash, Hasher}; collections::hash_map::{DefaultHasher, Entry, HashMap},
use std::io::Error as IoError; hash::{Hash, Hasher},
use std::os::unix::io::RawFd; io::Error as IoError,
use std::path::Path; os::unix::io::RawFd,
use std::rc::Rc; path::Path,
rc::Rc,
};
use wayland_server::calloop::generic::{EventedRawFd, Generic}; use wayland_server::calloop::{
use wayland_server::calloop::{LoopHandle, Ready, Source}; generic::{EventedRawFd, Generic},
LoopHandle, Ready, Source,
};
// No idea if this is the same across unix platforms // No idea if this is the same across unix platforms
// Lets make this linux exclusive for now, once someone tries to build it for // Lets make this linux exclusive for now, once someone tries to build it for

View File

@ -28,16 +28,14 @@
//! automatically by the `UdevBackend`, if not done manually). //! automatically by the `UdevBackend`, if not done manually).
//! ``` //! ```
use super::direct::{self, direct_session_bind, BoundDirectSession, DirectSession, DirectSessionNotifier};
#[cfg(feature = "backend_session_logind")] #[cfg(feature = "backend_session_logind")]
use super::logind::{self, logind_session_bind, BoundLogindSession, LogindSession, LogindSessionNotifier}; 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 nix::fcntl::OFlag;
use std::cell::RefCell; use std::{cell::RefCell, io::Error as IoError, os::unix::io::RawFd, path::Path, rc::Rc};
use std::io::Error as IoError;
use std::os::unix::io::RawFd;
use std::path::Path;
use std::rc::Rc;
use wayland_server::calloop::LoopHandle; use wayland_server::calloop::LoopHandle;

View File

@ -35,18 +35,24 @@ use dbus::{
BusName, BusType, Connection, ConnectionItem, ConnectionItems, Interface, Member, Message, MessageItem, BusName, BusType, Connection, ConnectionItem, ConnectionItems, Interface, Member, Message, MessageItem,
OwnedFd, Path as DbusPath, Watch, WatchEvent, OwnedFd, Path as DbusPath, Watch, WatchEvent,
}; };
use nix::fcntl::OFlag; use nix::{
use nix::sys::stat::{fstat, major, minor, stat}; fcntl::OFlag,
use std::cell::RefCell; sys::stat::{fstat, major, minor, stat},
use std::io::Error as IoError; };
use std::os::unix::io::RawFd; use std::{
use std::path::Path; cell::RefCell,
use std::rc::{Rc, Weak}; io::Error as IoError,
use std::sync::atomic::{AtomicBool, Ordering}; os::unix::io::RawFd,
path::Path,
rc::{Rc, Weak},
sync::atomic::{AtomicBool, Ordering},
};
use systemd::login; use systemd::login;
use wayland_server::calloop::generic::{Event, EventedRawFd, Generic}; use wayland_server::calloop::{
use wayland_server::calloop::{LoopHandle, Ready, Source}; generic::{Event, EventedRawFd, Generic},
LoopHandle, Ready, Source,
};
struct LogindSessionImpl { struct LogindSessionImpl {
conn: RefCell<Connection>, conn: RefCell<Connection>,

View File

@ -46,23 +46,30 @@
//! automatically by the `UdevBackend`, if not done manually). //! automatically by the `UdevBackend`, if not done manually).
use super::{AsErrno, AsSessionObserver, Session, SessionNotifier, SessionObserver}; use super::{AsErrno, AsSessionObserver, Session, SessionNotifier, SessionObserver};
use nix::fcntl::{self, open, OFlag}; use nix::{
use nix::libc::c_int; fcntl::{self, open, OFlag},
use nix::sys::signal::{self, Signal}; libc::c_int,
use nix::sys::stat::{dev_t, fstat, major, minor, Mode}; sys::{
use nix::unistd::{close, dup}; signal::{self, Signal},
use nix::{Error as NixError, Result as NixResult}; stat::{dev_t, fstat, major, minor, Mode},
use std::cell::RefCell; },
use std::io::Error as IoError; unistd::{close, dup},
use std::os::unix::io::RawFd; Error as NixError, Result as NixResult,
use std::path::Path; };
use std::rc::Rc; use std::{
use std::sync::atomic::{AtomicBool, Ordering}; cell::RefCell,
use std::sync::Arc; io::Error as IoError,
os::unix::io::RawFd,
path::Path,
rc::Rc,
sync::{
atomic::{AtomicBool, Ordering},
Arc,
},
};
#[cfg(feature = "backend_session_udev")] #[cfg(feature = "backend_session_udev")]
use udev::Context; use udev::Context;
use wayland_server::calloop::signals::Signals; use wayland_server::calloop::{signals::Signals, LoopHandle, Source};
use wayland_server::calloop::{LoopHandle, Source};
#[allow(dead_code)] #[allow(dead_code)]
mod tty { mod tty {

View File

@ -11,11 +11,13 @@
//! - direct - legacy tty / virtual terminal kernel api //! - direct - legacy tty / virtual terminal kernel api
//! //!
use nix::fcntl::OFlag; use nix::fcntl::OFlag;
use std::cell::RefCell; use std::{
use std::os::unix::io::RawFd; cell::RefCell,
use std::path::Path; os::unix::io::RawFd,
use std::rc::Rc; path::Path,
use std::sync::{Arc, Mutex}; rc::Rc,
sync::{Arc, Mutex},
};
/// General session interface. /// General session interface.
/// ///

View File

@ -9,24 +9,28 @@
//! See also `examples/udev.rs` for pure hardware backed example of a compositor utilizing this //! See also `examples/udev.rs` for pure hardware backed example of a compositor utilizing this
//! backend. //! backend.
use backend::drm::{drm_device_bind, DrmDevice, DrmHandler}; use backend::{
use backend::session::{AsSessionObserver, Session, SessionObserver}; drm::{drm_device_bind, DrmDevice, DrmHandler},
use drm::control::Device as ControlDevice; session::{AsSessionObserver, Session, SessionObserver},
use drm::Device as BasicDevice; };
use nix::fcntl; use drm::{control::Device as ControlDevice, Device as BasicDevice};
use nix::sys::stat::dev_t; use nix::{fcntl, sys::stat::dev_t};
use std::cell::RefCell; use std::{
use std::collections::HashMap; cell::RefCell,
use std::ffi::OsString; collections::HashMap,
use std::io::Error as IoError; ffi::OsString,
use std::mem::drop; io::Error as IoError,
use std::os::unix::io::{AsRawFd, RawFd}; mem::drop,
use std::path::{Path, PathBuf}; os::unix::io::{AsRawFd, RawFd},
use std::rc::{Rc, Weak}; path::{Path, PathBuf},
rc::{Rc, Weak},
};
use udev::{Context, Enumerator, Event, EventType, MonitorBuilder, MonitorSocket, Result as UdevResult}; use udev::{Context, Enumerator, Event, EventType, MonitorBuilder, MonitorSocket, Result as UdevResult};
use wayland_server::calloop::generic::{EventedRawFd, Generic}; use wayland_server::calloop::{
use wayland_server::calloop::{LoopHandle, Ready, Source}; generic::{EventedRawFd, Generic},
LoopHandle, Ready, Source,
};
/// Udev's `DrmDevice` type based on the underlying session /// Udev's `DrmDevice` type based on the underlying session
pub struct SessionFdDrmDevice(RawFd); pub struct SessionFdDrmDevice(RawFd);

View File

@ -1,28 +1,30 @@
//! Implementation of backend traits for types provided by `winit` //! Implementation of backend traits for types provided by `winit`
use backend::graphics::egl::context::GlAttributes; use backend::{
use backend::graphics::egl::error as egl_error; graphics::{
use backend::graphics::egl::error::Result as EGLResult; egl::{
use backend::graphics::egl::native; context::GlAttributes,
use backend::graphics::egl::wayland::{EGLDisplay, EGLWaylandExtensions}; error as egl_error,
use backend::graphics::egl::{EGLContext, EGLGraphicsBackend, EGLSurface, PixelFormat, SwapBuffersError}; error::Result as EGLResult,
use backend::graphics::GraphicsBackend; native,
use backend::input::{ wayland::{EGLDisplay, EGLWaylandExtensions},
EGLContext, EGLGraphicsBackend, EGLSurface, PixelFormat, SwapBuffersError,
},
GraphicsBackend,
},
input::{
Axis, AxisSource, Event as BackendEvent, InputBackend, InputHandler, KeyState, KeyboardKeyEvent, Axis, AxisSource, Event as BackendEvent, InputBackend, InputHandler, KeyState, KeyboardKeyEvent,
MouseButton, MouseButtonState, PointerAxisEvent, PointerButtonEvent, PointerMotionAbsoluteEvent, Seat, MouseButton, MouseButtonState, PointerAxisEvent, PointerButtonEvent, PointerMotionAbsoluteEvent,
SeatCapabilities, TouchCancelEvent, TouchDownEvent, TouchMotionEvent, TouchSlot, TouchUpEvent, Seat, SeatCapabilities, TouchCancelEvent, TouchDownEvent, TouchMotionEvent, TouchSlot, TouchUpEvent,
UnusedEvent, UnusedEvent,
},
}; };
use nix::libc::c_void; use nix::libc::c_void;
use std::cmp; use std::{cmp, error, fmt, rc::Rc, time::Instant};
use std::error;
use std::fmt;
use std::rc::Rc;
use std::time::Instant;
use wayland_client::egl as wegl; use wayland_client::egl as wegl;
use wayland_server::Display; use wayland_server::Display;
use winit::dpi::{LogicalPosition, LogicalSize};
use winit::{ use winit::{
dpi::{LogicalPosition, LogicalSize},
ElementState, Event, EventsLoop, KeyboardInput, MouseButton as WinitMouseButton, MouseCursor, ElementState, Event, EventsLoop, KeyboardInput, MouseButton as WinitMouseButton, MouseCursor,
MouseScrollDelta, Touch, TouchPhase, Window as WinitWindow, WindowBuilder, WindowEvent, MouseScrollDelta, Touch, TouchPhase, Window as WinitWindow, WindowBuilder, WindowEvent,
}; };

View File

@ -1,12 +1,12 @@
use std::cell::RefCell; use std::{cell::RefCell, rc::Rc, sync::Mutex};
use std::rc::Rc;
use std::sync::Mutex;
use wayland_server::protocol::{wl_compositor, wl_region, wl_subcompositor, wl_subsurface, wl_surface}; use wayland_server::{
use wayland_server::{DisplayToken, NewResource, Resource}; protocol::{wl_compositor, wl_region, wl_subcompositor, wl_subsurface, wl_surface},
DisplayToken, NewResource, Resource,
};
use super::tree::{Location, SurfaceData};
use super::{ use super::{
tree::{Location, SurfaceData},
CompositorToken, Damage, Rectangle, RectangleKind, RegionAttributes, Role, RoleType, SubsurfaceRole, CompositorToken, Damage, Rectangle, RectangleKind, RegionAttributes, Role, RoleType, SubsurfaceRole,
SurfaceEvent, SurfaceEvent,
}; };

View File

@ -76,23 +76,24 @@
//! This `CompositorToken` also provides access to the metadata associated with the role of the //! 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. //! surfaces. See the documentation of the `roles` submodule for a detailed explanation.
use std::cell::RefCell; use std::{cell::RefCell, rc::Rc, sync::Mutex};
use std::rc::Rc;
use std::sync::Mutex;
mod handlers; mod handlers;
pub mod roles; pub mod roles;
mod tree; mod tree;
use self::roles::{Role, RoleType, WrongRole};
use self::tree::SurfaceData;
pub use self::tree::TraversalAction; pub use self::tree::TraversalAction;
use utils::Rectangle; use self::{
use wayland_server::protocol::wl_surface::WlSurface; roles::{Role, RoleType, WrongRole},
use wayland_server::protocol::{ tree::SurfaceData,
wl_buffer, wl_callback, wl_compositor, wl_output, wl_region, wl_subcompositor, };
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 /// Description of which part of a surface
/// should be considered damaged and needs to be redrawn /// should be considered damaged and needs to be redrawn

View File

@ -1,8 +1,6 @@
use super::roles::*; use super::{roles::*, SubsurfaceRole, SurfaceAttributes};
use super::{SubsurfaceRole, SurfaceAttributes};
use std::sync::Mutex; use std::sync::Mutex;
use wayland_server::protocol::wl_surface::WlSurface; use wayland_server::{protocol::wl_surface::WlSurface, Resource};
use wayland_server::Resource;
/// Node of a subsurface tree, holding some user specified data type U /// Node of a subsurface tree, holding some user specified data type U
/// at each node /// at each node

View File

@ -53,9 +53,11 @@
use std::sync::{Arc, Mutex}; 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}; 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 /// An output mode
/// ///

View File

@ -1,14 +1,18 @@
use backend::input::KeyState; use backend::input::KeyState;
use std::default::Default; use std::{
use std::io::{Error as IoError, Write}; default::Default,
use std::os::unix::io::AsRawFd; io::{Error as IoError, Write},
use std::sync::{Arc, Mutex}; os::unix::io::AsRawFd,
use tempfile::tempfile; sync::{Arc, Mutex},
use wayland_server::protocol::wl_keyboard::{ };
Event, KeyState as WlKeyState, KeymapFormat, Request, WlKeyboard, 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; use xkbcommon::xkb;
pub use xkbcommon::xkb::{keysyms, Keysym}; pub use xkbcommon::xkb::{keysyms, Keysym};

View File

@ -59,12 +59,11 @@ use std::sync::{Arc, Mutex};
mod keyboard; mod keyboard;
mod pointer; mod pointer;
pub use self::keyboard::{ pub use self::{
keysyms, Error as KeyboardError, KeyboardHandle, Keysym, ModifiersState, XkbConfig, keyboard::{keysyms, Error as KeyboardError, KeyboardHandle, Keysym, ModifiersState, XkbConfig},
pointer::{PointerAxisHandle, PointerHandle},
}; };
pub use self::pointer::{PointerAxisHandle, PointerHandle}; use wayland_server::{protocol::wl_seat, Display, Global, NewResource, Resource};
use wayland_server::protocol::wl_seat;
use wayland_server::{Display, Global, NewResource, Resource};
struct Inner { struct Inner {
log: ::slog::Logger, log: ::slog::Logger,

View File

@ -1,7 +1,11 @@
use std::sync::{Arc, Mutex, MutexGuard}; use std::sync::{Arc, Mutex, MutexGuard};
use wayland_server::protocol::wl_pointer::{Axis, AxisSource, ButtonState, Event, Request, WlPointer}; use wayland_server::{
use wayland_server::protocol::wl_surface::WlSurface; protocol::{
use wayland_server::{NewResource, Resource}; wl_pointer::{Axis, AxisSource, ButtonState, Event, Request, WlPointer},
wl_surface::WlSurface,
},
NewResource, Resource,
};
// TODO: handle pointer surface role // TODO: handle pointer surface role

View File

@ -70,15 +70,18 @@
//! # } //! # }
//! ``` //! ```
use std::cell::RefCell; use std::{
use std::rc::Rc; cell::RefCell,
use std::sync::{Arc, Mutex}; rc::Rc,
sync::{Arc, Mutex},
};
use wayland::compositor::roles::Role; use wayland::compositor::{roles::Role, CompositorToken};
use wayland::compositor::CompositorToken;
use wayland_server::protocol::{wl_output, wl_seat, wl_shell, wl_shell_surface, wl_surface}; use wayland_server::{
use wayland_server::{Display, Global, Resource}; protocol::{wl_output, wl_seat, wl_shell, wl_shell_surface, wl_surface},
Display, Global, Resource,
};
mod wl_handlers; mod wl_handlers;

View File

@ -1,12 +1,15 @@
use std::cell::RefCell; use std::{
use std::rc::Rc; cell::RefCell,
use std::sync::{Arc, Mutex}; rc::Rc,
sync::{Arc, Mutex},
};
use wayland_server::protocol::{wl_shell, wl_shell_surface, wl_surface}; use wayland_server::{
use wayland_server::{DisplayToken, NewResource, Resource}; protocol::{wl_shell, wl_shell_surface, wl_surface},
DisplayToken, NewResource, Resource,
};
use wayland::compositor::roles::Role; use wayland::compositor::{roles::Role, CompositorToken};
use wayland::compositor::CompositorToken;
use super::{ShellRequest, ShellState, ShellSurface, ShellSurfaceKind, ShellSurfaceRole}; use super::{ShellRequest, ShellState, ShellSurface, ShellSurfaceKind, ShellSurfaceRole};

View File

@ -85,20 +85,21 @@
//! the subhandler you provided, or via methods on the `ShellState` that you are given //! the subhandler you provided, or via methods on the `ShellState` that you are given
//! (in an `Arc<Mutex<_>>`) as return value of the init function. //! (in an `Arc<Mutex<_>>`) as return value of the init function.
use std::cell::RefCell; use std::{
use std::rc::Rc; cell::RefCell,
use std::sync::{Arc, Mutex}; rc::Rc,
sync::{Arc, Mutex},
};
use utils::Rectangle; use utils::Rectangle;
use wayland::compositor::roles::Role; use wayland::compositor::{roles::Role, CompositorToken};
use wayland::compositor::CompositorToken; use wayland_protocols::{
use wayland_protocols::unstable::xdg_shell::v6::server::{ unstable::xdg_shell::v6::server::{zxdg_popup_v6, zxdg_shell_v6, zxdg_surface_v6, zxdg_toplevel_v6},
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::{ use wayland_server::{
xdg_popup, xdg_positioner, xdg_surface, xdg_toplevel, xdg_wm_base, 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 // handlers for the xdg_shell protocol
mod xdg_handlers; mod xdg_handlers;

View File

@ -1,13 +1,10 @@
use std::cell::RefCell; use std::{cell::RefCell, sync::Mutex};
use std::sync::Mutex;
use wayland::compositor::roles::*; use wayland::compositor::{roles::*, CompositorToken};
use wayland::compositor::CompositorToken;
use wayland_protocols::xdg_shell::server::{ use wayland_protocols::xdg_shell::server::{
xdg_popup, xdg_positioner, xdg_surface, xdg_toplevel, xdg_wm_base, xdg_popup, xdg_positioner, xdg_surface, xdg_toplevel, xdg_wm_base,
}; };
use wayland_server::protocol::wl_surface; use wayland_server::{protocol::wl_surface, DisplayToken, NewResource, Resource};
use wayland_server::{DisplayToken, NewResource, Resource};
use utils::Rectangle; use utils::Rectangle;

View File

@ -1,14 +1,13 @@
use std::cell::RefCell; use std::{cell::RefCell, sync::Mutex};
use std::sync::Mutex;
use wayland::compositor::roles::*; use wayland::compositor::{roles::*, CompositorToken};
use wayland::compositor::CompositorToken; use wayland_protocols::{
use wayland_protocols::unstable::xdg_shell::v6::server::{ unstable::xdg_shell::v6::server::{
zxdg_popup_v6, zxdg_positioner_v6, zxdg_shell_v6, zxdg_surface_v6, zxdg_toplevel_v6, 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, DisplayToken, NewResource, Resource};
use wayland_server::protocol::wl_surface;
use wayland_server::{DisplayToken, NewResource, Resource};
use utils::Rectangle; use utils::Rectangle;

View File

@ -78,10 +78,11 @@
//! If you are already using an handler for this signal, you probably don't want to use this handler. //! 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 self::pool::{Pool, ResizeError};
use std::rc::Rc; use std::{rc::Rc, sync::Arc};
use std::sync::Arc; use wayland_server::{
use wayland_server::protocol::{wl_buffer, wl_shm, wl_shm_pool}; protocol::{wl_buffer, wl_shm, wl_shm_pool},
use wayland_server::{Display, DisplayToken, Global, NewResource, Resource}; Display, DisplayToken, Global, NewResource, Resource,
};
mod pool; mod pool;

View File

@ -1,10 +1,17 @@
use nix::sys::mman; use nix::{
use nix::sys::signal::{self, SigAction, SigHandler, Signal}; libc,
use nix::{libc, unistd}; sys::{
use std::cell::Cell; mman,
use std::os::unix::io::RawFd; signal::{self, SigAction, SigHandler, Signal},
use std::ptr; },
use std::sync::{Once, RwLock, ONCE_INIT}; 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))); thread_local!(static SIGBUS_GUARD: Cell<(*const MemMap, bool)> = Cell::new((ptr::null_mut(), false)));

View File

@ -1,10 +1,9 @@
use std::io::{Read, Write}; use std::{
use std::os::unix::io::FromRawFd; io::{Read, Write},
use std::os::unix::net::UnixStream; os::unix::{io::FromRawFd, net::UnixStream},
};
use nix::errno::Errno; use nix::{errno::Errno, sys::socket, Error as NixError, Result as NixResult};
use nix::sys::socket;
use nix::{Error as NixError, Result as NixResult};
/// Find a free X11 display slot and setup /// Find a free X11 display slot and setup
pub(crate) fn prepare_x11_sockets(log: ::slog::Logger) -> Result<(X11Lock, [UnixStream; 2]), ()> { pub(crate) fn prepare_x11_sockets(log: ::slog::Logger) -> Result<(X11Lock, [UnixStream; 2]), ()> {

View File

@ -24,21 +24,31 @@
* cf https://github.com/swaywm/wlroots/blob/master/xwayland/xwayland.c * cf https://github.com/swaywm/wlroots/blob/master/xwayland/xwayland.c
* *
*/ */
use std::cell::RefCell; use std::{
use std::env; cell::RefCell,
use std::ffi::CString; env,
use std::os::unix::io::{AsRawFd, IntoRawFd}; ffi::CString,
use std::os::unix::net::UnixStream; os::unix::{
use std::rc::Rc; io::{AsRawFd, IntoRawFd},
net::UnixStream,
},
rc::Rc,
};
use nix::errno::Errno; use nix::{
use nix::sys::signal; errno::Errno,
use nix::unistd::{fork, ForkResult, Pid}; sys::signal,
use nix::{Error as NixError, Result as NixResult}; unistd::{fork, ForkResult, Pid},
Error as NixError, Result as NixResult,
};
use wayland_server::calloop::signals::{Signal, Signals}; use wayland_server::{
use wayland_server::calloop::{LoopHandle, Source}; calloop::{
use wayland_server::{Client, Display}; signals::{Signal, Signals},
LoopHandle, Source,
},
Client, Display,
};
use super::x11_sockets::{prepare_x11_sockets, X11Lock}; use super::x11_sockets::{prepare_x11_sockets, X11Lock};