Merge pull request #124 from Smithay/edition/2018

Migrate to Rust 2018 Edition
This commit is contained in:
Victor Brekenfeld 2018-12-17 23:28:55 +01:00 committed by GitHub
commit 039c86d99e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
58 changed files with 202 additions and 248 deletions

View File

@ -5,6 +5,7 @@ authors = ["Victor Berger <victor.berger@m4x.org>", "Drakulix (Victor Brekenfeld
license = "MIT" license = "MIT"
description = "Smithay is a library for writing wayland compositors." description = "Smithay is a library for writing wayland compositors."
repository = "https://github.com/Smithay/smithay" repository = "https://github.com/Smithay/smithay"
edition = "2018"
[workspace] [workspace]
members = [ "anvil" ] members = [ "anvil" ]

View File

@ -4,6 +4,7 @@ version = "0.0.1"
authors = ["Victor Berger <victor.berger@m4x.org>", "Drakulix (Victor Brekenfeld)"] authors = ["Victor Berger <victor.berger@m4x.org>", "Drakulix (Victor Brekenfeld)"]
license = "MIT" license = "MIT"
publish = false publish = false
edition = "2018"
[dependencies] [dependencies]
slog = { version = "2.1.1" } slog = { version = "2.1.1" }

View File

@ -18,20 +18,20 @@ use smithay::{
egl::{BufferAccessError, EGLImages, Format}, egl::{BufferAccessError, EGLImages, Format},
graphics::{gl::GLGraphicsBackend, glium::GliumGraphicsBackend}, graphics::{gl::GLGraphicsBackend, glium::GliumGraphicsBackend},
}, },
reexports::wayland_server::{
protocol::{wl_buffer, wl_surface},
Resource,
},
wayland::{ wayland::{
compositor::{roles::Role, SubsurfaceRole, TraversalAction}, compositor::{roles::Role, SubsurfaceRole, TraversalAction},
data_device::DnDIconRole, data_device::DnDIconRole,
seat::CursorImageRole, seat::CursorImageRole,
shm::with_buffer_contents as shm_buffer_contents, shm::with_buffer_contents as shm_buffer_contents,
}, },
wayland_server::{
protocol::{wl_buffer, wl_surface},
Resource,
},
}; };
use shaders; use crate::shaders;
use shell::{MyCompositorToken, MyWindowMap}; use crate::shell::{MyCompositorToken, MyWindowMap};
#[derive(Copy, Clone)] #[derive(Copy, Clone)]
struct Vertex { struct Vertex {
@ -52,7 +52,7 @@ pub struct GliumDrawer<F: GLGraphicsBackend + 'static> {
} }
impl<F: GLGraphicsBackend + 'static> GliumDrawer<F> { impl<F: GLGraphicsBackend + 'static> GliumDrawer<F> {
pub fn borrow(&self) -> Ref<F> { pub fn borrow(&self) -> Ref<'_, F> {
self.display.borrow() self.display.borrow()
} }
} }
@ -181,7 +181,7 @@ impl<F: GLGraphicsBackend + 'static> GliumDrawer<F> {
} }
Ok(TextureMetadata { Ok(TextureMetadata {
texture: opengl_texture, texture: opengl_texture,
fragment: ::shaders::BUFFER_RGBA, fragment: crate::shaders::BUFFER_RGBA,
y_inverted: images.y_inverted, y_inverted: images.y_inverted,
dimensions: (images.width, images.height), dimensions: (images.width, images.height),
images: Some(images), // I guess we need to keep this alive ? images: Some(images), // I guess we need to keep this alive ?
@ -205,7 +205,7 @@ impl<F: GLGraphicsBackend + 'static> GliumDrawer<F> {
fn texture_from_shm_buffer(&self, buffer: Resource<wl_buffer::WlBuffer>) -> Result<TextureMetadata, ()> { fn texture_from_shm_buffer(&self, buffer: Resource<wl_buffer::WlBuffer>) -> Result<TextureMetadata, ()> {
match shm_buffer_contents(&buffer, |slice, data| { match shm_buffer_contents(&buffer, |slice, data| {
::shm_load::load_shm_buffer(data, slice) crate::shm_load::load_shm_buffer(data, slice)
.map(|(image, kind)| (Texture2d::new(&self.display, image).unwrap(), kind, data)) .map(|(image, kind)| (Texture2d::new(&self.display, image).unwrap(), kind, data))
}) { }) {
Ok(Ok((texture, kind, data))) => Ok(TextureMetadata { Ok(Ok((texture, kind, data))) => Ok(TextureMetadata {

View File

@ -17,14 +17,14 @@ use smithay::{
self, Event, InputBackend, InputHandler, KeyState, KeyboardKeyEvent, PointerAxisEvent, self, Event, InputBackend, InputHandler, KeyState, KeyboardKeyEvent, PointerAxisEvent,
PointerButtonEvent, PointerMotionAbsoluteEvent, PointerMotionEvent, PointerButtonEvent, PointerMotionAbsoluteEvent, PointerMotionEvent,
}, },
reexports::wayland_server::protocol::wl_pointer,
wayland::{ wayland::{
seat::{keysyms as xkb, AxisFrame, KeyboardHandle, Keysym, ModifiersState, PointerHandle}, seat::{keysyms as xkb, AxisFrame, KeyboardHandle, Keysym, ModifiersState, PointerHandle},
SERIAL_COUNTER as SCOUNTER, SERIAL_COUNTER as SCOUNTER,
}, },
wayland_server::protocol::wl_pointer,
}; };
use shell::MyWindowMap; use crate::shell::MyWindowMap;
pub struct AnvilInputHandler { pub struct AnvilInputHandler {
log: Logger, log: Logger,

View File

@ -1,16 +1,14 @@
#![warn(rust_2018_idioms)]
#[macro_use] #[macro_use]
extern crate glium; extern crate glium;
extern crate rand;
#[macro_use] #[macro_use]
extern crate slog; extern crate slog;
extern crate slog_async;
extern crate slog_term;
#[macro_use(define_roles)] #[macro_use(define_roles)]
extern crate smithay; extern crate smithay;
extern crate xkbcommon;
use slog::Drain; use slog::Drain;
use smithay::wayland_server::{calloop::EventLoop, Display}; use smithay::reexports::wayland_server::{calloop::EventLoop, Display};
#[macro_use] #[macro_use]
mod shaders; mod shaders;

View File

@ -12,7 +12,7 @@ macro_rules! make_program(
($display: expr, $fragment_shader:expr) => { ($display: expr, $fragment_shader:expr) => {
program!($display, program!($display,
100 => { 100 => {
vertex: ::shaders::VERTEX_SHADER, vertex: crate::shaders::VERTEX_SHADER,
fragment: $fragment_shader, fragment: $fragment_shader,
}, },
).unwrap() ).unwrap()
@ -23,11 +23,11 @@ macro_rules! make_program(
macro_rules! opengl_programs( macro_rules! opengl_programs(
($display: expr) => { ($display: expr) => {
[ [
make_program!($display, ::shaders::FRAGMENT_SHADER_RGBA), make_program!($display, crate::shaders::FRAGMENT_SHADER_RGBA),
make_program!($display, ::shaders::FRAGMENT_SHADER_ABGR), make_program!($display, crate::shaders::FRAGMENT_SHADER_ABGR),
make_program!($display, ::shaders::FRAGMENT_SHADER_XBGR), make_program!($display, crate::shaders::FRAGMENT_SHADER_XBGR),
make_program!($display, ::shaders::FRAGMENT_SHADER_BGRA), make_program!($display, crate::shaders::FRAGMENT_SHADER_BGRA),
make_program!($display, ::shaders::FRAGMENT_SHADER_BGRX), make_program!($display, crate::shaders::FRAGMENT_SHADER_BGRX),
] ]
} }
); );

View File

@ -7,6 +7,10 @@ use std::{
use rand; use rand;
use smithay::{ use smithay::{
reexports::wayland_server::{
protocol::{wl_buffer, wl_callback, wl_shell_surface, wl_surface},
Display, Resource,
},
wayland::{ wayland::{
compositor::{compositor_init, CompositorToken, SurfaceAttributes, SurfaceEvent}, compositor::{compositor_init, CompositorToken, SurfaceAttributes, SurfaceEvent},
data_device::DnDIconRole, data_device::DnDIconRole,
@ -21,13 +25,9 @@ use smithay::{
}, },
}, },
}, },
wayland_server::{
protocol::{wl_buffer, wl_callback, wl_shell_surface, wl_surface},
Display, Resource,
},
}; };
use window_map::{Kind as SurfaceKind, WindowMap}; use crate::window_map::{Kind as SurfaceKind, WindowMap};
define_roles!(Roles => define_roles!(Roles =>
[ XdgSurface, XdgSurfaceRole ] [ XdgSurface, XdgSurfaceRole ]
@ -132,7 +132,7 @@ pub fn init_shell(
#[derive(Default)] #[derive(Default)]
pub struct SurfaceData { pub struct SurfaceData {
pub buffer: Option<Resource<wl_buffer::WlBuffer>>, pub buffer: Option<Resource<wl_buffer::WlBuffer>>,
pub texture: Option<::glium_drawer::TextureMetadata>, pub texture: Option<crate::glium_drawer::TextureMetadata>,
} }
fn surface_commit(surface: &Resource<wl_surface::WlSurface>, token: CompositorToken<SurfaceData, Roles>) { fn surface_commit(surface: &Resource<wl_surface::WlSurface>, token: CompositorToken<SurfaceData, Roles>) {

View File

@ -1,10 +1,10 @@
use std::borrow::Cow; use std::borrow::Cow;
use smithay::{wayland::shm::BufferData, wayland_server::protocol::wl_shm::Format}; use smithay::{reexports::wayland_server::protocol::wl_shm::Format, wayland::shm::BufferData};
use glium::texture::{ClientFormat, RawImage2d}; 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 offset = data.offset as usize;
let width = data.width as usize; let width = data.width as usize;
let height = data.height 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 // ensure consistency, the SHM handler of smithay should ensure this
assert!(offset + (height - 1) * stride + width * pixelsize <= pool.len()); 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 // the buffer is cleanly continuous, use as-is
Cow::Borrowed(&pool[offset..(offset + height * width * pixelsize)]) Cow::Borrowed(&pool[offset..(offset + height * width * pixelsize)])
} else { } else {
@ -33,10 +33,10 @@ pub fn load_shm_buffer(data: BufferData, pool: &[u8]) -> Result<(RawImage2d<u8>,
// sharders format need to be reversed to account for endianness // sharders format need to be reversed to account for endianness
let (client_format, fragment) = match data.format { let (client_format, fragment) = match data.format {
Format::Argb8888 => (ClientFormat::U8U8U8U8, ::shaders::BUFFER_BGRA), Format::Argb8888 => (ClientFormat::U8U8U8U8, crate::shaders::BUFFER_BGRA),
Format::Xrgb8888 => (ClientFormat::U8U8U8U8, ::shaders::BUFFER_BGRX), Format::Xrgb8888 => (ClientFormat::U8U8U8U8, crate::shaders::BUFFER_BGRX),
Format::Rgba8888 => (ClientFormat::U8U8U8U8, ::shaders::BUFFER_ABGR), Format::Rgba8888 => (ClientFormat::U8U8U8U8, crate::shaders::BUFFER_ABGR),
Format::Rgbx8888 => (ClientFormat::U8U8U8U8, ::shaders::BUFFER_XBGR), Format::Rgbx8888 => (ClientFormat::U8U8U8U8, crate::shaders::BUFFER_XBGR),
_ => return Err(data.format), _ => return Err(data.format),
}; };
Ok(( Ok((

View File

@ -61,9 +61,9 @@ use smithay::{
}, },
}; };
use glium_drawer::GliumDrawer; use crate::glium_drawer::GliumDrawer;
use input_handler::AnvilInputHandler; use crate::input_handler::AnvilInputHandler;
use shell::{init_shell, MyWindowMap, Roles, SurfaceData}; use crate::shell::{init_shell, MyWindowMap, Roles, SurfaceData};
pub struct SessionFd(RawFd); pub struct SessionFd(RawFd);
impl AsRawFd for SessionFd { impl AsRawFd for SessionFd {
@ -110,7 +110,7 @@ pub fn run_udev(mut display: Display, mut event_loop: EventLoop<()>, log: Logger
/* /*
* Initialize the udev backend * 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 seat = session.seat();
let primary_gpu = primary_gpu(&context, &seat).unwrap_or_default(); let primary_gpu = primary_gpu(&context, &seat).unwrap_or_default();

View File

@ -1,4 +1,5 @@
use smithay::{ use smithay::{
reexports::wayland_server::{protocol::wl_surface, Resource},
utils::Rectangle, utils::Rectangle,
wayland::{ wayland::{
compositor::{roles::Role, CompositorToken, SubsurfaceRole, SurfaceAttributes, TraversalAction}, compositor::{roles::Role, CompositorToken, SubsurfaceRole, SurfaceAttributes, TraversalAction},
@ -7,7 +8,6 @@ use smithay::{
xdg::{ToplevelSurface, XdgSurfaceRole}, xdg::{ToplevelSurface, XdgSurfaceRole},
}, },
}, },
wayland_server::{protocol::wl_surface, Resource},
}; };
pub enum Kind<U, R, SD, D> { pub enum Kind<U, R, SD, D> {

View File

@ -6,20 +6,20 @@ use std::{
use smithay::{ use smithay::{
backend::{egl::EGLGraphicsBackend, graphics::gl::GLGraphicsBackend, input::InputBackend, winit}, backend::{egl::EGLGraphicsBackend, graphics::gl::GLGraphicsBackend, input::InputBackend, winit},
reexports::wayland_server::{calloop::EventLoop, protocol::wl_output, Display},
wayland::{ wayland::{
data_device::{default_action_chooser, init_data_device, set_data_device_focus, DataDeviceEvent}, data_device::{default_action_chooser, init_data_device, set_data_device_focus, DataDeviceEvent},
output::{Mode, Output, PhysicalProperties}, output::{Mode, Output, PhysicalProperties},
seat::{CursorImageStatus, Seat, XkbConfig}, seat::{CursorImageStatus, Seat, XkbConfig},
shm::init_shm_global, shm::init_shm_global,
}, },
wayland_server::{calloop::EventLoop, protocol::wl_output, Display},
}; };
use slog::Logger; use slog::Logger;
use glium_drawer::GliumDrawer; use crate::glium_drawer::GliumDrawer;
use input_handler::AnvilInputHandler; use crate::input_handler::AnvilInputHandler;
use shell::init_shell; use crate::shell::init_shell;
pub fn run_winit(display: &mut Display, event_loop: &mut EventLoop<()>, log: Logger) -> Result<(), ()> { pub fn run_winit(display: &mut Display, event_loop: &mut EventLoop<()>, log: Logger) -> Result<(), ()> {
let (renderer, mut input) = winit::init(log.clone()).map_err(|_| ())?; let (renderer, mut input) = winit::init(log.clone()).map_err(|_| ())?;

View File

@ -1,7 +1,7 @@
extern crate smithay; #![warn(rust_2018_idioms)]
#[macro_use] #[macro_use]
extern crate slog; extern crate slog;
extern crate slog_term;
use slog::Drain; use slog::Drain;
use smithay::{ use smithay::{
@ -145,7 +145,7 @@ impl DeviceHandler for DrmHandlerImpl {
// now we could render to the mapping via software rendering. // now we could render to the mapping via software rendering.
// this example just sets some grey color // this example just sets some grey color
for mut x in mapping.as_mut() { for x in mapping.as_mut() {
*x = 128; *x = 128;
} }
} }

View File

@ -3,7 +3,7 @@
//! and [`EglSurface`](::backend::drm::egl::EglSurface). //! and [`EglSurface`](::backend::drm::egl::EglSurface).
//! //!
use backend::egl::error as egl; use crate::backend::egl::error as egl;
error_chain! { error_chain! {
errors { errors {

View File

@ -15,12 +15,12 @@ use std::rc::Rc;
use wayland_server::Display; use wayland_server::Display;
use super::{Device, DeviceHandler, Surface}; use super::{Device, DeviceHandler, Surface};
use backend::egl::context::GlAttributes; use crate::backend::egl::context::GlAttributes;
use backend::egl::error::Result as EGLResult; use crate::backend::egl::error::Result as EGLResult;
use backend::egl::native::{Backend, NativeDisplay, NativeSurface}; use crate::backend::egl::native::{Backend, NativeDisplay, NativeSurface};
use backend::egl::EGLContext; use crate::backend::egl::EGLContext;
#[cfg(feature = "native_lib")] #[cfg(feature = "native_lib")]
use backend::egl::{EGLDisplay, EGLGraphicsBackend}; use crate::backend::egl::{EGLDisplay, EGLGraphicsBackend};
pub mod error; pub mod error;
use self::error::*; use self::error::*;
@ -87,7 +87,7 @@ where
where where
L: Into<Option<::slog::Logger>>, L: Into<Option<::slog::Logger>>,
{ {
let log = ::slog_or_stdlog(logger).new(o!("smithay_module" => "backend_egl")); let log = crate::slog_or_stdlog(logger).new(o!("smithay_module" => "backend_egl"));
dev.clear_handler(); dev.clear_handler();
@ -108,7 +108,7 @@ where
D: Device + NativeDisplay<B, Arguments = crtc::Handle> + 'static, D: Device + NativeDisplay<B, Arguments = crtc::Handle> + 'static,
<D as Device>::Surface: NativeSurface, <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> impl<B, D> DeviceHandler for InternalDeviceHandler<B, D>

View File

@ -7,9 +7,9 @@ use drm::control::crtc;
use std::os::unix::io::RawFd; use std::os::unix::io::RawFd;
use super::EglDevice; use super::EglDevice;
use backend::drm::Device; use crate::backend::drm::Device;
use backend::egl::native::{Backend, NativeDisplay, NativeSurface}; use crate::backend::egl::native::{Backend, NativeDisplay, NativeSurface};
use backend::session::{AsSessionObserver, SessionObserver}; use crate::backend::session::{AsSessionObserver, SessionObserver};
/// [`SessionObserver`](SessionObserver) /// [`SessionObserver`](SessionObserver)
/// linked to the [`EglDevice`](EglDevice) it was /// linked to the [`EglDevice`](EglDevice) it was

View File

@ -3,14 +3,14 @@ use nix::libc::c_void;
use std::rc::Rc; use std::rc::Rc;
use super::error::*; use super::error::*;
use backend::drm::{Device, Surface}; use crate::backend::drm::{Device, Surface};
use backend::egl::native::{Backend, NativeDisplay, NativeSurface}; use crate::backend::egl::native::{Backend, NativeDisplay, NativeSurface};
use backend::egl::{EGLContext, EGLSurface}; use crate::backend::egl::{EGLContext, EGLSurface};
#[cfg(feature = "renderer_gl")] #[cfg(feature = "renderer_gl")]
use backend::graphics::gl::GLGraphicsBackend; use crate::backend::graphics::gl::GLGraphicsBackend;
#[cfg(feature = "renderer_gl")] #[cfg(feature = "renderer_gl")]
use backend::graphics::PixelFormat; use crate::backend::graphics::PixelFormat;
use backend::graphics::{CursorBackend, SwapBuffersError}; use crate::backend::graphics::{CursorBackend, SwapBuffersError};
/// Egl surface for rendering /// Egl surface for rendering
pub struct EglSurface<B, D> pub struct EglSurface<B, D>

View File

@ -4,11 +4,11 @@
//! [`GbmDevice`](GbmDevice) and [`GbmSurface`](GbmSurface). //! [`GbmDevice`](GbmDevice) and [`GbmSurface`](GbmSurface).
//! //!
use backend::drm::{Device, RawDevice}; use crate::backend::drm::{Device, RawDevice};
use backend::egl::error::Result as EglResult; use crate::backend::egl::error::Result as EglResult;
use backend::egl::ffi; use crate::backend::egl::ffi;
use backend::egl::native::{Backend, NativeDisplay, NativeSurface}; use crate::backend::egl::native::{Backend, NativeDisplay, NativeSurface};
use backend::graphics::SwapBuffersError; use crate::backend::graphics::SwapBuffersError;
use super::error::{Error, Result}; use super::error::{Error, Result};
use super::{GbmDevice, GbmSurface}; use super::{GbmDevice, GbmSurface};

View File

@ -49,6 +49,6 @@ error_chain! {
} }
foreign_links { foreign_links {
FailedToSwap(::backend::graphics::SwapBuffersError) #[doc = "Swapping front buffers failed"]; FailedToSwap(crate::backend::graphics::SwapBuffersError) #[doc = "Swapping front buffers failed"];
} }
} }

View File

@ -65,7 +65,7 @@ impl<D: RawDevice + ControlDevice + 'static> GbmDevice<D> {
); );
}); });
let log = ::slog_or_stdlog(logger).new(o!("smithay_module" => "backend_gbm")); let log = crate::slog_or_stdlog(logger).new(o!("smithay_module" => "backend_gbm"));
dev.clear_handler(); dev.clear_handler();
@ -82,7 +82,7 @@ impl<D: RawDevice + ControlDevice + 'static> GbmDevice<D> {
} }
struct InternalDeviceHandler<D: RawDevice + ControlDevice + 'static> { 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>>>>>, backends: Weak<RefCell<HashMap<crtc::Handle, Weak<GbmSurfaceInternal<D>>>>>,
logger: ::slog::Logger, logger: ::slog::Logger,
} }

View File

@ -11,8 +11,8 @@ use std::os::unix::io::RawFd;
use std::rc::{Rc, Weak}; use std::rc::{Rc, Weak};
use super::{GbmDevice, GbmSurfaceInternal}; use super::{GbmDevice, GbmSurfaceInternal};
use backend::drm::{RawDevice, RawSurface}; use crate::backend::drm::{RawDevice, RawSurface};
use backend::session::{AsSessionObserver, SessionObserver}; use crate::backend::session::{AsSessionObserver, SessionObserver};
/// [`SessionObserver`](SessionObserver) /// [`SessionObserver`](SessionObserver)
/// linked to the [`GbmDevice`](GbmDevice) it was /// linked to the [`GbmDevice`](GbmDevice) it was

View File

@ -10,9 +10,9 @@ use std::os::unix::io::AsRawFd;
use std::rc::Rc; use std::rc::Rc;
#[cfg(feature = "backend_drm_legacy")] #[cfg(feature = "backend_drm_legacy")]
use backend::drm::legacy::LegacyDrmDevice; use crate::backend::drm::legacy::LegacyDrmDevice;
use backend::graphics::CursorBackend; use crate::backend::graphics::CursorBackend;
use backend::graphics::SwapBuffersError; use crate::backend::graphics::SwapBuffersError;
pub(super) struct GbmSurfaceInternal<D: RawDevice + 'static> { pub(super) struct GbmSurfaceInternal<D: RawDevice + 'static> {
pub(super) dev: Rc<RefCell<gbm::Device<D>>>, pub(super) dev: Rc<RefCell<gbm::Device<D>>>,

View File

@ -49,6 +49,6 @@ error_chain! {
} }
foreign_links { foreign_links {
FailedToSwap(::backend::graphics::SwapBuffersError) #[doc = "Swapping front buffers failed"]; FailedToSwap(crate::backend::graphics::SwapBuffersError) #[doc = "Swapping front buffers failed"];
} }
} }

View File

@ -38,7 +38,7 @@ pub struct LegacyDrmDevice<A: AsRawFd + 'static> {
dev_id: dev_t, dev_id: dev_t,
active: Arc<AtomicBool>, active: Arc<AtomicBool>,
backends: Rc<RefCell<HashMap<crtc::Handle, Weak<LegacyDrmSurfaceInternal<A>>>>>, 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, logger: ::slog::Logger,
} }
@ -94,7 +94,7 @@ impl<A: AsRawFd + 'static> LegacyDrmDevice<A> {
where where
L: Into<Option<::slog::Logger>>, L: Into<Option<::slog::Logger>>,
{ {
let log = ::slog_or_stdlog(logger).new(o!("smithay_module" => "backend_drm")); let log = crate::slog_or_stdlog(logger).new(o!("smithay_module" => "backend_drm"));
info!(log, "DrmDevice initializing"); info!(log, "DrmDevice initializing");
let dev_id = fstat(dev.as_raw_fd()) let dev_id = fstat(dev.as_raw_fd())

View File

@ -15,7 +15,7 @@ use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::Arc; use std::sync::Arc;
use super::{Dev, LegacyDrmDevice, LegacyDrmSurfaceInternal}; use super::{Dev, LegacyDrmDevice, LegacyDrmSurfaceInternal};
use backend::session::{AsSessionObserver, SessionObserver}; use crate::backend::session::{AsSessionObserver, SessionObserver};
/// [`SessionObserver`](SessionObserver) /// [`SessionObserver`](SessionObserver)
/// linked to the [`LegacyDrmDevice`](LegacyDrmDevice) /// linked to the [`LegacyDrmDevice`](LegacyDrmDevice)

View File

@ -7,9 +7,9 @@ use std::os::unix::io::{AsRawFd, RawFd};
use std::rc::Rc; use std::rc::Rc;
use std::sync::RwLock; use std::sync::RwLock;
use backend::drm::{DevPath, RawSurface, Surface}; use crate::backend::drm::{DevPath, RawSurface, Surface};
use backend::graphics::CursorBackend; use crate::backend::graphics::CursorBackend;
use backend::graphics::SwapBuffersError; use crate::backend::graphics::SwapBuffersError;
use super::{error::*, Dev}; use super::{error::*, Dev};
@ -37,7 +37,7 @@ impl<A: AsRawFd + 'static> BasicDevice for LegacyDrmSurfaceInternal<A> {}
impl<A: AsRawFd + 'static> ControlDevice for LegacyDrmSurfaceInternal<A> {} impl<A: AsRawFd + 'static> ControlDevice for LegacyDrmSurfaceInternal<A> {}
impl<'a, A: AsRawFd + 'static> CursorBackend<'a> 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; type Error = Error;
fn set_cursor_position(&self, x: u32, y: u32) -> Result<()> { 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: AsRawFd + 'static> ControlDevice for LegacyDrmSurface<A> {}
impl<'a, A: AsRawFd + 'static> CursorBackend<'a> 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; type Error = Error;
fn set_cursor_position(&self, x: u32, y: u32) -> Result<()> { fn set_cursor_position(&self, x: u32, y: u32) -> Result<()> {

View File

@ -1,7 +1,7 @@
//! EGL context related structs //! EGL context related structs
use super::{error::*, ffi, native, EGLSurface}; use super::{error::*, ffi, native, EGLSurface};
use backend::graphics::PixelFormat; use crate::backend::graphics::PixelFormat;
use nix::libc::{c_int, c_void}; use nix::libc::{c_int, c_void};
use slog; use slog;
use std::{ use std::{
@ -36,7 +36,7 @@ impl<B: native::Backend, N: native::NativeDisplay<B>> EGLContext<B, N> {
where where
L: Into<Option<::slog::Logger>>, L: Into<Option<::slog::Logger>>,
{ {
let log = ::slog_or_stdlog(logger.into()).new(o!("smithay_module" => "renderer_egl")); let log = crate::slog_or_stdlog(logger.into()).new(o!("smithay_module" => "renderer_egl"));
let ptr = native.ptr()?; let ptr = native.ptr()?;
let (context, display, config_id, surface_attributes, pixel_format, wl_drm_support) = let (context, display, config_id, surface_attributes, pixel_format, wl_drm_support) =
unsafe { EGLContext::<B, N>::new_internal(ptr, attributes, reqs, log.clone()) }?; unsafe { EGLContext::<B, N>::new_internal(ptr, attributes, reqs, log.clone()) }?;
@ -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). /// This follows the same semantics as [`std::cell:RefCell`](std::cell::RefCell).
/// Multiple read-only borrows are possible. Borrowing the /// Multiple read-only borrows are possible. Borrowing the
/// backend while there is a mutable reference will panic. /// backend while there is a mutable reference will panic.
pub fn borrow(&self) -> Ref<N> { pub fn borrow(&self) -> Ref<'_, N> {
self.native.borrow() 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 /// Holding any other borrow while trying to borrow the backend
/// mutably will panic. Note that EGL will borrow the display /// mutably will panic. Note that EGL will borrow the display
/// mutably during surface creation. /// mutably during surface creation.
pub fn borrow_mut(&self) -> RefMut<N> { pub fn borrow_mut(&self) -> RefMut<'_, N> {
self.native.borrow_mut() self.native.borrow_mut()
} }
} }

View File

@ -13,7 +13,7 @@ pub type NativeDisplayType = *const c_void;
pub type NativePixmapType = *const c_void; pub type NativePixmapType = *const c_void;
pub type NativeWindowType = *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 { pub mod egl {
use super::*; use super::*;
use libloading::Library; use libloading::Library;

View File

@ -19,7 +19,7 @@
//! of an EGL-based [`WlBuffer`](wayland_server::protocol::wl_buffer::WlBuffer) for rendering. //! of an EGL-based [`WlBuffer`](wayland_server::protocol::wl_buffer::WlBuffer) for rendering.
#[cfg(feature = "renderer_gl")] #[cfg(feature = "renderer_gl")]
use backend::graphics::gl::ffi as gl_ffi; use crate::backend::graphics::gl::ffi as gl_ffi;
use nix::libc::c_uint; use nix::libc::c_uint;
use std::{ use std::{
ffi::CStr, ffi::CStr,
@ -51,7 +51,7 @@ pub use self::surface::EGLSurface;
pub struct EglExtensionNotSupportedError(&'static [&'static str]); pub struct EglExtensionNotSupportedError(&'static [&'static str]);
impl fmt::Display for EglExtensionNotSupportedError { 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!( write!(
formatter, formatter,
"None of the following EGL extensions is supported by the underlying EGL implementation, "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" "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 None
} }
} }
@ -84,7 +84,7 @@ pub enum BufferAccessError {
} }
impl fmt::Debug for 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 { match *self {
BufferAccessError::ContextLost => write!(formatter, "BufferAccessError::ContextLost"), BufferAccessError::ContextLost => write!(formatter, "BufferAccessError::ContextLost"),
BufferAccessError::NotManaged(_) => write!(formatter, "BufferAccessError::NotManaged"), BufferAccessError::NotManaged(_) => write!(formatter, "BufferAccessError::NotManaged"),
@ -97,7 +97,7 @@ impl fmt::Debug for BufferAccessError {
} }
impl fmt::Display 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; use std::error::Error;
match *self { match *self {
BufferAccessError::ContextLost 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 { match *self {
BufferAccessError::EglExtensionNotSupported(ref err) => Some(err), BufferAccessError::EglExtensionNotSupported(ref err) => Some(err),
_ => None, _ => None,
@ -158,7 +158,7 @@ pub enum TextureCreationError {
} }
impl fmt::Display for 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; use std::error::Error;
match *self { match *self {
TextureCreationError::ContextLost => write!(formatter, "{}", self.description()), 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 None
} }
} }

View File

@ -1,7 +1,7 @@
//! Type safe native types for safe context/surface creation //! Type safe native types for safe context/surface creation
use super::{error::*, ffi}; use super::{error::*, ffi};
use backend::graphics::SwapBuffersError; use crate::backend::graphics::SwapBuffersError;
#[cfg(feature = "backend_winit")] #[cfg(feature = "backend_winit")]
use std::ptr; use std::ptr;

View File

@ -1,7 +1,7 @@
//! EGL surface related structs //! EGL surface related structs
use super::{error::*, ffi, native, EGLContext}; use super::{error::*, ffi, native, EGLContext};
use backend::graphics::SwapBuffersError; use crate::backend::graphics::SwapBuffersError;
use nix::libc::c_int; use nix::libc::c_int;
use std::{ use std::{
cell::Cell, cell::Cell,

View File

@ -22,7 +22,7 @@ pub enum SwapBuffersError {
} }
impl fmt::Display for 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; use std::error::Error;
write!(formatter, "{}", self.description()) write!(formatter, "{}", self.description())
} }
@ -39,7 +39,7 @@ impl Error for SwapBuffersError {
} }
} }
fn cause(&self) -> Option<&Error> { fn cause(&self) -> Option<&dyn Error> {
None None
} }
} }

View File

@ -4,8 +4,7 @@ use nix::libc::c_void;
use super::{PixelFormat, SwapBuffersError}; use super::{PixelFormat, SwapBuffersError};
#[cfg_attr(feature = "cargo-clippy", allow(clippy))] #[allow(clippy::all, rust_2018_idioms, missing_docs)]
#[allow(missing_docs)]
pub(crate) mod ffi { pub(crate) mod ffi {
include!(concat!(env!("OUT_DIR"), "/gl_bindings.rs")); include!(concat!(env!("OUT_DIR"), "/gl_bindings.rs"));
} }

View File

@ -1,6 +1,6 @@
//! Glium compatibility module //! Glium compatibility module
use backend::graphics::{gl::GLGraphicsBackend, SwapBuffersError}; use crate::backend::graphics::{gl::GLGraphicsBackend, SwapBuffersError};
use glium::{ use glium::{
backend::{Backend, Context, Facade}, backend::{Backend, Context, Facade},
debug::DebugCallbackBehavior, debug::DebugCallbackBehavior,
@ -59,7 +59,7 @@ impl<T: GLGraphicsBackend + 'static> GliumGraphicsBackend<T> {
/// This follows the same semantics as [`std::cell::RefCell`](RefCell::borrow). /// This follows the same semantics as [`std::cell::RefCell`](RefCell::borrow).
/// Multiple read-only borrows are possible. Borrowing the /// Multiple read-only borrows are possible. Borrowing the
/// backend while there is a mutable reference will panic. /// 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() self.backend.0.borrow()
} }
@ -69,7 +69,7 @@ impl<T: GLGraphicsBackend + 'static> GliumGraphicsBackend<T> {
/// Holding any other borrow while trying to borrow the backend /// Holding any other borrow while trying to borrow the backend
/// mutably will panic. Note that Glium will borrow the backend /// mutably will panic. Note that Glium will borrow the backend
/// (not mutably) during rendering. /// (not mutably) during rendering.
pub fn borrow_mut(&self) -> RefMut<T> { pub fn borrow_mut(&self) -> RefMut<'_, T> {
self.backend.0.borrow_mut() self.backend.0.borrow_mut()
} }
} }

View File

@ -521,7 +521,7 @@ pub trait InputBackend: Sized {
/// Sets a new handler for this [`InputBackend`] /// Sets a new handler for this [`InputBackend`]
fn set_handler<H: InputHandler<Self> + 'static>(&mut self, handler: H); fn set_handler<H: InputHandler<Self> + 'static>(&mut self, handler: H);
/// Get a reference to the currently set handler, if any /// 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 /// Clears the currently handler, if one is set
fn clear_handler(&mut self); 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); 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) { fn on_seat_created(&mut self, seat: &Seat) {
(**self).on_seat_created(seat) (**self).on_seat_created(seat)
} }

View File

@ -1,8 +1,8 @@
//! Implementation of input backend trait for types provided by `libinput` //! Implementation of input backend trait for types provided by `libinput`
use backend::input::{self as backend, Axis, InputBackend}; use crate::backend::input::{self as backend, Axis, InputBackend};
#[cfg(feature = "backend_session")] #[cfg(feature = "backend_session")]
use backend::session::{AsErrno, Session, SessionObserver}; use crate::backend::session::{AsErrno, Session, SessionObserver};
use input as libinput; use input as libinput;
use input::event; use input::event;
@ -35,7 +35,7 @@ pub struct LibinputInputBackend {
context: libinput::Libinput, context: libinput::Libinput,
devices: Vec<libinput::Device>, devices: Vec<libinput::Device>,
seats: HashMap<libinput::Seat, backend::Seat>, seats: HashMap<libinput::Seat, backend::Seat>,
handler: Option<Box<backend::InputHandler<LibinputInputBackend> + 'static>>, handler: Option<Box<dyn backend::InputHandler<LibinputInputBackend> + 'static>>,
logger: ::slog::Logger, logger: ::slog::Logger,
} }
@ -46,7 +46,7 @@ impl LibinputInputBackend {
where where
L: Into<Option<::slog::Logger>>, L: Into<Option<::slog::Logger>>,
{ {
let log = ::slog_or_stdlog(logger).new(o!("smithay_module" => "backend_libinput")); let log = crate::slog_or_stdlog(logger).new(o!("smithay_module" => "backend_libinput"));
info!(log, "Initializing a libinput backend"); info!(log, "Initializing a libinput backend");
LibinputInputBackend { LibinputInputBackend {
context, context,
@ -275,10 +275,10 @@ impl InputBackend for LibinputInputBackend {
self.handler = Some(Box::new(handler)); 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 self.handler
.as_mut() .as_mut()
.map(|handler| handler as &mut backend::InputHandler<Self>) .map(|handler| handler as &mut dyn backend::InputHandler<Self>)
} }
fn clear_handler(&mut self) { fn clear_handler(&mut self) {
@ -612,7 +612,7 @@ pub fn libinput_bind<Data: 'static>(
source.set_interest(Ready::readable()); source.set_interest(Ready::readable());
handle.insert_source(source, move |evt, _| { handle.insert_source(source, move |evt, _| {
use backend::input::InputBackend; use crate::backend::input::InputBackend;
let mut backend = evt.source.borrow_mut(); let mut backend = evt.source.borrow_mut();
if let Err(error) = backend.0.dispatch_new_events() { if let Err(error) = backend.0.dispatch_new_events() {

View File

@ -88,7 +88,7 @@ impl AutoSession {
where where
L: Into<Option<::slog::Logger>>, L: Into<Option<::slog::Logger>>,
{ {
let logger = ::slog_or_stdlog(logger) let logger = crate::slog_or_stdlog(logger)
.new(o!("smithay_module" => "backend_session_auto", "session_type" => "auto")); .new(o!("smithay_module" => "backend_session_auto", "session_type" => "auto"));
info!(logger, "Trying to create logind session"); info!(logger, "Trying to create logind session");
@ -121,7 +121,7 @@ impl AutoSession {
where where
L: Into<Option<::slog::Logger>>, L: Into<Option<::slog::Logger>>,
{ {
let logger = ::slog_or_stdlog(logger) let logger = crate::slog_or_stdlog(logger)
.new(o!("smithay_module" => "backend_session_auto", "session_type" => "auto")); .new(o!("smithay_module" => "backend_session_auto", "session_type" => "auto"));
info!(logger, "Trying to create tty session"); info!(logger, "Trying to create tty session");

View File

@ -31,7 +31,7 @@
//! It is crucial to avoid errors during that state. Examples for object that might be registered //! It is crucial to avoid errors during that state. Examples for object that might be registered
//! for notifications are the [`Libinput`](input::Libinput) context or the [`Device`](::backend::drm::Device). //! for notifications are the [`Libinput`](input::Libinput) context or the [`Device`](::backend::drm::Device).
use backend::session::{AsErrno, Session, SessionNotifier, SessionObserver}; use crate::backend::session::{AsErrno, Session, SessionNotifier, SessionObserver};
use dbus::{ 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,
@ -60,7 +60,7 @@ struct LogindSessionImpl {
conn: RefCell<Connection>, conn: RefCell<Connection>,
session_path: DbusPath<'static>, session_path: DbusPath<'static>,
active: AtomicBool, active: AtomicBool,
signals: RefCell<Vec<Option<Box<SessionObserver>>>>, signals: RefCell<Vec<Option<Box<dyn SessionObserver>>>>,
seat: String, seat: String,
logger: ::slog::Logger, logger: ::slog::Logger,
} }
@ -84,7 +84,7 @@ impl LogindSession {
where where
L: Into<Option<::slog::Logger>>, L: Into<Option<::slog::Logger>>,
{ {
let logger = ::slog_or_stdlog(logger) let logger = crate::slog_or_stdlog(logger)
.new(o!("smithay_module" => "backend_session", "session_type" => "logind")); .new(o!("smithay_module" => "backend_session", "session_type" => "logind"));
// Acquire session_id, seat and vt (if any) via libsystemd // Acquire session_id, seat and vt (if any) via libsystemd
@ -246,7 +246,7 @@ impl LogindSessionImpl {
} }
} }
fn handle_signals(&self, signals: ConnectionItems) -> Result<()> { fn handle_signals(&self, signals: ConnectionItems<'_>) -> Result<()> {
for item in signals { for item in signals {
let message = if let ConnectionItem::Signal(ref s) = item { let message = if let ConnectionItem::Signal(ref s) = item {
s s
@ -314,7 +314,7 @@ impl LogindSessionImpl {
use dbus::arg::{Array, Dict, Get, Iter, Variant}; use dbus::arg::{Array, Dict, Get, Iter, Variant};
let (_, changed, _) = 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)?; let mut changed = changed.chain_err(|| ErrorKind::UnexpectedMethodReturn)?;
if let Some((_, mut value)) = changed.find(|&(ref key, _)| &*key == "Active") { if let Some((_, mut value)) = changed.find(|&(ref key, _)| &*key == "Active") {
if let Some(active) = Get::get(&mut value.0) { if let Some(active) = Get::get(&mut value.0) {

View File

@ -162,7 +162,7 @@ pub struct DirectSession {
pub struct DirectSessionNotifier { pub struct DirectSessionNotifier {
tty: RawFd, tty: RawFd,
active: Arc<AtomicBool>, active: Arc<AtomicBool>,
signals: Vec<Option<Box<SessionObserver>>>, signals: Vec<Option<Box<dyn SessionObserver>>>,
signal: Signal, signal: Signal,
logger: ::slog::Logger, logger: ::slog::Logger,
} }
@ -175,7 +175,7 @@ impl DirectSession {
where where
L: Into<Option<::slog::Logger>>, L: Into<Option<::slog::Logger>>,
{ {
let logger = ::slog_or_stdlog(logger) let logger = crate::slog_or_stdlog(logger)
.new(o!("smithay_module" => "backend_session", "session_type" => "direct/vt")); .new(o!("smithay_module" => "backend_session", "session_type" => "direct/vt"));
let fd = tty let fd = tty

View File

@ -16,26 +16,26 @@ static ID_COUNTER: AtomicUsize = AtomicUsize::new(0);
pub struct Id(usize); pub struct Id(usize);
struct MultiObserver { struct MultiObserver {
observer: Arc<Mutex<HashMap<Id, Box<SessionObserver>>>>, observer: Arc<Mutex<HashMap<Id, Box<dyn SessionObserver>>>>,
} }
impl SessionObserver for MultiObserver { impl SessionObserver for MultiObserver {
fn pause(&mut self, device: Option<(u32, u32)>) { fn pause(&mut self, device: Option<(u32, u32)>) {
let mut lock = self.observer.lock().unwrap(); let mut lock = self.observer.lock().unwrap();
for mut observer in lock.values_mut() { for observer in lock.values_mut() {
observer.pause(device) observer.pause(device)
} }
} }
fn activate(&mut self, device: Option<(u32, u32, Option<RawFd>)>) { fn activate(&mut self, device: Option<(u32, u32, Option<RawFd>)>) {
let mut lock = self.observer.lock().unwrap(); let mut lock = self.observer.lock().unwrap();
for mut observer in lock.values_mut() { for observer in lock.values_mut() {
observer.activate(device) observer.activate(device)
} }
} }
} }
struct MultiNotifier { struct MultiNotifier {
observer: Arc<Mutex<HashMap<Id, Box<SessionObserver>>>>, observer: Arc<Mutex<HashMap<Id, Box<dyn SessionObserver>>>>,
} }
impl SessionNotifier for MultiNotifier { impl SessionNotifier for MultiNotifier {

View File

@ -59,7 +59,7 @@ impl<T: UdevHandler + 'static> UdevBackend<T> {
where where
L: Into<Option<::slog::Logger>>, L: Into<Option<::slog::Logger>>,
{ {
let log = ::slog_or_stdlog(logger).new(o!("smithay_module" => "backend_udev")); let log = crate::slog_or_stdlog(logger).new(o!("smithay_module" => "backend_udev"));
let devices = all_gpus(context, seat)? let devices = all_gpus(context, seat)?
.into_iter() .into_iter()

View File

@ -1,6 +1,6 @@
//! Implementation of backend traits for types provided by `winit` //! Implementation of backend traits for types provided by `winit`
use backend::{ use crate::backend::{
egl::{ egl::{
context::GlAttributes, error::Result as EGLResult, native, EGLContext, EGLDisplay, context::GlAttributes, error::Result as EGLResult, native, EGLContext, EGLDisplay,
EGLGraphicsBackend, EGLSurface, EGLGraphicsBackend, EGLSurface,
@ -30,7 +30,7 @@ use winit::{
/// Errors thrown by the `winit` backends /// Errors thrown by the `winit` backends
pub mod errors { pub mod errors {
use backend::egl::error as egl_error; use crate::backend::egl::error as egl_error;
error_chain! { error_chain! {
errors { errors {
@ -64,7 +64,7 @@ enum Window {
} }
impl Window { impl Window {
fn window(&self) -> Ref<WinitWindow> { fn window(&self) -> Ref<'_, WinitWindow> {
match *self { match *self {
Window::Wayland { ref context, .. } => context.borrow(), Window::Wayland { ref context, .. } => context.borrow(),
Window::X11 { ref context, .. } => context.borrow(), Window::X11 { ref context, .. } => context.borrow(),
@ -91,13 +91,13 @@ pub struct WinitGraphicsBackend {
/// periodically to receive any events. /// periodically to receive any events.
pub struct WinitInputBackend { pub struct WinitInputBackend {
events_loop: EventsLoop, events_loop: EventsLoop,
events_handler: Option<Box<WinitEventsHandler>>, events_handler: Option<Box<dyn WinitEventsHandler>>,
window: Rc<Window>, window: Rc<Window>,
time: Instant, time: Instant,
key_counter: u32, key_counter: u32,
seat: Seat, seat: Seat,
input_config: (), input_config: (),
handler: Option<Box<InputHandler<WinitInputBackend> + 'static>>, handler: Option<Box<dyn InputHandler<WinitInputBackend> + 'static>>,
logger: ::slog::Logger, logger: ::slog::Logger,
size: Rc<RefCell<WindowSize>>, size: Rc<RefCell<WindowSize>>,
} }
@ -152,7 +152,7 @@ pub fn init_from_builder_with_gl_attr<L>(
where where
L: Into<Option<::slog::Logger>>, L: Into<Option<::slog::Logger>>,
{ {
let log = ::slog_or_stdlog(logger).new(o!("smithay_module" => "backend_winit")); let log = crate::slog_or_stdlog(logger).new(o!("smithay_module" => "backend_winit"));
info!(log, "Initializing a winit backend"); info!(log, "Initializing a winit backend");
let events_loop = EventsLoop::new(); let events_loop = EventsLoop::new();
@ -162,12 +162,12 @@ where
let reqs = Default::default(); let reqs = Default::default();
let window = Rc::new( let window = Rc::new(
if native::NativeDisplay::<native::Wayland>::is_backend(&winit_window) { 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())?; EGLContext::<native::Wayland, WinitWindow>::new(winit_window, attributes, reqs, log.clone())?;
let surface = context.create_surface(())?; let surface = context.create_surface(())?;
Window::Wayland { context, surface } Window::Wayland { context, surface }
} else if native::NativeDisplay::<native::X11>::is_backend(&winit_window) { } 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())?; EGLContext::<native::X11, WinitWindow>::new(winit_window, attributes, reqs, log.clone())?;
let surface = context.create_surface(())?; let surface = context.create_surface(())?;
Window::X11 { context, surface } Window::X11 { context, surface }
@ -227,7 +227,7 @@ pub trait WinitEventsHandler {
impl WinitGraphicsBackend { impl WinitGraphicsBackend {
/// Get a reference to the internally used [`WinitWindow`] /// 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() self.window.window()
} }
} }
@ -339,7 +339,7 @@ impl ::std::error::Error for WinitInputError {
} }
impl fmt::Display 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; use std::error::Error;
write!(f, "{}", self.description()) write!(f, "{}", self.description())
} }
@ -606,10 +606,10 @@ impl WinitInputBackend {
} }
/// Get a reference to the set events handler, if any /// 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 self.events_handler
.as_mut() .as_mut()
.map(|handler| &mut **handler as &mut WinitEventsHandler) .map(|handler| &mut **handler as &mut dyn WinitEventsHandler)
} }
/// Clear out the currently set events handler /// Clear out the currently set events handler
@ -644,10 +644,10 @@ impl InputBackend for WinitInputBackend {
self.handler = Some(Box::new(handler)); 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 self.handler
.as_mut() .as_mut()
.map(|handler| handler as &mut InputHandler<Self>) .map(|handler| handler as &mut dyn InputHandler<Self>)
} }
fn clear_handler(&mut 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 // upcoming closure, which is why all are borrowed manually and the
// assignments are then moved into the closure to avoid rustc's // assignments are then moved into the closure to avoid rustc's
// wrong interference. // wrong interference.
let mut closed_ptr = &mut closed; let closed_ptr = &mut closed;
let mut key_counter = &mut self.key_counter; let key_counter = &mut self.key_counter;
let time = &self.time; let time = &self.time;
let seat = &self.seat; let seat = &self.seat;
let window = &self.window; let window = &self.window;

View File

@ -1,4 +1,4 @@
#![warn(missing_docs)] #![warn(missing_docs, rust_2018_idioms)]
//! **Smithay: the Wayland compositor smithy** //! **Smithay: the Wayland compositor smithy**
//! //!
//! Most entry points in the modules can take an optional [`slog::Logger`](::slog::Logger) as argument //! 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 // `error_chain!` can recurse deeply
#![recursion_limit = "1024"] #![recursion_limit = "1024"]
#[cfg(feature = "backend_drm_gbm")]
#[doc(hidden)]
pub extern crate image;
#[cfg_attr(feature = "backend_session", macro_use)] #[cfg_attr(feature = "backend_session", macro_use)]
#[doc(hidden)] #[doc(hidden)]
pub extern crate nix; 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] #[macro_use]
extern crate slog; extern crate slog;
extern crate slog_stdlog;
#[macro_use] #[macro_use]
extern crate error_chain; extern crate error_chain;
#[macro_use] #[macro_use]
extern crate lazy_static; extern crate lazy_static;

View File

@ -51,7 +51,7 @@ where
// Internal implementation data of surfaces // Internal implementation data of surfaces
pub(crate) struct SurfaceImplem<U, R> { pub(crate) struct SurfaceImplem<U, R> {
log: ::slog::Logger, 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> { impl<U, R> SurfaceImplem<U, R> {

View File

@ -90,7 +90,7 @@ use self::{
roles::{Role, RoleType, WrongRole}, roles::{Role, RoleType, WrongRole},
tree::SurfaceData, tree::SurfaceData,
}; };
use utils::Rectangle; use crate::utils::Rectangle;
use wayland_server::{ use wayland_server::{
protocol::{ protocol::{
wl_buffer, wl_callback, wl_compositor, wl_output, wl_region, wl_subcompositor, wl_surface::WlSurface, wl_buffer, wl_callback, wl_compositor, wl_output, wl_region, wl_subcompositor, wl_surface::WlSurface,
@ -467,7 +467,7 @@ where
R: Default + RoleType + Role<SubsurfaceRole> + 'static, R: Default + RoleType + Role<SubsurfaceRole> + 'static,
Impl: FnMut(SurfaceEvent, Resource<WlSurface>, CompositorToken<U, R>) + 'static, Impl: FnMut(SurfaceEvent, Resource<WlSurface>, CompositorToken<U, R>) + 'static,
{ {
let log = ::slog_or_stdlog(logger).new(o!("smithay_module" => "compositor_handler")); let log = crate::slog_or_stdlog(logger).new(o!("smithay_module" => "compositor_handler"));
let implem = Rc::new(RefCell::new(implem)); let implem = Rc::new(RefCell::new(implem));
let comp_token = display.get_token(); let comp_token = display.get_token();

View File

@ -8,7 +8,7 @@ use wayland_server::{
NewResource, Resource, NewResource, Resource,
}; };
use wayland::{ use crate::wayland::{
compositor::{roles::Role, CompositorToken}, compositor::{roles::Role, CompositorToken},
seat::{AxisFrame, PointerGrab, PointerInnerHandle, Seat}, seat::{AxisFrame, PointerGrab, PointerInnerHandle, Seat},
}; };
@ -22,7 +22,7 @@ pub(crate) struct DnDGrab<U, R> {
offer_data: Option<Arc<Mutex<OfferData>>>, offer_data: Option<Arc<Mutex<OfferData>>>,
icon: Option<Resource<wl_surface::WlSurface>>, icon: Option<Resource<wl_surface::WlSurface>>,
origin: 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>, token: CompositorToken<U, R>,
seat: Seat, seat: Seat,
} }
@ -34,7 +34,7 @@ impl<U: 'static, R: Role<DnDIconRole> + 'static> DnDGrab<U, R> {
seat: Seat, seat: Seat,
icon: Option<Resource<wl_surface::WlSurface>>, icon: Option<Resource<wl_surface::WlSurface>>,
token: CompositorToken<U, R>, token: CompositorToken<U, R>,
callback: Arc<Mutex<FnMut(super::DataDeviceEvent) + Send>>, callback: Arc<Mutex<dyn FnMut(super::DataDeviceEvent) + Send>>,
) -> DnDGrab<U, R> { ) -> DnDGrab<U, R> {
DnDGrab { DnDGrab {
data_source: source, 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> { impl<U: 'static, R: Role<DnDIconRole> + 'static> PointerGrab for DnDGrab<U, R> {
fn motion( fn motion(
&mut self, &mut self,
_handle: &mut PointerInnerHandle, _handle: &mut PointerInnerHandle<'_>,
location: (f64, f64), location: (f64, f64),
focus: Option<(Resource<wl_surface::WlSurface>, (f64, f64))>, focus: Option<(Resource<wl_surface::WlSurface>, (f64, f64))>,
serial: u32, serial: u32,
@ -179,7 +179,7 @@ impl<U: 'static, R: Role<DnDIconRole> + 'static> PointerGrab for DnDGrab<U, R> {
fn button( fn button(
&mut self, &mut self,
handle: &mut PointerInnerHandle, handle: &mut PointerInnerHandle<'_>,
_button: u32, _button: u32,
_state: wl_pointer::ButtonState, _state: wl_pointer::ButtonState,
serial: u32, 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 // we just forward the axis events as is
handle.axis(details); handle.axis(details);
} }
@ -256,7 +256,7 @@ fn implement_dnd_data_offer(
offer: NewResource<wl_data_offer::WlDataOffer>, offer: NewResource<wl_data_offer::WlDataOffer>,
source: Resource<wl_data_source::WlDataSource>, source: Resource<wl_data_source::WlDataSource>,
offer_data: Arc<Mutex<OfferData>>, 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> { ) -> Resource<wl_data_offer::WlDataOffer> {
use self::wl_data_offer::Request; use self::wl_data_offer::Request;
offer.implement( offer.implement(

View File

@ -68,7 +68,7 @@ use wayland_server::{
Client, Display, Global, NewResource, Resource, Client, Display, Global, NewResource, Resource,
}; };
use wayland::{ use crate::wayland::{
compositor::{roles::Role, CompositorToken}, compositor::{roles::Role, CompositorToken},
seat::Seat, seat::Seat,
}; };
@ -294,7 +294,7 @@ where
U: 'static, U: 'static,
L: Into<Option<::slog::Logger>>, L: Into<Option<::slog::Logger>>,
{ {
let log = ::slog_or_stdlog(logger).new(o!("smithay_module" => "data_device_mgr")); let log = crate::slog_or_stdlog(logger).new(o!("smithay_module" => "data_device_mgr"));
let action_choice = Arc::new(Mutex::new(action_choice)); let action_choice = Arc::new(Mutex::new(action_choice));
let callback = Arc::new(Mutex::new(callback)); let callback = Arc::new(Mutex::new(callback));
let global = display.create_global(3, move |new_ddm, _version| { let global = display.create_global(3, move |new_ddm, _version| {
@ -419,8 +419,8 @@ where
} }
struct DataDeviceData { struct DataDeviceData {
callback: Arc<Mutex<FnMut(DataDeviceEvent) + Send + 'static>>, callback: Arc<Mutex<dyn FnMut(DataDeviceEvent) + Send + 'static>>,
action_choice: Arc<Mutex<FnMut(DndAction, DndAction) -> DndAction + Send + 'static>>, action_choice: Arc<Mutex<dyn FnMut(DndAction, DndAction) -> DndAction + Send + 'static>>,
} }
fn implement_data_device<F, C, U, R>( fn implement_data_device<F, C, U, R>(

View File

@ -6,7 +6,7 @@ use wayland_server::{
NewResource, Resource, NewResource, Resource,
}; };
use wayland::seat::{AxisFrame, PointerGrab, PointerInnerHandle, Seat}; use crate::wayland::seat::{AxisFrame, PointerGrab, PointerInnerHandle, Seat};
use super::{DataDeviceData, SeatData}; use super::{DataDeviceData, SeatData};
@ -67,7 +67,7 @@ where
{ {
fn motion( fn motion(
&mut self, &mut self,
_handle: &mut PointerInnerHandle, _handle: &mut PointerInnerHandle<'_>,
location: (f64, f64), location: (f64, f64),
focus: Option<(Resource<wl_surface::WlSurface>, (f64, f64))>, focus: Option<(Resource<wl_surface::WlSurface>, (f64, f64))>,
serial: u32, serial: u32,
@ -169,7 +169,7 @@ where
fn button( fn button(
&mut self, &mut self,
handle: &mut PointerInnerHandle, handle: &mut PointerInnerHandle<'_>,
_button: u32, _button: u32,
_state: wl_pointer::ButtonState, _state: wl_pointer::ButtonState,
serial: u32, 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 // we just forward the axis events as is
handle.axis(details); handle.axis(details);
} }
@ -238,7 +238,7 @@ fn implement_dnd_data_offer<C>(
metadata: super::SourceMetadata, metadata: super::SourceMetadata,
offer_data: Arc<Mutex<OfferData>>, offer_data: Arc<Mutex<OfferData>>,
callback: Arc<Mutex<C>>, 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> ) -> Resource<wl_data_offer::WlDataOffer>
where where
C: FnMut(ServerDndEvent) + Send + 'static, C: FnMut(ServerDndEvent) + Send + 'static,

View File

@ -179,7 +179,7 @@ impl Output {
where where
L: Into<Option<::slog::Logger>>, L: Into<Option<::slog::Logger>>,
{ {
let log = ::slog_or_stdlog(logger).new(o!("smithay_module" => "output_handler")); let log = crate::slog_or_stdlog(logger).new(o!("smithay_module" => "output_handler"));
info!(log, "Creating new wl_output"; "name" => &name); info!(log, "Creating new wl_output"; "name" => &name);

View File

@ -1,4 +1,4 @@
use backend::input::KeyState; use crate::backend::input::KeyState;
use std::{ use std::{
default::Default, default::Default,
io::{Error as IoError, Write}, io::{Error as IoError, Write},
@ -112,7 +112,7 @@ struct KbdInternal {
state: xkb::State, state: xkb::State,
repeat_rate: i32, repeat_rate: i32,
repeat_delay: 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 // This is OK because all parts of `xkb` will remain on the
@ -121,10 +121,10 @@ unsafe impl Send for KbdInternal {}
impl KbdInternal { impl KbdInternal {
fn new( fn new(
xkb_config: XkbConfig, xkb_config: XkbConfig<'_>,
repeat_rate: i32, repeat_rate: i32,
repeat_delay: i32, repeat_delay: i32,
focus_hook: Box<FnMut(Option<&Resource<WlSurface>>)>, focus_hook: Box<dyn FnMut(Option<&Resource<WlSurface>>)>,
) -> Result<KbdInternal, ()> { ) -> Result<KbdInternal, ()> {
// we create a new contex for each keyboard because libxkbcommon is actually NOT threadsafe // 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 // 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 /// Create a keyboard handler from a set of RMLVO rules
pub(crate) fn create_keyboard_handler<F>( pub(crate) fn create_keyboard_handler<F>(
xkb_config: XkbConfig, xkb_config: XkbConfig<'_>,
repeat_delay: i32, repeat_delay: i32,
repeat_rate: i32, repeat_rate: i32,
logger: &::slog::Logger, logger: &::slog::Logger,

View File

@ -55,7 +55,7 @@ pub use self::{
}, },
}; };
use wayland::compositor::{roles::Role, CompositorToken}; use crate::wayland::compositor::{roles::Role, CompositorToken};
use wayland_commons::utils::UserDataMap; use wayland_commons::utils::UserDataMap;
@ -133,7 +133,7 @@ impl Seat {
R: Role<CursorImageRole> + 'static, R: Role<CursorImageRole> + 'static,
L: Into<Option<::slog::Logger>>, L: Into<Option<::slog::Logger>>,
{ {
let log = ::slog_or_stdlog(logger); let log = crate::slog_or_stdlog(logger);
let arc = Arc::new(SeatArc { let arc = Arc::new(SeatArc {
inner: Mutex::new(Inner { inner: Mutex::new(Inner {
pointer: None, pointer: None,
@ -281,7 +281,7 @@ impl Seat {
/// ``` /// ```
pub fn add_keyboard<F>( pub fn add_keyboard<F>(
&mut self, &mut self,
xkb_config: keyboard::XkbConfig, xkb_config: keyboard::XkbConfig<'_>,
repeat_delay: i32, repeat_delay: i32,
repeat_rate: i32, repeat_rate: i32,
mut focus_hook: F, mut focus_hook: F,

View File

@ -7,7 +7,7 @@ use wayland_server::{
NewResource, Resource, NewResource, Resource,
}; };
use wayland::compositor::{roles::Role, CompositorToken}; use crate::wayland::compositor::{roles::Role, CompositorToken};
/// The role representing a surface set as the pointer cursor /// The role representing a surface set as the pointer cursor
#[derive(Default, Copy, Clone)] #[derive(Default, Copy, Clone)]
@ -29,7 +29,7 @@ pub enum CursorImageStatus {
enum GrabStatus { enum GrabStatus {
None, None,
Active(u32, Box<PointerGrab>), Active(u32, Box<dyn PointerGrab>),
Borrowed, Borrowed,
} }
@ -40,7 +40,7 @@ struct PointerInternal {
location: (f64, f64), location: (f64, f64),
grab: GrabStatus, grab: GrabStatus,
pressed_buttons: Vec<u32>, pressed_buttons: Vec<u32>,
image_callback: Box<FnMut(CursorImageStatus) + Send>, image_callback: Box<dyn FnMut(CursorImageStatus) + Send>,
} }
impl PointerInternal { impl PointerInternal {
@ -95,7 +95,7 @@ impl PointerInternal {
fn with_grab<F>(&mut self, f: F) fn with_grab<F>(&mut self, f: F)
where where
F: FnOnce(PointerInnerHandle, &mut PointerGrab), F: FnOnce(PointerInnerHandle<'_>, &mut dyn PointerGrab),
{ {
let mut grab = ::std::mem::replace(&mut self.grab, GrabStatus::Borrowed); let mut grab = ::std::mem::replace(&mut self.grab, GrabStatus::Borrowed);
match grab { match grab {
@ -239,7 +239,7 @@ pub trait PointerGrab: Send + Sync {
/// A motion was reported /// A motion was reported
fn motion( fn motion(
&mut self, &mut self,
handle: &mut PointerInnerHandle, handle: &mut PointerInnerHandle<'_>,
location: (f64, f64), location: (f64, f64),
focus: Option<(Resource<WlSurface>, (f64, f64))>, focus: Option<(Resource<WlSurface>, (f64, f64))>,
serial: u32, serial: u32,
@ -248,14 +248,14 @@ pub trait PointerGrab: Send + Sync {
/// A button press was reported /// A button press was reported
fn button( fn button(
&mut self, &mut self,
handle: &mut PointerInnerHandle, handle: &mut PointerInnerHandle<'_>,
button: u32, button: u32,
state: ButtonState, state: ButtonState,
serial: u32, serial: u32,
time: u32, time: u32,
); );
/// An axis scroll was reported /// 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 /// This inner handle is accessed from inside a pointer grab logic, and directly
@ -644,7 +644,7 @@ struct DefaultGrab;
impl PointerGrab for DefaultGrab { impl PointerGrab for DefaultGrab {
fn motion( fn motion(
&mut self, &mut self,
handle: &mut PointerInnerHandle, handle: &mut PointerInnerHandle<'_>,
location: (f64, f64), location: (f64, f64),
focus: Option<(Resource<WlSurface>, (f64, f64))>, focus: Option<(Resource<WlSurface>, (f64, f64))>,
serial: u32, serial: u32,
@ -654,7 +654,7 @@ impl PointerGrab for DefaultGrab {
} }
fn button( fn button(
&mut self, &mut self,
handle: &mut PointerInnerHandle, handle: &mut PointerInnerHandle<'_>,
button: u32, button: u32,
state: ButtonState, state: ButtonState,
serial: u32, 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); handle.axis(details);
} }
} }
@ -688,7 +688,7 @@ struct ClickGrab {
impl PointerGrab for ClickGrab { impl PointerGrab for ClickGrab {
fn motion( fn motion(
&mut self, &mut self,
handle: &mut PointerInnerHandle, handle: &mut PointerInnerHandle<'_>,
location: (f64, f64), location: (f64, f64),
focus: Option<(Resource<WlSurface>, (f64, f64))>, focus: Option<(Resource<WlSurface>, (f64, f64))>,
serial: u32, serial: u32,
@ -700,7 +700,7 @@ impl PointerGrab for ClickGrab {
} }
fn button( fn button(
&mut self, &mut self,
handle: &mut PointerInnerHandle, handle: &mut PointerInnerHandle<'_>,
button: u32, button: u32,
state: ButtonState, state: ButtonState,
serial: u32, serial: u32,
@ -712,7 +712,7 @@ impl PointerGrab for ClickGrab {
handle.unset_grab(serial, time); 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); handle.axis(details);
} }
} }

View File

@ -76,7 +76,7 @@ use std::{
sync::{Arc, Mutex}, sync::{Arc, Mutex},
}; };
use wayland::compositor::{roles::Role, CompositorToken}; use crate::wayland::compositor::{roles::Role, CompositorToken};
use wayland_server::{ use wayland_server::{
protocol::{wl_output, wl_seat, wl_shell, wl_shell_surface, wl_surface}, protocol::{wl_output, wl_seat, wl_shell, wl_shell_surface, wl_surface},
@ -327,7 +327,7 @@ where
L: Into<Option<::slog::Logger>>, L: Into<Option<::slog::Logger>>,
Impl: FnMut(ShellRequest<U, R, D>) + 'static, Impl: FnMut(ShellRequest<U, R, D>) + 'static,
{ {
let _log = ::slog_or_stdlog(logger); let _log = crate::slog_or_stdlog(logger);
let implementation = Rc::new(RefCell::new(implementation)); let implementation = Rc::new(RefCell::new(implementation));

View File

@ -9,7 +9,7 @@ use wayland_server::{
DisplayToken, NewResource, Resource, DisplayToken, NewResource, Resource,
}; };
use wayland::compositor::{roles::Role, CompositorToken}; use crate::wayland::compositor::{roles::Role, CompositorToken};
use super::{ShellRequest, ShellState, ShellSurface, ShellSurfaceKind, ShellSurfaceRole}; use super::{ShellRequest, ShellState, ShellSurface, ShellSurfaceKind, ShellSurfaceRole};

View File

@ -90,13 +90,13 @@
//! the subhandler you provided, or via methods on the [`ShellState`](::wayland::shell::xdg::ShellState) //! the subhandler you provided, or via methods on the [`ShellState`](::wayland::shell::xdg::ShellState)
//! that you are given (in an `Arc<Mutex<_>>`) as return value of the `init` function. //! that you are given (in an `Arc<Mutex<_>>`) as return value of the `init` function.
use crate::utils::Rectangle;
use crate::wayland::compositor::{roles::Role, CompositorToken};
use std::{ use std::{
cell::RefCell, cell::RefCell,
rc::Rc, rc::Rc,
sync::{Arc, Mutex}, sync::{Arc, Mutex},
}; };
use utils::Rectangle;
use wayland::compositor::{roles::Role, CompositorToken};
use wayland_protocols::{ use wayland_protocols::{
unstable::xdg_shell::v6::server::{zxdg_popup_v6, zxdg_shell_v6, zxdg_surface_v6, zxdg_toplevel_v6}, 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}, xdg_shell::server::{xdg_popup, xdg_positioner, xdg_surface, xdg_toplevel, xdg_wm_base},
@ -263,7 +263,7 @@ pub(crate) struct ShellData<U, R, SD> {
log: ::slog::Logger, log: ::slog::Logger,
compositor_token: CompositorToken<U, R>, compositor_token: CompositorToken<U, R>,
display_token: DisplayToken, 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>>>, shell_state: Arc<Mutex<ShellState<U, R, SD>>>,
} }
@ -297,7 +297,7 @@ where
L: Into<Option<::slog::Logger>>, L: Into<Option<::slog::Logger>>,
Impl: FnMut(XdgRequest<U, R, SD>) + 'static, Impl: FnMut(XdgRequest<U, R, SD>) + 'static,
{ {
let log = ::slog_or_stdlog(logger); let log = crate::slog_or_stdlog(logger);
let shell_state = Arc::new(Mutex::new(ShellState { let shell_state = Arc::new(Mutex::new(ShellState {
known_toplevels: Vec::new(), known_toplevels: Vec::new(),
known_popups: Vec::new(), known_popups: Vec::new(),

View File

@ -1,12 +1,12 @@
use std::{cell::RefCell, sync::Mutex}; use std::{cell::RefCell, sync::Mutex};
use wayland::compositor::{roles::*, CompositorToken}; use crate::wayland::compositor::{roles::*, 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, DisplayToken, NewResource, Resource}; use wayland_server::{protocol::wl_surface, DisplayToken, NewResource, Resource};
use utils::Rectangle; use crate::utils::Rectangle;
use super::{ use super::{
make_shell_client_data, PopupConfigure, PopupKind, PopupState, PositionerState, ShellClient, make_shell_client_data, PopupConfigure, PopupKind, PopupState, PositionerState, ShellClient,

View File

@ -1,6 +1,6 @@
use std::{cell::RefCell, sync::Mutex}; use std::{cell::RefCell, sync::Mutex};
use wayland::compositor::{roles::*, CompositorToken}; use crate::wayland::compositor::{roles::*, 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,
@ -9,7 +9,7 @@ use wayland_protocols::{
}; };
use wayland_server::{protocol::wl_surface, DisplayToken, NewResource, Resource}; use wayland_server::{protocol::wl_surface, DisplayToken, NewResource, Resource};
use utils::Rectangle; use crate::utils::Rectangle;
use super::{ use super::{
make_shell_client_data, PopupConfigure, PopupKind, PopupState, PositionerState, ShellClient, make_shell_client_data, PopupConfigure, PopupKind, PopupState, PositionerState, ShellClient,

View File

@ -115,7 +115,7 @@ pub fn init_shm_global<L>(
where where
L: Into<Option<::slog::Logger>>, L: Into<Option<::slog::Logger>>,
{ {
let log = ::slog_or_stdlog(logger); let log = crate::slog_or_stdlog(logger);
// always add the mandatory formats // always add the mandatory formats
formats.push(wl_shm::Format::Argb8888); formats.push(wl_shm::Format::Argb8888);

View File

@ -86,7 +86,7 @@ impl<WM: XWindowManager + 'static> XWayland<WM> {
where where
L: Into<Option<::slog::Logger>>, L: Into<Option<::slog::Logger>>,
{ {
let log = ::slog_or_stdlog(logger); let log = crate::slog_or_stdlog(logger);
let inner = Rc::new(RefCell::new(Inner { let inner = Rc::new(RefCell::new(Inner {
wm, wm,
source_maker: Box::new(move |inner| { source_maker: Box::new(move |inner| {
@ -127,7 +127,7 @@ struct XWaylandInstance {
// Inner implementation of the XWayland manager // Inner implementation of the XWayland manager
struct Inner<WM: XWindowManager> { struct Inner<WM: XWindowManager> {
wm: WM, 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>>, wayland_display: Rc<RefCell<Display>>,
instance: Option<XWaylandInstance>, instance: Option<XWaylandInstance>,
log: ::slog::Logger, log: ::slog::Logger,