From 7f452837594f083e964eacadc1f8ba529290d096 Mon Sep 17 00:00:00 2001 From: Drakulix Date: Thu, 21 Sep 2017 20:50:10 +0200 Subject: [PATCH] cargo fmt --- examples/helpers/glium.rs | 2 +- examples/helpers/implementations.rs | 5 ++- src/backend/drm/mod.rs | 7 +--- src/backend/graphics/egl.rs | 10 +++--- src/backend/winit.rs | 31 ++++++++-------- src/compositor/handlers.rs | 9 ++--- src/compositor/region.rs | 5 ++- src/compositor/tree.rs | 4 +-- src/shell/mod.rs | 8 ++--- src/shell/wl_handlers.rs | 9 ++--- src/shell/xdg_handlers.rs | 55 ++++++++--------------------- 11 files changed, 51 insertions(+), 94 deletions(-) diff --git a/examples/helpers/glium.rs b/examples/helpers/glium.rs index a96f24d..908db89 100644 --- a/examples/helpers/glium.rs +++ b/examples/helpers/glium.rs @@ -3,8 +3,8 @@ use glium::{Frame, Surface}; use glium::index::PrimitiveType; use smithay::backend::graphics::egl::EGLGraphicsBackend; use smithay::backend::graphics::glium::GliumGraphicsBackend; -use std::ops::Deref; use std::borrow::Borrow; +use std::ops::Deref; #[derive(Copy, Clone)] struct Vertex { diff --git a/examples/helpers/implementations.rs b/examples/helpers/implementations.rs index 231c3f8..e89874d 100644 --- a/examples/helpers/implementations.rs +++ b/examples/helpers/implementations.rs @@ -26,9 +26,8 @@ pub fn surface_implementation() -> SurfaceUserImplementation + 'static, - H: DrmHandler + 'static, - > { + struct PageFlipHandler<'a, 'b, B: Borrow + 'static, H: DrmHandler + 'static> { handler: &'a mut H, evlh: &'b mut EventLoopHandle, _marker: PhantomData, diff --git a/src/backend/graphics/egl.rs b/src/backend/graphics/egl.rs index 7c32f43..51fbaeb 100644 --- a/src/backend/graphics/egl.rs +++ b/src/backend/graphics/egl.rs @@ -619,11 +619,11 @@ impl<'a, T: NativeSurface> EGLContext<'a, T> { }; let desc = PixelFormat { - hardware_accelerated: attrib!(egl, display, config_id, ffi::egl::CONFIG_CAVEAT) != - ffi::egl::SLOW_CONFIG as i32, - color_bits: attrib!(egl, display, config_id, ffi::egl::RED_SIZE) as u8 + - attrib!(egl, display, config_id, ffi::egl::BLUE_SIZE) as u8 + - attrib!(egl, display, config_id, ffi::egl::GREEN_SIZE) as u8, + hardware_accelerated: attrib!(egl, display, config_id, ffi::egl::CONFIG_CAVEAT) + != ffi::egl::SLOW_CONFIG as i32, + color_bits: attrib!(egl, display, config_id, ffi::egl::RED_SIZE) as u8 + + attrib!(egl, display, config_id, ffi::egl::BLUE_SIZE) as u8 + + attrib!(egl, display, config_id, ffi::egl::GREEN_SIZE) as u8, alpha_bits: attrib!(egl, display, config_id, ffi::egl::ALPHA_SIZE) as u8, depth_bits: attrib!(egl, display, config_id, ffi::egl::DEPTH_SIZE) as u8, stencil_bits: attrib!(egl, display, config_id, ffi::egl::STENCIL_SIZE) as u8, diff --git a/src/backend/winit.rs b/src/backend/winit.rs index 04d262f..eae5fd7 100644 --- a/src/backend/winit.rs +++ b/src/backend/winit.rs @@ -308,8 +308,8 @@ impl PointerMotionAbsoluteEvent for WinitMouseMovedEvent { fn x_transformed(&self, width: u32) -> u32 { cmp::min( - (self.x * width as f64 / - self.window + (self.x * width as f64 + / self.window .head() .get_inner_size_points() .unwrap_or((width, 0)) @@ -320,8 +320,8 @@ impl PointerMotionAbsoluteEvent for WinitMouseMovedEvent { fn y_transformed(&self, height: u32) -> u32 { cmp::min( - (self.y * height as f64 / - self.window + (self.y * height as f64 + / self.window .head() .get_inner_size_points() .unwrap_or((0, height)) @@ -421,8 +421,8 @@ impl TouchDownEvent for WinitTouchStartedEvent { fn x_transformed(&self, width: u32) -> u32 { cmp::min( - self.location.0 as i32 * width as i32 / - self.window + self.location.0 as i32 * width as i32 + / self.window .head() .get_inner_size_points() .unwrap_or((width, 0)) @@ -433,8 +433,8 @@ impl TouchDownEvent for WinitTouchStartedEvent { fn y_transformed(&self, height: u32) -> u32 { cmp::min( - self.location.1 as i32 * height as i32 / - self.window + self.location.1 as i32 * height as i32 + / self.window .head() .get_inner_size_points() .unwrap_or((0, height)) @@ -473,8 +473,8 @@ impl TouchMotionEvent for WinitTouchMovedEvent { } fn x_transformed(&self, width: u32) -> u32 { - self.location.0 as u32 * width / - self.window + self.location.0 as u32 * width + / self.window .head() .get_inner_size_points() .unwrap_or((width, 0)) @@ -482,8 +482,8 @@ impl TouchMotionEvent for WinitTouchMovedEvent { } fn y_transformed(&self, height: u32) -> u32 { - self.location.1 as u32 * height / - self.window + self.location.1 as u32 * height + / self.window .head() .get_inner_size_points() .unwrap_or((0, height)) @@ -619,9 +619,10 @@ impl InputBackend for WinitInputBackend { } ( WindowEvent::KeyboardInput { - input: KeyboardInput { - scancode, state, .. - }, + input: + KeyboardInput { + scancode, state, .. + }, .. }, Some(handler), diff --git a/src/compositor/handlers.rs b/src/compositor/handlers.rs index 63d20d7..110df2c 100644 --- a/src/compositor/handlers.rs +++ b/src/compositor/handlers.rs @@ -227,9 +227,7 @@ where ); return; } - subsurface.set_user_data( - Box::into_raw(Box::new(unsafe { surface.clone_unchecked() })) as *mut _, - ); + subsurface.set_user_data(Box::into_raw(Box::new(unsafe { surface.clone_unchecked() })) as *mut _); evlh.register( &subsurface, subsurface_implementation::(), @@ -253,9 +251,8 @@ where { let ptr = subsurface.get_user_data(); let surface = &*(ptr as *mut wl_surface::WlSurface); - SurfaceData::::with_role_data::(surface, |d| f(d)).expect( - "The surface does not have a subsurface role while it has a wl_subsurface?!", - ); + SurfaceData::::with_role_data::(surface, |d| f(d)) + .expect("The surface does not have a subsurface role while it has a wl_subsurface?!"); } fn subsurface_implementation() -> wl_subsurface::Implementation<()> diff --git a/src/compositor/region.rs b/src/compositor/region.rs index 23952af..b4f0b48 100644 --- a/src/compositor/region.rs +++ b/src/compositor/region.rs @@ -11,9 +11,8 @@ pub struct RegionData { impl RegionData { /// Initialize the user_data of a region, must be called right when the surface is created pub unsafe fn init(region: &wl_region::WlRegion) { - region.set_user_data( - Box::into_raw(Box::new(Mutex::new(RegionData::default()))) as *mut _, - ) + region.set_user_data(Box::into_raw(Box::new(Mutex::new(RegionData::default()))) + as *mut _) } /// Cleans the user_data of that surface, must be called when it is destroyed diff --git a/src/compositor/tree.rs b/src/compositor/tree.rs index 134f7c9..10b2a55 100644 --- a/src/compositor/tree.rs +++ b/src/compositor/tree.rs @@ -57,9 +57,7 @@ impl SurfaceData { /// Initialize the user_data of a surface, must be called right when the surface is created pub unsafe fn init(surface: &wl_surface::WlSurface) { - surface.set_user_data( - Box::into_raw(Box::new(Mutex::new(SurfaceData::::new()))) as *mut _, - ) + surface.set_user_data(Box::into_raw(Box::new(Mutex::new(SurfaceData::::new()))) as *mut _) } } diff --git a/src/shell/mod.rs b/src/shell/mod.rs index 895a4b7..a8b7048 100644 --- a/src/shell/mod.rs +++ b/src/shell/mod.rs @@ -596,9 +596,7 @@ where } let configured = self.token .with_role_data::(&self.wl_surface, |data| data.configured) - .expect( - "A shell surface object exists but the surface does not have the shell_surface role ?!", - ); + .expect("A shell surface object exists but the surface does not have the shell_surface role ?!"); if !configured { if let SurfaceKind::XdgToplevel(ref s) = self.shell_surface { let ptr = s.get_user_data(); @@ -733,9 +731,7 @@ where } let configured = self.token .with_role_data::(&self.wl_surface, |data| data.configured) - .expect( - "A shell surface object exists but the surface does not have the shell_surface role ?!", - ); + .expect("A shell surface object exists but the surface does not have the shell_surface role ?!"); if !configured { if let SurfaceKind::XdgPopup(ref s) = self.shell_surface { let ptr = s.get_user_data(); diff --git a/src/shell/wl_handlers.rs b/src/shell/wl_handlers.rs index 26946c8..d97297e 100644 --- a/src/shell/wl_handlers.rs +++ b/src/shell/wl_handlers.rs @@ -78,9 +78,8 @@ where ); return; } - shell_surface.set_user_data( - Box::into_raw(Box::new(unsafe { surface.clone_unchecked() })) as *mut _, - ); + shell_surface + .set_user_data(Box::into_raw(Box::new(unsafe { surface.clone_unchecked() })) as *mut _); evlh.register( &shell_surface, shell_surface_implementation(), @@ -243,9 +242,7 @@ where }); return true; }) - .expect( - "xdg_surface exists but surface has not shell_surface role?!", - ); + .expect("xdg_surface exists but surface has not shell_surface role?!"); // we need to notify about this new toplevel surface if need_send { evlh.state() diff --git a/src/shell/xdg_handlers.rs b/src/shell/xdg_handlers.rs index c2faaec..7a568fe 100644 --- a/src/shell/xdg_handlers.rs +++ b/src/shell/xdg_handlers.rs @@ -19,9 +19,7 @@ where SID: 'static, SD: Default + 'static, { - shell.set_user_data( - Box::into_raw(Box::new(Mutex::new(make_shell_client_data::()))) as *mut _, - ); + shell.set_user_data(Box::into_raw(Box::new(Mutex::new(make_shell_client_data::()))) as *mut _); evlh.register( &shell, shell_implementation(), @@ -222,11 +220,8 @@ fn destroy_surface(surface: &zxdg_surface_v6::ZxdgSurfaceV6) { let ptr = surface.get_user_data(); surface.set_user_data(::std::ptr::null_mut()); // drop the state - let data = unsafe { - Box::from_raw( - ptr as *mut (zxdg_surface_v6::ZxdgSurfaceV6, zxdg_shell_v6::ZxdgShellV6), - ) - }; + let data = + unsafe { Box::from_raw(ptr as *mut (zxdg_surface_v6::ZxdgSurfaceV6, zxdg_shell_v6::ZxdgShellV6)) }; // explicit call to drop to not forget what we're doing here ::std::mem::drop(data); } @@ -258,9 +253,7 @@ where ); } }) - .expect( - "xdg_surface exists but surface has not shell_surface role?!", - ); + .expect("xdg_surface exists but surface has not shell_surface role?!"); }, get_toplevel: |evlh, idata, _, xdg_surface, toplevel| { let ptr = xdg_surface.get_user_data(); @@ -277,9 +270,7 @@ where max_size: (0, 0), }); }) - .expect( - "xdg_surface exists but surface has not shell_surface role?!", - ); + .expect("xdg_surface exists but surface has not shell_surface role?!"); toplevel.set_user_data(Box::into_raw(Box::new(unsafe { ( @@ -326,9 +317,7 @@ where positioner: positioner_data.clone(), }); }) - .expect( - "xdg_surface exists but surface has not shell_surface role?!", - ); + .expect("xdg_surface exists but surface has not shell_surface role?!"); popup.set_user_data(Box::into_raw(Box::new(unsafe { ( @@ -370,9 +359,7 @@ where height, }); }) - .expect( - "xdg_surface exists but surface has not shell_surface role?!", - ); + .expect("xdg_surface exists but surface has not shell_surface role?!"); }, ack_configure: |_, idata, _, surface, serial| { let ptr = surface.get_user_data(); @@ -397,9 +384,7 @@ where } data.configured = true; }) - .expect( - "xdg_surface exists but surface has not shell_surface role?!", - ); + .expect("xdg_surface exists but surface has not shell_surface role?!"); }, } } @@ -442,9 +427,7 @@ where ShellSurfacePendingState::Toplevel(ref mut toplevel_data) => f(toplevel_data), _ => unreachable!(), }) - .expect( - "xdg_toplevel exists but surface has not shell_surface role?!", - ); + .expect("xdg_toplevel exists but surface has not shell_surface role?!"); } fn xdg_handle_display_state_change(evlh: &mut EventLoopHandle, @@ -503,9 +486,7 @@ where // Add the configure as pending token .with_role_data::(surface, |data| data.pending_configures.push(serial)) - .expect( - "xdg_toplevel exists but surface has not shell_surface role?!", - ); + .expect("xdg_toplevel exists but surface has not shell_surface role?!"); } fn make_toplevel_handle(token: CompositorToken, @@ -541,9 +522,7 @@ where data.pending_state = ShellSurfacePendingState::None; data.configured = false; }) - .expect( - "xdg_toplevel exists but surface has not shell_surface role?!", - ); + .expect("xdg_toplevel exists but surface has not shell_surface role?!"); // remove this surface from the known ones (as well as any leftover dead surface) evlh.state() .get_mut(&idata.state_token) @@ -651,9 +630,7 @@ where // Add the configure as pending token .with_role_data::(surface, |data| data.pending_configures.push(serial)) - .expect( - "xdg_toplevel exists but surface has not shell_surface role?!", - ); + .expect("xdg_toplevel exists but surface has not shell_surface role?!"); } fn make_popup_handle(token: CompositorToken, resource: &zxdg_popup_v6::ZxdgPopupV6) @@ -682,8 +659,8 @@ where destroy: |evlh, idata, _, popup| { let ptr = popup.get_user_data(); let &(ref surface, _, _) = unsafe { - &*(ptr as - *mut ( + &*(ptr + as *mut ( wl_surface::WlSurface, zxdg_shell_v6::ZxdgShellV6, zxdg_surface_v6::ZxdgSurfaceV6, @@ -695,9 +672,7 @@ where data.pending_state = ShellSurfacePendingState::None; data.configured = false; }) - .expect( - "xdg_toplevel exists but surface has not shell_surface role?!", - ); + .expect("xdg_toplevel exists but surface has not shell_surface role?!"); // remove this surface from the known ones (as well as any leftover dead surface) evlh.state() .get_mut(&idata.state_token)