cargo fmt

This commit is contained in:
Drakulix 2017-09-21 20:50:10 +02:00
parent 74b56e6de2
commit 7f45283759
11 changed files with 51 additions and 94 deletions

View File

@ -3,8 +3,8 @@ use glium::{Frame, Surface};
use glium::index::PrimitiveType; use glium::index::PrimitiveType;
use smithay::backend::graphics::egl::EGLGraphicsBackend; use smithay::backend::graphics::egl::EGLGraphicsBackend;
use smithay::backend::graphics::glium::GliumGraphicsBackend; use smithay::backend::graphics::glium::GliumGraphicsBackend;
use std::ops::Deref;
use std::borrow::Borrow; use std::borrow::Borrow;
use std::ops::Deref;
#[derive(Copy, Clone)] #[derive(Copy, Clone)]
struct Vertex { struct Vertex {

View File

@ -26,9 +26,8 @@ pub fn surface_implementation() -> SurfaceUserImplementation<SurfaceData, Roles,
let height = data.height as usize; let height = data.height as usize;
let mut new_vec = Vec::with_capacity(width * height * 4); let mut new_vec = Vec::with_capacity(width * height * 4);
for i in 0..height { for i in 0..height {
new_vec.extend( new_vec
&slice[(offset + i * stride)..(offset + i * stride + width * 4)], .extend(&slice[(offset + i * stride)..(offset + i * stride + width * 4)]);
);
} }
attributes.user_data.buffer = attributes.user_data.buffer =
Some((new_vec, (data.width as u32, data.height as u32))); Some((new_vec, (data.width as u32, data.height as u32)));

View File

@ -491,12 +491,7 @@ where
let &mut (ref mut dev, ref mut handler) = id; let &mut (ref mut dev, ref mut handler) = id;
struct PageFlipHandler< struct PageFlipHandler<'a, 'b, B: Borrow<DrmBackend> + 'static, H: DrmHandler<B> + 'static> {
'a,
'b,
B: Borrow<DrmBackend> + 'static,
H: DrmHandler<B> + 'static,
> {
handler: &'a mut H, handler: &'a mut H,
evlh: &'b mut EventLoopHandle, evlh: &'b mut EventLoopHandle,
_marker: PhantomData<B>, _marker: PhantomData<B>,

View File

@ -619,11 +619,11 @@ impl<'a, T: NativeSurface> EGLContext<'a, T> {
}; };
let desc = PixelFormat { let desc = PixelFormat {
hardware_accelerated: attrib!(egl, display, config_id, ffi::egl::CONFIG_CAVEAT) != hardware_accelerated: attrib!(egl, display, config_id, ffi::egl::CONFIG_CAVEAT)
ffi::egl::SLOW_CONFIG as i32, != ffi::egl::SLOW_CONFIG as i32,
color_bits: attrib!(egl, display, config_id, ffi::egl::RED_SIZE) as u8 + 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::BLUE_SIZE) as u8
attrib!(egl, display, config_id, ffi::egl::GREEN_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, 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, 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, stencil_bits: attrib!(egl, display, config_id, ffi::egl::STENCIL_SIZE) as u8,

View File

@ -308,8 +308,8 @@ impl PointerMotionAbsoluteEvent for WinitMouseMovedEvent {
fn x_transformed(&self, width: u32) -> u32 { fn x_transformed(&self, width: u32) -> u32 {
cmp::min( cmp::min(
(self.x * width as f64 / (self.x * width as f64
self.window / self.window
.head() .head()
.get_inner_size_points() .get_inner_size_points()
.unwrap_or((width, 0)) .unwrap_or((width, 0))
@ -320,8 +320,8 @@ impl PointerMotionAbsoluteEvent for WinitMouseMovedEvent {
fn y_transformed(&self, height: u32) -> u32 { fn y_transformed(&self, height: u32) -> u32 {
cmp::min( cmp::min(
(self.y * height as f64 / (self.y * height as f64
self.window / self.window
.head() .head()
.get_inner_size_points() .get_inner_size_points()
.unwrap_or((0, height)) .unwrap_or((0, height))
@ -421,8 +421,8 @@ impl TouchDownEvent for WinitTouchStartedEvent {
fn x_transformed(&self, width: u32) -> u32 { fn x_transformed(&self, width: u32) -> u32 {
cmp::min( cmp::min(
self.location.0 as i32 * width as i32 / self.location.0 as i32 * width as i32
self.window / self.window
.head() .head()
.get_inner_size_points() .get_inner_size_points()
.unwrap_or((width, 0)) .unwrap_or((width, 0))
@ -433,8 +433,8 @@ impl TouchDownEvent for WinitTouchStartedEvent {
fn y_transformed(&self, height: u32) -> u32 { fn y_transformed(&self, height: u32) -> u32 {
cmp::min( cmp::min(
self.location.1 as i32 * height as i32 / self.location.1 as i32 * height as i32
self.window / self.window
.head() .head()
.get_inner_size_points() .get_inner_size_points()
.unwrap_or((0, height)) .unwrap_or((0, height))
@ -473,8 +473,8 @@ impl TouchMotionEvent for WinitTouchMovedEvent {
} }
fn x_transformed(&self, width: u32) -> u32 { fn x_transformed(&self, width: u32) -> u32 {
self.location.0 as u32 * width / self.location.0 as u32 * width
self.window / self.window
.head() .head()
.get_inner_size_points() .get_inner_size_points()
.unwrap_or((width, 0)) .unwrap_or((width, 0))
@ -482,8 +482,8 @@ impl TouchMotionEvent for WinitTouchMovedEvent {
} }
fn y_transformed(&self, height: u32) -> u32 { fn y_transformed(&self, height: u32) -> u32 {
self.location.1 as u32 * height / self.location.1 as u32 * height
self.window / self.window
.head() .head()
.get_inner_size_points() .get_inner_size_points()
.unwrap_or((0, height)) .unwrap_or((0, height))
@ -619,9 +619,10 @@ impl InputBackend for WinitInputBackend {
} }
( (
WindowEvent::KeyboardInput { WindowEvent::KeyboardInput {
input: KeyboardInput { input:
scancode, state, .. KeyboardInput {
}, scancode, state, ..
},
.. ..
}, },
Some(handler), Some(handler),

View File

@ -227,9 +227,7 @@ where
); );
return; return;
} }
subsurface.set_user_data( subsurface.set_user_data(Box::into_raw(Box::new(unsafe { surface.clone_unchecked() })) as *mut _);
Box::into_raw(Box::new(unsafe { surface.clone_unchecked() })) as *mut _,
);
evlh.register( evlh.register(
&subsurface, &subsurface,
subsurface_implementation::<U, R>(), subsurface_implementation::<U, R>(),
@ -253,9 +251,8 @@ where
{ {
let ptr = subsurface.get_user_data(); let ptr = subsurface.get_user_data();
let surface = &*(ptr as *mut wl_surface::WlSurface); let surface = &*(ptr as *mut wl_surface::WlSurface);
SurfaceData::<U, R>::with_role_data::<SubsurfaceRole, _, _>(surface, |d| f(d)).expect( SurfaceData::<U, R>::with_role_data::<SubsurfaceRole, _, _>(surface, |d| f(d))
"The surface does not have a subsurface role while it has a wl_subsurface?!", .expect("The surface does not have a subsurface role while it has a wl_subsurface?!");
);
} }
fn subsurface_implementation<U, R>() -> wl_subsurface::Implementation<()> fn subsurface_implementation<U, R>() -> wl_subsurface::Implementation<()>

View File

@ -11,9 +11,8 @@ pub struct RegionData {
impl RegionData { impl RegionData {
/// Initialize the user_data of a region, must be called right when the surface is created /// Initialize the user_data of a region, must be called right when the surface is created
pub unsafe fn init(region: &wl_region::WlRegion) { pub unsafe fn init(region: &wl_region::WlRegion) {
region.set_user_data( region.set_user_data(Box::into_raw(Box::new(Mutex::new(RegionData::default())))
Box::into_raw(Box::new(Mutex::new(RegionData::default()))) as *mut _, as *mut _)
)
} }
/// Cleans the user_data of that surface, must be called when it is destroyed /// Cleans the user_data of that surface, must be called when it is destroyed

View File

@ -57,9 +57,7 @@ impl<U: Default, R: Default> SurfaceData<U, R> {
/// Initialize the user_data of a surface, must be called right when the surface is created /// Initialize the user_data of a surface, must be called right when the surface is created
pub unsafe fn init(surface: &wl_surface::WlSurface) { pub unsafe fn init(surface: &wl_surface::WlSurface) {
surface.set_user_data( surface.set_user_data(Box::into_raw(Box::new(Mutex::new(SurfaceData::<U, R>::new()))) as *mut _)
Box::into_raw(Box::new(Mutex::new(SurfaceData::<U, R>::new()))) as *mut _,
)
} }
} }

View File

@ -596,9 +596,7 @@ where
} }
let configured = self.token let configured = self.token
.with_role_data::<ShellSurfaceRole, _, _>(&self.wl_surface, |data| data.configured) .with_role_data::<ShellSurfaceRole, _, _>(&self.wl_surface, |data| data.configured)
.expect( .expect("A shell surface object exists but the surface does not have the shell_surface role ?!");
"A shell surface object exists but the surface does not have the shell_surface role ?!",
);
if !configured { if !configured {
if let SurfaceKind::XdgToplevel(ref s) = self.shell_surface { if let SurfaceKind::XdgToplevel(ref s) = self.shell_surface {
let ptr = s.get_user_data(); let ptr = s.get_user_data();
@ -733,9 +731,7 @@ where
} }
let configured = self.token let configured = self.token
.with_role_data::<ShellSurfaceRole, _, _>(&self.wl_surface, |data| data.configured) .with_role_data::<ShellSurfaceRole, _, _>(&self.wl_surface, |data| data.configured)
.expect( .expect("A shell surface object exists but the surface does not have the shell_surface role ?!");
"A shell surface object exists but the surface does not have the shell_surface role ?!",
);
if !configured { if !configured {
if let SurfaceKind::XdgPopup(ref s) = self.shell_surface { if let SurfaceKind::XdgPopup(ref s) = self.shell_surface {
let ptr = s.get_user_data(); let ptr = s.get_user_data();

View File

@ -78,9 +78,8 @@ where
); );
return; return;
} }
shell_surface.set_user_data( shell_surface
Box::into_raw(Box::new(unsafe { surface.clone_unchecked() })) as *mut _, .set_user_data(Box::into_raw(Box::new(unsafe { surface.clone_unchecked() })) as *mut _);
);
evlh.register( evlh.register(
&shell_surface, &shell_surface,
shell_surface_implementation(), shell_surface_implementation(),
@ -243,9 +242,7 @@ where
}); });
return true; return true;
}) })
.expect( .expect("xdg_surface exists but surface has not shell_surface role?!");
"xdg_surface exists but surface has not shell_surface role?!",
);
// we need to notify about this new toplevel surface // we need to notify about this new toplevel surface
if need_send { if need_send {
evlh.state() evlh.state()

View File

@ -19,9 +19,7 @@ where
SID: 'static, SID: 'static,
SD: Default + 'static, SD: Default + 'static,
{ {
shell.set_user_data( shell.set_user_data(Box::into_raw(Box::new(Mutex::new(make_shell_client_data::<SD>()))) as *mut _);
Box::into_raw(Box::new(Mutex::new(make_shell_client_data::<SD>()))) as *mut _,
);
evlh.register( evlh.register(
&shell, &shell,
shell_implementation(), shell_implementation(),
@ -222,11 +220,8 @@ fn destroy_surface(surface: &zxdg_surface_v6::ZxdgSurfaceV6) {
let ptr = surface.get_user_data(); let ptr = surface.get_user_data();
surface.set_user_data(::std::ptr::null_mut()); surface.set_user_data(::std::ptr::null_mut());
// drop the state // drop the state
let data = unsafe { let data =
Box::from_raw( unsafe { Box::from_raw(ptr as *mut (zxdg_surface_v6::ZxdgSurfaceV6, zxdg_shell_v6::ZxdgShellV6)) };
ptr as *mut (zxdg_surface_v6::ZxdgSurfaceV6, zxdg_shell_v6::ZxdgShellV6),
)
};
// explicit call to drop to not forget what we're doing here // explicit call to drop to not forget what we're doing here
::std::mem::drop(data); ::std::mem::drop(data);
} }
@ -258,9 +253,7 @@ where
); );
} }
}) })
.expect( .expect("xdg_surface exists but surface has not shell_surface role?!");
"xdg_surface exists but surface has not shell_surface role?!",
);
}, },
get_toplevel: |evlh, idata, _, xdg_surface, toplevel| { get_toplevel: |evlh, idata, _, xdg_surface, toplevel| {
let ptr = xdg_surface.get_user_data(); let ptr = xdg_surface.get_user_data();
@ -277,9 +270,7 @@ where
max_size: (0, 0), max_size: (0, 0),
}); });
}) })
.expect( .expect("xdg_surface exists but surface has not shell_surface role?!");
"xdg_surface exists but surface has not shell_surface role?!",
);
toplevel.set_user_data(Box::into_raw(Box::new(unsafe { toplevel.set_user_data(Box::into_raw(Box::new(unsafe {
( (
@ -326,9 +317,7 @@ where
positioner: positioner_data.clone(), positioner: positioner_data.clone(),
}); });
}) })
.expect( .expect("xdg_surface exists but surface has not shell_surface role?!");
"xdg_surface exists but surface has not shell_surface role?!",
);
popup.set_user_data(Box::into_raw(Box::new(unsafe { popup.set_user_data(Box::into_raw(Box::new(unsafe {
( (
@ -370,9 +359,7 @@ where
height, height,
}); });
}) })
.expect( .expect("xdg_surface exists but surface has not shell_surface role?!");
"xdg_surface exists but surface has not shell_surface role?!",
);
}, },
ack_configure: |_, idata, _, surface, serial| { ack_configure: |_, idata, _, surface, serial| {
let ptr = surface.get_user_data(); let ptr = surface.get_user_data();
@ -397,9 +384,7 @@ where
} }
data.configured = true; data.configured = true;
}) })
.expect( .expect("xdg_surface exists but surface has not shell_surface role?!");
"xdg_surface exists but surface has not shell_surface role?!",
);
}, },
} }
} }
@ -442,9 +427,7 @@ where
ShellSurfacePendingState::Toplevel(ref mut toplevel_data) => f(toplevel_data), ShellSurfacePendingState::Toplevel(ref mut toplevel_data) => f(toplevel_data),
_ => unreachable!(), _ => unreachable!(),
}) })
.expect( .expect("xdg_toplevel exists but surface has not shell_surface role?!");
"xdg_toplevel exists but surface has not shell_surface role?!",
);
} }
fn xdg_handle_display_state_change<U, R, CID, SID, SD>(evlh: &mut EventLoopHandle, fn xdg_handle_display_state_change<U, R, CID, SID, SD>(evlh: &mut EventLoopHandle,
@ -503,9 +486,7 @@ where
// Add the configure as pending // Add the configure as pending
token token
.with_role_data::<ShellSurfaceRole, _, _>(surface, |data| data.pending_configures.push(serial)) .with_role_data::<ShellSurfaceRole, _, _>(surface, |data| data.pending_configures.push(serial))
.expect( .expect("xdg_toplevel exists but surface has not shell_surface role?!");
"xdg_toplevel exists but surface has not shell_surface role?!",
);
} }
fn make_toplevel_handle<U, R, H, SD>(token: CompositorToken<U, R, H>, fn make_toplevel_handle<U, R, H, SD>(token: CompositorToken<U, R, H>,
@ -541,9 +522,7 @@ where
data.pending_state = ShellSurfacePendingState::None; data.pending_state = ShellSurfacePendingState::None;
data.configured = false; data.configured = false;
}) })
.expect( .expect("xdg_toplevel exists but surface has not shell_surface role?!");
"xdg_toplevel exists but surface has not shell_surface role?!",
);
// remove this surface from the known ones (as well as any leftover dead surface) // remove this surface from the known ones (as well as any leftover dead surface)
evlh.state() evlh.state()
.get_mut(&idata.state_token) .get_mut(&idata.state_token)
@ -651,9 +630,7 @@ where
// Add the configure as pending // Add the configure as pending
token token
.with_role_data::<ShellSurfaceRole, _, _>(surface, |data| data.pending_configures.push(serial)) .with_role_data::<ShellSurfaceRole, _, _>(surface, |data| data.pending_configures.push(serial))
.expect( .expect("xdg_toplevel exists but surface has not shell_surface role?!");
"xdg_toplevel exists but surface has not shell_surface role?!",
);
} }
fn make_popup_handle<U, R, H, SD>(token: CompositorToken<U, R, H>, resource: &zxdg_popup_v6::ZxdgPopupV6) fn make_popup_handle<U, R, H, SD>(token: CompositorToken<U, R, H>, resource: &zxdg_popup_v6::ZxdgPopupV6)
@ -682,8 +659,8 @@ where
destroy: |evlh, idata, _, popup| { destroy: |evlh, idata, _, popup| {
let ptr = popup.get_user_data(); let ptr = popup.get_user_data();
let &(ref surface, _, _) = unsafe { let &(ref surface, _, _) = unsafe {
&*(ptr as &*(ptr
*mut ( as *mut (
wl_surface::WlSurface, wl_surface::WlSurface,
zxdg_shell_v6::ZxdgShellV6, zxdg_shell_v6::ZxdgShellV6,
zxdg_surface_v6::ZxdgSurfaceV6, zxdg_surface_v6::ZxdgSurfaceV6,
@ -695,9 +672,7 @@ where
data.pending_state = ShellSurfacePendingState::None; data.pending_state = ShellSurfacePendingState::None;
data.configured = false; data.configured = false;
}) })
.expect( .expect("xdg_toplevel exists but surface has not shell_surface role?!");
"xdg_toplevel exists but surface has not shell_surface role?!",
);
// remove this surface from the known ones (as well as any leftover dead surface) // remove this surface from the known ones (as well as any leftover dead surface)
evlh.state() evlh.state()
.get_mut(&idata.state_token) .get_mut(&idata.state_token)