fmt: rust 1.31

This commit is contained in:
Victor Brekenfeld 2018-12-08 18:31:08 +01:00
parent a1b8d2bf47
commit a3acd48cc3
24 changed files with 164 additions and 110 deletions

View File

@ -78,7 +78,8 @@ impl<T: Into<GliumGraphicsBackend<T>> + GLGraphicsBackend + 'static> GliumDrawer
tex_coords: [1.0, 0.0], tex_coords: [1.0, 0.0],
}, },
], ],
).unwrap(); )
.unwrap();
// building the index buffer // building the index buffer
let index_buffer = let index_buffer =
@ -121,7 +122,8 @@ impl<T: Into<GliumGraphicsBackend<T>> + GLGraphicsBackend + 'static> GliumDrawer
tex_coords: [1.0, 0.0], tex_coords: [1.0, 0.0],
}, },
], ],
).unwrap(); )
.unwrap();
// building the index buffer // building the index buffer
let index_buffer = let index_buffer =
@ -165,7 +167,8 @@ impl<F: GLGraphicsBackend + 'static> GliumDrawer<F> {
MipmapsOption::NoMipmap, MipmapsOption::NoMipmap,
images.width, images.width,
images.height, images.height,
).unwrap(); )
.unwrap();
unsafe { unsafe {
images images
.bind_to_texture(0, opengl_texture.get_id()) .bind_to_texture(0, opengl_texture.get_id())
@ -261,7 +264,8 @@ impl<F: GLGraphicsBackend + 'static> GliumDrawer<F> {
blend: blending, blend: blending,
..Default::default() ..Default::default()
}, },
).unwrap(); )
.unwrap();
} }
#[inline] #[inline]
@ -338,7 +342,8 @@ impl<F: GLGraphicsBackend + 'static> GliumDrawer<F> {
TraversalAction::SkipChildren TraversalAction::SkipChildren
} }
}, },
).unwrap(); )
.unwrap();
} }
}); });
} }

View File

