Apply a bunch of clippy suggestions
This commit is contained in:
parent
b41cf9c4c3
commit
4946017c0c
|
@ -114,7 +114,7 @@ impl DrmBackend {
|
||||||
|surface| {
|
|surface| {
|
||||||
// create an egl surface from the gbm one
|
// create an egl surface from the gbm one
|
||||||
debug!(log, "Creating EGLSurface");
|
debug!(log, "Creating EGLSurface");
|
||||||
let egl_surface = context.egl.create_surface(&surface)?;
|
let egl_surface = context.egl.create_surface(surface)?;
|
||||||
|
|
||||||
// make it active for the first `crtc::set`
|
// make it active for the first `crtc::set`
|
||||||
// (which is needed before the first page_flip)
|
// (which is needed before the first page_flip)
|
||||||
|
@ -270,7 +270,7 @@ impl DrmBackend {
|
||||||
/// Other errors might occur.
|
/// Other errors might occur.
|
||||||
pub fn use_mode(&mut self, mode: Mode) -> Result<()> {
|
pub fn use_mode(&mut self, mode: Mode) -> Result<()> {
|
||||||
// check the connectors
|
// check the connectors
|
||||||
for connector in self.connectors.iter() {
|
for connector in &self.connectors {
|
||||||
if !connector::Info::load_from_device(self.graphics.head().head().head(), *connector)
|
if !connector::Info::load_from_device(self.graphics.head().head().head(), *connector)
|
||||||
.chain_err(|| {
|
.chain_err(|| {
|
||||||
ErrorKind::DrmDev(format!("{:?}", self.graphics.head().head().head()))
|
ErrorKind::DrmDev(format!("{:?}", self.graphics.head().head().head()))
|
||||||
|
@ -318,7 +318,7 @@ impl DrmBackend {
|
||||||
|surface| {
|
|surface| {
|
||||||
// create an egl surface from the gbm one
|
// create an egl surface from the gbm one
|
||||||
debug!(logger_ref, "Creating EGLSurface");
|
debug!(logger_ref, "Creating EGLSurface");
|
||||||
let egl_surface = graphics.context.egl.create_surface(&surface)?;
|
let egl_surface = graphics.context.egl.create_surface(surface)?;
|
||||||
|
|
||||||
// make it active for the first `crtc::set`
|
// make it active for the first `crtc::set`
|
||||||
// (which is needed before the first page_flip)
|
// (which is needed before the first page_flip)
|
||||||
|
@ -383,13 +383,12 @@ impl Drop for DrmBackend {
|
||||||
self.graphics.rent_all_mut(|graphics| {
|
self.graphics.rent_all_mut(|graphics| {
|
||||||
if let Some(fb) = graphics.gbm.surface.rent(|egl| {
|
if let Some(fb) = graphics.gbm.surface.rent(|egl| {
|
||||||
if let Some(mut next) = egl.buffers.next_buffer.take() {
|
if let Some(mut next) = egl.buffers.next_buffer.take() {
|
||||||
return next.take_userdata();
|
next.take_userdata()
|
||||||
|
} else if let Ok(mut next) = graphics.gbm.surface.head().lock_front_buffer() {
|
||||||
|
next.take_userdata()
|
||||||
} else {
|
} else {
|
||||||
if let Ok(mut next) = graphics.gbm.surface.head().lock_front_buffer() {
|
None
|
||||||
return next.take_userdata();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
None
|
|
||||||
}) {
|
}) {
|
||||||
// ignore failure at this point
|
// ignore failure at this point
|
||||||
let _ = framebuffer::destroy(&*graphics.context.devices.drm, fb.handle());
|
let _ = framebuffer::destroy(&*graphics.context.devices.drm, fb.handle());
|
||||||
|
|
|
@ -397,7 +397,7 @@ impl<B: From<DrmBackend> + Borrow<DrmBackend> + 'static> DrmDevice<B> {
|
||||||
let connectors = connectors.into();
|
let connectors = connectors.into();
|
||||||
|
|
||||||
// check if we have an encoder for every connector and the mode mode
|
// check if we have an encoder for every connector and the mode mode
|
||||||
for connector in connectors.iter() {
|
for connector in &connectors {
|
||||||
let con_info = connector::Info::load_from_device(self.context.head().head(), *connector)
|
let con_info = connector::Info::load_from_device(self.context.head().head(), *connector)
|
||||||
.chain_err(|| {
|
.chain_err(|| {
|
||||||
ErrorKind::DrmDev(format!("{:?}", self.context.head().head()))
|
ErrorKind::DrmDev(format!("{:?}", self.context.head().head()))
|
||||||
|
@ -471,7 +471,7 @@ pub trait DrmHandler<B: Borrow<DrmBackend> + 'static> {
|
||||||
fn error(&mut self, evlh: &mut EventLoopHandle, device: &mut DrmDevice<B>, error: DrmError);
|
fn error(&mut self, evlh: &mut EventLoopHandle, device: &mut DrmDevice<B>, error: DrmError);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Bind a `DrmDevice` to an EventLoop,
|
/// Bind a `DrmDevice` to an `EventLoop`,
|
||||||
///
|
///
|
||||||
/// This will cause it to recieve events and feed them into an `DrmHandler`
|
/// This will cause it to recieve events and feed them into an `DrmHandler`
|
||||||
pub fn drm_device_bind<B, H>(evlh: &mut EventLoopHandle, device: DrmDevice<B>, handler: H)
|
pub fn drm_device_bind<B, H>(evlh: &mut EventLoopHandle, device: DrmDevice<B>, handler: H)
|
||||||
|
@ -500,21 +500,18 @@ where
|
||||||
let events = crtc::receive_events(dev);
|
let events = crtc::receive_events(dev);
|
||||||
match events {
|
match events {
|
||||||
Ok(events) => for event in events {
|
Ok(events) => for event in events {
|
||||||
match event {
|
if let crtc::Event::PageFlip(event) = event {
|
||||||
crtc::Event::PageFlip(event) => {
|
let token = dev.backends.get(&event.crtc).cloned();
|
||||||
let token = dev.backends.get(&event.crtc).cloned();
|
if let Some(token) = token {
|
||||||
if let Some(token) = token {
|
// we can now unlock the buffer
|
||||||
// we can now unlock the buffer
|
evlh.state().get(&token).borrow().unlock_buffer();
|
||||||
evlh.state().get(&token).borrow().unlock_buffer();
|
trace!(dev.logger, "Handling event for backend {:?}", event.crtc);
|
||||||
trace!(dev.logger, "Handling event for backend {:?}", event.crtc);
|
// and then call the user to render the next frame
|
||||||
// and then call the user to render the next frame
|
handler.ready(evlh, dev, &token, event.frame, event.duration);
|
||||||
handler.ready(evlh, dev, &token, event.frame, event.duration);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
_ => {}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
Err(err) => return handler.error(evlh, dev, err),
|
Err(err) => handler.error(evlh, dev, err),
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
error: |evlh, id, _, error| {
|
error: |evlh, id, _, error| {
|
||||||
|
|
|
@ -640,7 +640,7 @@ impl<'a, T: NativeSurface> EGLContext<'a, T> {
|
||||||
|
|
||||||
let mut context_attributes = Vec::with_capacity(10);
|
let mut context_attributes = Vec::with_capacity(10);
|
||||||
|
|
||||||
if egl_version >= (1, 5) || extensions.iter().any(|s| s == &"EGL_KHR_create_context") {
|
if egl_version >= (1, 5) || extensions.iter().any(|s| *s == "EGL_KHR_create_context") {
|
||||||
trace!(log, "Setting CONTEXT_MAJOR_VERSION to {}", version.0);
|
trace!(log, "Setting CONTEXT_MAJOR_VERSION to {}", version.0);
|
||||||
context_attributes.push(ffi::egl::CONTEXT_MAJOR_VERSION as i32);
|
context_attributes.push(ffi::egl::CONTEXT_MAJOR_VERSION as i32);
|
||||||
context_attributes.push(version.0 as i32);
|
context_attributes.push(version.0 as i32);
|
||||||
|
@ -728,8 +728,8 @@ impl<'a, T: NativeSurface> EGLContext<'a, T> {
|
||||||
self.display,
|
self.display,
|
||||||
self.config_id,
|
self.config_id,
|
||||||
match surface {
|
match surface {
|
||||||
NativeSurfacePtr::X11(ptr) => ptr,
|
NativeSurfacePtr::X11(ptr) |
|
||||||
NativeSurfacePtr::Wayland(ptr) => ptr,
|
NativeSurfacePtr::Wayland(ptr) |
|
||||||
NativeSurfacePtr::Gbm(ptr) => ptr,
|
NativeSurfacePtr::Gbm(ptr) => ptr,
|
||||||
},
|
},
|
||||||
self.surface_attributes.as_ptr(),
|
self.surface_attributes.as_ptr(),
|
||||||
|
@ -743,7 +743,7 @@ impl<'a, T: NativeSurface> EGLContext<'a, T> {
|
||||||
debug!(self.logger, "EGL surface successfully created");
|
debug!(self.logger, "EGL surface successfully created");
|
||||||
|
|
||||||
Ok(EGLSurface {
|
Ok(EGLSurface {
|
||||||
context: &self,
|
context: self,
|
||||||
surface: egl_surface,
|
surface: egl_surface,
|
||||||
keep,
|
keep,
|
||||||
_lifetime_surface: PhantomData,
|
_lifetime_surface: PhantomData,
|
||||||
|
@ -894,9 +894,9 @@ impl fmt::Display for SwapBuffersError {
|
||||||
|
|
||||||
impl error::Error for SwapBuffersError {
|
impl error::Error for SwapBuffersError {
|
||||||
fn description(&self) -> &str {
|
fn description(&self) -> &str {
|
||||||
match self {
|
match *self {
|
||||||
&SwapBuffersError::ContextLost => "The context has been lost, it needs to be recreated",
|
SwapBuffersError::ContextLost => "The context has been lost, it needs to be recreated",
|
||||||
&SwapBuffersError::AlreadySwapped => {
|
SwapBuffersError::AlreadySwapped => {
|
||||||
"Buffers are already swapped, swap_buffers was called too many times"
|
"Buffers are already swapped, swap_buffers was called too many times"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -987,7 +987,7 @@ pub struct PixelFormat {
|
||||||
pub srgb: bool,
|
pub srgb: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Trait that describes objects that have an OpenGl context
|
/// Trait that describes objects that have an OpenGL context
|
||||||
/// and can be used to render upon
|
/// and can be used to render upon
|
||||||
pub trait EGLGraphicsBackend: GraphicsBackend {
|
pub trait EGLGraphicsBackend: GraphicsBackend {
|
||||||
/// Swaps buffers at the end of a frame.
|
/// Swaps buffers at the end of a frame.
|
||||||
|
|
|
@ -618,8 +618,8 @@ impl InputBackend for WinitInputBackend {
|
||||||
let mut handler = self.handler.as_mut();
|
let mut handler = self.handler.as_mut();
|
||||||
let logger = &self.logger;
|
let logger = &self.logger;
|
||||||
|
|
||||||
self.events_loop.poll_events(move |event| match event {
|
self.events_loop.poll_events(move |event| {
|
||||||
Event::WindowEvent { event, .. } => {
|
if let Event::WindowEvent { event, .. } = event {
|
||||||
match (event, handler.as_mut()) {
|
match (event, handler.as_mut()) {
|
||||||
(WindowEvent::Resized(x, y), _) => {
|
(WindowEvent::Resized(x, y), _) => {
|
||||||
trace!(logger, "Resizing window to {:?}", (x, y));
|
trace!(logger, "Resizing window to {:?}", (x, y));
|
||||||
|
@ -816,8 +816,6 @@ impl InputBackend for WinitInputBackend {
|
||||||
}
|
}
|
||||||
*time_counter += 1;
|
*time_counter += 1;
|
||||||
}
|
}
|
||||||
Event::DeviceEvent { .. } => {}
|
|
||||||
_ => {}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -79,7 +79,7 @@ impl<U, R, ID> Clone for SurfaceIData<U, R, ID> {
|
||||||
fn clone(&self) -> SurfaceIData<U, R, ID> {
|
fn clone(&self) -> SurfaceIData<U, R, ID> {
|
||||||
SurfaceIData {
|
SurfaceIData {
|
||||||
log: self.log.clone(),
|
log: self.log.clone(),
|
||||||
implem: self.implem.clone(),
|
implem: self.implem,
|
||||||
idata: self.idata.clone(),
|
idata: self.idata.clone(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -77,7 +77,7 @@
|
||||||
//! the details of what it enables you.
|
//! the details of what it enables you.
|
||||||
//!
|
//!
|
||||||
//! The surface metadata is held in the `SurfaceAttributes` struct. In contains double-buffered
|
//! The surface metadata is held in the `SurfaceAttributes` struct. In contains double-buffered
|
||||||
//! state pending from the client as defined by the protocol for wl_surface, as well as your
|
//! state pending from the client as defined by the protocol for `wl_surface`, as well as your
|
||||||
//! user-defined type holding any data you need to have associated with a struct. See its
|
//! user-defined type holding any data you need to have associated with a struct. See its
|
||||||
//! documentation for details.
|
//! documentation for details.
|
||||||
//!
|
//!
|
||||||
|
@ -240,7 +240,7 @@ impl Default for RegionAttributes {
|
||||||
/// A Compositor global token
|
/// A Compositor global token
|
||||||
///
|
///
|
||||||
/// This token can be cloned at will, and is the entry-point to
|
/// This token can be cloned at will, and is the entry-point to
|
||||||
/// access data associated with the wl_surface and wl_region managed
|
/// access data associated with the `wl_surface` and `wl_region` managed
|
||||||
/// by the `CompositorGlobal` that provided it.
|
/// by the `CompositorGlobal` that provided it.
|
||||||
pub struct CompositorToken<U, R, ID> {
|
pub struct CompositorToken<U, R, ID> {
|
||||||
_data: ::std::marker::PhantomData<*mut U>,
|
_data: ::std::marker::PhantomData<*mut U>,
|
||||||
|
@ -524,7 +524,7 @@ impl<U: 'static, R: RoleType + 'static, ID: 'static> CompositorToken<U, R, ID> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Create new wl_compositor and wl_subcompositor globals.
|
/// Create new `wl_compositor` and `wl_subcompositor` globals.
|
||||||
///
|
///
|
||||||
/// The globals are directly registered into the eventloop, and this function
|
/// The globals are directly registered into the eventloop, and this function
|
||||||
/// returns a `CompositorToken` which you'll need access the data associated to
|
/// returns a `CompositorToken` which you'll need access the data associated to
|
||||||
|
|
|
@ -102,9 +102,9 @@ pub trait RoleType {
|
||||||
fn has_role(&self) -> bool;
|
fn has_role(&self) -> bool;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A trait representing the capability of a RoleType to handle a given role
|
/// A trait representing the capability of a `RoleType` to handle a given role
|
||||||
///
|
///
|
||||||
/// This trait allows to interact with the different roles a RoleType can
|
/// This trait allows to interact with the different roles a `RoleType` can
|
||||||
/// handle.
|
/// handle.
|
||||||
///
|
///
|
||||||
/// This trait is meant to be used generically, for example, to retrieve the
|
/// This trait is meant to be used generically, for example, to retrieve the
|
||||||
|
|
|
@ -21,8 +21,8 @@ use wayland_server::protocol::wl_surface;
|
||||||
/// have a failure case to forbid this. Note that if any node in such a graph does not
|
/// have a failure case to forbid this. Note that if any node in such a graph does not
|
||||||
/// have a parent, then the graph is a tree and this node is its root.
|
/// have a parent, then the graph is a tree and this node is its root.
|
||||||
///
|
///
|
||||||
/// All the methods here are unsafe, because they assume the provided wl_surface object
|
/// All the methods here are unsafe, because they assume the provided `wl_surface` object
|
||||||
/// is correctly initialized regarding its user_data.
|
/// is correctly initialized regarding its `user_data`.
|
||||||
pub struct SurfaceData<U, R> {
|
pub struct SurfaceData<U, R> {
|
||||||
parent: Option<wl_surface::WlSurface>,
|
parent: Option<wl_surface::WlSurface>,
|
||||||
children: Vec<wl_surface::WlSurface>,
|
children: Vec<wl_surface::WlSurface>,
|
||||||
|
@ -369,29 +369,26 @@ impl<U: 'static, R: 'static> SurfaceData<U, R> {
|
||||||
let mut data_guard = data_mutex.lock().unwrap();
|
let mut data_guard = data_mutex.lock().unwrap();
|
||||||
let data_guard = &mut *data_guard;
|
let data_guard = &mut *data_guard;
|
||||||
// call the callback on ourselves
|
// call the callback on ourselves
|
||||||
match f(
|
if let TraversalAction::DoChildren(t) = f(
|
||||||
root,
|
root,
|
||||||
&mut data_guard.attributes,
|
&mut data_guard.attributes,
|
||||||
&mut data_guard.role,
|
&mut data_guard.role,
|
||||||
&initial,
|
&initial,
|
||||||
) {
|
) {
|
||||||
TraversalAction::DoChildren(t) => {
|
// loop over children
|
||||||
// loop over children
|
if reverse {
|
||||||
if reverse {
|
for c in data_guard.children.iter().rev() {
|
||||||
for c in data_guard.children.iter().rev() {
|
if !map::<U, R, _, _>(c, root, &t, &mut f, true) {
|
||||||
if !map::<U, R, _, _>(c, root, &t, &mut f, true) {
|
break;
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
for c in &data_guard.children {
|
} else {
|
||||||
if !map::<U, R, _, _>(c, root, &t, &mut f, false) {
|
for c in &data_guard.children {
|
||||||
break;
|
if !map::<U, R, _, _>(c, root, &t, &mut f, false) {
|
||||||
}
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ => {}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -267,7 +267,7 @@ impl Output {
|
||||||
|
|
||||||
/// Chech is given wl_output instance is managed by this `Output`.
|
/// Chech is given wl_output instance is managed by this `Output`.
|
||||||
pub fn owns(&self, output: &wl_output::WlOutput) -> bool {
|
pub fn owns(&self, output: &wl_output::WlOutput) -> bool {
|
||||||
self.instances.iter().find(|&o| o.equals(output)).is_some()
|
self.instances.iter().any(|o| o.equals(output))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Cleanup internal `wl_output` instances list
|
/// Cleanup internal `wl_output` instances list
|
||||||
|
|
|
@ -170,7 +170,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(rules: &str, model: &str, layout: &str, variant: &str,
|
pub(crate) fn create_keyboard_handler(rules: &str, model: &str, layout: &str, variant: &str,
|
||||||
options: Option<String>, repeat_delay: i32, repeat_rate: i32,
|
options: Option<String>, repeat_delay: i32, repeat_rate: i32,
|
||||||
logger: ::slog::Logger)
|
logger: &::slog::Logger)
|
||||||
-> Result<KeyboardHandle, Error> {
|
-> Result<KeyboardHandle, Error> {
|
||||||
let log = logger.new(o!("smithay_module" => "xkbcommon_handler"));
|
let log = logger.new(o!("smithay_module" => "xkbcommon_handler"));
|
||||||
info!(log, "Initializing a xkbcommon handler with keymap query";
|
info!(log, "Initializing a xkbcommon handler with keymap query";
|
||||||
|
|
|
@ -169,7 +169,7 @@ impl Seat {
|
||||||
options,
|
options,
|
||||||
repeat_delay,
|
repeat_delay,
|
||||||
repeat_rate,
|
repeat_rate,
|
||||||
self.log.clone(),
|
&self.log,
|
||||||
)?;
|
)?;
|
||||||
if self.keyboard.is_some() {
|
if self.keyboard.is_some() {
|
||||||
// there is already a keyboard, remove it and notify the clients
|
// there is already a keyboard, remove it and notify the clients
|
||||||
|
|
|
@ -64,7 +64,7 @@ impl PointerHandle {
|
||||||
// do we leave a surface ?
|
// do we leave a surface ?
|
||||||
let mut leave = true;
|
let mut leave = true;
|
||||||
if let Some(ref focus) = guard.focus {
|
if let Some(ref focus) = guard.focus {
|
||||||
if let Some((ref surface, _, _)) = location {
|
if let Some((surface, _, _)) = location {
|
||||||
if focus.equals(surface) {
|
if focus.equals(surface) {
|
||||||
leave = false;
|
leave = false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -251,7 +251,7 @@ impl PopupState {
|
||||||
if let Some(p) = self.parent.clone() {
|
if let Some(p) = self.parent.clone() {
|
||||||
Some(PopupState {
|
Some(PopupState {
|
||||||
parent: p,
|
parent: p,
|
||||||
positioner: self.positioner.clone(),
|
positioner: self.positioner,
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
// the parent surface does no exist any longer,
|
// the parent surface does no exist any longer,
|
||||||
|
@ -283,15 +283,15 @@ impl<U, R, CID, SID, SD> Clone for ShellSurfaceIData<U, R, CID, SID, SD> {
|
||||||
fn clone(&self) -> ShellSurfaceIData<U, R, CID, SID, SD> {
|
fn clone(&self) -> ShellSurfaceIData<U, R, CID, SID, SD> {
|
||||||
ShellSurfaceIData {
|
ShellSurfaceIData {
|
||||||
log: self.log.clone(),
|
log: self.log.clone(),
|
||||||
compositor_token: self.compositor_token.clone(),
|
compositor_token: self.compositor_token,
|
||||||
implementation: self.implementation.clone(),
|
implementation: self.implementation,
|
||||||
idata: self.idata.clone(),
|
idata: self.idata.clone(),
|
||||||
state_token: self.state_token.clone(),
|
state_token: self.state_token.clone(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Create new xdg_shell and wl_shell globals.
|
/// Create new `xdg_shell` and `wl_shell` globals.
|
||||||
///
|
///
|
||||||
/// The globals are directly registered into the eventloop, and this function
|
/// The globals are directly registered into the eventloop, and this function
|
||||||
/// returns a `StateToken<_>` which you'll need access the list of shell
|
/// returns a `StateToken<_>` which you'll need access the list of shell
|
||||||
|
|
|
@ -72,7 +72,7 @@ where
|
||||||
pending_configures: Vec::new(),
|
pending_configures: Vec::new(),
|
||||||
configured: true,
|
configured: true,
|
||||||
};
|
};
|
||||||
if let Err(_) = idata.compositor_token.give_role_with(surface, role_data) {
|
if idata.compositor_token.give_role_with(surface, role_data).is_err() {
|
||||||
shell.post_error(
|
shell.post_error(
|
||||||
wl_shell::Error::Role as u32,
|
wl_shell::Error::Role as u32,
|
||||||
"Surface already has a role.".into(),
|
"Surface already has a role.".into(),
|
||||||
|
@ -91,7 +91,7 @@ where
|
||||||
// register ourselves to the wl_shell for ping handling
|
// register ourselves to the wl_shell for ping handling
|
||||||
let mutex = unsafe { &*(shell.get_user_data() as *mut ShellUserData<SD>) };
|
let mutex = unsafe { &*(shell.get_user_data() as *mut ShellUserData<SD>) };
|
||||||
let mut guard = mutex.lock().unwrap();
|
let mut guard = mutex.lock().unwrap();
|
||||||
if guard.1.len() == 0 && guard.0.pending_ping != 0 {
|
if guard.1.is_empty() && guard.0.pending_ping != 0 {
|
||||||
// there is a pending ping that no surface could receive yet, send it
|
// there is a pending ping that no surface could receive yet, send it
|
||||||
// note this is not possible that it was received and then a wl_shell_surface was
|
// note this is not possible that it was received and then a wl_shell_surface was
|
||||||
// destroyed, because wl_shell_surface has no destructor!
|
// destroyed, because wl_shell_surface has no destructor!
|
||||||
|
@ -241,7 +241,7 @@ where
|
||||||
min_size: (0, 0),
|
min_size: (0, 0),
|
||||||
max_size: (0, 0),
|
max_size: (0, 0),
|
||||||
});
|
});
|
||||||
return true;
|
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
|
// we need to notify about this new toplevel surface
|
||||||
|
@ -419,11 +419,10 @@ where
|
||||||
let &(ref surface, _) = unsafe { &*(ptr as *mut ShellSurfaceUserData) };
|
let &(ref surface, _) = unsafe { &*(ptr as *mut ShellSurfaceUserData) };
|
||||||
idata
|
idata
|
||||||
.compositor_token
|
.compositor_token
|
||||||
.with_role_data(surface, |data| match data.pending_state {
|
.with_role_data(surface, |data| {
|
||||||
ShellSurfacePendingState::Toplevel(ref mut state) => {
|
if let ShellSurfacePendingState::Toplevel(ref mut state) = data.pending_state {
|
||||||
state.title = title;
|
state.title = title;
|
||||||
}
|
}
|
||||||
_ => {}
|
|
||||||
})
|
})
|
||||||
.expect("wl_shell_surface exists but wl_surface has wrong role?!");
|
.expect("wl_shell_surface exists but wl_surface has wrong role?!");
|
||||||
},
|
},
|
||||||
|
|
|
@ -93,7 +93,7 @@ where
|
||||||
pending_configures: Vec::new(),
|
pending_configures: Vec::new(),
|
||||||
configured: false,
|
configured: false,
|
||||||
};
|
};
|
||||||
if let Err(_) = idata.compositor_token.give_role_with(wl_surface, role_data) {
|
if idata.compositor_token.give_role_with(wl_surface, role_data).is_err() {
|
||||||
shell.post_error(
|
shell.post_error(
|
||||||
zxdg_shell_v6::Error::Role as u32,
|
zxdg_shell_v6::Error::Role as u32,
|
||||||
"Surface already has a role.".into(),
|
"Surface already has a role.".into(),
|
||||||
|
@ -315,7 +315,7 @@ where
|
||||||
.with_role_data::<ShellSurfaceRole, _, _>(surface, |data| {
|
.with_role_data::<ShellSurfaceRole, _, _>(surface, |data| {
|
||||||
data.pending_state = ShellSurfacePendingState::Popup(PopupState {
|
data.pending_state = ShellSurfacePendingState::Popup(PopupState {
|
||||||
parent: unsafe { parent_surface.clone_unchecked() },
|
parent: unsafe { parent_surface.clone_unchecked() },
|
||||||
positioner: positioner_data.clone(),
|
positioner: *positioner_data,
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
.expect("xdg_surface exists but surface has not shell_surface role?!");
|
.expect("xdg_surface exists but surface has not shell_surface role?!");
|
||||||
|
|
|
@ -71,7 +71,7 @@ use wayland_server::protocol::{wl_buffer, wl_shm, wl_shm_pool};
|
||||||
mod pool;
|
mod pool;
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
/// Internal data storage of ShmGlobal
|
/// Internal data storage of `ShmGlobal`
|
||||||
///
|
///
|
||||||
/// This type is only visible as type parameter of
|
/// This type is only visible as type parameter of
|
||||||
/// the `Global` handle you are provided.
|
/// the `Global` handle you are provided.
|
||||||
|
@ -104,9 +104,7 @@ where
|
||||||
log: log.new(o!("smithay_module" => "shm_handler")),
|
log: log.new(o!("smithay_module" => "shm_handler")),
|
||||||
};
|
};
|
||||||
|
|
||||||
let global = evl.register_global::<wl_shm::WlShm, _>(1, shm_global_bind, data);
|
evl.register_global::<wl_shm::WlShm, _>(1, shm_global_bind, data)
|
||||||
|
|
||||||
global
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Error that can occur when accessing an SHM buffer
|
/// Error that can occur when accessing an SHM buffer
|
||||||
|
@ -125,13 +123,13 @@ pub enum BufferAccessError {
|
||||||
|
|
||||||
/// Call given closure with the contents of the given buffer
|
/// Call given closure with the contents of the given buffer
|
||||||
///
|
///
|
||||||
/// If the buffer is managed by the provided ShmGlobal, its contents are
|
/// If the buffer is managed by the provided `ShmGlobal`, its contents are
|
||||||
/// extracted and the closure is extracted with them:
|
/// extracted and the closure is extracted with them:
|
||||||
///
|
///
|
||||||
/// - The first argument is a data slice of the contents of the pool
|
/// - The first argument is a data slice of the contents of the pool
|
||||||
/// - The second argument is the specification of this buffer is this pool
|
/// - The second argument is the specification of this buffer is this pool
|
||||||
///
|
///
|
||||||
/// If the buffer is not managed by the provided ShmGlobal, the closure is not called
|
/// If the buffer is not managed by the provided `ShmGlobal`, the closure is not called
|
||||||
/// and this method will return `Err(())` (this will be the case for an EGL buffer for example).
|
/// and this method will return `Err(())` (this will be the case for an EGL buffer for example).
|
||||||
pub fn with_buffer_contents<F>(buffer: &wl_buffer::WlBuffer, f: F) -> Result<(), BufferAccessError>
|
pub fn with_buffer_contents<F>(buffer: &wl_buffer::WlBuffer, f: F) -> Result<(), BufferAccessError>
|
||||||
where
|
where
|
||||||
|
|
Loading…
Reference in New Issue