Check for rust_2018_idioms
This commit is contained in:
parent
71bd64a6bf
commit
e5f8c351c7
|
@ -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<F: GLGraphicsBackend + 'static> {
|
|||
}
|
||||
|
||||
impl<F: GLGraphicsBackend + 'static> GliumDrawer<F> {
|
||||
pub fn borrow(&self) -> Ref<F> {
|
||||
pub fn borrow(&self) -> Ref<'_, F> {
|
||||
self.display.borrow()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -21,7 +21,7 @@ use smithay::{
|
|||
},
|
||||
},
|
||||
},
|
||||
wayland_server::{
|
||||
reexports::wayland_server::{
|
||||
protocol::{wl_buffer, wl_callback, wl_shell_surface, wl_surface},
|
||||
Display, Resource,
|
||||
},
|
||||
|
|
|
@ -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<u8>, 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<u8>,
|
|||
// 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 {
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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<U, R, SD, D> {
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -108,7 +108,7 @@ where
|
|||
D: Device + NativeDisplay<B, Arguments = crtc::Handle> + 'static,
|
||||
<D as Device>::Surface: NativeSurface,
|
||||
{
|
||||
handler: Box<DeviceHandler<Device = EglDevice<B, D>> + 'static>,
|
||||
handler: Box<dyn DeviceHandler<Device = EglDevice<B, D>> + 'static>,
|
||||
}
|
||||
|
||||
impl<B, D> DeviceHandler for InternalDeviceHandler<B, D>
|
||||
|
|
|
@ -82,7 +82,7 @@ impl<D: RawDevice + ControlDevice + 'static> GbmDevice<D> {
|
|||
}
|
||||
|
||||
struct InternalDeviceHandler<D: RawDevice + ControlDevice + 'static> {
|
||||
handler: Box<DeviceHandler<Device = GbmDevice<D>> + 'static>,
|
||||
handler: Box<dyn DeviceHandler<Device = GbmDevice<D>> + 'static>,
|
||||
backends: Weak<RefCell<HashMap<crtc::Handle, Weak<GbmSurfaceInternal<D>>>>>,
|
||||
logger: ::slog::Logger,
|
||||
}
|
||||
|
|
|
@ -38,7 +38,7 @@ pub struct LegacyDrmDevice<A: AsRawFd + 'static> {
|
|||
dev_id: dev_t,
|
||||
active: Arc<AtomicBool>,
|
||||
backends: Rc<RefCell<HashMap<crtc::Handle, Weak<LegacyDrmSurfaceInternal<A>>>>>,
|
||||
handler: Option<RefCell<Box<DeviceHandler<Device = LegacyDrmDevice<A>>>>>,
|
||||
handler: Option<RefCell<Box<dyn DeviceHandler<Device = LegacyDrmDevice<A>>>>>,
|
||||
logger: ::slog::Logger,
|
||||
}
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ impl<A: AsRawFd + 'static> BasicDevice for LegacyDrmSurfaceInternal<A> {}
|
|||
impl<A: AsRawFd + 'static> ControlDevice for LegacyDrmSurfaceInternal<A> {}
|
||||
|
||||
impl<'a, A: AsRawFd + 'static> CursorBackend<'a> for LegacyDrmSurfaceInternal<A> {
|
||||
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<A: AsRawFd + 'static> BasicDevice for LegacyDrmSurface<A> {}
|
|||
impl<A: AsRawFd + 'static> ControlDevice for LegacyDrmSurface<A> {}
|
||||
|
||||
impl<'a, A: AsRawFd + 'static> CursorBackend<'a> for LegacyDrmSurface<A> {
|
||||
type CursorFormat = &'a Buffer;
|
||||
type CursorFormat = &'a dyn Buffer;
|
||||
type Error = Error;
|
||||
|
||||
fn set_cursor_position(&self, x: u32, y: u32) -> Result<()> {
|
||||
|
|
|
@ -452,7 +452,7 @@ impl<B: native::Backend, N: native::NativeDisplay<B>> EGLContext<B, N> {
|
|||
/// 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<N> {
|
||||
pub fn borrow(&self) -> Ref<'_, N> {
|
||||
self.native.borrow()
|
||||
}
|
||||
|
||||
|
@ -462,7 +462,7 @@ impl<B: native::Backend, N: native::NativeDisplay<B>> EGLContext<B, N> {
|
|||
/// 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<N> {
|
||||
pub fn borrow_mut(&self) -> RefMut<'_, N> {
|
||||
self.native.borrow_mut()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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"));
|
||||
}
|
||||
|
|
|
@ -59,7 +59,7 @@ impl<T: GLGraphicsBackend + 'static> GliumGraphicsBackend<T> {
|
|||
/// 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<T> {
|
||||
pub fn borrow(&self) -> Ref<'_, T> {
|
||||
self.backend.0.borrow()
|
||||
}
|
||||
|
||||
|
@ -69,7 +69,7 @@ impl<T: GLGraphicsBackend + 'static> GliumGraphicsBackend<T> {
|
|||
/// 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<T> {
|
||||
pub fn borrow_mut(&self) -> RefMut<'_, T> {
|
||||
self.backend.0.borrow_mut()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -521,7 +521,7 @@ pub trait InputBackend: Sized {
|
|||
/// Sets a new handler for this [`InputBackend`]
|
||||
fn set_handler<H: InputHandler<Self> + 'static>(&mut self, handler: H);
|
||||
/// Get a reference to the currently set handler, if any
|
||||
fn get_handler(&mut self) -> Option<&mut InputHandler<Self>>;
|
||||
fn get_handler(&mut self) -> Option<&mut dyn InputHandler<Self>>;
|
||||
/// Clears the currently handler, if one is set
|
||||
fn clear_handler(&mut self);
|
||||
|
||||
|
@ -626,7 +626,7 @@ pub trait InputHandler<B: InputBackend> {
|
|||
fn on_input_config_changed(&mut self, config: &mut B::InputConfig);
|
||||
}
|
||||
|
||||
impl<B: InputBackend> InputHandler<B> for Box<InputHandler<B>> {
|
||||
impl<B: InputBackend> InputHandler<B> for Box<dyn InputHandler<B>> {
|
||||
fn on_seat_created(&mut self, seat: &Seat) {
|
||||
(**self).on_seat_created(seat)
|
||||
}
|
||||
|
|
|
@ -35,7 +35,7 @@ pub struct LibinputInputBackend {
|
|||
context: libinput::Libinput,
|
||||
devices: Vec<libinput::Device>,
|
||||
seats: HashMap<libinput::Seat, backend::Seat>,
|
||||
handler: Option<Box<backend::InputHandler<LibinputInputBackend> + 'static>>,
|
||||
handler: Option<Box<dyn backend::InputHandler<LibinputInputBackend> + '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<Self>> {
|
||||
fn get_handler(&mut self) -> Option<&mut dyn backend::InputHandler<Self>> {
|
||||
self.handler
|
||||
.as_mut()
|
||||
.map(|handler| handler as &mut backend::InputHandler<Self>)
|
||||
.map(|handler| handler as &mut dyn backend::InputHandler<Self>)
|
||||
}
|
||||
|
||||
fn clear_handler(&mut self) {
|
||||
|
|
|
@ -60,7 +60,7 @@ struct LogindSessionImpl {
|
|||
conn: RefCell<Connection>,
|
||||
session_path: DbusPath<'static>,
|
||||
active: AtomicBool,
|
||||
signals: RefCell<Vec<Option<Box<SessionObserver>>>>,
|
||||
signals: RefCell<Vec<Option<Box<dyn SessionObserver>>>>,
|
||||
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::<String, Dict<String, Variant<Iter>, Iter>, Array<String, Iter>>();
|
||||
message.get3::<String, Dict<'_, String, Variant<Iter<'_>>, 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) {
|
||||
|
|
|
@ -162,7 +162,7 @@ pub struct DirectSession {
|
|||
pub struct DirectSessionNotifier {
|
||||
tty: RawFd,
|
||||
active: Arc<AtomicBool>,
|
||||
signals: Vec<Option<Box<SessionObserver>>>,
|
||||
signals: Vec<Option<Box<dyn SessionObserver>>>,
|
||||
signal: Signal,
|
||||
logger: ::slog::Logger,
|
||||
}
|
||||
|
|
|
@ -16,26 +16,26 @@ static ID_COUNTER: AtomicUsize = AtomicUsize::new(0);
|
|||
pub struct Id(usize);
|
||||
|
||||
struct MultiObserver {
|
||||
observer: Arc<Mutex<HashMap<Id, Box<SessionObserver>>>>,
|
||||
observer: Arc<Mutex<HashMap<Id, Box<dyn SessionObserver>>>>,
|
||||
}
|
||||
|
||||
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<RawFd>)>) {
|
||||
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<Mutex<HashMap<Id, Box<SessionObserver>>>>,
|
||||
observer: Arc<Mutex<HashMap<Id, Box<dyn SessionObserver>>>>,
|
||||
}
|
||||
|
||||
impl SessionNotifier for MultiNotifier {
|
||||
|
|
|
@ -64,7 +64,7 @@ enum Window {
|
|||
}
|
||||
|
||||
impl Window {
|
||||
fn window(&self) -> Ref<WinitWindow> {
|
||||
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<Box<WinitEventsHandler>>,
|
||||
events_handler: Option<Box<dyn WinitEventsHandler>>,
|
||||
window: Rc<Window>,
|
||||
time: Instant,
|
||||
key_counter: u32,
|
||||
seat: Seat,
|
||||
input_config: (),
|
||||
handler: Option<Box<InputHandler<WinitInputBackend> + 'static>>,
|
||||
handler: Option<Box<dyn InputHandler<WinitInputBackend> + 'static>>,
|
||||
logger: ::slog::Logger,
|
||||
size: Rc<RefCell<WindowSize>>,
|
||||
}
|
||||
|
@ -162,12 +162,12 @@ where
|
|||
let reqs = Default::default();
|
||||
let window = Rc::new(
|
||||
if native::NativeDisplay::<native::Wayland>::is_backend(&winit_window) {
|
||||
let mut context =
|
||||
let context =
|
||||
EGLContext::<native::Wayland, WinitWindow>::new(winit_window, attributes, reqs, log.clone())?;
|
||||
let surface = context.create_surface(())?;
|
||||
Window::Wayland { context, surface }
|
||||
} else if native::NativeDisplay::<native::X11>::is_backend(&winit_window) {
|
||||
let mut context =
|
||||
let context =
|
||||
EGLContext::<native::X11, WinitWindow>::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<WinitWindow> {
|
||||
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<Self>> {
|
||||
fn get_handler(&mut self) -> Option<&mut dyn InputHandler<Self>> {
|
||||
self.handler
|
||||
.as_mut()
|
||||
.map(|handler| handler as &mut InputHandler<Self>)
|
||||
.map(|handler| handler as &mut dyn InputHandler<Self>)
|
||||
}
|
||||
|
||||
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;
|
||||
|
|
47
src/lib.rs
47
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;
|
||||
|
||||
|
|
|
@ -51,7 +51,7 @@ where
|
|||
// Internal implementation data of surfaces
|
||||
pub(crate) struct SurfaceImplem<U, R> {
|
||||
log: ::slog::Logger,
|
||||
implem: Rc<RefCell<FnMut(SurfaceEvent, Resource<wl_surface::WlSurface>, CompositorToken<U, R>)>>,
|
||||
implem: Rc<RefCell<dyn FnMut(SurfaceEvent, Resource<wl_surface::WlSurface>, CompositorToken<U, R>)>>,
|
||||
}
|
||||
|
||||
impl<U, R> SurfaceImplem<U, R> {
|
||||
|
|
|
@ -22,7 +22,7 @@ pub(crate) struct DnDGrab<U, R> {
|
|||
offer_data: Option<Arc<Mutex<OfferData>>>,
|
||||
icon: Option<Resource<wl_surface::WlSurface>>,
|
||||
origin: Resource<wl_surface::WlSurface>,
|
||||
callback: Arc<Mutex<FnMut(super::DataDeviceEvent) + Send>>,
|
||||
callback: Arc<Mutex<dyn FnMut(super::DataDeviceEvent) + Send>>,
|
||||
token: CompositorToken<U, R>,
|
||||
seat: Seat,
|
||||
}
|
||||
|
@ -34,7 +34,7 @@ impl<U: 'static, R: Role<DnDIconRole> + 'static> DnDGrab<U, R> {
|
|||
seat: Seat,
|
||||
icon: Option<Resource<wl_surface::WlSurface>>,
|
||||
token: CompositorToken<U, R>,
|
||||
callback: Arc<Mutex<FnMut(super::DataDeviceEvent) + Send>>,
|
||||
callback: Arc<Mutex<dyn FnMut(super::DataDeviceEvent) + Send>>,
|
||||
) -> DnDGrab<U, R> {
|
||||
DnDGrab {
|
||||
data_source: source,
|
||||
|
@ -53,7 +53,7 @@ impl<U: 'static, R: Role<DnDIconRole> + 'static> DnDGrab<U, R> {
|
|||
impl<U: 'static, R: Role<DnDIconRole> + 'static> PointerGrab for DnDGrab<U, R> {
|
||||
fn motion(
|
||||
&mut self,
|
||||
_handle: &mut PointerInnerHandle,
|
||||
_handle: &mut PointerInnerHandle<'_>,
|
||||
location: (f64, f64),
|
||||
focus: Option<(Resource<wl_surface::WlSurface>, (f64, f64))>,
|
||||
serial: u32,
|
||||
|
@ -179,7 +179,7 @@ impl<U: 'static, R: Role<DnDIconRole> + 'static> PointerGrab for DnDGrab<U, R> {
|
|||
|
||||
fn button(
|
||||
&mut self,
|
||||
handle: &mut PointerInnerHandle,
|
||||
handle: &mut PointerInnerHandle<'_>,
|
||||
_button: u32,
|
||||
_state: wl_pointer::ButtonState,
|
||||
serial: u32,
|
||||
|
@ -239,7 +239,7 @@ impl<U: 'static, R: Role<DnDIconRole> + 'static> PointerGrab for DnDGrab<U, R> {
|
|||
}
|
||||
}
|
||||
|
||||
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<wl_data_offer::WlDataOffer>,
|
||||
source: Resource<wl_data_source::WlDataSource>,
|
||||
offer_data: Arc<Mutex<OfferData>>,
|
||||
action_choice: Arc<Mutex<FnMut(DndAction, DndAction) -> DndAction + Send + 'static>>,
|
||||
action_choice: Arc<Mutex<dyn FnMut(DndAction, DndAction) -> DndAction + Send + 'static>>,
|
||||
) -> Resource<wl_data_offer::WlDataOffer> {
|
||||
use self::wl_data_offer::Request;
|
||||
offer.implement(
|
||||
|
|
|
@ -419,8 +419,8 @@ where
|
|||
}
|
||||
|
||||
struct DataDeviceData {
|
||||
callback: Arc<Mutex<FnMut(DataDeviceEvent) + Send + 'static>>,
|
||||
action_choice: Arc<Mutex<FnMut(DndAction, DndAction) -> DndAction + Send + 'static>>,
|
||||
callback: Arc<Mutex<dyn FnMut(DataDeviceEvent) + Send + 'static>>,
|
||||
action_choice: Arc<Mutex<dyn FnMut(DndAction, DndAction) -> DndAction + Send + 'static>>,
|
||||
}
|
||||
|
||||
fn implement_data_device<F, C, U, R>(
|
||||
|
|
|
@ -67,7 +67,7 @@ where
|
|||
{
|
||||
fn motion(
|
||||
&mut self,
|
||||
_handle: &mut PointerInnerHandle,
|
||||
_handle: &mut PointerInnerHandle<'_>,
|
||||
location: (f64, f64),
|
||||
focus: Option<(Resource<wl_surface::WlSurface>, (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<C>(
|
|||
metadata: super::SourceMetadata,
|
||||
offer_data: Arc<Mutex<OfferData>>,
|
||||
callback: Arc<Mutex<C>>,
|
||||
action_choice: Arc<Mutex<FnMut(DndAction, DndAction) -> DndAction + Send + 'static>>,
|
||||
action_choice: Arc<Mutex<dyn FnMut(DndAction, DndAction) -> DndAction + Send + 'static>>,
|
||||
) -> Resource<wl_data_offer::WlDataOffer>
|
||||
where
|
||||
C: FnMut(ServerDndEvent) + Send + 'static,
|
||||
|
|
|
@ -112,7 +112,7 @@ struct KbdInternal {
|
|||
state: xkb::State,
|
||||
repeat_rate: i32,
|
||||
repeat_delay: i32,
|
||||
focus_hook: Box<FnMut(Option<&Resource<WlSurface>>)>,
|
||||
focus_hook: Box<dyn FnMut(Option<&Resource<WlSurface>>)>,
|
||||
}
|
||||
|
||||
// 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<FnMut(Option<&Resource<WlSurface>>)>,
|
||||
focus_hook: Box<dyn FnMut(Option<&Resource<WlSurface>>)>,
|
||||
) -> Result<KbdInternal, ()> {
|
||||
// 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<F>(
|
||||
xkb_config: XkbConfig,
|
||||
xkb_config: XkbConfig<'_>,
|
||||
repeat_delay: i32,
|
||||
repeat_rate: i32,
|
||||
logger: &::slog::Logger,
|
||||
|
|
|
@ -281,7 +281,7 @@ impl Seat {
|
|||
/// ```
|
||||
pub fn add_keyboard<F>(
|
||||
&mut self,
|
||||
xkb_config: keyboard::XkbConfig,
|
||||
xkb_config: keyboard::XkbConfig<'_>,
|
||||
repeat_delay: i32,
|
||||
repeat_rate: i32,
|
||||
mut focus_hook: F,
|
||||
|
|
|
@ -29,7 +29,7 @@ pub enum CursorImageStatus {
|
|||
|
||||
enum GrabStatus {
|
||||
None,
|
||||
Active(u32, Box<PointerGrab>),
|
||||
Active(u32, Box<dyn PointerGrab>),
|
||||
Borrowed,
|
||||
}
|
||||
|
||||
|
@ -40,7 +40,7 @@ struct PointerInternal {
|
|||
location: (f64, f64),
|
||||
grab: GrabStatus,
|
||||
pressed_buttons: Vec<u32>,
|
||||
image_callback: Box<FnMut(CursorImageStatus) + Send>,
|
||||
image_callback: Box<dyn FnMut(CursorImageStatus) + Send>,
|
||||
}
|
||||
|
||||
impl PointerInternal {
|
||||
|
@ -95,7 +95,7 @@ impl PointerInternal {
|
|||
|
||||
fn with_grab<F>(&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<WlSurface>, (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<WlSurface>, (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<WlSurface>, (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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -263,7 +263,7 @@ pub(crate) struct ShellData<U, R, SD> {
|
|||
log: ::slog::Logger,
|
||||
compositor_token: CompositorToken<U, R>,
|
||||
display_token: DisplayToken,
|
||||
user_impl: Rc<RefCell<FnMut(XdgRequest<U, R, SD>)>>,
|
||||
user_impl: Rc<RefCell<dyn FnMut(XdgRequest<U, R, SD>)>>,
|
||||
shell_state: Arc<Mutex<ShellState<U, R, SD>>>,
|
||||
}
|
||||
|
||||
|
|
|
@ -127,7 +127,7 @@ struct XWaylandInstance {
|
|||
// Inner implementation of the XWayland manager
|
||||
struct Inner<WM: XWindowManager> {
|
||||
wm: WM,
|
||||
source_maker: Box<FnMut(Rc<RefCell<Inner<WM>>>) -> Result<Source<Signals>, ()>>,
|
||||
source_maker: Box<dyn FnMut(Rc<RefCell<Inner<WM>>>) -> Result<Source<Signals>, ()>>,
|
||||
wayland_display: Rc<RefCell<Display>>,
|
||||
instance: Option<XWaylandInstance>,
|
||||
log: ::slog::Logger,
|
||||
|
|
Loading…
Reference in New Issue