@ -132,12 +132,14 @@ impl<B: InputBackend> InputHandler<B> for AnvilInputHandler {
self.running.store(false, Ordering::SeqCst); self.running.store(false, Ordering::SeqCst);
} }
#[cfg(feature = "udev")] #[cfg(feature = "udev")]
KeyAction::VtSwitch(vt) => if let Some(ref mut session) = self.session { KeyAction::VtSwitch(vt) => {
info!(log, "Trying to switch to vt {}", vt); if let Some(ref mut session) = self.session {
if let Err(err) = session.change_vt(vt) { info!(log, "Trying to switch to vt {}", vt);
error!(log, "Error switching to vt {}: {}", vt, err); if let Err(err) = session.change_vt(vt) {
error!(log, "Error switching to vt {}: {}", vt, err);
}
} }
}, }
KeyAction::Run(cmd) => { KeyAction::Run(cmd) => {
info!(self.log, "Starting program"; "cmd" => cmd.clone()); info!(self.log, "Starting program"; "cmd" => cmd.clone());
if let Err(e) = Command::new(&cmd).spawn() { if let Err(e) = Command::new(&cmd).spawn() {

View File

@ -130,7 +130,8 @@ pub fn run_udev(mut display: Display, mut event_loop: EventLoop<()>, log: Logger
}, },
seat.clone(), seat.clone(),
log.clone(), log.clone(),
).map_err(|_| ())?; )
.map_err(|_| ())?;
/* /*
* Initialize wayland clipboard * Initialize wayland clipboard
@ -151,7 +152,8 @@ pub fn run_udev(mut display: Display, mut event_loop: EventLoop<()>, log: Logger
let keyboard = w_seat let keyboard = w_seat
.add_keyboard(XkbConfig::default(), 1000, 500, |seat, focus| { .add_keyboard(XkbConfig::default(), 1000, 500, |seat, focus| {
set_data_device_focus(seat, focus.and_then(|s| s.client())) set_data_device_focus(seat, focus.and_then(|s| s.client()))
}).expect("Failed to initialize the keyboard"); })
.expect("Failed to initialize the keyboard");
/* /*
* Initialize a fake output (we render one screen to every device in this example) * Initialize a fake output (we render one screen to every device in this example)
@ -366,7 +368,8 @@ impl<S: SessionNotifier, Data: 'static> UdevHandler for UdevHandlerImpl<S, Data>
.open( .open(
&path, &path,
OFlag::O_RDWR | OFlag::O_CLOEXEC | OFlag::O_NOCTTY | OFlag::O_NONBLOCK, OFlag::O_RDWR | OFlag::O_CLOEXEC | OFlag::O_NOCTTY | OFlag::O_NONBLOCK,
).ok() )
.ok()
.and_then(|fd| LegacyDrmDevice::new(SessionFd(fd), self.logger.clone()).ok()) .and_then(|fd| LegacyDrmDevice::new(SessionFd(fd), self.logger.clone()).ok())
.and_then(|drm| GbmDevice::new(drm, self.logger.clone()).ok()) .and_then(|drm| GbmDevice::new(drm, self.logger.clone()).ok())
.and_then(|gbm| EglDevice::new(gbm, self.logger.clone()).ok()) .and_then(|gbm| EglDevice::new(gbm, self.logger.clone()).ok())

View File

@ -59,7 +59,8 @@ pub fn run_winit(display: &mut Display, event_loop: &mut EventLoop<()>, log: Log
let keyboard = seat let keyboard = seat
.add_keyboard(XkbConfig::default(), 1000, 500, |seat, focus| { .add_keyboard(XkbConfig::default(), 1000, 500, |seat, focus| {
set_data_device_focus(seat, focus.and_then(|s| s.client())) set_data_device_focus(seat, focus.and_then(|s| s.client()))
}).expect("Failed to initialize the keyboard"); })
.expect("Failed to initialize the keyboard");
let (output, _) = Output::new( let (output, _) = Output::new(
display, display,

View File

@ -33,7 +33,8 @@ fn main() {
"EGL_EXT_platform_device", "EGL_EXT_platform_device",
"EGL_KHR_image_base", "EGL_KHR_image_base",
], ],
).write_bindings(gl_generator::GlobalGenerator, &mut file) )
.write_bindings(gl_generator::GlobalGenerator, &mut file)
.unwrap(); .unwrap();
} }
@ -45,7 +46,8 @@ fn main() {
Profile::Compatibility, Profile::Compatibility,
Fallbacks::None, Fallbacks::None,
["GL_OES_EGL_image"], ["GL_OES_EGL_image"],
).write_bindings(gl_generator::StructGenerator, &mut file) )
.write_bindings(gl_generator::StructGenerator, &mut file)
.unwrap(); .unwrap();
} }
} }

View File

@ -149,7 +149,8 @@ impl<D: RawDevice + ControlDevice + 'static> Device for GbmDevice<D> {
h as u32, h as u32,
GbmFormat::XRGB8888, GbmFormat::XRGB8888,
BufferObjectFlags::SCANOUT | BufferObjectFlags::RENDERING, BufferObjectFlags::SCANOUT | BufferObjectFlags::RENDERING,
).chain_err(|| ErrorKind::SurfaceCreationFailed)?; )
.chain_err(|| ErrorKind::SurfaceCreationFailed)?;
// initialize a buffer for the cursor image // initialize a buffer for the cursor image
let cursor = Cell::new(( let cursor = Cell::new((
@ -160,7 +161,8 @@ impl<D: RawDevice + ControlDevice + 'static> Device for GbmDevice<D> {
1, 1,
GbmFormat::ARGB8888, GbmFormat::ARGB8888,
BufferObjectFlags::CURSOR | BufferObjectFlags::WRITE, BufferObjectFlags::CURSOR | BufferObjectFlags::WRITE,
).chain_err(|| ErrorKind::BufferCreationFailed)?, )
.chain_err(|| ErrorKind::BufferCreationFailed)?,
(0, 0), (0, 0),
)); ));

View File

@ -61,16 +61,15 @@ impl<S: SessionObserver + 'static, D: RawDevice + ControlDevice + AsSessionObser
} }
// reset cursor // reset cursor
{ {
let &(ref cursor, ref hotspot): &( let &(ref cursor, ref hotspot): &(BufferObject<()>, (u32, u32)) =
BufferObject<()>, unsafe { &*backend.cursor.as_ptr() };
(u32, u32),
) = unsafe { &*backend.cursor.as_ptr() };
if crtc::set_cursor2( if crtc::set_cursor2(
&*backend.dev.borrow(), &*backend.dev.borrow(),
*crtc, *crtc,
cursor, cursor,
((*hotspot).0 as i32, (*hotspot).1 as i32), ((*hotspot).0 as i32, (*hotspot).1 as i32),
).is_err() )
.is_err()
{ {
if let Err(err) = crtc::set_cursor(&*backend.dev.borrow(), *crtc, cursor) { if let Err(err) = crtc::set_cursor(&*backend.dev.borrow(), *crtc, cursor) {
error!(self.logger, "Failed to reset cursor. Error: {}", err); error!(self.logger, "Failed to reset cursor. Error: {}", err);

View File

@ -103,7 +103,8 @@ impl<D: RawDevice + 'static> GbmSurfaceInternal<D> {
h as u32, h as u32,
GbmFormat::XRGB8888, GbmFormat::XRGB8888,
BufferObjectFlags::SCANOUT | BufferObjectFlags::RENDERING, BufferObjectFlags::SCANOUT | BufferObjectFlags::RENDERING,
).chain_err(|| ErrorKind::SurfaceCreationFailed)?; )
.chain_err(|| ErrorKind::SurfaceCreationFailed)?;
// Clean up buffers // Clean up buffers
if let Some(Ok(Some(fb))) = self.next_buffer.take().map(|mut bo| bo.take_userdata()) { if let Some(Ok(Some(fb))) = self.next_buffer.take().map(|mut bo| bo.take_userdata()) {
@ -231,7 +232,8 @@ impl<'a, A: AsRawFd + 'static> CursorBackend<'a> for GbmSurfaceInternal<LegacyDr
h, h,
GbmFormat::ARGB8888, GbmFormat::ARGB8888,
BufferObjectFlags::CURSOR | BufferObjectFlags::WRITE, BufferObjectFlags::CURSOR | BufferObjectFlags::WRITE,
).chain_err(|| ErrorKind::BufferCreationFailed)?; )
.chain_err(|| ErrorKind::BufferCreationFailed)?;
cursor cursor
.write(&**buffer) .write(&**buffer)

View File

@ -227,35 +227,40 @@ impl<A: AsRawFd + 'static> Device for LegacyDrmDevice<A> {
fn process_events(&mut self) { fn process_events(&mut self) {
match crtc::receive_events(self) { match crtc::receive_events(self) {
Ok(events) => for event in events { Ok(events) => {
if let crtc::Event::PageFlip(event) = event { for event in events {
if self.active.load(Ordering::SeqCst) { if let crtc::Event::PageFlip(event) = event {
if self if self.active.load(Ordering::SeqCst) {
.backends if self
.borrow() .backends
.get(&event.crtc) .borrow()
.iter() .get(&event.crtc)
.flat_map(|x| x.upgrade()) .iter()
.next() .flat_map(|x| x.upgrade())
.is_some() .next()
{ .is_some()
trace!(self.logger, "Handling event for backend {:?}", event.crtc); {
if let Some(handler) = self.handler.as_ref() { trace!(self.logger, "Handling event for backend {:?}", event.crtc);
handler.borrow_mut().vblank(event.crtc); if let Some(handler) = self.handler.as_ref() {
handler.borrow_mut().vblank(event.crtc);
}
} else {
self.backends.borrow_mut().remove(&event.crtc);
} }
} else {
self.backends.borrow_mut().remove(&event.crtc);
} }
} }
} }
}, }
Err(err) => if let Some(handler) = self.handler.as_ref() { Err(err) => {
handler.borrow_mut().error( if let Some(handler) = self.handler.as_ref() {
ResultExt::<()>::chain_err(Err(err), || { handler.borrow_mut().error(
ErrorKind::DrmDev(format!("Error processing drm events on {:?}", self.dev_path())) ResultExt::<()>::chain_err(Err(err), || {
}).unwrap_err(), ErrorKind::DrmDev(format!("Error processing drm events on {:?}", self.dev_path()))
); })
}, .unwrap_err(),
);
}
}
} }
} }

View File

@ -102,7 +102,8 @@ impl<A: AsRawFd + 'static> Surface for LegacyDrmSurfaceInternal<A> {
encoder::Info::load_from_device(self, *encoder).chain_err(|| { encoder::Info::load_from_device(self, *encoder).chain_err(|| {
ErrorKind::DrmDev(format!("Error loading encoder info on {:?}", self.dev_path())) ErrorKind::DrmDev(format!("Error loading encoder info on {:?}", self.dev_path()))
}) })
}).collect::<Result<Vec<encoder::Info>>>()?; })
.collect::<Result<Vec<encoder::Info>>>()?;
// and if any encoder supports the selected crtc // and if any encoder supports the selected crtc
let resource_handles = self.resource_handles().chain_err(|| { let resource_handles = self.resource_handles().chain_err(|| {
@ -137,7 +138,8 @@ impl<A: AsRawFd + 'static> Surface for LegacyDrmSurfaceInternal<A> {
if !connector::Info::load_from_device(self, *connector) if !connector::Info::load_from_device(self, *connector)
.chain_err(|| { .chain_err(|| {
ErrorKind::DrmDev(format!("Error loading connector info on {:?}", self.dev_path())) ErrorKind::DrmDev(format!("Error loading connector info on {:?}", self.dev_path()))
})?.modes() })?
.modes()
.contains(&mode) .contains(&mode)
{ {
bail!(ErrorKind::ModeNotSuitable(mode)); bail!(ErrorKind::ModeNotSuitable(mode));
@ -201,7 +203,8 @@ impl<A: AsRawFd + 'static> RawSurface for LegacyDrmSurfaceInternal<A> {
.collect::<Vec<connector::Handle>>(), .collect::<Vec<connector::Handle>>(),
(0, 0), (0, 0),
pending.mode, pending.mode,
).chain_err(|| { )
.chain_err(|| {
ErrorKind::DrmDev(format!( ErrorKind::DrmDev(format!(
"Error setting crtc {:?} on {:?}", "Error setting crtc {:?} on {:?}",
self.crtc, self.crtc,
@ -222,7 +225,8 @@ impl<A: AsRawFd + 'static> RawSurface for LegacyDrmSurfaceInternal<A> {
self.crtc, self.crtc,
framebuffer, framebuffer,
&[crtc::PageFlipFlags::PageFlipEvent], &[crtc::PageFlipFlags::PageFlipEvent],
).map_err(|_| SwapBuffersError::ContextLost) )
.map_err(|_| SwapBuffersError::ContextLost)
} }
} }

View File

@ -37,12 +37,7 @@ pub use self::context::EGLContext;
pub mod error; pub mod error;
use self::error::*; use self::error::*;
#[allow( #[allow(non_camel_case_types, dead_code, unused_mut, non_upper_case_globals)]
non_camel_case_types,
dead_code,
unused_mut,
non_upper_case_globals
)]
pub mod ffi; pub mod ffi;
use self::ffi::egl::types::EGLImage; use self::ffi::egl::types::EGLImage;

View File

@ -24,10 +24,7 @@ use wayland_server::calloop::{
// No idea if this is the same across unix platforms // No idea if this is the same across unix platforms
// Lets make this linux exclusive for now, once someone tries to build it for // Lets make this linux exclusive for now, once someone tries to build it for
// any BSD-like system, they can verify if this is right and make a PR to change this. // any BSD-like system, they can verify if this is right and make a PR to change this.
#[cfg(all( #[cfg(all(any(target_os = "linux", target_os = "android"), feature = "backend_session"))]
any(target_os = "linux", target_os = "android"),
feature = "backend_session"
))]
const INPUT_MAJOR: u32 = 13; const INPUT_MAJOR: u32 = 13;
/// Libinput based `InputBackend`. /// Libinput based `InputBackend`.
@ -448,16 +445,18 @@ impl backend::InputBackend for LibinputInputBackend {
libinput::Event::Keyboard(keyboard_event) => { libinput::Event::Keyboard(keyboard_event) => {
use input::event::keyboard::*; use input::event::keyboard::*;
match keyboard_event { match keyboard_event {
KeyboardEvent::Key(key_event) => if let Some(ref mut handler) = self.handler { KeyboardEvent::Key(key_event) => {
let device_seat = key_event.device().seat(); if let Some(ref mut handler) = self.handler {
if let Some(ref seat) = self.seats.get(&device_seat) { let device_seat = key_event.device().seat();
trace!(self.logger, "Calling on_keyboard_key with {:?}", key_event); if let Some(ref seat) = self.seats.get(&device_seat) {
handler.on_keyboard_key(seat, key_event); trace!(self.logger, "Calling on_keyboard_key with {:?}", key_event);
} else { handler.on_keyboard_key(seat, key_event);
warn!(self.logger, "Received key event of non existing Seat"); } else {
continue; warn!(self.logger, "Received key event of non existing Seat");
continue;
}
} }
}, }
} }
} }
libinput::Event::Pointer(pointer_event) => { libinput::Event::Pointer(pointer_event) => {

View File

@ -101,7 +101,8 @@ impl LogindSession {
"org.freedesktop.login1.Manager", "org.freedesktop.login1.Manager",
"GetSession", "GetSession",
Some(vec![session_id.clone().into()]), Some(vec![session_id.clone().into()]),
)?.get1::<DbusPath<'static>>() )?
.get1::<DbusPath<'static>>()
.chain_err(|| ErrorKind::UnexpectedMethodReturn)?; .chain_err(|| ErrorKind::UnexpectedMethodReturn)?;
// Match all signals that we want to receive and handle // Match all signals that we want to receive and handle
@ -342,7 +343,8 @@ impl Session for LogindSession {
(major(stat.st_rdev) as u32).into(), (major(stat.st_rdev) as u32).into(),
(minor(stat.st_rdev) as u32).into(), (minor(stat.st_rdev) as u32).into(),
]), ]),
)?.get2::<OwnedFd, bool>(); )?
.get2::<OwnedFd, bool>();
let fd = fd.chain_err(|| ErrorKind::UnexpectedMethodReturn)?.into_fd(); let fd = fd.chain_err(|| ErrorKind::UnexpectedMethodReturn)?.into_fd();
Ok(fd) Ok(fd)
} else { } else {
@ -363,7 +365,8 @@ impl Session for LogindSession {
(major(stat.st_rdev) as u32).into(), (major(stat.st_rdev) as u32).into(),
(minor(stat.st_rdev) as u32).into(), (minor(stat.st_rdev) as u32).into(),
]), ]),
).map(|_| ()) )
.map(|_| ())
} else { } else {
bail!(ErrorKind::SessionLost) bail!(ErrorKind::SessionLost)
} }
@ -390,7 +393,8 @@ impl Session for LogindSession {
"org.freedesktop.login1.Seat", "org.freedesktop.login1.Seat",
"SwitchTo", "SwitchTo",
Some(vec![(vt_num as u32).into()]), Some(vec![(vt_num as u32).into()]),
).map(|_| ()) )
.map(|_| ())
} else { } else {
bail!(ErrorKind::SessionLost) bail!(ErrorKind::SessionLost)
} }

View File

@ -185,8 +185,10 @@ impl DirectSession {
path, path,
fcntl::OFlag::O_RDWR | fcntl::OFlag::O_CLOEXEC, fcntl::OFlag::O_RDWR | fcntl::OFlag::O_CLOEXEC,
Mode::empty(), Mode::empty(),
).chain_err(|| ErrorKind::FailedToOpenTTY(String::from(path.to_string_lossy()))) )
}).unwrap_or_else(|| { .chain_err(|| ErrorKind::FailedToOpenTTY(String::from(path.to_string_lossy())))
})
.unwrap_or_else(|| {
dup(0 /*stdin*/).chain_err(|| ErrorKind::FailedToOpenTTY(String::from("<stdin>"))) dup(0 /*stdin*/).chain_err(|| ErrorKind::FailedToOpenTTY(String::from("<stdin>")))
})?; })?;
@ -429,7 +431,8 @@ pub fn direct_session_bind<Data: 'static>(
.insert_source(source, { .insert_source(source, {
let notifier = notifier.clone(); let notifier = notifier.clone();
move |_, _| notifier.borrow_mut().signal_received() move |_, _| notifier.borrow_mut().signal_received()
}).map_err(move |e| { })
.map_err(move |e| {
// the backend in the closure should already have been dropped // the backend in the closure should already have been dropped
let notifier = Rc::try_unwrap(fail_notifier) let notifier = Rc::try_unwrap(fail_notifier)
.unwrap_or_else(|_| unreachable!()) .unwrap_or_else(|_| unreachable!())

View File

@ -73,7 +73,8 @@ impl<T: UdevHandler + 'static> UdevBackend<T> {
warn!(log, "Unable to get id of {:?}, Error: {:?}. Skipping", path, err); warn!(log, "Unable to get id of {:?}, Error: {:?}. Skipping", path, err);
None None
} }
}).collect(); })
.collect();
let mut builder = MonitorBuilder::new(context)?; let mut builder = MonitorBuilder::new(context)?;
builder.match_subsystem("drm")?; builder.match_subsystem("drm")?;
@ -217,6 +218,7 @@ pub fn all_gpus<S: AsRef<str>>(context: &Context, seat: S) -> UdevResult<Vec<Pat
.map(|x| x.to_os_string()) .map(|x| x.to_os_string())
.unwrap_or(OsString::from("seat0")) .unwrap_or(OsString::from("seat0"))
== *seat.as_ref() == *seat.as_ref()
}).flat_map(|device| device.devnode().map(PathBuf::from)) })
.flat_map(|device| device.devnode().map(PathBuf::from))
.collect()) .collect())
} }

View File

@ -108,7 +108,8 @@ impl PointerGrab for DnDGrab {
offer_data.clone(), offer_data.clone(),
action_choice, action_choice,
) )
}).unwrap(); })
.unwrap();
// advertize the offer to the client // advertize the offer to the client
device.send(wl_data_device::Event::DataOffer { id: offer.clone() }); device.send(wl_data_device::Event::DataOffer { id: offer.clone() });
with_source_metadata(source, |meta| { with_source_metadata(source, |meta| {
@ -118,7 +119,8 @@ impl PointerGrab for DnDGrab {
offer.send(wl_data_offer::Event::SourceActions { offer.send(wl_data_offer::Event::SourceActions {
source_actions: meta.dnd_action.to_raw(), source_actions: meta.dnd_action.to_raw(),
}); });
}).unwrap(); })
.unwrap();
device.send(wl_data_device::Event::Enter { device.send(wl_data_device::Event::Enter {
serial, serial,
x: x - sx, x: x - sx,

View File

@ -150,7 +150,8 @@ impl SeatData {
// check if the source and associated mime type is still valid // check if the source and associated mime type is still valid
let valid = with_source_metadata(&source, |meta| { let valid = with_source_metadata(&source, |meta| {
meta.mime_types.contains(&mime_type) meta.mime_types.contains(&mime_type)
}).unwrap_or(false) })
.unwrap_or(false)
&& source.is_alive(); && source.is_alive();
if !valid { if !valid {
// deny the receive // deny the receive
@ -171,7 +172,8 @@ impl SeatData {
for mime_type in meta.mime_types.iter().cloned() { for mime_type in meta.mime_types.iter().cloned() {
offer.send(wl_data_offer::Event::Offer { mime_type }) offer.send(wl_data_offer::Event::Offer { mime_type })
} }
}).unwrap(); })
.unwrap();
dd.send(wl_data_device::Event::Selection { id: Some(offer) }); dd.send(wl_data_device::Event::Selection { id: Some(offer) });
} }
} }

View File

@ -131,7 +131,8 @@ where
self.callback.clone(), self.callback.clone(),
action_choice, action_choice,
) )
}).unwrap(); })
.unwrap();
// advertize the offer to the client // advertize the offer to the client
device.send(wl_data_device::Event::DataOffer { id: offer.clone() }); device.send(wl_data_device::Event::DataOffer { id: offer.clone() });
for mime_type in self.metadata.mime_types.iter().cloned() { for mime_type in self.metadata.mime_types.iter().cloned() {

View File

@ -141,7 +141,8 @@ impl KbdInternal {
&xkb_config.variant, &xkb_config.variant,
xkb_config.options, xkb_config.options,
xkb::KEYMAP_COMPILE_NO_FLAGS, xkb::KEYMAP_COMPILE_NO_FLAGS,
).ok_or(())?; )
.ok_or(())?;
let state = xkb::State::new(&keymap); let state = xkb::State::new(&keymap);
Ok(KbdInternal { Ok(KbdInternal {
known_kbds: Vec::new(), known_kbds: Vec::new(),

View File

@ -119,7 +119,8 @@ where
} else { } else {
false false
} }
}).expect("wl_shell_surface exists but surface has not the right role?"); })
.expect("wl_shell_surface exists but surface has not the right role?");
if valid { if valid {
(&mut *user_impl)(ShellRequest::Pong { (&mut *user_impl)(ShellRequest::Pong {
surface: make_handle(&shell_surface, ctoken), surface: make_handle(&shell_surface, ctoken),

View File

@ -620,7 +620,8 @@ where
.with_role_data::<XdgSurfaceRole, _, _>(&self.wl_surface, |data| match data.pending_state { .with_role_data::<XdgSurfaceRole, _, _>(&self.wl_surface, |data| match data.pending_state {
XdgSurfacePendingState::Toplevel(ref state) => Some(state.clone()), XdgSurfacePendingState::Toplevel(ref state) => Some(state.clone()),
_ => None, _ => None,
}).ok() })
.ok()
.and_then(|x| x) .and_then(|x| x)
} }
} }
@ -782,7 +783,8 @@ where
.with_role_data::<XdgSurfaceRole, _, _>(&self.wl_surface, |data| match data.pending_state { .with_role_data::<XdgSurfaceRole, _, _>(&self.wl_surface, |data| match data.pending_state {
XdgSurfacePendingState::Popup(ref state) => Some(state.clone()), XdgSurfacePendingState::Popup(ref state) => Some(state.clone()),
_ => None, _ => None,
}).ok() })
.ok()
.and_then(|x| x) .and_then(|x| x)
} }
} }

View File

@ -217,7 +217,8 @@ where
"xdg_surface was destroyed before its role object".into(), "xdg_surface was destroyed before its role object".into(),
); );
} }
}).expect("xdg_surface exists but surface has not shell_surface role?!"); })
.expect("xdg_surface exists but surface has not shell_surface role?!");
} }
fn xdg_surface_implementation<U, R, SD>( fn xdg_surface_implementation<U, R, SD>(
@ -244,7 +245,8 @@ fn xdg_surface_implementation<U, R, SD>(
min_size: (0, 0), min_size: (0, 0),
max_size: (0, 0), 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?!");
let toplevel = id.implement_nonsend( let toplevel = id.implement_nonsend(
toplevel_implementation::<U, R, SD>, toplevel_implementation::<U, R, SD>,
Some(destroy_toplevel::<U, R, SD>), Some(destroy_toplevel::<U, R, SD>),
@ -286,7 +288,8 @@ fn xdg_surface_implementation<U, R, SD>(
parent: parent_surface, parent: parent_surface,
positioner: positioner_data.borrow().clone(), positioner: positioner_data.borrow().clone(),
}); });
}).expect("xdg_surface exists but surface has not shell_surface role?!"); })
.expect("xdg_surface exists but surface has not shell_surface role?!");
let popup = id.implement_nonsend( let popup = id.implement_nonsend(
xg_popup_implementation::<U, R, SD>, xg_popup_implementation::<U, R, SD>,
Some(destroy_popup::<U, R, SD>), Some(destroy_popup::<U, R, SD>),
@ -315,7 +318,8 @@ fn xdg_surface_implementation<U, R, SD>(
.compositor_token .compositor_token
.with_role_data::<XdgSurfaceRole, _, _>(&data.wl_surface, |data| { .with_role_data::<XdgSurfaceRole, _, _>(&data.wl_surface, |data| {
data.window_geometry = Some(Rectangle { x, y, width, height }); data.window_geometry = Some(Rectangle { x, y, width, height });
}).expect("xdg_surface exists but surface has not shell_surface role?!"); })
.expect("xdg_surface exists but surface has not shell_surface role?!");
} }
xdg_surface::Request::AckConfigure { serial } => { xdg_surface::Request::AckConfigure { serial } => {
data.shell_data data.shell_data
@ -336,7 +340,8 @@ fn xdg_surface_implementation<U, R, SD>(
); );
} }
role_data.configured = true; role_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?!");
} }
} }
} }
@ -369,7 +374,8 @@ fn with_surface_toplevel_data<U, R, SD, F>(
.with_role_data::<XdgSurfaceRole, _, _>(&toplevel_data.wl_surface, |data| match data.pending_state { .with_role_data::<XdgSurfaceRole, _, _>(&toplevel_data.wl_surface, |data| match data.pending_state {
XdgSurfacePendingState::Toplevel(ref mut toplevel_data) => f(toplevel_data), XdgSurfacePendingState::Toplevel(ref mut toplevel_data) => f(toplevel_data),
_ => unreachable!(), _ => unreachable!(),
}).expect("xdg_toplevel exists but surface has not shell_surface role?!"); })
.expect("xdg_toplevel exists but surface has not shell_surface role?!");
} }
pub fn send_toplevel_configure<U, R, SD>( pub fn send_toplevel_configure<U, R, SD>(
@ -539,7 +545,8 @@ where
.with_role_data::<XdgSurfaceRole, _, _>(&data.wl_surface, |data| { .with_role_data::<XdgSurfaceRole, _, _>(&data.wl_surface, |data| {
data.pending_state = XdgSurfacePendingState::None; data.pending_state = XdgSurfacePendingState::None;
data.configured = false; 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) // remove this surface from the known ones (as well as any leftover dead surface)
data.shell_data data.shell_data
@ -627,7 +634,8 @@ where
.with_role_data::<XdgSurfaceRole, _, _>(&data.wl_surface, |data| { .with_role_data::<XdgSurfaceRole, _, _>(&data.wl_surface, |data| {
data.pending_state = XdgSurfacePendingState::None; data.pending_state = XdgSurfacePendingState::None;
data.configured = false; data.configured = false;
}).expect("xdg_popup exists but surface has not shell_surface role?!"); })
.expect("xdg_popup 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)
data.shell_data data.shell_data

View File

@ -236,7 +236,8 @@ where
"xdg_surface was destroyed before its role object".into(), "xdg_surface was destroyed before its role object".into(),
); );
} }
}).expect("xdg_surface exists but surface has not shell_surface role?!"); })
.expect("xdg_surface exists but surface has not shell_surface role?!");
} }
fn xdg_surface_implementation<U, R, SD>( fn xdg_surface_implementation<U, R, SD>(
@ -263,7 +264,8 @@ fn xdg_surface_implementation<U, R, SD>(
min_size: (0, 0), min_size: (0, 0),
max_size: (0, 0), 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?!");
let toplevel = id.implement_nonsend( let toplevel = id.implement_nonsend(
toplevel_implementation::<U, R, SD>, toplevel_implementation::<U, R, SD>,
Some(destroy_toplevel::<U, R, SD>), Some(destroy_toplevel::<U, R, SD>),
@ -302,7 +304,8 @@ fn xdg_surface_implementation<U, R, SD>(
parent: Some(parent_data.wl_surface.clone()), parent: Some(parent_data.wl_surface.clone()),
positioner: positioner_data.borrow().clone(), positioner: positioner_data.borrow().clone(),
}); });
}).expect("xdg_surface exists but surface has not shell_surface role?!"); })
.expect("xdg_surface exists but surface has not shell_surface role?!");
let popup = id.implement_nonsend( let popup = id.implement_nonsend(
popup_implementation::<U, R, SD>, popup_implementation::<U, R, SD>,
Some(destroy_popup::<U, R, SD>), Some(destroy_popup::<U, R, SD>),
@ -331,7 +334,8 @@ fn xdg_surface_implementation<U, R, SD>(
.compositor_token .compositor_token
.with_role_data::<XdgSurfaceRole, _, _>(&data.wl_surface, |data| { .with_role_data::<XdgSurfaceRole, _, _>(&data.wl_surface, |data| {
data.window_geometry = Some(Rectangle { x, y, width, height }); data.window_geometry = Some(Rectangle { x, y, width, height });
}).expect("xdg_surface exists but surface has not shell_surface role?!"); })
.expect("xdg_surface exists but surface has not shell_surface role?!");
} }
zxdg_surface_v6::Request::AckConfigure { serial } => { zxdg_surface_v6::Request::AckConfigure { serial } => {
data.shell_data data.shell_data
@ -352,7 +356,8 @@ fn xdg_surface_implementation<U, R, SD>(
); );
} }
role_data.configured = true; role_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?!");
} }
} }
} }
@ -382,7 +387,8 @@ where
.with_role_data::<XdgSurfaceRole, _, _>(&data.wl_surface, |data| match data.pending_state { .with_role_data::<XdgSurfaceRole, _, _>(&data.wl_surface, |data| match data.pending_state {
XdgSurfacePendingState::Toplevel(ref mut toplevel_data) => f(toplevel_data), XdgSurfacePendingState::Toplevel(ref mut toplevel_data) => f(toplevel_data),
_ => unreachable!(), _ => unreachable!(),
}).expect("xdg_toplevel exists but surface has not shell_surface role?!"); })
.expect("xdg_toplevel exists but surface has not shell_surface role?!");
} }
pub fn send_toplevel_configure<U, R, SD>( pub fn send_toplevel_configure<U, R, SD>(
@ -553,7 +559,8 @@ where
.with_role_data::<XdgSurfaceRole, _, _>(&data.wl_surface, |data| { .with_role_data::<XdgSurfaceRole, _, _>(&data.wl_surface, |data| {
data.pending_state = XdgSurfacePendingState::None; data.pending_state = XdgSurfacePendingState::None;
data.configured = false; 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) // remove this surface from the known ones (as well as any leftover dead surface)
data.shell_data data.shell_data
@ -644,7 +651,8 @@ where
.with_role_data::<XdgSurfaceRole, _, _>(&data.wl_surface, |data| { .with_role_data::<XdgSurfaceRole, _, _>(&data.wl_surface, |data| {
data.pending_state = XdgSurfacePendingState::None; data.pending_state = XdgSurfacePendingState::None;
data.configured = false; data.configured = false;
}).expect("xdg_popup exists but surface has not shell_surface role?!"); })
.expect("xdg_popup 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)
data.shell_data data.shell_data

View File

@ -97,7 +97,8 @@ impl<WM: XWindowManager + 'static> XWayland<WM> {
debug_assert!(evt.signal() == Signal::SIGUSR1); debug_assert!(evt.signal() == Signal::SIGUSR1);
xwayland_ready(&inner); xwayland_ready(&inner);
}, },
).map_err(|_| ()) )
.map_err(|_| ())
}), }),
wayland_display: display, wayland_display: display,
instance: None, instance: None,